source: branches/delphi/LocalPlayer/Select.pas

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