1 | {$INCLUDE Switches.inc}
|
---|
2 | unit Select;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Protocol, ClientTools, ScreenTools, PVSB, BaseWin, LCLIntf, LCLType, Messages,
|
---|
8 | SysUtils, Classes, ButtonB, ButtonBase, Types,
|
---|
9 | {$IFDEF DPI}Dpi.Graphics, Dpi.Controls, Dpi.Forms, Dpi.ExtCtrls, Dpi.Menus,
|
---|
10 | Dpi.Common, System.UITypes{$ELSE}
|
---|
11 | Graphics, Controls, Forms, ExtCtrls, Menus{$ENDIF};
|
---|
12 |
|
---|
13 | const
|
---|
14 | MaxLayer = 3;
|
---|
15 |
|
---|
16 | type
|
---|
17 | TListKind = (kProject, kAdvance, kFarAdvance, kCities, kCityEvents, kModels,
|
---|
18 | kEModels, kAllEModels, kTribe, kScience, kShipPart, kEShipPart, kChooseTech,
|
---|
19 | kChooseETech, kChooseModel, kChooseEModel, kChooseCity, kChooseECity,
|
---|
20 | kStealTech, kGov, kMission);
|
---|
21 |
|
---|
22 | { TListDlg }
|
---|
23 |
|
---|
24 | TListDlg = class(TFramedDlg)
|
---|
25 | CloseBtn: TButtonB;
|
---|
26 | Layer2Btn: TButtonB;
|
---|
27 | Layer1Btn: TButtonB;
|
---|
28 | Layer0Btn: TButtonB;
|
---|
29 | ToggleBtn: TButtonB;
|
---|
30 | Popup: TPopupMenu;
|
---|
31 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
32 | procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
|
---|
33 | WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
---|
34 | procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
|
---|
35 | X, Y: Integer);
|
---|
36 | procedure FormCreate(Sender: TObject);
|
---|
37 | procedure FormDestroy(Sender: TObject);
|
---|
38 | procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
|
---|
39 | Shift: TShiftState; X, Y: Integer);
|
---|
40 | procedure FormPaint(Sender: TObject);
|
---|
41 | procedure CloseBtnClick(Sender: TObject);
|
---|
42 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
---|
43 | procedure FormShow(Sender: TObject);
|
---|
44 | procedure ModeBtnClick(Sender: TObject);
|
---|
45 | procedure ToggleBtnClick(Sender: TObject);
|
---|
46 | procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
---|
47 | procedure PlayerClick(Sender: TObject);
|
---|
48 | private
|
---|
49 | Kind: TListKind;
|
---|
50 | LineDistance: Integer;
|
---|
51 | MaxLines: Integer;
|
---|
52 | cixProject: Integer;
|
---|
53 | pView: Integer;
|
---|
54 | Selected: Integer;
|
---|
55 | DispLines: Integer;
|
---|
56 | Layer: Integer;
|
---|
57 | nColumn: Integer;
|
---|
58 | TechNameSpace: Integer;
|
---|
59 | ScienceNation: Integer;
|
---|
60 | ScrollBar: TPVScrollbar;
|
---|
61 | Lines: array [0 .. MaxLayer - 1] of Integer;
|
---|
62 | FirstShrinkedLine: array [0 .. MaxLayer - 1] of Integer;
|
---|
63 | Code: array [0 .. MaxLayer - 1, 0 .. 4095] of Integer;
|
---|
64 | Column: array [0 .. nPl - 1] of Integer;
|
---|
65 | Closable: Boolean;
|
---|
66 | MultiPage: Boolean;
|
---|
67 | ScienceNationDotBuffer: TBitmap;
|
---|
68 | procedure ScrollBarUpdate(Sender: TObject);
|
---|
69 | procedure InitLines;
|
---|
70 | procedure Line(ca: TCanvas; L: Integer; NonText, lit: Boolean);
|
---|
71 | function RenameModel(mix: Integer): Boolean;
|
---|
72 | procedure OnScroll(var Msg: TMessage); message WM_VSCROLL;
|
---|
73 | procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
|
---|
74 | public
|
---|
75 | Result: Integer;
|
---|
76 | function RenameCity(cix: Integer): Boolean;
|
---|
77 | function OnlyChoice(TestKind: TListKind): Integer;
|
---|
78 | // -2=empty, -1=ambiguous, other=only choice
|
---|
79 | procedure OffscreenPaint; override;
|
---|
80 | procedure ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
|
---|
81 | procedure ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
|
---|
82 | procedure ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
|
---|
83 | procedure EcoChange;
|
---|
84 | procedure TechChange;
|
---|
85 | procedure AddCity;
|
---|
86 | procedure RemoveUnit;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | TModalSelectDlg = TListDlg;
|
---|
90 |
|
---|
91 | const
|
---|
92 | cpType = $10000;
|
---|
93 | mixAll = $10000;
|
---|
94 | adAll = $10000;
|
---|
95 |
|
---|
96 |
|
---|
97 | implementation
|
---|
98 |
|
---|
99 | uses
|
---|
100 | Term, CityScreen, Help, UnitStat, Tribes, Inp, CmdList;
|
---|
101 |
|
---|
102 | {$R *.lfm}
|
---|
103 |
|
---|
104 | const
|
---|
105 | CityNameSpace = 127;
|
---|
106 |
|
---|
107 | MustChooseKind = [kTribe, kStealTech, kGov];
|
---|
108 |
|
---|
109 | procedure TListDlg.FormCreate(Sender: TObject);
|
---|
110 | begin
|
---|
111 | inherited;
|
---|
112 | Canvas.Font.Assign(UniFont[ftNormal]);
|
---|
113 | ScrollBar := TPVScrollbar.Create(Self);
|
---|
114 | ScrollBar.SetBorderSpacing(36, 10, 36);
|
---|
115 | ScrollBar.OnUpdate := ScrollBarUpdate;
|
---|
116 | InitButtons;
|
---|
117 | Kind := kMission;
|
---|
118 | Layer0Btn.Hint := Phrases.Lookup('BTN_IMPRS');
|
---|
119 | Layer1Btn.Hint := Phrases.Lookup('BTN_WONDERS');
|
---|
120 | Layer2Btn.Hint := Phrases.Lookup('BTN_CLASSES');
|
---|
121 | ScienceNationDotBuffer := TBitmap.Create;
|
---|
122 | ScienceNationDotBuffer.PixelFormat := TPixelFormat.pf24bit;
|
---|
123 | ScienceNationDotBuffer.SetSize(17, 17);
|
---|
124 | ScienceNationDotBuffer.Canvas.FillRect(0, 0, ScienceNationDotBuffer.Width, ScienceNationDotBuffer.Height);
|
---|
125 | end;
|
---|
126 |
|
---|
127 | procedure TListDlg.FormDestroy(Sender: TObject);
|
---|
128 | begin
|
---|
129 | FreeAndNil(ScrollBar);
|
---|
130 | FreeAndNil(ScienceNationDotBuffer);
|
---|
131 | end;
|
---|
132 |
|
---|
133 | procedure TListDlg.CloseBtnClick(Sender: TObject);
|
---|
134 | begin
|
---|
135 | Closable := True;
|
---|
136 | Close;
|
---|
137 | end;
|
---|
138 |
|
---|
139 | procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
---|
140 | begin
|
---|
141 | CanClose := Closable or not (Kind in MustChooseKind);
|
---|
142 | end;
|
---|
143 |
|
---|
144 | procedure TListDlg.OnScroll(var Msg: TMessage);
|
---|
145 | begin
|
---|
146 | { TODO: Handled by MouseWheel event
|
---|
147 | if ScrollBar.Process(Msg) then begin
|
---|
148 | Selected := -2;
|
---|
149 | SmartUpdateContent(True);
|
---|
150 | end;
|
---|
151 | }
|
---|
152 | end;
|
---|
153 |
|
---|
154 | procedure TListDlg.OnMouseLeave(var Msg: TMessage);
|
---|
155 | begin
|
---|
156 | if not Closable and (Selected <> -2) then
|
---|
157 | begin
|
---|
158 | Line(Canvas, Selected, False, False);
|
---|
159 | Selected := -2;
|
---|
160 | end;
|
---|
161 | end;
|
---|
162 |
|
---|
163 | procedure TListDlg.FormPaint(Sender: TObject);
|
---|
164 | var
|
---|
165 | S: string;
|
---|
166 | begin
|
---|
167 | inherited;
|
---|
168 | Canvas.Font.Assign(UniFont[ftNormal]);
|
---|
169 | if Selected <> -2 then
|
---|
170 | Line(Canvas, Selected, False, True);
|
---|
171 | S := '';
|
---|
172 | if (Kind = kAdvance) and (MyData.FarTech <> adNone) then
|
---|
173 | S := Format(Phrases.Lookup('TECHFOCUS'),
|
---|
174 | [Phrases.Lookup('ADVANCES', MyData.FarTech)])
|
---|
175 | else if Kind = kModels then
|
---|
176 | S := Tribe[Me].TPhrase('SHORTNAME')
|
---|
177 | else if Kind = kEModels then
|
---|
178 | S := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
|
---|
179 | TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport) + ')';
|
---|
180 | if S <> '' then
|
---|
181 | LoweredTextOut(Canvas, -1, MainTexture,
|
---|
182 | (Width - BiColorTextWidth(Canvas, S)) div 2, 31, S);
|
---|
183 | if not MultiPage and (Kind in [kProject, kAdvance, kFarAdvance]) and
|
---|
184 | not Phrases2FallenBackToEnglish then begin
|
---|
185 | S := Phrases2.Lookup('SHIFTCLICK');
|
---|
186 | LoweredTextOut(Canvas, -2, MainTexture,
|
---|
187 | (Width - BiColorTextWidth(Canvas, S)) div 2, Height - 29, S);
|
---|
188 | end;
|
---|
189 | end;
|
---|
190 |
|
---|
191 | procedure TListDlg.Line(ca: TCanvas; L: Integer; NonText, lit: Boolean);
|
---|
192 | // paint a line
|
---|
193 |
|
---|
194 | procedure DisplayProject(X, Y, pix: Integer);
|
---|
195 | begin
|
---|
196 | if pix and (cpType or cpImp) = 0 then
|
---|
197 | with Tribe[Me].ModelPicture[pix and cpIndex] do
|
---|
198 | Sprite(Offscreen, HGr, X, Y, 64, 48, pix mod 10 * 65 + 1,
|
---|
199 | pix div 10 * 49 + 1)
|
---|
200 | else
|
---|
201 | begin
|
---|
202 | Frame(Offscreen.Canvas, X + (16 - 1), Y + (16 - 2), X + (16 + xSizeSmall),
|
---|
203 | Y + (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight,
|
---|
204 | MainTexture.ColorBevelShade);
|
---|
205 | if pix and cpType = 0 then
|
---|
206 | if (pix and cpIndex = imPalace) and (MyRO.Government <> gAnarchy) then
|
---|
207 | BitBltBitmap(Offscreen, X + 16, Y + (16 - 1), xSizeSmall,
|
---|
208 | ySizeSmall, SmallImp, (MyRO.Government - 1) *
|
---|
209 | xSizeSmall, ySizeSmall)
|
---|
210 | else
|
---|
211 | BitBltBitmap(Offscreen, X + 16, Y + (16 - 1), xSizeSmall,
|
---|
212 | ySizeSmall, SmallImp, pix and cpIndex mod 7 *
|
---|
213 | xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 *
|
---|
214 | ySizeSmall)
|
---|
215 | else
|
---|
216 | BitBltBitmap(Offscreen, X + 16, Y + (16 - 1), xSizeSmall,
|
---|
217 | ySizeSmall, SmallImp, (3 + pix and cpIndex) *
|
---|
218 | xSizeSmall, 0);
|
---|
219 | end;
|
---|
220 | end;
|
---|
221 |
|
---|
222 | procedure ReplaceText(X, Y, Color: Integer; S: string);
|
---|
223 | var
|
---|
224 | TextSize: TSize;
|
---|
225 | begin
|
---|
226 | if ca = Canvas then
|
---|
227 | begin
|
---|
228 | TextSize.cx := BiColorTextWidth(ca, S);
|
---|
229 | TextSize.cy := ca.TextHeight(S);
|
---|
230 | if Y + TextSize.cy >= TitleHeight + InnerHeight then
|
---|
231 | TextSize.cy := TitleHeight + InnerHeight - Y;
|
---|
232 | Fill(ca, X, Y, TextSize.cx, TextSize.cy, (Maintexture.Width - Width)
|
---|
233 | div 2, (Maintexture.Height - Height) div 2);
|
---|
234 | end;
|
---|
235 | LoweredTextOut(ca, Color, MainTexture, X, Y, S);
|
---|
236 | end;
|
---|
237 |
|
---|
238 | var
|
---|
239 | icon, ofs, X, Y, y0, lix, I, J, TextColor, Available, First, Test,
|
---|
240 | FutureCount, Growth, TrueFood, TrueProd: Integer;
|
---|
241 | CityReport: TCityReportNew;
|
---|
242 | mox: ^TModelInfo;
|
---|
243 | S, Number: string;
|
---|
244 | CanGrow: Boolean;
|
---|
245 | begin
|
---|
246 | lix := Code[Layer, ScrollBar.Position + L];
|
---|
247 | y0 := 2 + (L + 1) * LineDistance;
|
---|
248 | if ScrollBar.Position + L >= FirstShrinkedLine[Layer] then
|
---|
249 | ofs := (ScrollBar.Position + L - FirstShrinkedLine[Layer]) and 1 * 33
|
---|
250 | else { if FirstShrinkedLine[Layer] < Lines[Layer] then }
|
---|
251 | ofs := 33;
|
---|
252 |
|
---|
253 | if Kind in [kCities, kCityEvents] then
|
---|
254 | with TCity(MyCity[lix]) do
|
---|
255 | begin
|
---|
256 | X := 104 - 76;
|
---|
257 | Y := y0;
|
---|
258 | if ca = Canvas then
|
---|
259 | begin
|
---|
260 | X := X + SideFrame;
|
---|
261 | Y := Y + TitleHeight;
|
---|
262 | end;
|
---|
263 | if lit then
|
---|
264 | TextColor := MainTexture.ColorLitText
|
---|
265 | else
|
---|
266 | TextColor := -1;
|
---|
267 | S := CityName(ID);
|
---|
268 | while BiColorTextWidth(ca, S) > CityNameSpace do
|
---|
269 | Delete(S, Length(S), 1);
|
---|
270 | ReplaceText(X + 15, Y, TextColor, S);
|
---|
271 |
|
---|
272 | if NonText then
|
---|
273 | with Offscreen.Canvas do
|
---|
274 | begin // city size
|
---|
275 | Brush.Color := $000000;
|
---|
276 | FillRect(Rect(X - 4 - 11, Y + 1, X - 4 + 13, Y + 21));
|
---|
277 | Brush.Color := $FFFFFF;
|
---|
278 | FillRect(Rect(X - 4 - 12, Y, X - 4 + 12, Y + 20));
|
---|
279 | Brush.Style := TBrushStyle.bsClear;
|
---|
280 | Font.Color := $000000;
|
---|
281 | S := IntToStr(MyCity[lix].Size);
|
---|
282 | TextOut(X - 4 - TextWidth(S) div 2, Y, S);
|
---|
283 | end;
|
---|
284 |
|
---|
285 | if Kind = kCityEvents then
|
---|
286 | begin
|
---|
287 | First := -1;
|
---|
288 | for J := 0 to nCityEventPriority - 1 do
|
---|
289 | if (Flags and CityRepMask and CityEventPriority[J] <> 0) then
|
---|
290 | begin
|
---|
291 | First := J;
|
---|
292 | Break;
|
---|
293 | end;
|
---|
294 | if First >= 0 then
|
---|
295 | begin
|
---|
296 | I := 0;
|
---|
297 | Test := 1;
|
---|
298 | while Test < CityEventPriority[First] do
|
---|
299 | begin
|
---|
300 | Inc(I);
|
---|
301 | Inc(Test, Test);
|
---|
302 | end;
|
---|
303 | S := CityEventName(I);
|
---|
304 | { if CityEventPriority[First] = chNoGrowthWarning then
|
---|
305 | if Built[imAqueduct] = 0 then
|
---|
306 | S := Format(S, [Phrases.Lookup('IMPROVEMENTS', imAqueduct)])
|
---|
307 | else begin S := Format(S, [Phrases.Lookup('IMPROVEMENTS', imSewer)]); I := 17 end; }
|
---|
308 | ReplaceText(X + (CityNameSpace + 4 + 40 + 18 + 8), Y, TextColor, S);
|
---|
309 | if NonText then
|
---|
310 | begin
|
---|
311 | Sprite(Offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,
|
---|
312 | y0 + 1, 18, 18, 1 + I mod 3 * 19, 1 + I div 3 * 19);
|
---|
313 | X := InnerWidth - 26;
|
---|
314 | for J := nCityEventPriority - 1 downto First + 1 do
|
---|
315 | if (Flags and CityRepMask and CityEventPriority[J] <> 0) then
|
---|
316 | begin
|
---|
317 | I := 0;
|
---|
318 | Test := 1;
|
---|
319 | while Test < CityEventPriority[J] do
|
---|
320 | begin
|
---|
321 | Inc(I);
|
---|
322 | Inc(Test, Test);
|
---|
323 | end;
|
---|
324 | if (CityEventPriority[J] = chNoGrowthWarning) and
|
---|
325 | (Built[imAqueduct] > 0) then
|
---|
326 | I := 17;
|
---|
327 | Sprite(Offscreen, HGrSystem, X, y0 + 1, 18, 18,
|
---|
328 | 1 + I mod 3 * 19, 1 + I div 3 * 19);
|
---|
329 | Dec(X, 20);
|
---|
330 | end;
|
---|
331 | end;
|
---|
332 | end;
|
---|
333 | end
|
---|
334 | else
|
---|
335 | begin
|
---|
336 | CityReport.HypoTiles := -1;
|
---|
337 | CityReport.HypoTaxRate := -1;
|
---|
338 | CityReport.HypoLuxuryRate := -1;
|
---|
339 | Server(sGetCityReportNew, Me, lix, CityReport);
|
---|
340 | TrueFood := Food;
|
---|
341 | TrueProd := Prod;
|
---|
342 | if Supervising then
|
---|
343 | begin // normalize city from after-turn state
|
---|
344 | Dec(TrueFood, CityReport.FoodSurplus);
|
---|
345 | if TrueFood < 0 then
|
---|
346 | TrueFood := 0; // shouldn't happen
|
---|
347 | Dec(TrueProd, CityReport.Production);
|
---|
348 | if TrueProd < 0 then
|
---|
349 | TrueProd := 0; // shouldn't happen
|
---|
350 | end;
|
---|
351 |
|
---|
352 | S := ''; // disorder info
|
---|
353 | if Flags and chCaptured <> 0 then
|
---|
354 | S := Phrases.Lookup('CITYEVENTS', 14)
|
---|
355 | else if CityReport.HappinessBalance < 0 then
|
---|
356 | S := Phrases.Lookup('CITYEVENTS', 0);
|
---|
357 | if S <> '' then
|
---|
358 | begin { disorder }
|
---|
359 | if NonText then
|
---|
360 | begin
|
---|
361 | DarkGradient(Offscreen.Canvas, 99 + 31 + CityNameSpace + 4,
|
---|
362 | y0 + 2, 131, 3);
|
---|
363 | ca.Font.Assign(UniFont[ftSmall]);
|
---|
364 | RisedTextOut(Offscreen.Canvas, 103 + CityNameSpace + 4 + 31,
|
---|
365 | y0 + 1, S);
|
---|
366 | ca.Font.Assign(UniFont[ftNormal]);
|
---|
367 | end;
|
---|
368 | end
|
---|
369 | else
|
---|
370 | begin
|
---|
371 | { s:=IntToStr(CityReport.FoodSurplus);
|
---|
372 | ReplaceText(X+(CityNameSpace+4+48)-BiColorTextWidth(ca,S),Y,TextColor,S); }
|
---|
373 | S := IntToStr(CityReport.Science);
|
---|
374 | ReplaceText(X + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,
|
---|
375 | S), Y, TextColor, S);
|
---|
376 | S := IntToStr(CityReport.Production);
|
---|
377 | ReplaceText(X + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, S), Y,
|
---|
378 | TextColor, S);
|
---|
379 | if NonText then
|
---|
380 | begin
|
---|
381 | // Sprite(offscreen,HGrSystem,x+CityNameSpace+4+333+1,y+6,10,10,66,115);
|
---|
382 | Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 48 + 1,
|
---|
383 | Y + 6, 10, 10, 77, 126);
|
---|
384 | Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 132 + 1, Y + 6,
|
---|
385 | 10, 10, 88, 115);
|
---|
386 | end;
|
---|
387 | end;
|
---|
388 | S := IntToStr(CityTaxBalance(lix, CityReport));
|
---|
389 | ReplaceText(X + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, S), Y,
|
---|
390 | TextColor, S);
|
---|
391 | // if Project and (cpImp+cpIndex)<>cpImp+imTrGoods then
|
---|
392 | // ReplaceText(x+CityNameSpace+4+333+1,y,TextColor,Format('%d/%d',[TrueProd,CityReport.ProjectCost]));
|
---|
393 | if NonText then
|
---|
394 | begin
|
---|
395 | Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 1, Y + 6,
|
---|
396 | 10, 10, 132, 115);
|
---|
397 |
|
---|
398 | // food progress
|
---|
399 | CanGrow := (Size < MaxCitySize) and (MyRO.Government <> gFuture) and
|
---|
400 | (CityReport.FoodSurplus > 0) and
|
---|
401 | ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and
|
---|
402 | (Size < NeedSewerSize) or (Built[imSewer] = 1));
|
---|
403 | Growth := CutCityFoodSurplus(CityReport.FoodSurplus,
|
---|
404 | (MyRO.Government <> gAnarchy) and (Flags and chCaptured = 0),
|
---|
405 | MyRO.Government, Size);
|
---|
406 | PaintRelativeProgressBar(Offscreen.Canvas, 1, X + 15 + CityNameSpace +
|
---|
407 | 4, Y + 7, 68, TrueFood, Growth, CityReport.Storage, CanGrow, MainTexture);
|
---|
408 |
|
---|
409 | if Project <> cpImp + imTrGoods then
|
---|
410 | begin
|
---|
411 | DisplayProject(ofs + 104 - 76 + X - 28 + CityNameSpace + 4 + 206 -
|
---|
412 | 60, y0 - 15, Project);
|
---|
413 |
|
---|
414 | // production progress
|
---|
415 | Growth := CityReport.Production;
|
---|
416 | if (Growth < 0) or (MyRO.Government = gAnarchy) or
|
---|
417 | (Flags and chCaptured <> 0) then
|
---|
418 | Growth := 0;
|
---|
419 | PaintRelativeProgressBar(Offscreen.Canvas, 4,
|
---|
420 | X + CityNameSpace + 4 + 304 - 60 + 9, Y + 7, 68, TrueProd, Growth,
|
---|
421 | CityReport.ProjectCost, True, MainTexture);
|
---|
422 | end;
|
---|
423 | end;
|
---|
424 | end;
|
---|
425 | end
|
---|
426 | else if Kind in [kModels, kEModels] then
|
---|
427 | begin
|
---|
428 | X := 104;
|
---|
429 | Y := y0;
|
---|
430 | if ca = Canvas then
|
---|
431 | begin
|
---|
432 | X := X + SideFrame;
|
---|
433 | Y := Y + TitleHeight;
|
---|
434 | end;
|
---|
435 | if lit then
|
---|
436 | TextColor := MainTexture.ColorLitText
|
---|
437 | else
|
---|
438 | TextColor := -1;
|
---|
439 | if Kind = kModels then
|
---|
440 | begin
|
---|
441 | Available := 0;
|
---|
442 | for J := 0 to MyRO.nUn - 1 do
|
---|
443 | if (MyUn[J].Loc >= 0) and (MyUn[J].mix = lix) then
|
---|
444 | Inc(Available);
|
---|
445 | if MainScreen.mNames.Checked then
|
---|
446 | S := Tribe[Me].ModelName[lix]
|
---|
447 | else
|
---|
448 | S := Format(Tribe[Me].TPhrase('GENMODEL'), [lix]);
|
---|
449 | if NonText then
|
---|
450 | DisplayProject(8 + ofs, y0 - 15, lix);
|
---|
451 | end
|
---|
452 | else
|
---|
453 | begin
|
---|
454 | Available := MyRO.EnemyReport[pView].UnCount[lix];
|
---|
455 | if MainScreen.mNames.Checked then
|
---|
456 | S := Tribe[pView].ModelName[lix]
|
---|
457 | else
|
---|
458 | S := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
|
---|
459 | if NonText then
|
---|
460 | with Tribe[pView].ModelPicture[lix] do
|
---|
461 | Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
|
---|
462 | pix div 10 * 49 + 1);
|
---|
463 | end;
|
---|
464 | if Available > 0 then
|
---|
465 | ReplaceText(X + 32 - BiColorTextWidth(ca, IntToStr(Available)), Y,
|
---|
466 | TextColor, IntToStr(Available));
|
---|
467 | ReplaceText(X + 40, Y, TextColor, S);
|
---|
468 | end
|
---|
469 | else
|
---|
470 | begin
|
---|
471 | case Kind of
|
---|
472 | kAllEModels, kChooseEModel:
|
---|
473 | if lix = mixAll then
|
---|
474 | S := Phrases.Lookup('PRICECAT_ALLMODEL')
|
---|
475 | else
|
---|
476 | begin
|
---|
477 | mox := @MyRO.EnemyModel[lix];
|
---|
478 | if MainScreen.mNames.Checked then
|
---|
479 | begin
|
---|
480 | S := Tribe[mox.Owner].ModelName[mox.mix];
|
---|
481 | if (Kind = kAllEModels) and (Code[1, ScrollBar.Position + L] = 0) then
|
---|
482 | S := Format(Tribe[mox.Owner].TPhrase('OWNED'), [S]);
|
---|
483 | end
|
---|
484 | else
|
---|
485 | S := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
|
---|
486 | if NonText then
|
---|
487 | with Tribe[mox.Owner].ModelPicture[mox.mix] do
|
---|
488 | Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
|
---|
489 | pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
|
---|
490 | end;
|
---|
491 | kChooseModel:
|
---|
492 | if lix = mixAll then
|
---|
493 | S := Phrases.Lookup('PRICECAT_ALLMODEL')
|
---|
494 | else
|
---|
495 | begin
|
---|
496 | S := Tribe[Me].ModelName[lix];
|
---|
497 | if NonText then
|
---|
498 | DisplayProject(8 + ofs, y0 - 15, lix);
|
---|
499 | end;
|
---|
500 | kProject:
|
---|
501 | begin
|
---|
502 | if lix and cpType <> 0 then
|
---|
503 | S := Phrases.Lookup('CITYTYPE', lix and cpIndex)
|
---|
504 | else if lix and cpImp = 0 then
|
---|
505 | with MyModel[lix and cpIndex] do
|
---|
506 | begin
|
---|
507 | S := Tribe[Me].ModelName[lix and cpIndex];
|
---|
508 | if lix and cpConscripts <> 0 then
|
---|
509 | S := Format(Phrases.Lookup('CONSCRIPTS'), [S]);
|
---|
510 | end
|
---|
511 | else
|
---|
512 | begin
|
---|
513 | S := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
|
---|
514 | if (Imp[lix and cpIndex].Kind in [ikNatLocal, ikNatGlobal]) and
|
---|
515 | (MyRO.NatBuilt[lix and cpIndex] > 0) or
|
---|
516 | (lix and cpIndex in [imPower, imHydro, imNuclear]) and
|
---|
517 | (MyCity[cixProject].Built[imPower] + MyCity[cixProject].Built
|
---|
518 | [imHydro] + MyCity[cixProject].Built[imNuclear] > 0) then
|
---|
519 | S := Format(Phrases.Lookup('NATEXISTS'), [S]);
|
---|
520 | end;
|
---|
521 | if NonText then
|
---|
522 | DisplayProject(8 + ofs, y0 - 15, lix);
|
---|
523 | end;
|
---|
524 | kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
|
---|
525 | begin
|
---|
526 | if lix = adAll then
|
---|
527 | S := Phrases.Lookup('PRICECAT_ALLTECH')
|
---|
528 | else
|
---|
529 | begin
|
---|
530 | if lix = adNexus then
|
---|
531 | S := Phrases.Lookup('NEXUS')
|
---|
532 | else if lix = adNone then
|
---|
533 | S := Phrases.Lookup('NOFARTECH')
|
---|
534 | else if lix = adMilitary then
|
---|
535 | S := Phrases.Lookup('INITUNIT')
|
---|
536 | else
|
---|
537 | begin
|
---|
538 | S := Phrases.Lookup('ADVANCES', lix);
|
---|
539 | if (Kind = kAdvance) and (lix in FutureTech) then
|
---|
540 | if MyRO.Tech[lix] < tsApplicable then
|
---|
541 | S := S + ' 1'
|
---|
542 | else
|
---|
543 | S := S + ' ' + IntToStr(MyRO.Tech[lix] + 1);
|
---|
544 | end;
|
---|
545 | if BiColorTextWidth(ca, S) > TechNameSpace + 8 then
|
---|
546 | begin
|
---|
547 | repeat
|
---|
548 | Delete(S, Length(S), 1);
|
---|
549 | until BiColorTextWidth(ca, S) <= TechNameSpace + 5;
|
---|
550 | S := S + '.';
|
---|
551 | end;
|
---|
552 |
|
---|
553 | if NonText then
|
---|
554 | begin // show tech icon
|
---|
555 | if lix = adNexus then
|
---|
556 | begin
|
---|
557 | Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
|
---|
558 | y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
---|
559 | Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
|
---|
560 | end
|
---|
561 | else if lix = adNone then
|
---|
562 | begin
|
---|
563 | Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
|
---|
564 | y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
---|
565 | Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
|
---|
566 | end
|
---|
567 | else if lix = adMilitary then
|
---|
568 | begin
|
---|
569 | Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
|
---|
570 | y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
---|
571 | Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
|
---|
572 | end
|
---|
573 | else
|
---|
574 | begin
|
---|
575 | Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1,
|
---|
576 | (8 + 16 + xSizeSmall), y0 + ySizeSmall,
|
---|
577 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
---|
578 | if AdvIcon[lix] < 84 then
|
---|
579 | BitBltBitmap(Offscreen, (8 + 16), y0, xSizeSmall,
|
---|
580 | ySizeSmall, SmallImp,
|
---|
581 | (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall,
|
---|
582 | (AdvIcon[lix] + SystemIconLines * 7) div 7 *
|
---|
583 | ySizeSmall)
|
---|
584 | else
|
---|
585 | Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20,
|
---|
586 | 1 + (AdvIcon[lix] - 84) mod 8 * 37,
|
---|
587 | 295 + (AdvIcon[lix] - 84) div 8 * 21);
|
---|
588 | J := AdvValue[lix] div 1000;
|
---|
589 | BitBltBitmap(Offscreen, (8 + 16 - 4), y0 + 2, 14, 14,
|
---|
590 | HGrSystem.Mask, 127 + J * 15,
|
---|
591 | 85, SRCAND);
|
---|
592 | Sprite(Offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
|
---|
593 | 127 + J * 15, 85);
|
---|
594 | end;
|
---|
595 | end;
|
---|
596 | end;
|
---|
597 |
|
---|
598 | if NonText and (Kind in [kAdvance, kScience]) then
|
---|
599 | begin // show research state
|
---|
600 | for J := 0 to nColumn - 1 do
|
---|
601 | begin
|
---|
602 | FutureCount := 0;
|
---|
603 | if J = 0 then // own science
|
---|
604 | if lix = MyRO.ResearchTech then
|
---|
605 | begin
|
---|
606 | Server(sGetTechCost, Me, 0, icon);
|
---|
607 | icon := 4 + MyRO.Research * 4 div icon;
|
---|
608 | if icon > 4 + 3 then
|
---|
609 | icon := 4 + 3
|
---|
610 | end
|
---|
611 | else if (lix >= adMilitary) then
|
---|
612 | icon := -1
|
---|
613 | else if lix in FutureTech then
|
---|
614 | begin
|
---|
615 | icon := -1;
|
---|
616 | FutureCount := MyRO.Tech[lix];
|
---|
617 | end
|
---|
618 | else if MyRO.Tech[lix] = tsSeen then
|
---|
619 | icon := 1
|
---|
620 | else if MyRO.Tech[lix] >= tsApplicable then
|
---|
621 | icon := 2
|
---|
622 | else
|
---|
623 | icon := -1
|
---|
624 | else
|
---|
625 | with MyRO.EnemyReport[Column[J]]^ do // enemy science
|
---|
626 | if (MyRO.Alive and (1 shl Column[J]) <> 0) and
|
---|
627 | (TurnOfCivilReport >= 0) and (lix = ResearchTech) and
|
---|
628 | ((lix = adMilitary) or (lix in FutureTech) or
|
---|
629 | (Tech[lix] < tsApplicable)) then
|
---|
630 | begin
|
---|
631 | icon := 4 + ResearchDone div 25;
|
---|
632 | if icon > 4 + 3 then
|
---|
633 | icon := 4 + 3;
|
---|
634 | end
|
---|
635 | else if lix = adMilitary then
|
---|
636 | icon := -1
|
---|
637 | else if lix in FutureTech then
|
---|
638 | begin
|
---|
639 | icon := -1;
|
---|
640 | FutureCount := Tech[lix]
|
---|
641 | end
|
---|
642 | else if Tech[lix] >= tsApplicable then
|
---|
643 | icon := 2
|
---|
644 | else if Tech[lix] = tsSeen then
|
---|
645 | icon := 1
|
---|
646 | else
|
---|
647 | icon := -1;
|
---|
648 | if icon >= 0 then
|
---|
649 | Sprite(Offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
|
---|
650 | 24 * J, y0 + 3, 14, 14, 67 + icon * 15, 85)
|
---|
651 | else if (Kind = kScience) and (FutureCount > 0) then
|
---|
652 | begin
|
---|
653 | Number := IntToStr(FutureCount);
|
---|
654 | RisedTextOut(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * J -
|
---|
655 | BiColorTextWidth(ca, Number) div 2, y0, Number);
|
---|
656 | end;
|
---|
657 | end;
|
---|
658 | end;
|
---|
659 | end; // kAdvance, kScience
|
---|
660 | kTribe:
|
---|
661 | S := TribeNames[lix];
|
---|
662 | kShipPart:
|
---|
663 | begin
|
---|
664 | S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
|
---|
665 | IntToStr(MyRO.Ship[Me].Parts[lix]) + ')';
|
---|
666 | if NonText then
|
---|
667 | DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
|
---|
668 | end;
|
---|
669 | kEShipPart:
|
---|
670 | begin
|
---|
671 | S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
|
---|
672 | IntToStr(MyRO.Ship[DipMem[Me].pContact].Parts[lix]) + ')';
|
---|
673 | if NonText then
|
---|
674 | DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
|
---|
675 | end;
|
---|
676 | kGov:
|
---|
677 | begin
|
---|
678 | S := Phrases.Lookup('GOVERNMENT', lix);
|
---|
679 | if NonText then
|
---|
680 | begin
|
---|
681 | Frame(Offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
|
---|
682 | 8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall),
|
---|
683 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
---|
684 | BitBltBitmap(Offscreen, 8 + 16, y0 - 15 + (16 - 1),
|
---|
685 | xSizeSmall, ySizeSmall, SmallImp, (lix - 1) * xSizeSmall, ySizeSmall);
|
---|
686 | end;
|
---|
687 | end;
|
---|
688 | kMission:
|
---|
689 | S := Phrases.Lookup('SPYMISSION', lix);
|
---|
690 | end;
|
---|
691 | case Kind of
|
---|
692 | kTribe, kMission: // center text
|
---|
693 | if Lines[0] > MaxLines then
|
---|
694 | X := (InnerWidth - GetSystemMetrics(SM_CXVSCROLL)) div 2 -
|
---|
695 | BiColorTextWidth(ca, S) div 2
|
---|
696 | else
|
---|
697 | X := InnerWidth div 2 - BiColorTextWidth(ca, S) div 2;
|
---|
698 | kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech,
|
---|
699 | kStealTech, kGov:
|
---|
700 | X := 104 - 33;
|
---|
701 | kAllEModels:
|
---|
702 | X := 104;
|
---|
703 | else
|
---|
704 | X := 104 + 15;
|
---|
705 | end;
|
---|
706 | Y := y0;
|
---|
707 | if ca = Canvas then
|
---|
708 | begin
|
---|
709 | X := X + SideFrame;
|
---|
710 | Y := Y + TitleHeight;
|
---|
711 | end;
|
---|
712 | if lit then
|
---|
713 | TextColor := MainTexture.ColorLitText
|
---|
714 | else
|
---|
715 | TextColor := -1;
|
---|
716 | { if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor,
|
---|
717 | Integer(TribeNames.Objects[lix]),S)
|
---|
718 | else } ReplaceText(X, Y, TextColor, S);
|
---|
719 | end;
|
---|
720 | end;
|
---|
721 |
|
---|
722 | procedure TListDlg.OffscreenPaint;
|
---|
723 | var
|
---|
724 | I, J: Integer;
|
---|
725 | begin
|
---|
726 | case Kind of
|
---|
727 | kCities:
|
---|
728 | Caption := Tribe[Me].TPhrase('TITLE_CITIES');
|
---|
729 | kCityEvents:
|
---|
730 | Caption := Format(Phrases.Lookup('TITLE_EVENTS'),
|
---|
731 | [TurnToString(MyRO.Turn)]);
|
---|
732 | end;
|
---|
733 |
|
---|
734 | inherited;
|
---|
735 | Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
|
---|
736 | FillOffscreen(0, 0, InnerWidth, InnerHeight);
|
---|
737 | with Offscreen.Canvas do
|
---|
738 | begin
|
---|
739 | if Kind = kScience then
|
---|
740 | for I := 1 to nColumn - 1 do
|
---|
741 | begin
|
---|
742 | Pen.Color := $000000;
|
---|
743 | MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I, 0);
|
---|
744 | LineTo(104 - 33 + 15 + TechNameSpace + 24 * I, InnerHeight);
|
---|
745 | MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, 0);
|
---|
746 | LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, InnerHeight);
|
---|
747 | if MyRO.EnemyReport[Column[I]].TurnOfCivilReport >= MyRO.Turn - 1 then
|
---|
748 | begin
|
---|
749 | Brush.Color := Tribe[Column[I]].Color;
|
---|
750 | FillRect(rect(104 - 33 + 14 + TechNameSpace + 24 * I + 1 * 2, 0,
|
---|
751 | 104 - 33 + 17 + TechNameSpace + 24 * I + 8 * 2, InnerHeight));
|
---|
752 | Brush.Style := TBrushStyle.bsClear;
|
---|
753 | end
|
---|
754 | else
|
---|
755 | begin // colored player columns
|
---|
756 | Pen.Color := Tribe[Column[I]].Color;
|
---|
757 | for J := 1 to 8 do
|
---|
758 | begin
|
---|
759 | MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, 0);
|
---|
760 | LineTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, InnerHeight);
|
---|
761 | end;
|
---|
762 | end;
|
---|
763 | end;
|
---|
764 |
|
---|
765 | for I := -1 to DispLines do
|
---|
766 | if (I + ScrollBar.Position >= 0) and (I + ScrollBar.Position < Lines[Layer]) then
|
---|
767 | Self.Line(Offscreen.Canvas, I, True, False);
|
---|
768 | end;
|
---|
769 | MarkUsedOffscreen(InnerWidth, 8 + 48 + DispLines * LineDistance);
|
---|
770 | end;
|
---|
771 |
|
---|
772 | procedure TListDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
|
---|
773 | X, Y: Integer);
|
---|
774 | var
|
---|
775 | i0, Sel0, iColumn, OldScienceNation, xScreen: Integer;
|
---|
776 | S: string;
|
---|
777 | begin
|
---|
778 | Y := Y - TitleHeight;
|
---|
779 | i0 := ScrollBar.Position;
|
---|
780 | Sel0 := Selected;
|
---|
781 | if (X >= SideFrame) and (X < SideFrame + InnerWidth) and (Y >= 0) and
|
---|
782 | (Y < InnerHeight) and (Y mod LineDistance >= 4) and (Y mod LineDistance < 20)
|
---|
783 | then
|
---|
784 | Selected := Y div LineDistance - 1
|
---|
785 | else
|
---|
786 | Selected := -2;
|
---|
787 | if (Selected < -1) or (Selected > DispLines) or (Selected + i0 < 0) or
|
---|
788 | (Selected + i0 >= Lines[Layer]) then
|
---|
789 | Selected := -2;
|
---|
790 | if Selected <> Sel0 then
|
---|
791 | begin
|
---|
792 | if Sel0 <> -2 then
|
---|
793 | Line(Canvas, Sel0, False, False);
|
---|
794 | if Selected <> -2 then
|
---|
795 | Line(Canvas, Selected, False, True);
|
---|
796 | end;
|
---|
797 |
|
---|
798 | if Kind = kScience then
|
---|
799 | begin // show nation under cursor position
|
---|
800 | OldScienceNation := ScienceNation;
|
---|
801 | ScienceNation := -1;
|
---|
802 | if (X >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and
|
---|
803 | ((X - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and
|
---|
804 | (Y >= 0) and (Y < InnerHeight) then
|
---|
805 | begin
|
---|
806 | iColumn := (X - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;
|
---|
807 | if (iColumn >= 1) and (iColumn < nColumn) then
|
---|
808 | ScienceNation := Column[iColumn];
|
---|
809 | end;
|
---|
810 | if ScienceNation <> OldScienceNation then
|
---|
811 | begin
|
---|
812 | Fill(Canvas, 9, Height - 29, Width - 18, 24,
|
---|
813 | (Maintexture.Width - Width) div 2,
|
---|
814 | (Maintexture.Height - Height) div 2);
|
---|
815 | if ScienceNation >= 0 then
|
---|
816 | begin
|
---|
817 | S := Tribe[ScienceNation].TPhrase('SHORTNAME');
|
---|
818 | if MyRO.Alive and (1 shl ScienceNation) = 0 then
|
---|
819 | S := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [S]) // extinct
|
---|
820 | else if MyRO.EnemyReport[ScienceNation].TurnOfCivilReport < MyRO.Turn - 1
|
---|
821 | then
|
---|
822 | S := S + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]
|
---|
823 | .TurnOfCivilReport) + ')'; // old report
|
---|
824 | xScreen := (Width - BiColorTextWidth(Canvas, S)) div 2;
|
---|
825 | LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10,
|
---|
826 | Height - 29, S);
|
---|
827 | BitBltCanvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width,
|
---|
828 | ScienceNationDot.Height, Canvas, xScreen - 10, Height - 27);
|
---|
829 | ImageOp_BCC(ScienceNationDotBuffer, Templates.Data, Point(0, 0),
|
---|
830 | ScienceNationDot.BoundsRect, MainTexture.ColorBevelShade, Tribe[ScienceNation].Color);
|
---|
831 | BitBltCanvas(Canvas, xScreen - 10, Height - 27, ScienceNationDot.Width,
|
---|
832 | ScienceNationDot.Height, ScienceNationDotBuffer.Canvas, 0, 0);
|
---|
833 | end;
|
---|
834 | end;
|
---|
835 | end;
|
---|
836 | end;
|
---|
837 |
|
---|
838 | procedure TListDlg.FormMouseWheel(Sender: TObject; Shift: TShiftState;
|
---|
839 | WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
|
---|
840 | begin
|
---|
841 | if ScrollBar.ProcessMouseWheel(WheelDelta) then begin
|
---|
842 | PaintBox1MouseMove(nil, [], MousePos.X - Left,
|
---|
843 | MousePos.Y - Top);
|
---|
844 | end;
|
---|
845 | end;
|
---|
846 |
|
---|
847 | procedure TListDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
848 | begin
|
---|
849 | //Gtk2Fix;
|
---|
850 | end;
|
---|
851 |
|
---|
852 | function TListDlg.RenameCity(cix: Integer): Boolean;
|
---|
853 | var
|
---|
854 | CityNameInfo: TCityNameInfo;
|
---|
855 | begin
|
---|
856 | InputDlg.Caption := Phrases.Lookup('TITLE_CITYNAME');
|
---|
857 | InputDlg.EditInput.Text := CityName(MyCity[cix].ID);
|
---|
858 | InputDlg.CenterToRect(BoundsRect);
|
---|
859 | InputDlg.ShowModal;
|
---|
860 | if (InputDlg.ModalResult = mrOK) and (InputDlg.EditInput.Text <> '') and
|
---|
861 | (InputDlg.EditInput.Text <> CityName(MyCity[cix].ID)) then
|
---|
862 | begin
|
---|
863 | CityNameInfo.ID := MyCity[cix].ID;
|
---|
864 | CityNameInfo.NewName := InputDlg.EditInput.Text;
|
---|
865 | if CityNameInfo.GetCommandDataSize > CommandDataMaxSize then
|
---|
866 | Delete(CityNameInfo.NewName, Length(CityNameInfo.NewName) -
|
---|
867 | (CityNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt);
|
---|
868 | Server(CommandWithData(cSetCityName, CityNameInfo.GetCommandDataSize),
|
---|
869 | Me, 0, CityNameInfo);
|
---|
870 | if MainScreen.CityDlg.Visible then
|
---|
871 | begin
|
---|
872 | MainScreen.CityDlg.FormShow(nil);
|
---|
873 | MainScreen.CityDlg.Invalidate;
|
---|
874 | end;
|
---|
875 | Result := True;
|
---|
876 | end
|
---|
877 | else
|
---|
878 | Result := False;
|
---|
879 | end;
|
---|
880 |
|
---|
881 | function TListDlg.RenameModel(mix: Integer): Boolean;
|
---|
882 | var
|
---|
883 | ModelNameInfo: TModelNameInfo;
|
---|
884 | begin
|
---|
885 | InputDlg.Caption := Phrases.Lookup('TITLE_MODELNAME');
|
---|
886 | InputDlg.EditInput.Text := Tribe[Me].ModelName[mix];
|
---|
887 | InputDlg.CenterToRect(BoundsRect);
|
---|
888 | InputDlg.ShowModal;
|
---|
889 | if (InputDlg.ModalResult = mrOK) and (InputDlg.EditInput.Text <> '') and
|
---|
890 | (InputDlg.EditInput.Text <> Tribe[Me].ModelName[mix]) then
|
---|
891 | begin
|
---|
892 | ModelNameInfo.mix := mix;
|
---|
893 | ModelNameInfo.NewName := InputDlg.EditInput.Text;
|
---|
894 | if ModelNameInfo.GetCommandDataSize > CommandDataMaxSize then
|
---|
895 | Delete(ModelNameInfo.NewName, Length(ModelNameInfo.NewName) -
|
---|
896 | (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt);
|
---|
897 | Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize),
|
---|
898 | Me, 0, ModelNameInfo);
|
---|
899 | if MainScreen.UnitStatDlg.Visible then
|
---|
900 | begin
|
---|
901 | MainScreen.UnitStatDlg.FormShow(nil);
|
---|
902 | MainScreen.UnitStatDlg.Invalidate;
|
---|
903 | end;
|
---|
904 | Result := True;
|
---|
905 | end
|
---|
906 | else
|
---|
907 | Result := False;
|
---|
908 | end;
|
---|
909 |
|
---|
910 | procedure TListDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
|
---|
911 | Shift: TShiftState; X, Y: Integer);
|
---|
912 | var
|
---|
913 | lix: Integer;
|
---|
914 | begin
|
---|
915 | if ScrollBar.Position + Selected >= 0 then
|
---|
916 | lix := Code[Layer, ScrollBar.Position + Selected];
|
---|
917 | if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels]
|
---|
918 | then
|
---|
919 | Include(Shift, ssShift); // don't close list window
|
---|
920 | if (ssLeft in Shift) and not (ssShift in Shift) then
|
---|
921 | begin
|
---|
922 | if Selected <> -2 then
|
---|
923 | begin
|
---|
924 | Result := lix;
|
---|
925 | Closable := True;
|
---|
926 | Close;
|
---|
927 | end;
|
---|
928 | end
|
---|
929 | else if (ssLeft in Shift) and (ssShift in Shift) then
|
---|
930 | begin // show help/info popup
|
---|
931 | if Selected <> -2 then
|
---|
932 | case Kind of
|
---|
933 | kCities:
|
---|
934 | MainScreen.ZoomToCity(MyCity[lix].Loc);
|
---|
935 | kCityEvents:
|
---|
936 | MainScreen.ZoomToCity(MyCity[lix].Loc, False, MyCity[lix].Flags and
|
---|
937 | CityRepMask);
|
---|
938 | kModels, kChooseModel:
|
---|
939 | if lix <> mixAll then
|
---|
940 | MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmPersistent, lix);
|
---|
941 | kEModels:
|
---|
942 | MainScreen.UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent,
|
---|
943 | Code[1, ScrollBar.Position + Selected]);
|
---|
944 | kAllEModels, kChooseEModel:
|
---|
945 | if lix <> mixAll then
|
---|
946 | MainScreen.UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent, lix);
|
---|
947 | kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
|
---|
948 | if lix = adMilitary then
|
---|
949 | MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkText,
|
---|
950 | MainScreen.HelpDlg.TextIndex('MILRES'))
|
---|
951 | else if lix < adMilitary then
|
---|
952 | MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkAdv, lix);
|
---|
953 | kProject:
|
---|
954 | if lix = cpImp + imTrGoods then
|
---|
955 | MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkText,
|
---|
956 | MainScreen.HelpDlg.TextIndex('TRADINGGOODS'))
|
---|
957 | else if lix and (cpImp + cpType) = 0 then
|
---|
958 | MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmPersistent,
|
---|
959 | lix and cpIndex)
|
---|
960 | else if (lix and cpType = 0) and (lix <> cpImp + imTrGoods) then
|
---|
961 | MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkImp,
|
---|
962 | lix and cpIndex);
|
---|
963 | kGov:
|
---|
964 | MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkMisc,
|
---|
965 | Integer(miscGovList));
|
---|
966 | kShipPart, kEShipPart:
|
---|
967 | ;
|
---|
968 | end;
|
---|
969 | end
|
---|
970 | else if ssRight in Shift then
|
---|
971 | begin
|
---|
972 | if Selected <> -2 then
|
---|
973 | case Kind of
|
---|
974 | kCities, kCityEvents:
|
---|
975 | if RenameCity(lix) then begin
|
---|
976 | SmartUpdateContent;
|
---|
977 | Term.MainScreen.RepaintAll;
|
---|
978 | end;
|
---|
979 | kModels:
|
---|
980 | if RenameModel(lix) then begin
|
---|
981 | SmartUpdateContent;
|
---|
982 | Term.MainScreen.RepaintAll;
|
---|
983 | end;
|
---|
984 | end;
|
---|
985 | end;
|
---|
986 | end;
|
---|
987 |
|
---|
988 | procedure TListDlg.InitLines;
|
---|
989 | var
|
---|
990 | Required: array [0 .. nAdv - 1] of Integer;
|
---|
991 |
|
---|
992 | procedure TryAddImpLine(Layer, Project: Integer);
|
---|
993 | begin
|
---|
994 | if Server(sSetCityProject - sExecute, Me, cixProject, Project) >= rExecuted
|
---|
995 | then
|
---|
996 | begin
|
---|
997 | Code[Layer, Lines[Layer]] := Project;
|
---|
998 | Inc(Lines[Layer]);
|
---|
999 | end;
|
---|
1000 | end;
|
---|
1001 |
|
---|
1002 | procedure SortTechs;
|
---|
1003 | var
|
---|
1004 | I, J, Swap: Integer;
|
---|
1005 | begin // sort by advancedness
|
---|
1006 | for I := 0 to Lines[0] - 2 do
|
---|
1007 | if Code[0, I] < adMilitary then
|
---|
1008 | for J := I + 1 to Lines[0] - 1 do
|
---|
1009 | if AdvValue[Code[0, I]] * nAdv + Code[0, I] < AdvValue[Code[0, J]] *
|
---|
1010 | nAdv + Code[0, J] then
|
---|
1011 | begin
|
---|
1012 | Swap := Code[0, I];
|
---|
1013 | Code[0, I] := Code[0, J];
|
---|
1014 | Code[0, J] := Swap;
|
---|
1015 | end;
|
---|
1016 | end;
|
---|
1017 |
|
---|
1018 | procedure SortCities;
|
---|
1019 | var
|
---|
1020 | I, J, Swap: Integer;
|
---|
1021 | begin
|
---|
1022 | for I := 0 to Lines[0] - 2 do
|
---|
1023 | for J := I + 1 to Lines[0] - 1 do
|
---|
1024 | if CityName(MyCity[Code[0, I]].ID) > CityName(MyCity[Code[0, J]].ID)
|
---|
1025 | then
|
---|
1026 | begin
|
---|
1027 | Swap := Code[0, I];
|
---|
1028 | Code[0, I] := Code[0, J];
|
---|
1029 | Code[0, J] := Swap;
|
---|
1030 | end;
|
---|
1031 | end;
|
---|
1032 |
|
---|
1033 | function ModelSortValue(const mi: TModelInfo;
|
---|
1034 | MixPlayers: Boolean = False): Integer;
|
---|
1035 | begin
|
---|
1036 | Result := (mi.Domain + 1) shl 28 - mi.mix;
|
---|
1037 | if MixPlayers then
|
---|
1038 | Dec(Result, ModelCode(mi) shl 16);
|
---|
1039 | end;
|
---|
1040 |
|
---|
1041 | procedure SortModels;
|
---|
1042 | var
|
---|
1043 | I, J, Swap: Integer;
|
---|
1044 | begin // sort by code[2]
|
---|
1045 | for I := 0 to Lines[0] - 2 do
|
---|
1046 | for J := I + 1 to Lines[0] - 1 do
|
---|
1047 | if Code[2, I] > Code[2, J] then
|
---|
1048 | begin
|
---|
1049 | Swap := Code[0, I];
|
---|
1050 | Code[0, I] := Code[0, J];
|
---|
1051 | Code[0, J] := Swap;
|
---|
1052 | Swap := Code[1, I];
|
---|
1053 | Code[1, I] := Code[1, J];
|
---|
1054 | Code[1, J] := Swap;
|
---|
1055 | Swap := Code[2, I];
|
---|
1056 | Code[2, I] := Code[2, J];
|
---|
1057 | Code[2, J] := Swap;
|
---|
1058 | end;
|
---|
1059 | end;
|
---|
1060 |
|
---|
1061 | procedure MarkPreqs(I: Integer);
|
---|
1062 | begin
|
---|
1063 | Required[I] := 1;
|
---|
1064 | if MyRO.Tech[I] < tsSeen then
|
---|
1065 | begin
|
---|
1066 | if (AdvPreq[I, 0] >= 0) then
|
---|
1067 | MarkPreqs(AdvPreq[I, 0]);
|
---|
1068 | if (AdvPreq[I, 1] >= 0) then
|
---|
1069 | MarkPreqs(AdvPreq[I, 1]);
|
---|
1070 | end;
|
---|
1071 | end;
|
---|
1072 |
|
---|
1073 | var
|
---|
1074 | Loc1, I, J, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: Integer;
|
---|
1075 | mi: TModelInfo;
|
---|
1076 | PPicture, PTestPicture: ^TModelPicture;
|
---|
1077 | ModelOk: array [0 .. 4095] of Boolean;
|
---|
1078 | Ok: Boolean;
|
---|
1079 | begin
|
---|
1080 | for I := 0 to MaxLayer - 1 do
|
---|
1081 | begin
|
---|
1082 | Lines[I] := 0;
|
---|
1083 | FirstShrinkedLine[I] := MaxInt;
|
---|
1084 | end;
|
---|
1085 | case Kind of
|
---|
1086 | kProject:
|
---|
1087 | begin
|
---|
1088 | // improvements
|
---|
1089 | Code[0, 0] := cpImp + imTrGoods;
|
---|
1090 | Lines[0] := 1;
|
---|
1091 | for I := nWonder to nImp - 1 do
|
---|
1092 | if Imp[I].Kind = ikCommon then
|
---|
1093 | TryAddImpLine(0, I + cpImp);
|
---|
1094 | for I := nWonder to nImp - 1 do
|
---|
1095 | if not (Imp[I].Kind in [ikCommon, ikTrGoods]) and
|
---|
1096 | ((MyRO.NatBuilt[I] = 0) or (Imp[I].Kind = ikNatLocal)) then
|
---|
1097 | TryAddImpLine(0, I + cpImp);
|
---|
1098 | for I := 0 to nCityType - 1 do
|
---|
1099 | if MyData.ImpOrder[I, 0] >= 0 then
|
---|
1100 | begin
|
---|
1101 | Code[0, Lines[0]] := cpType + I;
|
---|
1102 | Inc(Lines[0]);
|
---|
1103 | end;
|
---|
1104 |
|
---|
1105 | // wonders
|
---|
1106 | for I := 0 to nWonder - 1 do
|
---|
1107 | TryAddImpLine(1, I + cpImp);
|
---|
1108 |
|
---|
1109 | // units
|
---|
1110 | for I := 0 to MyRO.nModel - 1 do
|
---|
1111 | begin
|
---|
1112 | { if MyModel[i].Kind=mkSlaves then
|
---|
1113 | Ok:= MyRO.Wonder[woPyramids].EffectiveOwner=Me
|
---|
1114 | else } if MyModel[I].Domain = dSea then
|
---|
1115 | begin
|
---|
1116 | Ok := False;
|
---|
1117 | for dx := -2 to 2 do
|
---|
1118 | for dy := -2 to 2 do
|
---|
1119 | if Abs(dx) + Abs(dy) = 2 then
|
---|
1120 | begin
|
---|
1121 | Loc1 := dLoc(MyCity[cixProject].Loc, dx, dy);
|
---|
1122 | if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
|
---|
1123 | ((MyMap[Loc1] and fTerrain = fShore) or
|
---|
1124 | (MyMap[Loc1] and fCanal > 0)) then begin
|
---|
1125 | Ok := True;
|
---|
1126 | Break;
|
---|
1127 | end;
|
---|
1128 | end;
|
---|
1129 | end
|
---|
1130 | else
|
---|
1131 | Ok := True;
|
---|
1132 | if Ok then
|
---|
1133 | begin
|
---|
1134 | if MyModel[I].Status and msObsolete = 0 then
|
---|
1135 | begin
|
---|
1136 | Code[2, Lines[2]] := I;
|
---|
1137 | Inc(Lines[2]);
|
---|
1138 | end;
|
---|
1139 | if MyModel[I].Status and msAllowConscripts <> 0 then
|
---|
1140 | begin
|
---|
1141 | Code[2, Lines[2]] := I + cpConscripts;
|
---|
1142 | Inc(Lines[2]);
|
---|
1143 | end;
|
---|
1144 | end;
|
---|
1145 | end;
|
---|
1146 | FirstShrinkedLine[2] := 0;
|
---|
1147 | end;
|
---|
1148 | kAdvance:
|
---|
1149 | begin
|
---|
1150 | nColumn := 1;
|
---|
1151 | if MyData.FarTech <> adNone then
|
---|
1152 | begin
|
---|
1153 | FillChar(Required, SizeOf(Required), 0);
|
---|
1154 | MarkPreqs(MyData.FarTech);
|
---|
1155 | end;
|
---|
1156 | for I := 0 to nAdv - 1 do
|
---|
1157 | if ((I in FutureTech) or (MyRO.Tech[I] < tsApplicable)) and
|
---|
1158 | (Server(sSetResearch - sExecute, Me, I, nil^) >= rExecuted) and
|
---|
1159 | ((MyData.FarTech = adNone) or (Required[I] > 0)) then
|
---|
1160 | begin
|
---|
1161 | Code[0, Lines[0]] := I;
|
---|
1162 | Inc(Lines[0]);
|
---|
1163 | end;
|
---|
1164 | SortTechs;
|
---|
1165 | if Lines[0] = 0 then // no more techs -- offer nexus
|
---|
1166 | begin
|
---|
1167 | Code[0, Lines[0]] := adNexus;
|
---|
1168 | Inc(Lines[0]);
|
---|
1169 | end;
|
---|
1170 | Ok := False;
|
---|
1171 | for I := 0 to nDomains - 1 do
|
---|
1172 | if (upgrade[I, 0].Preq = preNone) or
|
---|
1173 | (MyRO.Tech[upgrade[I, 0].Preq] >= tsApplicable) then begin
|
---|
1174 | Ok := True;
|
---|
1175 | Break;
|
---|
1176 | end;
|
---|
1177 | if Ok then { new unit class }
|
---|
1178 | begin
|
---|
1179 | Code[0, Lines[0]] := adMilitary;
|
---|
1180 | Inc(Lines[0]);
|
---|
1181 | end;
|
---|
1182 | end;
|
---|
1183 | kFarAdvance:
|
---|
1184 | begin
|
---|
1185 | Code[0, Lines[0]] := adNone;
|
---|
1186 | Inc(Lines[0]);
|
---|
1187 | for I := 0 to nAdv - 1 do
|
---|
1188 | if not (I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
|
---|
1189 | ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
|
---|
1190 | ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
|
---|
1191 | begin
|
---|
1192 | Code[0, Lines[0]] := I;
|
---|
1193 | Inc(Lines[0]);
|
---|
1194 | end;
|
---|
1195 | SortTechs;
|
---|
1196 | end;
|
---|
1197 | kChooseTech:
|
---|
1198 | begin
|
---|
1199 | for I := 0 to nAdv - 1 do
|
---|
1200 | if not (I in FutureTech) and (MyRO.Tech[I] >= tsApplicable) and
|
---|
1201 | (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) then
|
---|
1202 | begin
|
---|
1203 | Code[0, Lines[0]] := I;
|
---|
1204 | Inc(Lines[0]);
|
---|
1205 | end;
|
---|
1206 | SortTechs;
|
---|
1207 | // if Lines[0]>1 then
|
---|
1208 | begin
|
---|
1209 | Code[0, Lines[0]] := adAll;
|
---|
1210 | Inc(Lines[0]);
|
---|
1211 | end;
|
---|
1212 | end;
|
---|
1213 | kChooseETech:
|
---|
1214 | begin
|
---|
1215 | for I := 0 to nAdv - 1 do
|
---|
1216 | if not (I in FutureTech) and (MyRO.Tech[I] < tsSeen) and
|
---|
1217 | (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then
|
---|
1218 | begin
|
---|
1219 | Code[0, Lines[0]] := I;
|
---|
1220 | Inc(Lines[0]);
|
---|
1221 | end;
|
---|
1222 | SortTechs;
|
---|
1223 | // if Lines[0]>1 then
|
---|
1224 | begin
|
---|
1225 | Code[0, Lines[0]] := adAll;
|
---|
1226 | Inc(Lines[0]);
|
---|
1227 | end;
|
---|
1228 | end;
|
---|
1229 | kStealTech:
|
---|
1230 | begin
|
---|
1231 | for I := 0 to nAdv - 1 do
|
---|
1232 | if Server(sStealTech - sExecute, Me, I, nil^) >= rExecuted then
|
---|
1233 | begin
|
---|
1234 | Code[0, Lines[0]] := I;
|
---|
1235 | Inc(Lines[0]);
|
---|
1236 | end;
|
---|
1237 | SortTechs;
|
---|
1238 | end;
|
---|
1239 | kScience:
|
---|
1240 | begin
|
---|
1241 | Column[0] := Me;
|
---|
1242 | nColumn := 1;
|
---|
1243 | for EnemyType := 0 to 2 do
|
---|
1244 | for p1 := 0 to nPl - 1 do
|
---|
1245 | if (MyRO.EnemyReport[p1] <> nil) and
|
---|
1246 | ((MyRO.EnemyReport[p1].TurnOfContact >= 0) or
|
---|
1247 | (MyRO.EnemyReport[p1].TurnOfCivilReport >= 0)) then
|
---|
1248 | begin
|
---|
1249 | if MyRO.Alive and (1 shl p1) = 0 then
|
---|
1250 | TestEnemyType := 2 // extinct enemy -- move to right end
|
---|
1251 | else if MyRO.EnemyReport[p1].TurnOfCivilReport >= MyRO.Turn - 1
|
---|
1252 | then
|
---|
1253 | TestEnemyType := 0 // current report -- move to left end
|
---|
1254 | else
|
---|
1255 | TestEnemyType := 1;
|
---|
1256 | if TestEnemyType = EnemyType then
|
---|
1257 | begin
|
---|
1258 | Column[nColumn] := p1;
|
---|
1259 | Inc(nColumn);
|
---|
1260 | end;
|
---|
1261 | end;
|
---|
1262 | for I := 0 to nAdv - 1 do
|
---|
1263 | begin
|
---|
1264 | Ok := (MyRO.Tech[I] <> tsNA) or (MyRO.ResearchTech = I);
|
---|
1265 | for J := 1 to nColumn - 1 do
|
---|
1266 | with MyRO.EnemyReport[Column[J]]^ do
|
---|
1267 | if (Tech[I] <> tsNA) or (TurnOfCivilReport >= 0) and
|
---|
1268 | (ResearchTech = I) then
|
---|
1269 | Ok := True;
|
---|
1270 | if Ok then
|
---|
1271 | begin
|
---|
1272 | Code[0, Lines[0]] := I;
|
---|
1273 | Inc(Lines[0]);
|
---|
1274 | end;
|
---|
1275 | end;
|
---|
1276 | SortTechs;
|
---|
1277 |
|
---|
1278 | Ok := MyRO.ResearchTech = adMilitary;
|
---|
1279 | for J := 1 to nColumn - 1 do
|
---|
1280 | with MyRO.EnemyReport[Column[J]]^ do
|
---|
1281 | if (MyRO.Alive and (1 shl Column[J]) <> 0) and
|
---|
1282 | (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then begin
|
---|
1283 | Ok := True;
|
---|
1284 | Break;
|
---|
1285 | end;
|
---|
1286 | if Ok then
|
---|
1287 | begin
|
---|
1288 | Code[0, Lines[0]] := adMilitary;
|
---|
1289 | Inc(Lines[0]);
|
---|
1290 | end
|
---|
1291 | end;
|
---|
1292 | kCities { , kChooseCity } :
|
---|
1293 | begin
|
---|
1294 | if ClientMode < scContact then
|
---|
1295 | for I := 0 to MyRO.nCity - 1 do
|
---|
1296 | if MyCity[I].Loc >= 0 then
|
---|
1297 | begin
|
---|
1298 | Code[0, Lines[0]] := I;
|
---|
1299 | Inc(Lines[0]);
|
---|
1300 | end;
|
---|
1301 | SortCities;
|
---|
1302 | FirstShrinkedLine[0] := 0
|
---|
1303 | end;
|
---|
1304 | kCityEvents:
|
---|
1305 | begin
|
---|
1306 | for I := 0 to MyRO.nCity - 1 do
|
---|
1307 | if (MyCity[I].Loc >= 0) and (MyCity[I].Flags and CityRepMask <> 0)
|
---|
1308 | then
|
---|
1309 | begin
|
---|
1310 | Code[0, Lines[0]] := I;
|
---|
1311 | Inc(Lines[0]);
|
---|
1312 | end;
|
---|
1313 | SortCities;
|
---|
1314 | FirstShrinkedLine[0] := 0;
|
---|
1315 | end;
|
---|
1316 | { kChooseECity:
|
---|
1317 | begin
|
---|
1318 | for I:=0 to MyRO.nEnemyCity-1 do
|
---|
1319 | if (MyRO.EnemyCity[I].Loc>=0)
|
---|
1320 | and (MyRO.EnemyCity[I].owner=DipMem[Me].pContact) then
|
---|
1321 | begin Code[0,Lines[0]]:=I; Inc(Lines[0]); end;
|
---|
1322 | FirstShrinkedLine:=0
|
---|
1323 | end; }
|
---|
1324 | kModels:
|
---|
1325 | begin
|
---|
1326 | for mix := 0 to MyRO.nModel - 1 do
|
---|
1327 | begin
|
---|
1328 | Code[0, mix] := mix;
|
---|
1329 | MakeModelInfo(Me, mix, MyModel[mix], mi);
|
---|
1330 | Code[2, mix] := ModelSortValue(mi);
|
---|
1331 | end;
|
---|
1332 | Lines[0] := MyRO.nModel;
|
---|
1333 | SortModels;
|
---|
1334 | FirstShrinkedLine[0] := 0;
|
---|
1335 | end;
|
---|
1336 | kChooseModel:
|
---|
1337 | begin
|
---|
1338 | for mix := 3 to MyRO.nModel - 1 do
|
---|
1339 | begin // check if opponent already has this model
|
---|
1340 | MakeModelInfo(Me, mix, MyModel[mix], mi);
|
---|
1341 | Ok := True;
|
---|
1342 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
---|
1343 | if (MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact) and
|
---|
1344 | IsSameModel(MyRO.EnemyModel[emix], mi) then begin
|
---|
1345 | Ok := False;
|
---|
1346 | Break;
|
---|
1347 | end;
|
---|
1348 | if Ok then
|
---|
1349 | begin
|
---|
1350 | Code[0, Lines[0]] := mix;
|
---|
1351 | MakeModelInfo(Me, mix, MyModel[mix], mi);
|
---|
1352 | Code[2, Lines[0]] := ModelSortValue(mi);
|
---|
1353 | Inc(Lines[0]);
|
---|
1354 | end;
|
---|
1355 | end;
|
---|
1356 | SortModels;
|
---|
1357 | // if Lines[0]>1 then
|
---|
1358 | begin
|
---|
1359 | Code[0, Lines[0]] := mixAll;
|
---|
1360 | Inc(Lines[0]);;
|
---|
1361 | end;
|
---|
1362 | FirstShrinkedLine[0] := 0;
|
---|
1363 | end;
|
---|
1364 | kChooseEModel:
|
---|
1365 | begin
|
---|
1366 | if MyRO.TestFlags and tfUncover <> 0 then
|
---|
1367 | Server(sGetModels, Me, 0, nil^);
|
---|
1368 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
---|
1369 | ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact;
|
---|
1370 | for mix := 0 to MyRO.nModel - 1 do
|
---|
1371 | begin // don't list models I already have
|
---|
1372 | MakeModelInfo(Me, mix, MyModel[mix], mi);
|
---|
1373 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
---|
1374 | ModelOk[emix] := ModelOk[emix] and
|
---|
1375 | not IsSameModel(MyRO.EnemyModel[emix], mi);
|
---|
1376 | end;
|
---|
1377 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
---|
1378 | if ModelOk[emix] then
|
---|
1379 | begin
|
---|
1380 | if not Assigned(Tribe[DipMem[Me].pContact].ModelPicture
|
---|
1381 | [MyRO.EnemyModel[emix].mix].HGr) then
|
---|
1382 | InitEnemyModel(emix);
|
---|
1383 | Code[0, Lines[0]] := emix;
|
---|
1384 | Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
|
---|
1385 | Inc(Lines[0]);
|
---|
1386 | end;
|
---|
1387 | SortModels;
|
---|
1388 | // if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then
|
---|
1389 | begin
|
---|
1390 | Code[0, Lines[0]] := mixAll;
|
---|
1391 | Inc(Lines[0]);
|
---|
1392 | end;
|
---|
1393 | FirstShrinkedLine[0] := 0;
|
---|
1394 | end;
|
---|
1395 | kEModels:
|
---|
1396 | begin
|
---|
1397 | for I := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
|
---|
1398 | begin
|
---|
1399 | Code[1, Lines[0]] := MyRO.nEnemyModel - 1;
|
---|
1400 | while (Code[1, Lines[0]] >= 0) and
|
---|
1401 | not ((MyRO.EnemyModel[Code[1, Lines[0]]].Owner = pView) and
|
---|
1402 | (MyRO.EnemyModel[Code[1, Lines[0]]].mix = I)) do
|
---|
1403 | Dec(Code[1, Lines[0]]);
|
---|
1404 | if not Assigned(Tribe[pView].ModelPicture[I].HGr) then
|
---|
1405 | InitEnemyModel(Code[1, Lines[0]]);
|
---|
1406 | Code[0, Lines[0]] := I;
|
---|
1407 | Code[2, Lines[0]] :=
|
---|
1408 | ModelSortValue(MyRO.EnemyModel[Code[1, Lines[0]]]);
|
---|
1409 | Inc(Lines[0]);
|
---|
1410 | end;
|
---|
1411 | SortModels;
|
---|
1412 | FirstShrinkedLine[0] := 0;
|
---|
1413 | end;
|
---|
1414 | kAllEModels:
|
---|
1415 | begin
|
---|
1416 | if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[Me] = 0) then
|
---|
1417 | Server(sGetModels, Me, 0, nil^);
|
---|
1418 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
---|
1419 | if (MyRO.EnemyModel[emix].mix >= 3) and
|
---|
1420 | (MyRO.EnemyModel[emix].Kind in [mkSelfDeveloped, mkEnemyDeveloped])
|
---|
1421 | then
|
---|
1422 | begin
|
---|
1423 | PPicture := @Tribe[MyRO.EnemyModel[emix].Owner].ModelPicture
|
---|
1424 | [MyRO.EnemyModel[emix].mix];
|
---|
1425 | if not Assigned(PPicture.HGr) then
|
---|
1426 | InitEnemyModel(emix);
|
---|
1427 | Ok := True;
|
---|
1428 | if MainScreen.mNames.Checked then
|
---|
1429 | for J := 0 to Lines[0] - 1 do
|
---|
1430 | begin
|
---|
1431 | PTestPicture := @Tribe[MyRO.EnemyModel[Code[0, J]].Owner]
|
---|
1432 | .ModelPicture[MyRO.EnemyModel[Code[0, J]].mix];
|
---|
1433 | if (PPicture.HGr = PTestPicture.HGr) and
|
---|
1434 | (PPicture.pix = PTestPicture.pix) and
|
---|
1435 | (ModelHash(MyRO.EnemyModel[emix])
|
---|
1436 | = ModelHash(MyRO.EnemyModel[Code[0, J]])) then
|
---|
1437 | begin
|
---|
1438 | Code[1, J] := 1;
|
---|
1439 | Ok := False;
|
---|
1440 | Break;
|
---|
1441 | end;
|
---|
1442 | end;
|
---|
1443 | if Ok then
|
---|
1444 | begin
|
---|
1445 | Code[0, Lines[0]] := emix;
|
---|
1446 | Code[1, Lines[0]] := 0;
|
---|
1447 | Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], True);
|
---|
1448 | Inc(Lines[0]);
|
---|
1449 | end;
|
---|
1450 | end;
|
---|
1451 | SortModels;
|
---|
1452 | FirstShrinkedLine[0] := 0;
|
---|
1453 | end;
|
---|
1454 | kTribe:
|
---|
1455 | for I := 0 to TribeNames.Count - 1 do
|
---|
1456 | begin
|
---|
1457 | Code[0, Lines[0]] := I;
|
---|
1458 | Inc(Lines[0]);
|
---|
1459 | end;
|
---|
1460 | (* kDeliver:
|
---|
1461 | if MyRO.Treaty[DipMem[Me].pContact]<trAlliance then
|
---|
1462 | begin // suggest next treaty level
|
---|
1463 | Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]+1;
|
---|
1464 | Inc(Lines[0]);
|
---|
1465 | end;
|
---|
1466 | if MyRO.Treaty[DipMem[Me].pContact]=trNone then
|
---|
1467 | begin // suggest peace
|
---|
1468 | Code[0,Lines[0]]:=opTreaty+trPeace;
|
---|
1469 | Inc(Lines[0]);
|
---|
1470 | end;
|
---|
1471 | if MyRO.Treaty[DipMem[Me].pContact]>trNone then
|
---|
1472 | begin // suggest next treaty level
|
---|
1473 | Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
|
---|
1474 | Inc(Lines[0]);
|
---|
1475 | end; *)
|
---|
1476 | kShipPart:
|
---|
1477 | begin
|
---|
1478 | Lines[0] := 0;
|
---|
1479 | for I := 0 to nShipPart - 1 do
|
---|
1480 | if MyRO.Ship[Me].Parts[I] > 0 then
|
---|
1481 | begin
|
---|
1482 | Code[0, Lines[0]] := I;
|
---|
1483 | Inc(Lines[0]);
|
---|
1484 | end;
|
---|
1485 | end;
|
---|
1486 | kEShipPart:
|
---|
1487 | begin
|
---|
1488 | Lines[0] := 0;
|
---|
1489 | for I := 0 to nShipPart - 1 do
|
---|
1490 | if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then
|
---|
1491 | begin
|
---|
1492 | Code[0, Lines[0]] := I;
|
---|
1493 | Inc(Lines[0]);
|
---|
1494 | end;
|
---|
1495 | end;
|
---|
1496 | kGov:
|
---|
1497 | for I := 1 to nGov - 1 do
|
---|
1498 | if (GovPreq[I] <> preNA) and
|
---|
1499 | ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable))
|
---|
1500 | then
|
---|
1501 | begin
|
---|
1502 | Code[0, Lines[0]] := I;
|
---|
1503 | Inc(Lines[0]);
|
---|
1504 | end;
|
---|
1505 | kMission:
|
---|
1506 | for I := 0 to nSpyMission - 1 do
|
---|
1507 | begin
|
---|
1508 | Code[0, Lines[0]] := I;
|
---|
1509 | Inc(Lines[0]);
|
---|
1510 | end;
|
---|
1511 | end;
|
---|
1512 |
|
---|
1513 | if Kind = kProject then // test if choice fitting to one screen
|
---|
1514 | if Lines[0] + Lines[1] + Lines[2] <= MaxLines then
|
---|
1515 | begin
|
---|
1516 | for I := 0 to Lines[1] - 1 do // add wonders to first page
|
---|
1517 | begin
|
---|
1518 | Code[0, Lines[0]] := Code[1, I];
|
---|
1519 | Inc(Lines[0]);
|
---|
1520 | end;
|
---|
1521 | Lines[1] := 0;
|
---|
1522 | FirstShrinkedLine[0] := Lines[0];
|
---|
1523 | for I := 0 to Lines[2] - 1 do // add models to first page
|
---|
1524 | begin
|
---|
1525 | Code[0, Lines[0]] := Code[2, I];
|
---|
1526 | Inc(Lines[0]);
|
---|
1527 | end;
|
---|
1528 | Lines[2] := 0;
|
---|
1529 | end;
|
---|
1530 | end;
|
---|
1531 |
|
---|
1532 | function TListDlg.OnlyChoice(TestKind: TListKind): Integer;
|
---|
1533 | begin
|
---|
1534 | Kind := TestKind;
|
---|
1535 | InitLines;
|
---|
1536 | if Lines[0] = 0 then
|
---|
1537 | Result := -2
|
---|
1538 | else if Lines[0] > 1 then
|
---|
1539 | Result := -1
|
---|
1540 | else
|
---|
1541 | Result := Code[0, 0];
|
---|
1542 | end;
|
---|
1543 |
|
---|
1544 | procedure TListDlg.FormShow(Sender: TObject);
|
---|
1545 | var
|
---|
1546 | I: Integer;
|
---|
1547 | NewTop, NewLeft: Integer;
|
---|
1548 | begin
|
---|
1549 | Result := -1;
|
---|
1550 | Closable := False;
|
---|
1551 |
|
---|
1552 | if Kind = kTribe then
|
---|
1553 | begin
|
---|
1554 | LineDistance := 21; // looks ugly with scrollbar
|
---|
1555 | MaxLines := (Maintexture.Height - (24 + TitleHeight + NarrowFrame))
|
---|
1556 | div LineDistance - 1;
|
---|
1557 | end
|
---|
1558 | else
|
---|
1559 | begin
|
---|
1560 | LineDistance := 24;
|
---|
1561 | MaxLines := (Maintexture.Height - (24 + TitleHeight + WideFrame))
|
---|
1562 | div LineDistance - 1;
|
---|
1563 | end;
|
---|
1564 | InitLines;
|
---|
1565 |
|
---|
1566 | MultiPage := False;
|
---|
1567 | for I := 1 to MaxLayer - 1 do
|
---|
1568 | if Lines[I] > 0 then begin
|
---|
1569 | MultiPage := True;
|
---|
1570 | Break;
|
---|
1571 | end;
|
---|
1572 | WideBottom := MultiPage or (Kind = kScience) or
|
---|
1573 | not Phrases2FallenBackToEnglish and
|
---|
1574 | (Kind in [kProject, kAdvance, kFarAdvance]);
|
---|
1575 | if (Kind = kAdvance) and (MyData.FarTech <> adNone) or (Kind = kModels) or
|
---|
1576 | (Kind = kEModels) then begin
|
---|
1577 | ScrollBar.SetBorderSpacing(56, 10, 10);
|
---|
1578 | TitleHeight := WideFrame + 20;
|
---|
1579 | end else begin
|
---|
1580 | ScrollBar.SetBorderSpacing(36, 10, 34);
|
---|
1581 | TitleHeight := WideFrame;
|
---|
1582 | end;
|
---|
1583 |
|
---|
1584 | DispLines := Lines[0];
|
---|
1585 | for I := 0 to MaxLayer - 1 do
|
---|
1586 | if Lines[I] > DispLines then
|
---|
1587 | DispLines := Lines[I];
|
---|
1588 | if WideBottom then
|
---|
1589 | begin
|
---|
1590 | if DispLines > MaxLines then
|
---|
1591 | DispLines := MaxLines;
|
---|
1592 | InnerHeight := LineDistance * (DispLines + 1) + 24;
|
---|
1593 | Height := InnerHeight + TitleHeight + WideFrame;
|
---|
1594 | end
|
---|
1595 | else
|
---|
1596 | begin
|
---|
1597 | if DispLines > MaxLines then
|
---|
1598 | DispLines := MaxLines;
|
---|
1599 | InnerHeight := LineDistance * (DispLines + 1) + 24;
|
---|
1600 | Height := InnerHeight + TitleHeight + NarrowFrame;
|
---|
1601 | end;
|
---|
1602 | Assert(Height <= Maintexture.Height);
|
---|
1603 |
|
---|
1604 | TechNameSpace := 224;
|
---|
1605 | case Kind of
|
---|
1606 | kGov:
|
---|
1607 | InnerWidth := 272;
|
---|
1608 | kCities, kCityEvents:
|
---|
1609 | InnerWidth := 640 - 18;
|
---|
1610 | kTribe:
|
---|
1611 | if Lines[0] > MaxLines then
|
---|
1612 | InnerWidth := 280 + GetSystemMetrics(SM_CXVSCROLL)
|
---|
1613 | else
|
---|
1614 | InnerWidth := 280;
|
---|
1615 | kScience:
|
---|
1616 | begin
|
---|
1617 | InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 * nColumn +
|
---|
1618 | GetSystemMetrics(SM_CXVSCROLL);
|
---|
1619 | if InnerWidth + 2 * SideFrame > 640 then
|
---|
1620 | begin
|
---|
1621 | TechNameSpace := TechNameSpace + 640 - InnerWidth - 2 * SideFrame;
|
---|
1622 | InnerWidth := 640 - 2 * SideFrame
|
---|
1623 | end;
|
---|
1624 | end;
|
---|
1625 | kAdvance, kFarAdvance:
|
---|
1626 | InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 +
|
---|
1627 | GetSystemMetrics(SM_CXVSCROLL);
|
---|
1628 | kChooseTech, kChooseETech, kStealTech:
|
---|
1629 | InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace +
|
---|
1630 | GetSystemMetrics(SM_CXVSCROLL);
|
---|
1631 | else
|
---|
1632 | InnerWidth := 363;
|
---|
1633 | end;
|
---|
1634 | Width := InnerWidth + 2 * SideFrame;
|
---|
1635 |
|
---|
1636 | CloseBtn.Left := Width - 38;
|
---|
1637 | CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
|
---|
1638 | CaptionRight := CloseBtn.Left;
|
---|
1639 | SetWindowPos(ScrollBar.ScrollBar.Handle, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL),
|
---|
1640 | TitleHeight, GetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48,
|
---|
1641 | SWP_NOZORDER or SWP_NOREDRAW);
|
---|
1642 |
|
---|
1643 | if WindowMode = wmModal then
|
---|
1644 | begin { center on screen }
|
---|
1645 | if Kind = kTribe then
|
---|
1646 | NewLeft := Screen.PrimaryMonitor.Left + (Screen.PrimaryMonitor.Width - 800) * 3 div 8 + 130
|
---|
1647 | else
|
---|
1648 | NewLeft := Screen.PrimaryMonitor.Left + (Screen.PrimaryMonitor.Width - Width) div 2;
|
---|
1649 | NewTop := Screen.PrimaryMonitor.Top + (Screen.PrimaryMonitor.Height - Height) div 2;
|
---|
1650 | if Kind = kProject then
|
---|
1651 | NewTop := NewTop + 48;
|
---|
1652 | BoundsRect := Bounds(NewLeft, NewTop, Width, Height);
|
---|
1653 | end;
|
---|
1654 |
|
---|
1655 | Layer0Btn.Visible := MultiPage and (Lines[0] > 0);
|
---|
1656 | Layer1Btn.Visible := MultiPage and (Lines[1] > 0);
|
---|
1657 | Layer2Btn.Visible := MultiPage and (Lines[2] > 0);
|
---|
1658 | if Kind = kProject then
|
---|
1659 | begin
|
---|
1660 | Layer0Btn.Top := Height - 31;
|
---|
1661 | Layer0Btn.Left := Width div 2 - (12 + 29);
|
---|
1662 | Layer0Btn.Down := True;
|
---|
1663 | Layer1Btn.Top := Height - 31;
|
---|
1664 | Layer1Btn.Left := Width div 2 - (12 - 29);
|
---|
1665 | Layer1Btn.Down := False;
|
---|
1666 | Layer2Btn.Top := Height - 31;
|
---|
1667 | Layer2Btn.Left := Width div 2 - 12;
|
---|
1668 | Layer2Btn.Down := False;
|
---|
1669 | end;
|
---|
1670 |
|
---|
1671 | Layer := 0;
|
---|
1672 | Selected := -2;
|
---|
1673 | ScienceNation := -1;
|
---|
1674 | ScrollBar.Init(Lines[Layer] - 1, DispLines);
|
---|
1675 |
|
---|
1676 | OffscreenPaint;
|
---|
1677 | end;
|
---|
1678 |
|
---|
1679 | procedure TListDlg.ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
|
---|
1680 | var
|
---|
1681 | I: Integer;
|
---|
1682 | ShowFocus, ForceClose: Boolean;
|
---|
1683 | begin
|
---|
1684 | ForceClose := (ListKind <> Kind) and
|
---|
1685 | not ((Kind = kCities) and (ListKind = kCityEvents)) and
|
---|
1686 | not ((Kind = kCityEvents) and (ListKind = kCities)) and
|
---|
1687 | not ((Kind = kModels) and (ListKind = kEModels)) and
|
---|
1688 | not ((Kind = kEModels) and (ListKind = kModels));
|
---|
1689 |
|
---|
1690 | Kind := ListKind;
|
---|
1691 | ModalIndication := not (Kind in MustChooseKind);
|
---|
1692 | case Kind of
|
---|
1693 | kProject:
|
---|
1694 | Caption := Phrases.Lookup('TITLE_PROJECT');
|
---|
1695 | kAdvance:
|
---|
1696 | Caption := Phrases.Lookup('TITLE_TECHSELECT');
|
---|
1697 | kFarAdvance:
|
---|
1698 | Caption := Phrases.Lookup('TITLE_FARTECH');
|
---|
1699 | kModels, kEModels:
|
---|
1700 | Caption := Phrases.Lookup('FRMILREP');
|
---|
1701 | kAllEModels:
|
---|
1702 | Caption := Phrases.Lookup('TITLE_EMODELS');
|
---|
1703 | kTribe:
|
---|
1704 | Caption := Phrases.Lookup('TITLE_TRIBE');
|
---|
1705 | kScience:
|
---|
1706 | Caption := Phrases.Lookup('TITLE_SCIENCE');
|
---|
1707 | kShipPart, kEShipPart:
|
---|
1708 | Caption := Phrases.Lookup('TITLE_CHOOSESHIPPART');
|
---|
1709 | kChooseTech, kChooseETech:
|
---|
1710 | Caption := Phrases.Lookup('TITLE_CHOOSETECH');
|
---|
1711 | kChooseModel, kChooseEModel:
|
---|
1712 | Caption := Phrases.Lookup('TITLE_CHOOSEMODEL');
|
---|
1713 | kStealTech:
|
---|
1714 | Caption := Phrases.Lookup('TITLE_CHOOSETECH');
|
---|
1715 | kGov:
|
---|
1716 | Caption := Phrases.Lookup('TITLE_GOV');
|
---|
1717 | kMission:
|
---|
1718 | Caption := Phrases.Lookup('TITLE_SPYMISSION');
|
---|
1719 | end;
|
---|
1720 |
|
---|
1721 | case Kind of
|
---|
1722 | kMission:
|
---|
1723 | HelpContext := 'SPYMISSIONS';
|
---|
1724 | else
|
---|
1725 | HelpContext := 'CONCEPTS'
|
---|
1726 | end;
|
---|
1727 |
|
---|
1728 | if Kind = kAdvance then
|
---|
1729 | begin
|
---|
1730 | ToggleBtn.ButtonIndex := 13;
|
---|
1731 | ToggleBtn.Hint := Phrases.Lookup('FARTECH');
|
---|
1732 | end
|
---|
1733 | else if Kind = kCities then
|
---|
1734 | begin
|
---|
1735 | ToggleBtn.ButtonIndex := 15;
|
---|
1736 | ToggleBtn.Hint := Phrases.Lookup('BTN_PAGE');
|
---|
1737 | end
|
---|
1738 | else
|
---|
1739 | begin
|
---|
1740 | ToggleBtn.ButtonIndex := 28;
|
---|
1741 | ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT');
|
---|
1742 | end;
|
---|
1743 |
|
---|
1744 | if Kind = kAdvance then // show focus button?
|
---|
1745 | if MyData.FarTech <> adNone then
|
---|
1746 | ShowFocus := True
|
---|
1747 | else
|
---|
1748 | begin
|
---|
1749 | ShowFocus := False;
|
---|
1750 | for I := 0 to nAdv - 1 do
|
---|
1751 | if not (I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
|
---|
1752 | ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
|
---|
1753 | ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
|
---|
1754 | (Server(sSetResearch - sExecute, Me, I, nil^) < rExecuted) then begin
|
---|
1755 | ShowFocus := True;
|
---|
1756 | Break;
|
---|
1757 | end;
|
---|
1758 | end;
|
---|
1759 | ToggleBtn.Visible := (Kind = kCities) and not Supervising or (Kind = kAdvance)
|
---|
1760 | and ShowFocus or (Kind = kModels) or (Kind = kEModels);
|
---|
1761 | CloseBtn.Visible := not (Kind in MustChooseKind);
|
---|
1762 |
|
---|
1763 | inherited ShowNewContent(NewMode, ForceClose);
|
---|
1764 | end;
|
---|
1765 |
|
---|
1766 | procedure TListDlg.ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
|
---|
1767 | begin
|
---|
1768 | cixProject := cix;
|
---|
1769 | ShowNewContent(NewMode, kProject);
|
---|
1770 | end;
|
---|
1771 |
|
---|
1772 | procedure TListDlg.ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
|
---|
1773 | begin
|
---|
1774 | pView := P;
|
---|
1775 | if P = Me then
|
---|
1776 | ShowNewContent(NewMode, kModels)
|
---|
1777 | else
|
---|
1778 | ShowNewContent(NewMode, kEModels);
|
---|
1779 | end;
|
---|
1780 |
|
---|
1781 | procedure TListDlg.PlayerClick(Sender: TObject);
|
---|
1782 | begin
|
---|
1783 | if TComponent(Sender).Tag = Me then
|
---|
1784 | Kind := kModels
|
---|
1785 | else
|
---|
1786 | begin
|
---|
1787 | Kind := kEModels;
|
---|
1788 | pView := TComponent(Sender).Tag;
|
---|
1789 | end;
|
---|
1790 | InitLines;
|
---|
1791 | Selected := -2;
|
---|
1792 | ScrollBar.Init(Lines[Layer] - 1, DispLines);
|
---|
1793 | OffscreenPaint;
|
---|
1794 | Invalidate;
|
---|
1795 | end;
|
---|
1796 |
|
---|
1797 | procedure TListDlg.ModeBtnClick(Sender: TObject);
|
---|
1798 | begin
|
---|
1799 | Layer0Btn.Down := Sender = Layer0Btn;
|
---|
1800 | Layer1Btn.Down := Sender = Layer1Btn;
|
---|
1801 | Layer2Btn.Down := Sender = Layer2Btn;
|
---|
1802 | Layer := TComponent(Sender).Tag;
|
---|
1803 |
|
---|
1804 | Selected := -2;
|
---|
1805 | ScrollBar.Init(Lines[Layer] - 1, DispLines);
|
---|
1806 | SmartUpdateContent;
|
---|
1807 | end;
|
---|
1808 |
|
---|
1809 | procedure TListDlg.ToggleBtnClick(Sender: TObject);
|
---|
1810 | var
|
---|
1811 | p1: Integer;
|
---|
1812 | M: TMenuItem;
|
---|
1813 | begin
|
---|
1814 | case Kind of
|
---|
1815 | kAdvance:
|
---|
1816 | begin
|
---|
1817 | Result := adFar;
|
---|
1818 | Closable := True;
|
---|
1819 | Close;
|
---|
1820 | end;
|
---|
1821 | kCities, kCityEvents:
|
---|
1822 | begin
|
---|
1823 | if Kind = kCities then
|
---|
1824 | Kind := kCityEvents
|
---|
1825 | else
|
---|
1826 | Kind := kCities;
|
---|
1827 | OffscreenPaint;
|
---|
1828 | Invalidate;
|
---|
1829 | end;
|
---|
1830 | kModels, kEModels:
|
---|
1831 | begin
|
---|
1832 | EmptyMenu(Popup.Items);
|
---|
1833 | if G.Difficulty[Me] > 0 then
|
---|
1834 | begin
|
---|
1835 | M := TMenuItem.Create(Popup);
|
---|
1836 | M.RadioItem := True;
|
---|
1837 | M.Caption := Tribe[Me].TPhrase('SHORTNAME');
|
---|
1838 | M.Tag := Me;
|
---|
1839 | M.OnClick := PlayerClick;
|
---|
1840 | if Kind = kModels then
|
---|
1841 | M.Checked := True;
|
---|
1842 | Popup.Items.Add(M);
|
---|
1843 | end;
|
---|
1844 | for p1 := 0 to nPl - 1 do
|
---|
1845 | if (p1 <> Me) and (MyRO.EnemyReport[p1] <> nil) and
|
---|
1846 | (MyRO.EnemyReport[p1].TurnOfMilReport >= 0) then
|
---|
1847 | begin
|
---|
1848 | M := TMenuItem.Create(Popup);
|
---|
1849 | M.RadioItem := True;
|
---|
1850 | M.Caption := Tribe[p1].TPhrase('SHORTNAME');
|
---|
1851 | M.Tag := p1;
|
---|
1852 | M.OnClick := PlayerClick;
|
---|
1853 | if (Kind = kEModels) and (p1 = pView) then
|
---|
1854 | M.Checked := True;
|
---|
1855 | Popup.Items.Add(M);
|
---|
1856 | end;
|
---|
1857 | Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top +
|
---|
1858 | ToggleBtn.Height);
|
---|
1859 | end;
|
---|
1860 | end;
|
---|
1861 | end;
|
---|
1862 |
|
---|
1863 | procedure TListDlg.FormKeyDown(Sender: TObject; var Key: Word;
|
---|
1864 | Shift: TShiftState);
|
---|
1865 | begin
|
---|
1866 | if (Key = VK_F2) and (Kind in [kModels, kEModels]) then // my key
|
---|
1867 | // !!! toggle
|
---|
1868 | else if (Key = VK_F3) and (Kind in [kCities, kCityEvents]) then // my key
|
---|
1869 | ToggleBtnClick(nil)
|
---|
1870 | else if ((Key = VK_ESCAPE) or (Key = VK_RETURN)) and not CloseBtn.Visible then
|
---|
1871 | // prevent closing
|
---|
1872 | else
|
---|
1873 | inherited;
|
---|
1874 | end;
|
---|
1875 |
|
---|
1876 | procedure TListDlg.EcoChange;
|
---|
1877 | begin
|
---|
1878 | if Visible and (Kind = kCities) then
|
---|
1879 | SmartUpdateContent;
|
---|
1880 | end;
|
---|
1881 |
|
---|
1882 | procedure TListDlg.TechChange;
|
---|
1883 | begin
|
---|
1884 | if Visible and (Kind = kScience) then
|
---|
1885 | begin
|
---|
1886 | FormShow(nil);
|
---|
1887 | Invalidate;
|
---|
1888 | end;
|
---|
1889 | end;
|
---|
1890 |
|
---|
1891 | procedure TListDlg.AddCity;
|
---|
1892 | begin
|
---|
1893 | if Visible and (Kind = kCities) then
|
---|
1894 | begin
|
---|
1895 | FormShow(nil);
|
---|
1896 | Invalidate;
|
---|
1897 | end;
|
---|
1898 | end;
|
---|
1899 |
|
---|
1900 | procedure TListDlg.RemoveUnit;
|
---|
1901 | begin
|
---|
1902 | if Visible and (Kind = kModels) then
|
---|
1903 | SmartUpdateContent;
|
---|
1904 | end;
|
---|
1905 |
|
---|
1906 | procedure TListDlg.ScrollBarUpdate(Sender: TObject);
|
---|
1907 | begin
|
---|
1908 | Selected := -2;
|
---|
1909 | SmartUpdateContent(True);
|
---|
1910 | end;
|
---|
1911 |
|
---|
1912 | end.
|
---|