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