source: branches/highdpi/LocalPlayer/Select.pas

Last change on this file was 467, checked in by chronos, 5 months ago
  • Modified: DpiControls unit split into multiple units according to their LCL names.
File size: 60.5 KB
Line 
1{$INCLUDE Switches.inc}
2unit Select;
3
4interface
5
6uses
7 Dpi.Menus, Dpi.Graphics, Dpi.Common, Dpi.Forms,
8 Protocol, ClientTools, ScreenTools, PVSB, BaseWin,
9 LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms,
10 ExtCtrls, ButtonB, ButtonBase, Menus, Types;
11
12const
13 MaxLayer = 3;
14
15type
16 TListKind = (kProject, kAdvance, kFarAdvance, kCities, kCityEvents, kModels,
17 kEModels, kAllEModels, kTribe, kScience, kShipPart, kEShipPart, kChooseTech,
18 kChooseETech, kChooseModel, kChooseEModel, kChooseCity, kChooseECity,
19 kStealTech, kGov, kMission);
20
21 { TListDlg }
22
23 TListDlg = class(TFramedDlg)
24 CloseBtn: TButtonB;
25 Layer2Btn: TButtonB;
26 Layer1Btn: TButtonB;
27 Layer0Btn: TButtonB;
28 ToggleBtn: TButtonB;
29 Popup: TDpiPopupMenu;
30 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
31 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
32 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
33 procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
34 X, Y: Integer);
35 procedure FormCreate(Sender: TObject);
36 procedure FormDestroy(Sender: TObject);
37 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
38 Shift: TShiftState; X, Y: Integer);
39 procedure FormPaint(Sender: TObject);
40 procedure CloseBtnClick(Sender: TObject);
41 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
42 procedure FormShow(Sender: TObject);
43 procedure ModeBtnClick(Sender: TObject);
44 procedure ToggleBtnClick(Sender: TObject);
45 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
46 procedure PlayerClick(Sender: TObject);
47 private
48 Kind: TListKind;
49 LineDistance: Integer;
50 MaxLines: Integer;
51 cixProject: Integer;
52 pView: Integer;
53 Selected: Integer;
54 DispLines: Integer;
55 Layer: Integer;
56 nColumn: Integer;
57 TechNameSpace: Integer;
58 ScienceNation: Integer;
59 ScrollBar: TPVScrollbar;
60 Lines: array [0 .. MaxLayer - 1] of Integer;
61 FirstShrinkedLine: array [0 .. MaxLayer - 1] of Integer;
62 Code: array [0 .. MaxLayer - 1, 0 .. 4095] of Integer;
63 Column: array [0 .. nPl - 1] of Integer;
64 Closable: Boolean;
65 MultiPage: Boolean;
66 ScienceNationDotBuffer: TDpiBitmap;
67 procedure ScrollBarUpdate(Sender: TObject);
68 procedure InitLines;
69 procedure Line(ca: TDpiCanvas; L: Integer; NonText, lit: Boolean);
70 function RenameCity(cix: Integer): 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 OnlyChoice(TestKind: TListKind): Integer;
77 // -2=empty, -1=ambiguous, other=only choice
78 procedure OffscreenPaint; override;
79 procedure ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
80 procedure ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
81 procedure ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
82 procedure EcoChange;
83 procedure TechChange;
84 procedure AddCity;
85 procedure RemoveUnit;
86 end;
87
88 TModalSelectDlg = TListDlg;
89
90const
91 cpType = $10000;
92 mixAll = $10000;
93 adAll = $10000;
94
95
96implementation
97
98uses
99 Term, CityScreen, Help, UnitStat, Tribes, Inp, CmdList;
100
101{$R *.lfm}
102
103const
104 CityNameSpace = 127;
105
106 MustChooseKind = [kTribe, kStealTech, kGov];
107
108procedure TListDlg.FormCreate(Sender: TObject);
109begin
110 inherited;
111 Canvas.Font.Assign(UniFont[ftNormal]);
112 ScrollBar := TPVScrollbar.Create(Self);
113 ScrollBar.SetBorderSpacing(36, 10, 36);
114 ScrollBar.OnUpdate := ScrollBarUpdate;
115 InitButtons;
116 Kind := kMission;
117 Layer0Btn.Hint := Phrases.Lookup('BTN_IMPRS');
118 Layer1Btn.Hint := Phrases.Lookup('BTN_WONDERS');
119 Layer2Btn.Hint := Phrases.Lookup('BTN_CLASSES');
120 ScienceNationDotBuffer := TDpiBitmap.Create;
121 ScienceNationDotBuffer.PixelFormat := pf24bit;
122 ScienceNationDotBuffer.SetSize(17, 17);
123 ScienceNationDotBuffer.Canvas.FillRect(0, 0, ScienceNationDotBuffer.Width, ScienceNationDotBuffer.Height);
124end;
125
126procedure TListDlg.FormDestroy(Sender: TObject);
127begin
128 FreeAndNil(ScrollBar);
129 FreeAndNil(ScienceNationDotBuffer);
130end;
131
132procedure TListDlg.CloseBtnClick(Sender: TObject);
133begin
134 Closable := True;
135 Close;
136end;
137
138procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
139begin
140 CanClose := Closable or not(Kind in MustChooseKind);
141end;
142
143procedure TListDlg.OnScroll(var Msg: TMessage);
144begin
145 { TODO: Handled by MouseWheel event
146 if ScrollBar.Process(Msg) then begin
147 Selected := -2;
148 SmartUpdateContent(True);
149 end;
150 }
151end;
152
153procedure TListDlg.OnMouseLeave(var Msg: TMessage);
154begin
155 if not Closable and (Selected <> -2) then
156 begin
157 Line(Canvas, Selected, False, False);
158 Selected := -2;
159 end;
160end;
161
162procedure TListDlg.FormPaint(Sender: TObject);
163var
164 S: string;
165begin
166 inherited;
167 Canvas.Font.Assign(UniFont[ftNormal]);
168 if Selected <> -2 then
169 Line(Canvas, Selected, False, True);
170 S := '';
171 if (Kind = kAdvance) and (MyData.FarTech <> adNone) then
172 S := Format(Phrases.Lookup('TECHFOCUS'),
173 [Phrases.Lookup('ADVANCES', MyData.FarTech)])
174 else if Kind = kModels then
175 S := Tribe[Me].TPhrase('SHORTNAME')
176 else if Kind = kEModels then
177 S := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
178 TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport) + ')';
179 if S <> '' then
180 LoweredTextOut(Canvas, -1, MainTexture,
181 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S);
182 if not MultiPage and (Kind in [kProject, kAdvance, kFarAdvance]) and not Phrases2FallenBackToEnglish
183 then
184 begin
185 S := Phrases2.Lookup('SHIFTCLICK');
186 LoweredTextOut(Canvas, -2, MainTexture,
187 (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, ClientHeight - 29, S);
188 end;
189end;
190
191procedure TListDlg.Line(ca: TDpiCanvas; 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 DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
208 ySizeSmall, SmallImp.Canvas, (MyRO.Government - 1) *
209 xSizeSmall, ySizeSmall)
210 else
211 DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
212 ySizeSmall, SmallImp.Canvas, pix and cpIndex mod 7 *
213 xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 *
214 ySizeSmall)
215 else
216 DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
217 ySizeSmall, SmallImp.Canvas, (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 - ClientWidth)
233 div 2, (Maintexture.Height - ClientHeight) div 2);
234 end;
235 LoweredTextOut(ca, Color, MainTexture, X, Y, S);
236 end;
237
238var
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;
245begin
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 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 := 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 PaintRelativeProgressBar(Offscreen.Canvas, 1, X + 15 + CityNameSpace +
404 4, Y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,
405 (MyRO.Government <> gAnarchy) and (Flags and chCaptured = 0),
406 MyRO.Government, Size), CityReport.Storage, CanGrow, MainTexture);
407
408 if Project <> cpImp + imTrGoods then
409 begin
410 DisplayProject(ofs + 104 - 76 + X - 28 + CityNameSpace + 4 + 206 -
411 60, y0 - 15, Project);
412
413 // production progress
414 growth := CityReport.Production;
415 if (growth < 0) or (MyRO.Government = gAnarchy) or
416 (Flags and chCaptured <> 0) then
417 growth := 0;
418 PaintRelativeProgressBar(Offscreen.Canvas, 4,
419 X + CityNameSpace + 4 + 304 - 60 + 9, Y + 7, 68, TrueProd, growth,
420 CityReport.ProjectCost, True, MainTexture);
421 end;
422 end;
423 end;
424 end
425 else if Kind in [kModels, kEModels] then
426 begin
427 X := 104;
428 Y := y0;
429 if ca = Canvas then
430 begin
431 X := X + SideFrame;
432 Y := Y + TitleHeight;
433 end;
434 if lit then
435 TextColor := MainTexture.ColorLitText
436 else
437 TextColor := -1;
438 if Kind = kModels then
439 begin
440 Available := 0;
441 for J := 0 to MyRO.nUn - 1 do
442 if (MyUn[J].Loc >= 0) and (MyUn[J].mix = lix) then
443 Inc(Available);
444 if MainScreen.mNames.Checked then
445 S := Tribe[Me].ModelName[lix]
446 else
447 S := Format(Tribe[Me].TPhrase('GENMODEL'), [lix]);
448 if NonText then
449 DisplayProject(8 + ofs, y0 - 15, lix);
450 end
451 else
452 begin
453 Available := MyRO.EnemyReport[pView].UnCount[lix];
454 if MainScreen.mNames.Checked then
455 S := Tribe[pView].ModelName[lix]
456 else
457 S := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
458 if NonText then
459 with Tribe[pView].ModelPicture[lix] do
460 Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
461 pix div 10 * 49 + 1);
462 end;
463 if Available > 0 then
464 ReplaceText(X + 32 - BiColorTextWidth(ca, IntToStr(Available)), Y,
465 TextColor, IntToStr(Available));
466 ReplaceText(X + 40, Y, TextColor, S);
467 end
468 else
469 begin
470 case Kind of
471 kAllEModels, kChooseEModel:
472 if lix = mixAll then
473 S := Phrases.Lookup('PRICECAT_ALLMODEL')
474 else
475 begin
476 mox := @MyRO.EnemyModel[lix];
477 if MainScreen.mNames.Checked then
478 begin
479 S := Tribe[mox.Owner].ModelName[mox.mix];
480 if (Kind = kAllEModels) and (Code[1, ScrollBar.Position + L] = 0) then
481 S := Format(Tribe[mox.Owner].TPhrase('OWNED'), [S]);
482 end
483 else
484 S := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
485 if NonText then
486 with Tribe[mox.Owner].ModelPicture[mox.mix] do
487 Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
488 pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
489 end;
490 kChooseModel:
491 if lix = mixAll then
492 S := Phrases.Lookup('PRICECAT_ALLMODEL')
493 else
494 begin
495 S := Tribe[Me].ModelName[lix];
496 if NonText then
497 DisplayProject(8 + ofs, y0 - 15, lix);
498 end;
499 kProject:
500 begin
501 if lix and cpType <> 0 then
502 S := Phrases.Lookup('CITYTYPE', lix and cpIndex)
503 else if lix and cpImp = 0 then
504 with MyModel[lix and cpIndex] do
505 begin
506 S := Tribe[Me].ModelName[lix and cpIndex];
507 if lix and cpConscripts <> 0 then
508 S := Format(Phrases.Lookup('CONSCRIPTS'), [S]);
509 end
510 else
511 begin
512 S := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
513 if (Imp[lix and cpIndex].Kind in [ikNatLocal, ikNatGlobal]) and
514 (MyRO.NatBuilt[lix and cpIndex] > 0) or
515 (lix and cpIndex in [imPower, imHydro, imNuclear]) and
516 (MyCity[cixProject].Built[imPower] + MyCity[cixProject].Built
517 [imHydro] + MyCity[cixProject].Built[imNuclear] > 0) then
518 S := Format(Phrases.Lookup('NATEXISTS'), [S]);
519 end;
520 if NonText then
521 DisplayProject(8 + ofs, y0 - 15, lix);
522 end;
523 kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
524 begin
525 if lix = adAll then
526 S := Phrases.Lookup('PRICECAT_ALLTECH')
527 else
528 begin
529 if lix = adNexus then
530 S := Phrases.Lookup('NEXUS')
531 else if lix = adNone then
532 S := Phrases.Lookup('NOFARTECH')
533 else if lix = adMilitary then
534 S := Phrases.Lookup('INITUNIT')
535 else
536 begin
537 S := Phrases.Lookup('ADVANCES', lix);
538 if (Kind = kAdvance) and (lix in FutureTech) then
539 if MyRO.Tech[lix] < tsApplicable then
540 S := S + ' 1'
541 else
542 S := S + ' ' + IntToStr(MyRO.Tech[lix] + 1);
543 end;
544 if BiColorTextWidth(ca, S) > TechNameSpace + 8 then
545 begin
546 repeat
547 Delete(S, Length(S), 1);
548 until BiColorTextWidth(ca, S) <= TechNameSpace + 5;
549 S := S + '.';
550 end;
551
552 if NonText then
553 begin // show tech icon
554 if lix = adNexus then
555 begin
556 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
557 y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
558 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
559 end
560 else if lix = adNone then
561 begin
562 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
563 y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
564 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
565 end
566 else if lix = adMilitary then
567 begin
568 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
569 y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
570 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
571 end
572 else
573 begin
574 Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1,
575 (8 + 16 + xSizeSmall), y0 + ySizeSmall,
576 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
577 if AdvIcon[lix] < 84 then
578 DpiBitBltCanvas(Offscreen.Canvas, (8 + 16), y0, xSizeSmall,
579 ySizeSmall, SmallImp.Canvas,
580 (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall,
581 (AdvIcon[lix] + SystemIconLines * 7) div 7 *
582 ySizeSmall)
583 else
584 Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20,
585 1 + (AdvIcon[lix] - 84) mod 8 * 37,
586 295 + (AdvIcon[lix] - 84) div 8 * 21);
587 J := AdvValue[lix] div 1000;
588 DpiBitBltCanvas(Offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14,
589 HGrSystem.Mask.Canvas, 127 + J * 15,
590 85, SRCAND);
591 Sprite(Offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
592 127 + J * 15, 85);
593 end;
594 end;
595 end;
596
597 if NonText and (Kind in [kAdvance, kScience]) then
598 begin // show research state
599 for J := 0 to nColumn - 1 do
600 begin
601 FutureCount := 0;
602 if J = 0 then // own science
603 if lix = MyRO.ResearchTech then
604 begin
605 Server(sGetTechCost, Me, 0, icon);
606 icon := 4 + MyRO.Research * 4 div icon;
607 if icon > 4 + 3 then
608 icon := 4 + 3
609 end
610 else if (lix >= adMilitary) then
611 icon := -1
612 else if lix in FutureTech then
613 begin
614 icon := -1;
615 FutureCount := MyRO.Tech[lix];
616 end
617 else if MyRO.Tech[lix] = tsSeen then
618 icon := 1
619 else if MyRO.Tech[lix] >= tsApplicable then
620 icon := 2
621 else
622 icon := -1
623 else
624 with MyRO.EnemyReport[Column[J]]^ do // enemy science
625 if (MyRO.Alive and (1 shl Column[J]) <> 0) and
626 (TurnOfCivilReport >= 0) and (lix = ResearchTech) and
627 ((lix = adMilitary) or (lix in FutureTech) or
628 (Tech[lix] < tsApplicable)) then
629 begin
630 icon := 4 + ResearchDone div 25;
631 if icon > 4 + 3 then
632 icon := 4 + 3;
633 end
634 else if lix = adMilitary then
635 icon := -1
636 else if lix in FutureTech then
637 begin
638 icon := -1;
639 FutureCount := Tech[lix]
640 end
641 else if Tech[lix] >= tsApplicable then
642 icon := 2
643 else if Tech[lix] = tsSeen then
644 icon := 1
645 else
646 icon := -1;
647 if icon >= 0 then
648 Sprite(Offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
649 24 * J, y0 + 3, 14, 14, 67 + icon * 15, 85)
650 else if (Kind = kScience) and (FutureCount > 0) then
651 begin
652 number := IntToStr(FutureCount);
653 RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * J -
654 BiColorTextWidth(ca, number) div 2, y0, number);
655 end;
656 end;
657 end;
658 end; // kAdvance, kScience
659 kTribe:
660 S := TribeNames[lix];
661 kShipPart:
662 begin
663 S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
664 IntToStr(MyRO.Ship[Me].Parts[lix]) + ')';
665 if NonText then
666 DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
667 end;
668 kEShipPart:
669 begin
670 S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
671 IntToStr(MyRO.Ship[DipMem[Me].pContact].Parts[lix]) + ')';
672 if NonText then
673 DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
674 end;
675 kGov:
676 begin
677 S := Phrases.Lookup('GOVERNMENT', lix);
678 if NonText then
679 begin
680 Frame(Offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
681 8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall),
682 MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
683 DpiBitBltCanvas(Offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),
684 xSizeSmall, ySizeSmall, SmallImp.Canvas,
685 (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 - DpiGetSystemMetrics(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;
720end;
721
722procedure TListDlg.OffscreenPaint;
723var
724 I, J: Integer;
725begin
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 := 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);
770end;
771
772procedure TListDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
773 X, Y: Integer);
774var
775 i0, Sel0, iColumn, OldScienceNation, xScreen: Integer;
776 S: string;
777begin
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, ClientHeight - 29, ClientWidth - 18, 24,
813 (Maintexture.Width - ClientWidth) div 2,
814 (Maintexture.Height - ClientHeight) 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 := (ClientWidth - BiColorTextWidth(Canvas, S)) div 2;
825 LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10,
826 ClientHeight - 29, S);
827 DpiBitBltCanvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width,
828 ScienceNationDot.Height, Canvas, xScreen - 10, ClientHeight - 27);
829 ImageOp_BCC(ScienceNationDotBuffer, Templates.Data, Point(0, 0),
830 ScienceNationDot.BoundsRect, MainTexture.ColorBevelShade, Tribe[ScienceNation].Color);
831 DpiBitBltCanvas(Canvas, xScreen - 10, ClientHeight - 27, ScienceNationDot.Width,
832 ScienceNationDot.Height, ScienceNationDotBuffer.Canvas, 0, 0);
833 end;
834 end;
835 end;
836end;
837
838procedure TListDlg.FormMouseWheel(Sender: TObject; Shift: TShiftState;
839 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
840begin
841 if ScrollBar.ProcessMouseWheel(WheelDelta) then begin
842 PaintBox1MouseMove(nil, [], MousePos.X - Left,
843 MousePos.Y - Top);
844 end;
845end;
846
847procedure TListDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
848begin
849 //Gtk2Fix;
850end;
851
852function TListDlg.RenameCity(cix: Integer): Boolean;
853var
854 CityNameInfo: TCityNameInfo;
855begin
856 InputDlg.Caption := Phrases.Lookup('TITLE_CITYNAME');
857 InputDlg.EInput.Text := CityName(MyCity[cix].ID);
858 InputDlg.CenterToRect(BoundsRect);
859 InputDlg.ShowModal;
860 if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
861 (InputDlg.EInput.Text <> CityName(MyCity[cix].ID)) then
862 begin
863 CityNameInfo.ID := MyCity[cix].ID;
864 CityNameInfo.NewName := InputDlg.EInput.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;
879end;
880
881function TListDlg.RenameModel(mix: Integer): Boolean;
882var
883 ModelNameInfo: TModelNameInfo;
884begin
885 InputDlg.Caption := Phrases.Lookup('TITLE_MODELNAME');
886 InputDlg.EInput.Text := Tribe[Me].ModelName[mix];
887 InputDlg.CenterToRect(BoundsRect);
888 InputDlg.ShowModal;
889 if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
890 (InputDlg.EInput.Text <> Tribe[Me].ModelName[mix]) then
891 begin
892 ModelNameInfo.mix := mix;
893 ModelNameInfo.NewName := InputDlg.EInput.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;
908end;
909
910procedure TListDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
911 Shift: TShiftState; X, Y: Integer);
912var
913 lix: Integer;
914begin
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
976 SmartUpdateContent;
977 kModels:
978 if RenameModel(lix) then
979 SmartUpdateContent;
980 end;
981 end;
982end;
983
984procedure TListDlg.InitLines;
985var
986 required: array [0 .. nAdv - 1] of Integer;
987
988 procedure TryAddImpLine(Layer, Project: Integer);
989 begin
990 if Server(sSetCityProject - sExecute, Me, cixProject, Project) >= rExecuted
991 then
992 begin
993 Code[Layer, Lines[Layer]] := Project;
994 Inc(Lines[Layer]);
995 end;
996 end;
997
998 procedure SortTechs;
999 var
1000 I, J, swap: Integer;
1001 begin // sort by advancedness
1002 for I := 0 to Lines[0] - 2 do
1003 if Code[0, I] < adMilitary then
1004 for J := I + 1 to Lines[0] - 1 do
1005 if AdvValue[Code[0, I]] * nAdv + Code[0, I] < AdvValue[Code[0, J]] *
1006 nAdv + Code[0, J] then
1007 begin
1008 swap := Code[0, I];
1009 Code[0, I] := Code[0, J];
1010 Code[0, J] := swap;
1011 end;
1012 end;
1013
1014 procedure SortCities;
1015 var
1016 I, J, swap: Integer;
1017 begin
1018 for I := 0 to Lines[0] - 2 do
1019 for J := I + 1 to Lines[0] - 1 do
1020 if CityName(MyCity[Code[0, I]].ID) > CityName(MyCity[Code[0, J]].ID)
1021 then
1022 begin
1023 swap := Code[0, I];
1024 Code[0, I] := Code[0, J];
1025 Code[0, J] := swap;
1026 end;
1027 end;
1028
1029 function ModelSortValue(const mi: TModelInfo;
1030 MixPlayers: Boolean = False): Integer;
1031 begin
1032 Result := (mi.Domain + 1) shl 28 - mi.mix;
1033 if MixPlayers then
1034 Dec(Result, ModelCode(mi) shl 16);
1035 end;
1036
1037 procedure SortModels;
1038 var
1039 I, J, swap: Integer;
1040 begin // sort by code[2]
1041 for I := 0 to Lines[0] - 2 do
1042 for J := I + 1 to Lines[0] - 1 do
1043 if Code[2, I] > Code[2, J] then
1044 begin
1045 swap := Code[0, I];
1046 Code[0, I] := Code[0, J];
1047 Code[0, J] := swap;
1048 swap := Code[1, I];
1049 Code[1, I] := Code[1, J];
1050 Code[1, J] := swap;
1051 swap := Code[2, I];
1052 Code[2, I] := Code[2, J];
1053 Code[2, J] := swap;
1054 end;
1055 end;
1056
1057 procedure MarkPreqs(I: Integer);
1058 begin
1059 required[I] := 1;
1060 if MyRO.Tech[I] < tsSeen then
1061 begin
1062 if (AdvPreq[I, 0] >= 0) then
1063 MarkPreqs(AdvPreq[I, 0]);
1064 if (AdvPreq[I, 1] >= 0) then
1065 MarkPreqs(AdvPreq[I, 1]);
1066 end;
1067 end;
1068
1069var
1070 Loc1, I, J, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: Integer;
1071 mi: TModelInfo;
1072 PPicture, PTestPicture: ^TModelPicture;
1073 ModelOk: array [0 .. 4095] of Boolean;
1074 ok: Boolean;
1075begin
1076 for I := 0 to MaxLayer - 1 do
1077 begin
1078 Lines[I] := 0;
1079 FirstShrinkedLine[I] := MaxInt;
1080 end;
1081 case Kind of
1082 kProject:
1083 begin
1084 // improvements
1085 Code[0, 0] := cpImp + imTrGoods;
1086 Lines[0] := 1;
1087 for I := nWonder to nImp - 1 do
1088 if Imp[I].Kind = ikCommon then
1089 TryAddImpLine(0, I + cpImp);
1090 for I := nWonder to nImp - 1 do
1091 if not(Imp[I].Kind in [ikCommon, ikTrGoods]) and
1092 ((MyRO.NatBuilt[I] = 0) or (Imp[I].Kind = ikNatLocal)) then
1093 TryAddImpLine(0, I + cpImp);
1094 for I := 0 to nCityType - 1 do
1095 if MyData.ImpOrder[I, 0] >= 0 then
1096 begin
1097 Code[0, Lines[0]] := cpType + I;
1098 Inc(Lines[0]);
1099 end;
1100
1101 // wonders
1102 for I := 0 to nWonder - 1 do
1103 TryAddImpLine(1, I + cpImp);
1104
1105 // units
1106 for I := 0 to MyRO.nModel - 1 do
1107 begin
1108 { if MyModel[i].Kind=mkSlaves then
1109 ok:= MyRO.Wonder[woPyramids].EffectiveOwner=Me
1110 else } if MyModel[I].Domain = dSea then
1111 begin
1112 ok := False;
1113 for dx := -2 to 2 do
1114 for dy := -2 to 2 do
1115 if abs(dx) + abs(dy) = 2 then
1116 begin
1117 Loc1 := dLoc(MyCity[cixProject].Loc, dx, dy);
1118 if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
1119 ((MyMap[Loc1] and fTerrain = fShore) or
1120 (MyMap[Loc1] and fCanal > 0)) then
1121 ok := True;
1122 end;
1123 end
1124 else
1125 ok := True;
1126 if ok then
1127 begin
1128 if MyModel[I].Status and msObsolete = 0 then
1129 begin
1130 Code[2, Lines[2]] := I;
1131 Inc(Lines[2]);
1132 end;
1133 if MyModel[I].Status and msAllowConscripts <> 0 then
1134 begin
1135 Code[2, Lines[2]] := I + cpConscripts;
1136 Inc(Lines[2]);
1137 end;
1138 end;
1139 end;
1140 FirstShrinkedLine[2] := 0;
1141 end;
1142 kAdvance:
1143 begin
1144 nColumn := 1;
1145 if MyData.FarTech <> adNone then
1146 begin
1147 FillChar(required, SizeOf(required), 0);
1148 MarkPreqs(MyData.FarTech);
1149 end;
1150 for I := 0 to nAdv - 1 do
1151 if ((I in FutureTech) or (MyRO.Tech[I] < tsApplicable)) and
1152 (Server(sSetResearch - sExecute, Me, I, nil^) >= rExecuted) and
1153 ((MyData.FarTech = adNone) or (required[I] > 0)) then
1154 begin
1155 Code[0, Lines[0]] := I;
1156 Inc(Lines[0]);
1157 end;
1158 SortTechs;
1159 if Lines[0] = 0 then // no more techs -- offer nexus
1160 begin
1161 Code[0, Lines[0]] := adNexus;
1162 Inc(Lines[0]);
1163 end;
1164 ok := False;
1165 for I := 0 to nDomains - 1 do
1166 if (upgrade[I, 0].Preq = preNone) or
1167 (MyRO.Tech[upgrade[I, 0].Preq] >= tsApplicable) then
1168 ok := True;
1169 if ok then { new unit class }
1170 begin
1171 Code[0, Lines[0]] := adMilitary;
1172 Inc(Lines[0]);
1173 end;
1174 end;
1175 kFarAdvance:
1176 begin
1177 Code[0, Lines[0]] := adNone;
1178 Inc(Lines[0]);
1179 for I := 0 to nAdv - 1 do
1180 if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
1181 ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
1182 ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
1183 begin
1184 Code[0, Lines[0]] := I;
1185 Inc(Lines[0]);
1186 end;
1187 SortTechs;
1188 end;
1189 kChooseTech:
1190 begin
1191 for I := 0 to nAdv - 1 do
1192 if not(I in FutureTech) and (MyRO.Tech[I] >= tsApplicable) and
1193 (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) then
1194 begin
1195 Code[0, Lines[0]] := I;
1196 Inc(Lines[0]);
1197 end;
1198 SortTechs;
1199 // if Lines[0]>1 then
1200 begin
1201 Code[0, Lines[0]] := adAll;
1202 Inc(Lines[0]);
1203 end;
1204 end;
1205 kChooseETech:
1206 begin
1207 for I := 0 to nAdv - 1 do
1208 if not(I in FutureTech) and (MyRO.Tech[I] < tsSeen) and
1209 (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then
1210 begin
1211 Code[0, Lines[0]] := I;
1212 Inc(Lines[0]);
1213 end;
1214 SortTechs;
1215 // if Lines[0]>1 then
1216 begin
1217 Code[0, Lines[0]] := adAll;
1218 Inc(Lines[0]);
1219 end;
1220 end;
1221 kStealTech:
1222 begin
1223 for I := 0 to nAdv - 1 do
1224 if Server(sStealTech - sExecute, Me, I, nil^) >= rExecuted then
1225 begin
1226 Code[0, Lines[0]] := I;
1227 Inc(Lines[0]);
1228 end;
1229 SortTechs;
1230 end;
1231 kScience:
1232 begin
1233 Column[0] := Me;
1234 nColumn := 1;
1235 for EnemyType := 0 to 2 do
1236 for p1 := 0 to nPl - 1 do
1237 if (MyRO.EnemyReport[p1] <> nil) and
1238 ((MyRO.EnemyReport[p1].TurnOfContact >= 0) or
1239 (MyRO.EnemyReport[p1].TurnOfCivilReport >= 0)) then
1240 begin
1241 if MyRO.Alive and (1 shl p1) = 0 then
1242 TestEnemyType := 2 // extinct enemy -- move to right end
1243 else if MyRO.EnemyReport[p1].TurnOfCivilReport >= MyRO.Turn - 1
1244 then
1245 TestEnemyType := 0 // current report -- move to left end
1246 else
1247 TestEnemyType := 1;
1248 if TestEnemyType = EnemyType then
1249 begin
1250 Column[nColumn] := p1;
1251 Inc(nColumn);
1252 end;
1253 end;
1254 for I := 0 to nAdv - 1 do
1255 begin
1256 ok := (MyRO.Tech[I] <> tsNA) or (MyRO.ResearchTech = I);
1257 for J := 1 to nColumn - 1 do
1258 with MyRO.EnemyReport[Column[J]]^ do
1259 if (Tech[I] <> tsNA) or (TurnOfCivilReport >= 0) and
1260 (ResearchTech = I) then
1261 ok := True;
1262 if ok then
1263 begin
1264 Code[0, Lines[0]] := I;
1265 Inc(Lines[0]);
1266 end;
1267 end;
1268 SortTechs;
1269
1270 ok := MyRO.ResearchTech = adMilitary;
1271 for J := 1 to nColumn - 1 do
1272 with MyRO.EnemyReport[Column[J]]^ do
1273 if (MyRO.Alive and (1 shl Column[J]) <> 0) and
1274 (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then
1275 ok := True;
1276 if ok then
1277 begin
1278 Code[0, Lines[0]] := adMilitary;
1279 Inc(Lines[0]);
1280 end
1281 end;
1282 kCities { , kChooseCity } :
1283 begin
1284 if ClientMode < scContact then
1285 for I := 0 to MyRO.nCity - 1 do
1286 if MyCity[I].Loc >= 0 then
1287 begin
1288 Code[0, Lines[0]] := I;
1289 Inc(Lines[0]);
1290 end;
1291 SortCities;
1292 FirstShrinkedLine[0] := 0
1293 end;
1294 kCityEvents:
1295 begin
1296 for I := 0 to MyRO.nCity - 1 do
1297 if (MyCity[I].Loc >= 0) and (MyCity[I].Flags and CityRepMask <> 0)
1298 then
1299 begin
1300 Code[0, Lines[0]] := I;
1301 Inc(Lines[0]);
1302 end;
1303 SortCities;
1304 FirstShrinkedLine[0] := 0;
1305 end;
1306 { kChooseECity:
1307 begin
1308 for I:=0 to MyRO.nEnemyCity-1 do
1309 if (MyRO.EnemyCity[I].Loc>=0)
1310 and (MyRO.EnemyCity[I].owner=DipMem[Me].pContact) then
1311 begin Code[0,Lines[0]]:=I; Inc(Lines[0]); end;
1312 FirstShrinkedLine:=0
1313 end; }
1314 kModels:
1315 begin
1316 for mix := 0 to MyRO.nModel - 1 do
1317 begin
1318 Code[0, mix] := mix;
1319 MakeModelInfo(Me, mix, MyModel[mix], mi);
1320 Code[2, mix] := ModelSortValue(mi);
1321 end;
1322 Lines[0] := MyRO.nModel;
1323 SortModels;
1324 FirstShrinkedLine[0] := 0;
1325 end;
1326 kChooseModel:
1327 begin
1328 for mix := 3 to MyRO.nModel - 1 do
1329 begin // check if opponent already has this model
1330 MakeModelInfo(Me, mix, MyModel[mix], mi);
1331 ok := True;
1332 for emix := 0 to MyRO.nEnemyModel - 1 do
1333 if (MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact) and
1334 IsSameModel(MyRO.EnemyModel[emix], mi) then
1335 ok := False;
1336 if ok then
1337 begin
1338 Code[0, Lines[0]] := mix;
1339 MakeModelInfo(Me, mix, MyModel[mix], mi);
1340 Code[2, Lines[0]] := ModelSortValue(mi);
1341 Inc(Lines[0]);
1342 end;
1343 end;
1344 SortModels;
1345 // if Lines[0]>1 then
1346 begin
1347 Code[0, Lines[0]] := mixAll;
1348 Inc(Lines[0]);;
1349 end;
1350 FirstShrinkedLine[0] := 0;
1351 end;
1352 kChooseEModel:
1353 begin
1354 if MyRO.TestFlags and tfUncover <> 0 then
1355 Server(sGetModels, Me, 0, nil^);
1356 for emix := 0 to MyRO.nEnemyModel - 1 do
1357 ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact;
1358 for mix := 0 to MyRO.nModel - 1 do
1359 begin // don't list models I already have
1360 MakeModelInfo(Me, mix, MyModel[mix], mi);
1361 for emix := 0 to MyRO.nEnemyModel - 1 do
1362 ModelOk[emix] := ModelOk[emix] and
1363 not IsSameModel(MyRO.EnemyModel[emix], mi);
1364 end;
1365 for emix := 0 to MyRO.nEnemyModel - 1 do
1366 if ModelOk[emix] then
1367 begin
1368 if not Assigned(Tribe[DipMem[Me].pContact].ModelPicture
1369 [MyRO.EnemyModel[emix].mix].HGr) then
1370 InitEnemyModel(emix);
1371 Code[0, Lines[0]] := emix;
1372 Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
1373 Inc(Lines[0]);
1374 end;
1375 SortModels;
1376 // if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then
1377 begin
1378 Code[0, Lines[0]] := mixAll;
1379 Inc(Lines[0]);
1380 end;
1381 FirstShrinkedLine[0] := 0;
1382 end;
1383 kEModels:
1384 begin
1385 for I := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
1386 begin
1387 Code[1, Lines[0]] := MyRO.nEnemyModel - 1;
1388 while (Code[1, Lines[0]] >= 0) and
1389 not((MyRO.EnemyModel[Code[1, Lines[0]]].Owner = pView) and
1390 (MyRO.EnemyModel[Code[1, Lines[0]]].mix = I)) do
1391 Dec(Code[1, Lines[0]]);
1392 if not Assigned(Tribe[pView].ModelPicture[I].HGr) then
1393 InitEnemyModel(Code[1, Lines[0]]);
1394 Code[0, Lines[0]] := I;
1395 Code[2, Lines[0]] :=
1396 ModelSortValue(MyRO.EnemyModel[Code[1, Lines[0]]]);
1397 Inc(Lines[0]);
1398 end;
1399 SortModels;
1400 FirstShrinkedLine[0] := 0;
1401 end;
1402 kAllEModels:
1403 begin
1404 if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[Me] = 0) then
1405 Server(sGetModels, Me, 0, nil^);
1406 for emix := 0 to MyRO.nEnemyModel - 1 do
1407 if (MyRO.EnemyModel[emix].mix >= 3) and
1408 (MyRO.EnemyModel[emix].Kind in [mkSelfDeveloped, mkEnemyDeveloped])
1409 then
1410 begin
1411 PPicture := @Tribe[MyRO.EnemyModel[emix].Owner].ModelPicture
1412 [MyRO.EnemyModel[emix].mix];
1413 if not Assigned(PPicture.HGr) then
1414 InitEnemyModel(emix);
1415 ok := True;
1416 if MainScreen.mNames.Checked then
1417 for J := 0 to Lines[0] - 1 do
1418 begin
1419 PTestPicture := @Tribe[MyRO.EnemyModel[Code[0, J]].Owner]
1420 .ModelPicture[MyRO.EnemyModel[Code[0, J]].mix];
1421 if (PPicture.HGr = PTestPicture.HGr) and
1422 (PPicture.pix = PTestPicture.pix) and
1423 (ModelHash(MyRO.EnemyModel[emix])
1424 = ModelHash(MyRO.EnemyModel[Code[0, J]])) then
1425 begin
1426 Code[1, J] := 1;
1427 ok := False;
1428 Break;
1429 end;
1430 end;
1431 if ok then
1432 begin
1433 Code[0, Lines[0]] := emix;
1434 Code[1, Lines[0]] := 0;
1435 Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], True);
1436 Inc(Lines[0]);
1437 end;
1438 end;
1439 SortModels;
1440 FirstShrinkedLine[0] := 0
1441 end;
1442 kTribe:
1443 for I := 0 to TribeNames.Count - 1 do
1444 begin
1445 Code[0, Lines[0]] := I;
1446 Inc(Lines[0]);
1447 end;
1448 (* kDeliver:
1449 if MyRO.Treaty[DipMem[Me].pContact]<trAlliance then
1450 begin // suggest next treaty level
1451 Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]+1;
1452 Inc(Lines[0]);
1453 end;
1454 if MyRO.Treaty[DipMem[Me].pContact]=trNone then
1455 begin // suggest peace
1456 Code[0,Lines[0]]:=opTreaty+trPeace;
1457 Inc(Lines[0]);
1458 end;
1459 if MyRO.Treaty[DipMem[Me].pContact]>trNone then
1460 begin // suggest next treaty level
1461 Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
1462 Inc(Lines[0]);
1463 end; *)
1464 kShipPart:
1465 begin
1466 Lines[0] := 0;
1467 for I := 0 to nShipPart - 1 do
1468 if MyRO.Ship[Me].Parts[I] > 0 then
1469 begin
1470 Code[0, Lines[0]] := I;
1471 Inc(Lines[0]);
1472 end;
1473 end;
1474 kEShipPart:
1475 begin
1476 Lines[0] := 0;
1477 for I := 0 to nShipPart - 1 do
1478 if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then
1479 begin
1480 Code[0, Lines[0]] := I;
1481 Inc(Lines[0]);
1482 end;
1483 end;
1484 kGov:
1485 for I := 1 to nGov - 1 do
1486 if (GovPreq[I] <> preNA) and
1487 ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable))
1488 then
1489 begin
1490 Code[0, Lines[0]] := I;
1491 Inc(Lines[0]);
1492 end;
1493 kMission:
1494 for I := 0 to nSpyMission - 1 do
1495 begin
1496 Code[0, Lines[0]] := I;
1497 Inc(Lines[0]);
1498 end;
1499 end;
1500
1501 if Kind = kProject then // test if choice fitting to one screen
1502 if Lines[0] + Lines[1] + Lines[2] <= MaxLines then
1503 begin
1504 for I := 0 to Lines[1] - 1 do // add wonders to first page
1505 begin
1506 Code[0, Lines[0]] := Code[1, I];
1507 Inc(Lines[0]);
1508 end;
1509 Lines[1] := 0;
1510 FirstShrinkedLine[0] := Lines[0];
1511 for I := 0 to Lines[2] - 1 do // add models to first page
1512 begin
1513 Code[0, Lines[0]] := Code[2, I];
1514 Inc(Lines[0]);
1515 end;
1516 Lines[2] := 0;
1517 end;
1518end;
1519
1520function TListDlg.OnlyChoice(TestKind: TListKind): Integer;
1521begin
1522 Kind := TestKind;
1523 InitLines;
1524 if Lines[0] = 0 then
1525 Result := -2
1526 else if Lines[0] > 1 then
1527 Result := -1
1528 else
1529 Result := Code[0, 0];
1530end;
1531
1532procedure TListDlg.FormShow(Sender: TObject);
1533var
1534 I: Integer;
1535begin
1536 Result := -1;
1537 Closable := False;
1538
1539 if Kind = kTribe then
1540 begin
1541 LineDistance := 21; // looks ugly with scrollbar
1542 MaxLines := (Maintexture.Height - (24 + TitleHeight + NarrowFrame))
1543 div LineDistance - 1;
1544 end
1545 else
1546 begin
1547 LineDistance := 24;
1548 MaxLines := (Maintexture.Height - (24 + TitleHeight + WideFrame))
1549 div LineDistance - 1;
1550 end;
1551 InitLines;
1552
1553 MultiPage := False;
1554 for I := 1 to MaxLayer - 1 do
1555 if Lines[I] > 0 then
1556 MultiPage := True;
1557 WideBottom := MultiPage or (Kind = kScience) or
1558 not Phrases2FallenBackToEnglish and
1559 (Kind in [kProject, kAdvance, kFarAdvance]);
1560 if (Kind = kAdvance) and (MyData.FarTech <> adNone) or (Kind = kModels) or
1561 (Kind = kEModels) then begin
1562 ScrollBar.SetBorderSpacing(56, 10, 10);
1563 TitleHeight := WideFrame + 20;
1564 end else begin
1565 ScrollBar.SetBorderSpacing(36, 10, 34);
1566 TitleHeight := WideFrame;
1567 end;
1568
1569 DispLines := Lines[0];
1570 for I := 0 to MaxLayer - 1 do
1571 if Lines[I] > DispLines then
1572 DispLines := Lines[I];
1573 if WideBottom then
1574 begin
1575 if DispLines > MaxLines then
1576 DispLines := MaxLines;
1577 InnerHeight := LineDistance * (DispLines + 1) + 24;
1578 ClientHeight := InnerHeight + TitleHeight + WideFrame;
1579 end
1580 else
1581 begin
1582 if DispLines > MaxLines then
1583 DispLines := MaxLines;
1584 InnerHeight := LineDistance * (DispLines + 1) + 24;
1585 ClientHeight := InnerHeight + TitleHeight + NarrowFrame;
1586 end;
1587 Assert(ClientHeight <= Maintexture.Height);
1588
1589 TechNameSpace := 224;
1590 case Kind of
1591 kGov:
1592 InnerWidth := 272;
1593 kCities, kCityEvents:
1594 InnerWidth := 640 - 18;
1595 kTribe:
1596 if Lines[0] > MaxLines then
1597 InnerWidth := 280 + DpiGetSystemMetrics(SM_CXVSCROLL)
1598 else
1599 InnerWidth := 280;
1600 kScience:
1601 begin
1602 InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 * nColumn +
1603 DpiGetSystemMetrics(SM_CXVSCROLL);
1604 if InnerWidth + 2 * SideFrame > 640 then
1605 begin
1606 TechNameSpace := TechNameSpace + 640 - InnerWidth - 2 * SideFrame;
1607 InnerWidth := 640 - 2 * SideFrame
1608 end;
1609 end;
1610 kAdvance, kFarAdvance:
1611 InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 +
1612 DpiGetSystemMetrics(SM_CXVSCROLL);
1613 kChooseTech, kChooseETech, kStealTech:
1614 InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace +
1615 DpiGetSystemMetrics(SM_CXVSCROLL);
1616 else
1617 InnerWidth := 363;
1618 end;
1619 ClientWidth := InnerWidth + 2 * SideFrame;
1620
1621 CloseBtn.Left := ClientWidth - 38;
1622 CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
1623 CaptionRight := CloseBtn.Left;
1624 { TODO:
1625 SetWindowPos(ScrollBar.ScrollBar.Handle, 0, SideFrame + InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL),
1626 TitleHeight, DpiGetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48,
1627 SWP_NOZORDER or SWP_NOREDRAW);
1628 }
1629
1630 if WindowMode = wmModal then
1631 begin { center on screen }
1632 if Kind = kTribe then
1633 Left := (DpiScreen.Width - 800) * 3 div 8 + 130
1634 else
1635 Left := (DpiScreen.Width - Width) div 2;
1636 Top := (DpiScreen.Height - Height) div 2;
1637 if Kind = kProject then
1638 Top := Top + 48;
1639 end;
1640
1641 Layer0Btn.Visible := MultiPage and (Lines[0] > 0);
1642 Layer1Btn.Visible := MultiPage and (Lines[1] > 0);
1643 Layer2Btn.Visible := MultiPage and (Lines[2] > 0);
1644 if Kind = kProject then
1645 begin
1646 Layer0Btn.Top := ClientHeight - 31;
1647 Layer0Btn.Left := ClientWidth div 2 - (12 + 29);
1648 Layer0Btn.Down := True;
1649 Layer1Btn.Top := ClientHeight - 31;
1650 Layer1Btn.Left := ClientWidth div 2 - (12 - 29);
1651 Layer1Btn.Down := False;
1652 Layer2Btn.Top := ClientHeight - 31;
1653 Layer2Btn.Left := ClientWidth div 2 - 12;
1654 Layer2Btn.Down := False;
1655 end;
1656
1657 Layer := 0;
1658 Selected := -2;
1659 ScienceNation := -1;
1660 ScrollBar.Init(Lines[Layer] - 1, DispLines);
1661
1662 OffscreenPaint;
1663end;
1664
1665procedure TListDlg.ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
1666var
1667 I: Integer;
1668 ShowFocus, forceclose: Boolean;
1669begin
1670 forceclose := (ListKind <> Kind) and
1671 not((Kind = kCities) and (ListKind = kCityEvents)) and
1672 not((Kind = kCityEvents) and (ListKind = kCities)) and
1673 not((Kind = kModels) and (ListKind = kEModels)) and
1674 not((Kind = kEModels) and (ListKind = kModels));
1675
1676 Kind := ListKind;
1677 ModalIndication := not(Kind in MustChooseKind);
1678 case Kind of
1679 kProject:
1680 Caption := Phrases.Lookup('TITLE_PROJECT');
1681 kAdvance:
1682 Caption := Phrases.Lookup('TITLE_TECHSELECT');
1683 kFarAdvance:
1684 Caption := Phrases.Lookup('TITLE_FARTECH');
1685 kModels, kEModels:
1686 Caption := Phrases.Lookup('FRMILREP');
1687 kAllEModels:
1688 Caption := Phrases.Lookup('TITLE_EMODELS');
1689 kTribe:
1690 Caption := Phrases.Lookup('TITLE_TRIBE');
1691 kScience:
1692 Caption := Phrases.Lookup('TITLE_SCIENCE');
1693 kShipPart, kEShipPart:
1694 Caption := Phrases.Lookup('TITLE_CHOOSESHIPPART');
1695 kChooseTech, kChooseETech:
1696 Caption := Phrases.Lookup('TITLE_CHOOSETECH');
1697 kChooseModel, kChooseEModel:
1698 Caption := Phrases.Lookup('TITLE_CHOOSEMODEL');
1699 kStealTech:
1700 Caption := Phrases.Lookup('TITLE_CHOOSETECH');
1701 kGov:
1702 Caption := Phrases.Lookup('TITLE_GOV');
1703 kMission:
1704 Caption := Phrases.Lookup('TITLE_SPYMISSION');
1705 end;
1706
1707 case Kind of
1708 kMission:
1709 HelpContext := 'SPYMISSIONS';
1710 else
1711 HelpContext := 'CONCEPTS'
1712 end;
1713
1714 if Kind = kAdvance then
1715 begin
1716 ToggleBtn.ButtonIndex := 13;
1717 ToggleBtn.Hint := Phrases.Lookup('FARTECH');
1718 end
1719 else if Kind = kCities then
1720 begin
1721 ToggleBtn.ButtonIndex := 15;
1722 ToggleBtn.Hint := Phrases.Lookup('BTN_PAGE');
1723 end
1724 else
1725 begin
1726 ToggleBtn.ButtonIndex := 28;
1727 ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT');
1728 end;
1729
1730 if Kind = kAdvance then // show focus button?
1731 if MyData.FarTech <> adNone then
1732 ShowFocus := True
1733 else
1734 begin
1735 ShowFocus := False;
1736 for I := 0 to nAdv - 1 do
1737 if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
1738 ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
1739 ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
1740 (Server(sSetResearch - sExecute, Me, I, nil^) < rExecuted) then
1741 ShowFocus := True;
1742 end;
1743 ToggleBtn.Visible := (Kind = kCities) and not Supervising or (Kind = kAdvance)
1744 and ShowFocus or (Kind = kModels) or (Kind = kEModels);
1745 CloseBtn.Visible := not(Kind in MustChooseKind);
1746
1747 inherited ShowNewContent(NewMode, forceclose);
1748end;
1749
1750procedure TListDlg.ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
1751begin
1752 cixProject := cix;
1753 ShowNewContent(NewMode, kProject);
1754end;
1755
1756procedure TListDlg.ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
1757begin
1758 pView := P;
1759 if P = Me then
1760 ShowNewContent(NewMode, kModels)
1761 else
1762 ShowNewContent(NewMode, kEModels);
1763end;
1764
1765procedure TListDlg.PlayerClick(Sender: TObject);
1766begin
1767 if TComponent(Sender).Tag = Me then
1768 Kind := kModels
1769 else
1770 begin
1771 Kind := kEModels;
1772 pView := TComponent(Sender).Tag;
1773 end;
1774 InitLines;
1775 Selected := -2;
1776 ScrollBar.Init(Lines[Layer] - 1, DispLines);
1777 OffscreenPaint;
1778 Invalidate;
1779end;
1780
1781procedure TListDlg.ModeBtnClick(Sender: TObject);
1782begin
1783 Layer0Btn.Down := Sender = Layer0Btn;
1784 Layer1Btn.Down := Sender = Layer1Btn;
1785 Layer2Btn.Down := Sender = Layer2Btn;
1786 Layer := TComponent(Sender).Tag;
1787
1788 Selected := -2;
1789 ScrollBar.Init(Lines[Layer] - 1, DispLines);
1790 SmartUpdateContent;
1791end;
1792
1793procedure TListDlg.ToggleBtnClick(Sender: TObject);
1794var
1795 p1: Integer;
1796 M: TDpiMenuItem;
1797begin
1798 case Kind of
1799 kAdvance:
1800 begin
1801 Result := adFar;
1802 Closable := True;
1803 Close;
1804 end;
1805 kCities, kCityEvents:
1806 begin
1807 if Kind = kCities then
1808 Kind := kCityEvents
1809 else
1810 Kind := kCities;
1811 OffscreenPaint;
1812 Invalidate;
1813 end;
1814 kModels, kEModels:
1815 begin
1816 EmptyMenu(Popup.Items);
1817 if G.Difficulty[Me] > 0 then
1818 begin
1819 M := TDpiMenuItem.Create(Popup);
1820 M.RadioItem := True;
1821 M.Caption := Tribe[Me].TPhrase('SHORTNAME');
1822 M.Tag := Me;
1823 M.OnClick := PlayerClick;
1824 if Kind = kModels then
1825 M.Checked := True;
1826 Popup.Items.Add(M);
1827 end;
1828 for p1 := 0 to nPl - 1 do
1829 if (p1 <> Me) and (MyRO.EnemyReport[p1] <> nil) and
1830 (MyRO.EnemyReport[p1].TurnOfMilReport >= 0) then
1831 begin
1832 M := TDpiMenuItem.Create(Popup);
1833 M.RadioItem := True;
1834 M.Caption := Tribe[p1].TPhrase('SHORTNAME');
1835 M.Tag := p1;
1836 M.OnClick := PlayerClick;
1837 if (Kind = kEModels) and (p1 = pView) then
1838 M.Checked := True;
1839 Popup.Items.Add(M);
1840 end;
1841 Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top +
1842 ToggleBtn.Height);
1843 end;
1844 end;
1845end;
1846
1847procedure TListDlg.FormKeyDown(Sender: TObject; var Key: Word;
1848 Shift: TShiftState);
1849begin
1850 if (Key = VK_F2) and (Kind in [kModels, kEModels]) then // my key
1851 // !!! toggle
1852 else if (Key = VK_F3) and (Kind in [kCities, kCityEvents]) then // my key
1853 ToggleBtnClick(nil)
1854 else if ((Key = VK_ESCAPE) or (Key = VK_RETURN)) and not CloseBtn.Visible then
1855 // prevent closing
1856 else
1857 inherited;
1858end;
1859
1860procedure TListDlg.EcoChange;
1861begin
1862 if Visible and (Kind = kCities) then
1863 SmartUpdateContent;
1864end;
1865
1866procedure TListDlg.TechChange;
1867begin
1868 if Visible and (Kind = kScience) then
1869 begin
1870 FormShow(nil);
1871 Invalidate;
1872 end;
1873end;
1874
1875procedure TListDlg.AddCity;
1876begin
1877 if Visible and (Kind = kCities) then
1878 begin
1879 FormShow(nil);
1880 Invalidate;
1881 end;
1882end;
1883
1884procedure TListDlg.RemoveUnit;
1885begin
1886 if Visible and (Kind = kModels) then
1887 SmartUpdateContent;
1888end;
1889
1890procedure TListDlg.ScrollBarUpdate(Sender: TObject);
1891begin
1892 Selected := -2;
1893 SmartUpdateContent(True);
1894end;
1895
1896end.
Note: See TracBrowser for help on using the repository browser.