source: trunk/LocalPlayer/Select.pas

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