1 | {$INCLUDE Switches.inc}
|
---|
2 | unit CityScreen;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | {$IFDEF UNIX}LMessages,{$ENDIF}
|
---|
8 | Protocol, ClientTools, ScreenTools, IsoEngine, BaseWin, LCLIntf, LCLType,
|
---|
9 | Messages, SysUtils, Classes, ButtonA, ButtonC, Area, GraphType, Texture,
|
---|
10 | {$IFDEF DPI}Dpi.Graphics, Dpi.Controls, Dpi.Forms, Dpi.ExtCtrls, System.UITypes{$ELSE}
|
---|
11 | Graphics, Controls, Forms, ExtCtrls{$ENDIF};
|
---|
12 |
|
---|
13 | const
|
---|
14 | WM_PLAYSOUND = WM_USER;
|
---|
15 |
|
---|
16 | type
|
---|
17 | TCityCloseAction = (None, RestoreFocus, StepFocus);
|
---|
18 | TSmallMapMode = (smSupportedUnits, smImprovements);
|
---|
19 |
|
---|
20 | TCityDlg = class(TBufferedDrawDlg)
|
---|
21 | Timer1: TTimer;
|
---|
22 | CloseBtn: TButtonA;
|
---|
23 | PrevCityBtn: TButtonC;
|
---|
24 | NextCityBtn: TButtonC;
|
---|
25 | PageUpBtn: TButtonC;
|
---|
26 | PageDownBtn: TButtonC;
|
---|
27 | BuyBtn: TButtonC;
|
---|
28 | ProjectArea: TArea;
|
---|
29 | PrimacyArea: TArea;
|
---|
30 | Imp2Area: TArea;
|
---|
31 | Imp4Area: TArea;
|
---|
32 | Imp0Area: TArea;
|
---|
33 | Imp3Area: TArea;
|
---|
34 | Imp5Area: TArea;
|
---|
35 | Imp1Area: TArea;
|
---|
36 | Pop0Area: TArea;
|
---|
37 | Pop1Area: TArea;
|
---|
38 | SupportArea: TArea;
|
---|
39 | procedure FormCreate(Sender: TObject);
|
---|
40 | procedure FormDestroy(Sender: TObject);
|
---|
41 | procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
|
---|
42 | Shift: TShiftState; X, Y: Integer);
|
---|
43 | procedure BuyClick(Sender: TObject);
|
---|
44 | procedure CloseBtnClick(Sender: TObject);
|
---|
45 | procedure FormShow(Sender: TObject);
|
---|
46 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
47 | procedure Timer1Timer(Sender: TObject);
|
---|
48 | procedure FormPaint(Sender: TObject);
|
---|
49 | procedure NextCityBtnClick(Sender: TObject);
|
---|
50 | procedure PrevCityBtnClick(Sender: TObject);
|
---|
51 | procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
---|
52 | procedure PageUpBtnClick(Sender: TObject);
|
---|
53 | procedure PageDownBtnClick(Sender: TObject);
|
---|
54 | private
|
---|
55 | C: TCity;
|
---|
56 | Report: TCityReportNew;
|
---|
57 | cOwner: Integer;
|
---|
58 | cGov: Integer;
|
---|
59 | emix: Integer; { enemy model index of produced unit }
|
---|
60 | cix: Integer;
|
---|
61 | cLoc: Integer;
|
---|
62 | SmallMapMode: TSmallMapMode;
|
---|
63 | ZoomArea: Integer;
|
---|
64 | Page: Integer;
|
---|
65 | PageCount: Integer;
|
---|
66 | BlinkTime: Integer;
|
---|
67 | OpenSoundEvent: Integer;
|
---|
68 | SizeClass: Integer;
|
---|
69 | AgePrepared: Integer;
|
---|
70 | Optimize_cixTileChange: Integer;
|
---|
71 | Optimize_TilesBeforeChange: Integer;
|
---|
72 | Happened: Cardinal;
|
---|
73 | imix: array [0 .. 15] of Integer;
|
---|
74 | CityAreaInfo: TCityAreaInfo;
|
---|
75 | AreaMap: TIsoMap;
|
---|
76 | NoMap: TIsoMap;
|
---|
77 | CityMapTemplate: TBitmap;
|
---|
78 | SmallCityMapTemplate: TBitmap;
|
---|
79 | Back: TBitmap;
|
---|
80 | SmallCityMap: TBitmap;
|
---|
81 | ZoomCityMap: TBitmap;
|
---|
82 | Template: TBitmap;
|
---|
83 | IsPort: Boolean;
|
---|
84 | ProdHint: Boolean;
|
---|
85 | AllowChange: Boolean;
|
---|
86 | RedTex: TTexture;
|
---|
87 | BarTex: TTexture;
|
---|
88 | procedure InitSmallCityMap;
|
---|
89 | procedure InitZoomCityMap;
|
---|
90 | procedure ChooseProject;
|
---|
91 | procedure ChangeCity(D: Integer);
|
---|
92 | procedure ChangeResourceWeights(iResourceWeights: Integer);
|
---|
93 | procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
|
---|
94 | public
|
---|
95 | RestoreUnFocus: Integer;
|
---|
96 | CloseAction: TCityCloseAction;
|
---|
97 | procedure OffscreenPaint; override;
|
---|
98 | procedure ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal);
|
---|
99 | procedure Reset;
|
---|
100 | procedure CheckAge;
|
---|
101 | end;
|
---|
102 |
|
---|
103 |
|
---|
104 | implementation
|
---|
105 |
|
---|
106 | uses
|
---|
107 | Select, Messg, MessgEx, Help, Tribes, Directories, Math, Sound, Term;
|
---|
108 |
|
---|
109 | {$R *.lfm}
|
---|
110 |
|
---|
111 | const
|
---|
112 | wBar = 106;
|
---|
113 | xDiv = 400;
|
---|
114 | xService = 296;
|
---|
115 | xmArea = 197;
|
---|
116 | ymArea = 170;
|
---|
117 | xView = 326;
|
---|
118 | yView = 275;
|
---|
119 | dxBar = wBar + 12;
|
---|
120 | dyBar = 39;
|
---|
121 | xHapp = 404;
|
---|
122 | yHapp = 9;
|
---|
123 | xFood = 404;
|
---|
124 | yFood = yHapp + 3 * dyBar + 6;
|
---|
125 | xProd = 404;
|
---|
126 | yProd = yFood + 3 * dyBar + 6;
|
---|
127 | xTrade = 404;
|
---|
128 | yTrade = yProd + 2 * dyBar + 22;
|
---|
129 | xPoll = xmArea - 186;
|
---|
130 | yPoll = ymArea + 64;
|
---|
131 | xmOpt = 40;
|
---|
132 | ymOpt = ymArea + 96 + 34;
|
---|
133 | xSmallMap = 271;
|
---|
134 | ySmallMap = 339;
|
---|
135 | wSmallMap = 98;
|
---|
136 | hSmallMap = 74;
|
---|
137 | xSupport = xSmallMap;
|
---|
138 | ySupport = ySmallMap + hSmallMap + 2;
|
---|
139 | wSupport = 64;
|
---|
140 | hSupport = 18;
|
---|
141 | xZoomMap = 34;
|
---|
142 | yZoomMap = 338;
|
---|
143 | wZoomMap = 228;
|
---|
144 | hZoomMap = 124;
|
---|
145 | wZoomEnvironment = 68;
|
---|
146 |
|
---|
147 | ImpPosition: array [28 .. nImp - 1] of Integer = (
|
---|
148 | -1, // imTrGoods
|
---|
149 | 21, // imBarracks
|
---|
150 | 6, // imGranary
|
---|
151 | 1, // imTemple
|
---|
152 | 7, // imMarket
|
---|
153 | 14, // imLibrary
|
---|
154 | 8, // imCourt
|
---|
155 | 18, // imWalls
|
---|
156 | 10, // imAqueduct
|
---|
157 | 11, // imBank
|
---|
158 | 5, // imCathedral
|
---|
159 | 13, // imUniversity
|
---|
160 | 29, // imHarbor
|
---|
161 | 2, // imTheater
|
---|
162 | 24, // imFactory
|
---|
163 | 25, // imMfgPlant
|
---|
164 | 28, // imRecycling
|
---|
165 | 27, // imPower
|
---|
166 | 27, // imHydro
|
---|
167 | 27, // imNuclear
|
---|
168 | 26, // imPlatform
|
---|
169 | 8, // imTownHall
|
---|
170 | 10, // imSewer
|
---|
171 | 3, // imSupermarket
|
---|
172 | 17, // imHighways
|
---|
173 | 15, // imResLab
|
---|
174 | 19, // imMissileBat
|
---|
175 | 23, // imCoastalFort
|
---|
176 | 22, // imAirport
|
---|
177 | 20, // imDockyard
|
---|
178 | 8, // imPalace
|
---|
179 | -1, // imGrWall
|
---|
180 | 4, // imColosseum
|
---|
181 | 16, // imObservatory
|
---|
182 | 21, // imMilAcademy
|
---|
183 | -1, // imBunker
|
---|
184 | -1, // imAlgae
|
---|
185 | 9, // imStockEx
|
---|
186 | -1, // imSpacePort
|
---|
187 | -1, // imShipComp
|
---|
188 | -1, // imShipPow
|
---|
189 | -1); // imShipHab
|
---|
190 |
|
---|
191 | var
|
---|
192 | ImpSorted: array [0 .. nImp - 1] of Integer;
|
---|
193 |
|
---|
194 | procedure TCityDlg.FormCreate(Sender: TObject);
|
---|
195 | begin
|
---|
196 | RedTex := TTexture.Create;
|
---|
197 | BarTex := TTexture.Create;
|
---|
198 | NoMap := TIsoMap.Create;
|
---|
199 | AreaMap := TIsoMap.Create;
|
---|
200 | AreaMap.SetOutput(Offscreen);
|
---|
201 | AreaMap.SetPaintBounds(xmArea - 192, ymArea - 96 - 32, xmArea + 192,
|
---|
202 | ymArea + 96);
|
---|
203 | Reset;
|
---|
204 | ProdHint := False;
|
---|
205 | RestoreUnFocus := -1;
|
---|
206 | OpenSoundEvent := -1;
|
---|
207 | AgePrepared := -2;
|
---|
208 | Optimize_cixTileChange := -1;
|
---|
209 | InitButtons;
|
---|
210 | // InitWindowRegion;
|
---|
211 | CloseBtn.Caption := Phrases.Lookup('BTN_OK');
|
---|
212 | BuyBtn.Hint := Phrases.Lookup('BTN_BUY');
|
---|
213 | if not Phrases2FallenBackToEnglish then
|
---|
214 | SupportArea.Hint := Phrases2.Lookup('TIP_SUPUNITS')
|
---|
215 | else
|
---|
216 | SupportArea.Hint := Phrases.Lookup('SUPUNITS');
|
---|
217 | if not Phrases2FallenBackToEnglish then
|
---|
218 | begin
|
---|
219 | Pop0Area.Hint := Phrases2.Lookup('TIP_WORKING');
|
---|
220 | Pop1Area.Hint := Phrases2.Lookup('TIP_CIVIL');
|
---|
221 | PrimacyArea.Hint := Phrases2.Lookup('TIP_PRIMACY');
|
---|
222 | ProjectArea.Hint := Phrases2.Lookup('TIP_PROJECT');
|
---|
223 | end;
|
---|
224 |
|
---|
225 | Back := TBitmap.Create;
|
---|
226 | Back.PixelFormat := TPixelFormat.pf24bit;
|
---|
227 | Back.SetSize(Width, Height);
|
---|
228 | Back.Canvas.FillRect(0, 0, Back.Width, Back.Height);
|
---|
229 | Template := TBitmap.Create;
|
---|
230 | Template.PixelFormat := TPixelFormat.pf24bit;
|
---|
231 | LoadGraphicFile(Template, GetGraphicsDir + DirectorySeparator + 'City.png',
|
---|
232 | [gfNoGamma]);
|
---|
233 | CityMapTemplate := TBitmap.Create;
|
---|
234 | CityMapTemplate.PixelFormat := TPixelFormat.pf24bit;
|
---|
235 | LoadGraphicFile(CityMapTemplate, GetGraphicsDir + DirectorySeparator + 'BigCityMap.png',
|
---|
236 | [gfNoGamma]);
|
---|
237 | SmallCityMapTemplate := TBitmap.Create;
|
---|
238 | SmallCityMapTemplate.PixelFormat := TPixelFormat.pf24bit;
|
---|
239 | LoadGraphicFile(SmallCityMapTemplate, GetGraphicsDir + DirectorySeparator + 'SmallCityMap.png',
|
---|
240 | [gfNoGamma]);
|
---|
241 | SmallCityMap := TBitmap.Create;
|
---|
242 | SmallCityMap.PixelFormat := TPixelFormat.pf24bit;
|
---|
243 | SmallCityMap.SetSize(98, 74);
|
---|
244 | SmallCityMap.Canvas.FillRect(0, 0, SmallCityMap.Width, SmallCityMap.Height);
|
---|
245 | ZoomCityMap := TBitmap.Create;
|
---|
246 | ZoomCityMap.PixelFormat := TPixelFormat.pf24bit;
|
---|
247 | ZoomCityMap.SetSize(228, 124);
|
---|
248 | ZoomCityMap.Canvas.FillRect(0, 0, ZoomCityMap.Width, ZoomCityMap.Height);
|
---|
249 | end;
|
---|
250 |
|
---|
251 | procedure TCityDlg.FormDestroy(Sender: TObject);
|
---|
252 | begin
|
---|
253 | FreeAndNil(NoMap);
|
---|
254 | FreeAndNil(AreaMap);
|
---|
255 | FreeAndNil(SmallCityMap);
|
---|
256 | FreeAndNil(ZoomCityMap);
|
---|
257 | FreeAndNil(SmallCityMapTemplate);
|
---|
258 | FreeAndNil(CityMapTemplate);
|
---|
259 | FreeAndNil(Template);
|
---|
260 | FreeAndNil(Back);
|
---|
261 | FreeAndNil(RedTex);
|
---|
262 | FreeAndNil(BarTex);
|
---|
263 | end;
|
---|
264 |
|
---|
265 | procedure TCityDlg.Reset;
|
---|
266 | begin
|
---|
267 | SmallMapMode := smImprovements;
|
---|
268 | ZoomArea := 1;
|
---|
269 | end;
|
---|
270 |
|
---|
271 | procedure TCityDlg.CheckAge;
|
---|
272 | begin
|
---|
273 | if MainTexture.Age <> AgePrepared then begin
|
---|
274 | AgePrepared := MainTexture.Age;
|
---|
275 |
|
---|
276 | UnshareBitmap(Back);
|
---|
277 | BitBltBitmap(Back, 0, 0, Width, Height, MainTexture.Image, 0, 0);
|
---|
278 | ImageOp_B(Back, Template, 0, 0, 0, 0, Width, Height);
|
---|
279 | end;
|
---|
280 | end;
|
---|
281 |
|
---|
282 | procedure TCityDlg.CloseBtnClick(Sender: TObject);
|
---|
283 | begin
|
---|
284 | Close;
|
---|
285 | end;
|
---|
286 |
|
---|
287 | procedure TCityDlg.InitSmallCityMap;
|
---|
288 | var
|
---|
289 | I, iix, cli1, Color0, Color1, Color2: Integer;
|
---|
290 | begin
|
---|
291 | if cix >= 0 then
|
---|
292 | C := MyCity[cix];
|
---|
293 | case MyMap[cLoc] and fTerrain of
|
---|
294 | fPrairie: cli1 := cliPrairie;
|
---|
295 | fHills: cli1 := cliHills;
|
---|
296 | fTundra: cli1 := cliTundra;
|
---|
297 | else
|
---|
298 | cli1 := cliPlains;
|
---|
299 | end;
|
---|
300 | Color0 := Colors.Canvas.Pixels[clkAge0 + Age, cliRoad];
|
---|
301 | Color1 := Colors.Canvas.Pixels[clkCity, cli1];
|
---|
302 | Color2 := Colors.Canvas.Pixels[clkAge0 + Age, cliHouse];
|
---|
303 | SmallCityMap.Canvas.FillRect(0, 0, SmallCityMap.Width, SmallCityMap.Height);
|
---|
304 | BitBltBitmap(SmallCityMap, 0, 0, 83, hSmallMap,
|
---|
305 | SmallCityMapTemplate, 83 * SizeClass, 0);
|
---|
306 | if IsPort then
|
---|
307 | begin
|
---|
308 | BitBltBitmap(SmallCityMap, 83, 0, 15, hSmallMap,
|
---|
309 | SmallCityMapTemplate, 332 + 15, 0);
|
---|
310 | ImageOp_CCC(SmallCityMap, 0, 0, 83, hSmallMap, Color0, Color1, Color2);
|
---|
311 | Color2 := Colors.Canvas.Pixels[clkCity, cliWater];
|
---|
312 | ImageOp_CCC(SmallCityMap, 83, 0, 15, hSmallMap, Color0, Color1, Color2);
|
---|
313 | end
|
---|
314 | else
|
---|
315 | begin
|
---|
316 | BitBltBitmap(SmallCityMap, 83, 0, 15, hSmallMap,
|
---|
317 | SmallCityMapTemplate, 332, 0);
|
---|
318 | ImageOp_CCC(SmallCityMap, 0, 0, wSmallMap, hSmallMap, Color0,
|
---|
319 | Color1, Color2);
|
---|
320 | end;
|
---|
321 |
|
---|
322 | with SmallCityMap.Canvas do
|
---|
323 | begin
|
---|
324 | Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImp];
|
---|
325 | for I := 0 to 29 do
|
---|
326 | begin
|
---|
327 | for iix := nWonder to nImp - 1 do
|
---|
328 | if (ImpPosition[iix] = I) and (C.Built[iix] > 0) then
|
---|
329 | begin
|
---|
330 | FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18),
|
---|
331 | 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18),
|
---|
332 | 11 + 12 * (I mod 18 div 3)));
|
---|
333 | Break;
|
---|
334 | end;
|
---|
335 | end;
|
---|
336 | I := 30;
|
---|
337 | for iix := 0 to nImp do
|
---|
338 | if (C.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then
|
---|
339 | begin
|
---|
340 | FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18),
|
---|
341 | 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18),
|
---|
342 | 11 + 12 * (I mod 18 div 3)));
|
---|
343 | Inc(I);
|
---|
344 | if I = 36 then
|
---|
345 | Break; // area is full
|
---|
346 | end;
|
---|
347 | if C.Project and cpImp <> 0 then
|
---|
348 | begin
|
---|
349 | iix := C.Project and cpIndex;
|
---|
350 | if iix <> imTrGoods then
|
---|
351 | begin
|
---|
352 | if (iix >= nWonder) and (ImpPosition[iix] >= 0) then
|
---|
353 | I := ImpPosition[iix];
|
---|
354 | if I < 36 then
|
---|
355 | begin
|
---|
356 | Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImpProject];
|
---|
357 | FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18),
|
---|
358 | 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18),
|
---|
359 | 11 + 12 * (I mod 18 div 3)));
|
---|
360 | end;
|
---|
361 | end;
|
---|
362 | end;
|
---|
363 | Brush.Style := TBrushStyle.bsClear;
|
---|
364 | end;
|
---|
365 | end;
|
---|
366 |
|
---|
367 | procedure TCityDlg.InitZoomCityMap;
|
---|
368 | begin
|
---|
369 | UnshareBitmap(ZoomCityMap);
|
---|
370 | BitBltBitmap(ZoomCityMap, 0, 0, wZoomMap, hZoomMap,
|
---|
371 | Back, xZoomMap, yZoomMap);
|
---|
372 | if SmallMapMode = smImprovements then begin
|
---|
373 | if ZoomArea < 3 then begin
|
---|
374 | ImageOp_B(ZoomCityMap, CityMapTemplate, 0, 0, 376 * SizeClass,
|
---|
375 | 112 * ZoomArea, wZoomMap, hZoomMap);
|
---|
376 | end else begin
|
---|
377 | ImageOp_B(ZoomCityMap, CityMapTemplate, 0, 0, 376 * SizeClass + 216,
|
---|
378 | 112 * (ZoomArea - 3), wZoomMap - wZoomEnvironment, hZoomMap);
|
---|
379 | ImageOp_B(ZoomCityMap, CityMapTemplate, wZoomMap - wZoomEnvironment, 0,
|
---|
380 | 1504 + wZoomEnvironment * Byte(IsPort), 112 * (ZoomArea - 3),
|
---|
381 | wZoomEnvironment, hZoomMap);
|
---|
382 | end;
|
---|
383 | end;
|
---|
384 | end;
|
---|
385 |
|
---|
386 | procedure TCityDlg.OffscreenPaint;
|
---|
387 |
|
---|
388 | procedure FillBar(X, Y, Pos, Growth, Max, Kind: Integer;
|
---|
389 | IndicateComplete: Boolean);
|
---|
390 | begin
|
---|
391 | BarTex.Assign(MainTexture);
|
---|
392 | if Kind = 3 then begin
|
---|
393 | BarTex.ColorBevelLight := HGrSystem.Data.Canvas.Pixels[104, 36];
|
---|
394 | BarTex.ColorBevelShade := BarTex.ColorBevelLight;
|
---|
395 | end;
|
---|
396 | PaintRelativeProgressBar(Offscreen.Canvas, Kind, X - 3, Y, wBar - 4, Pos,
|
---|
397 | Growth, Max, IndicateComplete, BarTex);
|
---|
398 | end;
|
---|
399 |
|
---|
400 | procedure PaintResources(X, Y, Loc: Integer; Add4Happy: Boolean);
|
---|
401 | var
|
---|
402 | D, I, Total, xGr, yGr: Integer;
|
---|
403 | TileInfo: TTileInfo;
|
---|
404 | Rare: Boolean;
|
---|
405 | begin
|
---|
406 | with AreaMap do begin
|
---|
407 | if Server(sGetCityTileInfo, Me, Loc, TileInfo) <> eOk then
|
---|
408 | begin
|
---|
409 | Assert(cix < 0);
|
---|
410 | Exit
|
---|
411 | end;
|
---|
412 | Total := TileInfo.Food + TileInfo.Prod + TileInfo.Trade;
|
---|
413 | Rare := MyMap[Loc] and $06000000 > 0;
|
---|
414 | if Rare then
|
---|
415 | Inc(Total);
|
---|
416 | if Add4Happy then
|
---|
417 | Inc(Total, 4);
|
---|
418 | if Total > 1 then
|
---|
419 | D := (xxt - 11) div (Total - 1);
|
---|
420 | if D < 1 then
|
---|
421 | D := 1;
|
---|
422 | if D > 4 then
|
---|
423 | D := 4;
|
---|
424 | for I := 0 to Total - 1 do
|
---|
425 | begin
|
---|
426 | yGr := 115;
|
---|
427 | if Add4Happy and (I >= Total - 4) then
|
---|
428 | begin
|
---|
429 | xGr := 132;
|
---|
430 | yGr := 126
|
---|
431 | end
|
---|
432 | else if Rare and (I = Total - 1) then
|
---|
433 | xGr := 66 + 110
|
---|
434 | else if I >= TileInfo.Food + TileInfo.Prod then
|
---|
435 | xGr := 66 + 44
|
---|
436 | else if I >= TileInfo.Prod then
|
---|
437 | xGr := 66
|
---|
438 | else
|
---|
439 | xGr := 66 + 22;
|
---|
440 | Sprite(Offscreen, HGrSystem, X + xxt - 5 + D * (2 * I + 1 - Total),
|
---|
441 | Y + yyt - 5, 10, 10, xGr, yGr);
|
---|
442 | end;
|
---|
443 | end;
|
---|
444 | end;
|
---|
445 | var
|
---|
446 | Line, MessageCount: Integer;
|
---|
447 |
|
---|
448 | procedure CheckMessage(Flag: Integer);
|
---|
449 | var
|
---|
450 | I, Test: Integer;
|
---|
451 | S: string;
|
---|
452 | begin
|
---|
453 | if Happened and Flag <> 0 then
|
---|
454 | begin
|
---|
455 | I := 0;
|
---|
456 | Test := 1;
|
---|
457 | while Test < Flag do
|
---|
458 | begin
|
---|
459 | Inc(I);
|
---|
460 | Inc(Test, Test);
|
---|
461 | end;
|
---|
462 |
|
---|
463 | if AllowChange and (Sounds <> nil) and (OpenSoundEvent = -1) then
|
---|
464 | begin
|
---|
465 | S := CityEventSoundItem[I];
|
---|
466 | if S <> '' then
|
---|
467 | S := Sounds.Lookup(S);
|
---|
468 | if (Flag = chProduction) or (S <> '') and (S[1] <> '*') and (S[1] <> '[')
|
---|
469 | then
|
---|
470 | OpenSoundEvent := I;
|
---|
471 | end;
|
---|
472 |
|
---|
473 | S := CityEventName(I);
|
---|
474 | { if Flag=chNoGrowthWarning then
|
---|
475 | if C.Built[imAqueduct]=0 then
|
---|
476 | S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
|
---|
477 | else S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); }
|
---|
478 | RisedTextOut(Offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount +
|
---|
479 | 16 * Line, S);
|
---|
480 | Inc(Line);
|
---|
481 | end;
|
---|
482 | end;
|
---|
483 |
|
---|
484 | var
|
---|
485 | X, Y, xGr, I, J, iix, D, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,
|
---|
486 | HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: Integer;
|
---|
487 | av: Integer;
|
---|
488 | PrName, S: string;
|
---|
489 | UnitInfo: TUnitInfo;
|
---|
490 | UnitReport: TUnitReport;
|
---|
491 | IsCityAlive, CanGrow: Boolean;
|
---|
492 | begin
|
---|
493 | inherited;
|
---|
494 | if cix >= 0 then
|
---|
495 | C := MyCity[cix];
|
---|
496 | Report.HypoTiles := -1;
|
---|
497 | Report.HypoTaxRate := -1;
|
---|
498 | Report.HypoLuxuryRate := -1;
|
---|
499 | if cix >= 0 then
|
---|
500 | Server(sGetCityReportNew, Me, cix, Report) // own city
|
---|
501 | else
|
---|
502 | Server(sGetEnemyCityReportNew, Me, cLoc, Report); // enemy city
|
---|
503 | TrueFood := C.Food;
|
---|
504 | TrueProd := C.Prod;
|
---|
505 | TruePoll := C.Pollution;
|
---|
506 | if Supervising or (cix < 0) then
|
---|
507 | begin // normalize city from after-turn state
|
---|
508 | Dec(TrueFood, Report.FoodSurplus);
|
---|
509 | if TrueFood < 0 then
|
---|
510 | TrueFood := 0; // shouldn't happen
|
---|
511 | Dec(TrueProd, Report.Production);
|
---|
512 | if TrueProd < 0 then
|
---|
513 | TrueProd := 0; // shouldn't happen
|
---|
514 | Dec(TruePoll, Report.AddPollution);
|
---|
515 | if TruePoll < 0 then
|
---|
516 | TruePoll := 0; // shouldn't happen
|
---|
517 | end;
|
---|
518 | IsCityAlive := (cGov <> gAnarchy) and (C.Flags and chCaptured = 0);
|
---|
519 | if not IsCityAlive then
|
---|
520 | Report.Working := C.Size;
|
---|
521 |
|
---|
522 | RedTex.Assign(MainTexture);
|
---|
523 | RedTex.ColorBevelLight := $0000FF;
|
---|
524 | RedTex.ColorBevelShade := $000000;
|
---|
525 | RedTex.ColorTextLight := $000000;
|
---|
526 | RedTex.ColorTextShade := $0000FF;
|
---|
527 |
|
---|
528 | BitBltBitmap(Offscreen, 0, 0, 640, 480, Back, 0, 0);
|
---|
529 |
|
---|
530 | Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
|
---|
531 | RisedTextOut(Offscreen.Canvas, 42, 7, Caption);
|
---|
532 | with Offscreen.Canvas do
|
---|
533 | begin // city size
|
---|
534 | Brush.Color := $000000;
|
---|
535 | FillRect(Rect(8 + 1, 7 + 1, 36 + 1, 32 + 1));
|
---|
536 | Brush.Color := $FFFFFF;
|
---|
537 | FillRect(Rect(8, 7, 36, 32));
|
---|
538 | Brush.Style := TBrushStyle.bsClear;
|
---|
539 | Font.Color := $000000;
|
---|
540 | S := IntToStr(C.Size);
|
---|
541 | TextOut(8 + 14 - TextWidth(S) div 2, 7, S);
|
---|
542 | end;
|
---|
543 | Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
|
---|
544 |
|
---|
545 | if not IsCityAlive then
|
---|
546 | begin
|
---|
547 | MakeRed(Offscreen, 18, 280, 298, 40);
|
---|
548 | if cGov = gAnarchy then
|
---|
549 | S := Phrases.Lookup('GOVERNMENT', gAnarchy)
|
---|
550 | else { if c.Flags and chCaptured<>0 then }
|
---|
551 | S := Phrases.Lookup('CITYEVENTS', 14);
|
---|
552 | RisedTextOut(Offscreen.Canvas, 167 - BiColorTextWidth(Offscreen.Canvas, S)
|
---|
553 | div 2, ymOpt - 9, S);
|
---|
554 | end
|
---|
555 | else if AllowChange then
|
---|
556 | begin
|
---|
557 | OptiType := C.Status shr 4 and $0F;
|
---|
558 | Sprite(Offscreen, HGrSystem2, xmOpt - 32, ymOpt - 32, 64, 64,
|
---|
559 | 1 + OptiType mod 3 * 64, 217 + OptiType div 3 * 64);
|
---|
560 |
|
---|
561 | { display messages now }
|
---|
562 | MessageCount := 0;
|
---|
563 | for I := 0 to 31 do
|
---|
564 | if Happened and ($FFFFFFFF - chCaptured) and (1 shl I) <> 0 then
|
---|
565 | Inc(MessageCount);
|
---|
566 | if MessageCount > 3 then
|
---|
567 | MessageCount := 3;
|
---|
568 | if MessageCount > 0 then
|
---|
569 | begin
|
---|
570 | MakeBlue(Offscreen, 74, 280, 242, 40);
|
---|
571 | Line := 0;
|
---|
572 | for I := 0 to nCityEventPriority - 1 do
|
---|
573 | if Line < MessageCount then
|
---|
574 | CheckMessage(CityEventPriority[I]);
|
---|
575 | end
|
---|
576 | else
|
---|
577 | begin
|
---|
578 | S := Phrases.Lookup('CITYMANAGETYPE', OptiType);
|
---|
579 | J := Pos('\', S);
|
---|
580 | if J = 0 then
|
---|
581 | LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xmOpt + 40,
|
---|
582 | ymOpt - 9, S)
|
---|
583 | else
|
---|
584 | begin
|
---|
585 | LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xmOpt + 40,
|
---|
586 | ymOpt - 17, Copy(S, 1, J - 1));
|
---|
587 | LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, ymOpt - 1,
|
---|
588 | Copy(S, J + 1, 255));
|
---|
589 | end;
|
---|
590 | end;
|
---|
591 | end;
|
---|
592 |
|
---|
593 | with AreaMap do begin
|
---|
594 | rx := (192 + xxt * 2 - 1) div (xxt * 2);
|
---|
595 | ry := (96 + yyt * 2 - 1) div (yyt * 2);
|
---|
596 | AreaMap.Paint(xmArea - xxt * 2 * rx, ymArea - yyt * 2 * ry - 3 * yyt,
|
---|
597 | dLoc(cLoc, -2 * rx + 1, -2 * ry - 1), 4 * rx - 1, 4 * ry + 1, cLoc, cOwner,
|
---|
598 | False, AllowChange and IsCityAlive and
|
---|
599 | (C.Status and csResourceWeightsMask = 0));
|
---|
600 | BitBltBitmap(Offscreen, xmArea + 102, 42, 90, 33, Back, xmArea + 102, 42);
|
---|
601 |
|
---|
602 | if IsCityAlive then
|
---|
603 | for dy := -3 to 3 do
|
---|
604 | for dx := -3 to 3 do
|
---|
605 | if ((dx + dy) and 1 = 0) and (dx * dx * dy * dy < 81) then begin
|
---|
606 | Loc1 := dLoc(cLoc, dx, dy);
|
---|
607 | av := CityAreaInfo.Available[(dy + 3) shl 2 + (dx + 3) shr 1];
|
---|
608 | if ((av = faNotAvailable) or (av = faTreaty) or (av = faInvalid)) and
|
---|
609 | ((Loc1 < 0) or (Loc1 >= G.lx * G.ly) or (MyMap[Loc1] and fCity = 0))
|
---|
610 | then
|
---|
611 | Sprite(Offscreen, HGrTerrain, xmArea - xxt + xxt * dx,
|
---|
612 | ymArea - yyt + yyt * dy, xxt * 2, yyt * 2, 1 + 5 * (xxt * 2 + 1),
|
---|
613 | 1 + yyt + 15 * (yyt * 3 + 1));
|
---|
614 | if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and C.Tiles <> 0) then
|
---|
615 | PaintResources(xmArea - xxt + xxt * dx, ymArea - yyt + yyt * dy,
|
---|
616 | Loc1, (dx = 0) and (dy = 0));
|
---|
617 | end;
|
---|
618 | end;
|
---|
619 |
|
---|
620 | if Report.Working > 1 then
|
---|
621 | D := (xService - (xmArea - 192) - 8 - 32) div (Report.Working - 1);
|
---|
622 | if D > 28 then
|
---|
623 | D := 28;
|
---|
624 | for I := Report.Working - 1 downto 0 do
|
---|
625 | begin
|
---|
626 | if IsCityAlive then
|
---|
627 | xGr := 29
|
---|
628 | else
|
---|
629 | xGr := 141;
|
---|
630 | BitBltBitmap(Offscreen, xmArea - 192 + 5 + I * D, ymArea - 96 - 29,
|
---|
631 | 27, 30, HGrSystem.Mask, xGr, 171, SRCAND); { shadow }
|
---|
632 | Sprite(Offscreen, HGrSystem, xmArea - 192 + 4 + I * D, ymArea - 96 - 30, 27,
|
---|
633 | 30, xGr, 171);
|
---|
634 | end;
|
---|
635 | if C.Size - Report.Working > 1 then
|
---|
636 | D := (xmArea + 192 - xService - 32) div (C.Size - Report.Working - 1);
|
---|
637 | if D > 28 then
|
---|
638 | D := 28;
|
---|
639 | for I := 0 to C.Size - Report.Working - 1 do
|
---|
640 | begin
|
---|
641 | xGr := 1 + 112;
|
---|
642 | BitBltBitmap(Offscreen, xmArea + 192 - 27 + 1 - I * D, 29 + 1, 27,
|
---|
643 | 30, HGrSystem.Mask, xGr, 171, SRCAND); { shadow }
|
---|
644 | Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 - I * D, 29, 27, 30,
|
---|
645 | xGr, 171);
|
---|
646 | Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 4 - I * D, 29 + 32, 10,
|
---|
647 | 10, 121, 126);
|
---|
648 | Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 13 - I * D, 29 + 32, 10,
|
---|
649 | 10, 121, 126);
|
---|
650 | // Sprite(offscreen,HGrSystem,xmArea+192-31+18-i*d,ymArea-96-80+32,10,10,88,115);
|
---|
651 | end;
|
---|
652 |
|
---|
653 | if C.Project and cpImp = 0 then
|
---|
654 | PrName := Tribe[cOwner].ModelName[C.Project and cpIndex]
|
---|
655 | else
|
---|
656 | PrName := Phrases.Lookup('IMPROVEMENTS', C.Project and cpIndex);
|
---|
657 | PrCost := Report.ProjectCost;
|
---|
658 |
|
---|
659 | // happiness section
|
---|
660 | if IsCityAlive then
|
---|
661 | begin
|
---|
662 | if cGov = gFundamentalism then
|
---|
663 | CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17,
|
---|
664 | Phrases.Lookup('FAITH'), Report.CollectedControl, MainTexture)
|
---|
665 | else
|
---|
666 | begin
|
---|
667 | CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17,
|
---|
668 | Phrases.Lookup('HAPPINESS'), Report.Morale, MainTexture);
|
---|
669 | CountBar(Offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16,
|
---|
670 | Phrases.Lookup('CONTROL'), Report.CollectedControl, MainTexture);
|
---|
671 | end;
|
---|
672 | CountBar(Offscreen, xHapp, yHapp, wBar, 8, Phrases.Lookup('LUX'),
|
---|
673 | Report.Luxury, MainTexture);
|
---|
674 | CountBar(Offscreen, xHapp + dxBar, yHapp, wBar, 19,
|
---|
675 | Phrases.Lookup('UNREST'), 2 * Report.Deployed, MainTexture);
|
---|
676 | CountBar(Offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17,
|
---|
677 | Phrases.Lookup('HAPPINESSDEMAND'), C.Size, MainTexture);
|
---|
678 | if Report.HappinessBalance >= 0 then
|
---|
679 | CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17,
|
---|
680 | Phrases.Lookup('HAPPINESSPLUS'), Report.HappinessBalance, MainTexture)
|
---|
681 | else
|
---|
682 | begin
|
---|
683 | MakeRed(Offscreen, xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38);
|
---|
684 | CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18,
|
---|
685 | Phrases.Lookup('LACK'), -Report.HappinessBalance, RedTex);
|
---|
686 | end;
|
---|
687 | end;
|
---|
688 |
|
---|
689 | // food section
|
---|
690 | if IsCityAlive then
|
---|
691 | begin
|
---|
692 | CountBar(Offscreen, xFood, yFood + dyBar div 2, wBar, 0,
|
---|
693 | Phrases.Lookup('FOOD'), Report.CollectedFood, MainTexture);
|
---|
694 | CountBar(Offscreen, xFood + dxBar, yFood + dyBar, wBar, 0,
|
---|
695 | Phrases.Lookup('DEMAND'), 2 * C.Size, MainTexture);
|
---|
696 | CountBar(Offscreen, xFood + dxBar, yFood, wBar, 0,
|
---|
697 | Phrases.Lookup('SUPPORT'), Report.FoodSupport, MainTexture);
|
---|
698 | if Report.FoodSurplus >= 0 then
|
---|
699 | if (cGov = gFuture) or (C.Size >= NeedAqueductSize) and
|
---|
700 | (Report.FoodSurplus < 2) then
|
---|
701 | CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6,
|
---|
702 | Phrases.Lookup('PROFIT'), Report.FoodSurplus, MainTexture)
|
---|
703 | else
|
---|
704 | CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0,
|
---|
705 | Phrases.Lookup('SURPLUS'), Report.FoodSurplus, MainTexture)
|
---|
706 | else
|
---|
707 | begin
|
---|
708 | MakeRed(Offscreen, xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38);
|
---|
709 | CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1,
|
---|
710 | Phrases.Lookup('LACK'), -Report.FoodSurplus, RedTex);
|
---|
711 | end;
|
---|
712 | end;
|
---|
713 | CanGrow := (C.Size < MaxCitySize) and (cGov <> gFuture) and
|
---|
714 | (Report.FoodSurplus > 0) and ((C.Size < NeedAqueductSize) or
|
---|
715 | (C.Built[imAqueduct] = 1) and (C.Size < NeedSewerSize) or
|
---|
716 | (C.Built[imSewer] = 1));
|
---|
717 | FillBar(xFood + 3, yFood + 102, TrueFood,
|
---|
718 | CutCityFoodSurplus(Report.FoodSurplus, IsCityAlive, cGov, C.Size),
|
---|
719 | Report.Storage, 1, CanGrow);
|
---|
720 | LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xFood + 3 - 5,
|
---|
721 | yFood + 102 - 20, Format('%d/%d', [TrueFood, Report.Storage]));
|
---|
722 | LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xFood - 2, yFood + 66,
|
---|
723 | Phrases.Lookup('STORAGE'));
|
---|
724 |
|
---|
725 | // production section
|
---|
726 | if IsCityAlive then
|
---|
727 | begin
|
---|
728 | CountBar(Offscreen, xProd, yProd, wBar, 2, Phrases.Lookup('MATERIAL'),
|
---|
729 | Report.CollectedMaterial, MainTexture);
|
---|
730 | CountBar(Offscreen, xProd + dxBar, yProd, wBar, 2,
|
---|
731 | Phrases.Lookup('SUPPORT'), Report.MaterialSupport, MainTexture);
|
---|
732 | if Report.Production >= 0 then
|
---|
733 | if C.Project and (cpImp + cpIndex) = cpImp + imTrGoods then
|
---|
734 | CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6,
|
---|
735 | Phrases.Lookup('PROFIT'), Report.Production, MainTexture)
|
---|
736 | else
|
---|
737 | CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2,
|
---|
738 | Phrases.Lookup('PROD'), Report.Production, MainTexture)
|
---|
739 | else
|
---|
740 | begin
|
---|
741 | MakeRed(Offscreen, xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38);
|
---|
742 | CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3,
|
---|
743 | Phrases.Lookup('LACK'), -Report.Production, RedTex);
|
---|
744 | end;
|
---|
745 | end;
|
---|
746 | if C.Project and (cpImp + cpIndex) <> cpImp + imTrGoods then
|
---|
747 | with Offscreen.Canvas do
|
---|
748 | begin
|
---|
749 | I := Report.Production;
|
---|
750 | if (I < 0) or not IsCityAlive then
|
---|
751 | I := 0;
|
---|
752 | FillBar(xProd + 3, yProd + 16 + 63, TrueProd, I, PrCost, 4, True);
|
---|
753 | LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xProd + 3 - 5,
|
---|
754 | yProd + 16 + 43, Format('%d/%d', [TrueProd, PrCost]));
|
---|
755 | if BiColorTextWidth(Offscreen.Canvas, PrName) > wBar + dxBar then
|
---|
756 | begin
|
---|
757 | repeat
|
---|
758 | Delete(PrName, Length(PrName), 1)
|
---|
759 | until BiColorTextWidth(Offscreen.Canvas, PrName) <= wBar + dxBar;
|
---|
760 | PrName := PrName + '.'
|
---|
761 | end;
|
---|
762 | end;
|
---|
763 | RisedTextOut(Offscreen.Canvas, xProd - 2, yProd + 36, PrName);
|
---|
764 |
|
---|
765 | // pollution section
|
---|
766 | if IsCityAlive and (Report.AddPollution > 0) then
|
---|
767 | begin
|
---|
768 | FillBar(xPoll + 3, yPoll + 20, TruePoll, Report.AddPollution,
|
---|
769 | MaxPollution, 3, True);
|
---|
770 | RisedTextOut(Offscreen.Canvas, xPoll + 3 - 5, yPoll + 20 - 20,
|
---|
771 | Phrases.Lookup('POLL'));
|
---|
772 | end;
|
---|
773 |
|
---|
774 | // trade section
|
---|
775 | if IsCityAlive and (Report.CollectedTrade > 0) then
|
---|
776 | begin
|
---|
777 | CountBar(Offscreen, xTrade, yTrade + dyBar div 2, wBar, 4,
|
---|
778 | Phrases.Lookup('TRADE'), Report.CollectedTrade, MainTexture);
|
---|
779 | CountBar(Offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5,
|
---|
780 | Phrases.Lookup('CORR'), Report.Corruption, MainTexture);
|
---|
781 | CountBar(Offscreen, xTrade + dxBar, yTrade, wBar, 6, Phrases.Lookup('TAX'),
|
---|
782 | Report.Tax, MainTexture);
|
---|
783 | CountBar(Offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12,
|
---|
784 | Phrases.Lookup('SCIENCE'), Report.Science, MainTexture);
|
---|
785 | end;
|
---|
786 |
|
---|
787 | // small map
|
---|
788 | BitBltBitmap(Offscreen, xSmallMap, ySmallMap, wSmallMap, hSmallMap,
|
---|
789 | SmallCityMap, 0, 0);
|
---|
790 | if SmallMapMode = smImprovements then
|
---|
791 | Frame(Offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3),
|
---|
792 | ySmallMap + 24 * (ZoomArea mod 3), xSmallMap + 48 * (ZoomArea div 3) + 49,
|
---|
793 | ySmallMap + 24 * (ZoomArea mod 3) + 25, MainTexture.ColorMark,
|
---|
794 | MainTexture.ColorMark);
|
---|
795 | Frame(Offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap,
|
---|
796 | ySmallMap + hSmallMap, $B0B0B0, $FFFFFF);
|
---|
797 | RFrame(Offscreen.Canvas, xSmallMap - 2, ySmallMap - 2, xSmallMap + wSmallMap +
|
---|
798 | 1, ySmallMap + hSmallMap + 1, $FFFFFF, $B0B0B0);
|
---|
799 |
|
---|
800 | Frame(Offscreen.Canvas, xSupport - 1, ySupport - 1, xSupport + wSupport,
|
---|
801 | ySupport + hSupport, $B0B0B0, $FFFFFF);
|
---|
802 | RFrame(Offscreen.Canvas, xSupport - 2, ySupport - 2, xSupport + wSupport + 1,
|
---|
803 | ySupport + hSupport + 1, $FFFFFF, $B0B0B0);
|
---|
804 | X := xSupport + wSupport div 2;
|
---|
805 | Y := ySupport + hSupport div 2;
|
---|
806 | if SmallMapMode = smSupportedUnits then
|
---|
807 | begin
|
---|
808 | Offscreen.Canvas.Brush.Color := MainTexture.ColorMark;
|
---|
809 | Offscreen.Canvas.FillRect(Rect(X - 27, Y - 6, X + 27, Y + 6));
|
---|
810 | Offscreen.Canvas.Brush.Style := TBrushStyle.bsClear;
|
---|
811 | end;
|
---|
812 | Sprite(Offscreen, HGrSystem, X - 16, Y - 5, 10, 10, 88, 115);
|
---|
813 | Sprite(Offscreen, HGrSystem, X - 5, Y - 5, 10, 10, 66, 115);
|
---|
814 | Sprite(Offscreen, HGrSystem, X + 6, Y - 5, 10, 10, 154, 126);
|
---|
815 |
|
---|
816 | BitBltBitmap(Offscreen, xZoomMap, yZoomMap, wZoomMap, hZoomMap, ZoomCityMap, 0, 0);
|
---|
817 |
|
---|
818 | for I := 0 to 5 do
|
---|
819 | imix[I] := -1;
|
---|
820 | if SmallMapMode = smImprovements then
|
---|
821 | begin
|
---|
822 | if ZoomArea = 5 then
|
---|
823 | begin
|
---|
824 | Cnt := 0;
|
---|
825 | for iix := 0 to nImp - 1 do
|
---|
826 | if ((iix < nWonder) or (ImpPosition[iix] < 0)) and (C.Built[iix] > 0) then
|
---|
827 | begin
|
---|
828 | I := Cnt - Page * 6;
|
---|
829 | if (I >= 0) and (I < 6) then
|
---|
830 | imix[I] := iix;
|
---|
831 | Inc(Cnt);
|
---|
832 | end;
|
---|
833 | PageCount := (Cnt + 5) div 6;
|
---|
834 | end
|
---|
835 | else
|
---|
836 | begin
|
---|
837 | for iix := nWonder to nImp - 1 do
|
---|
838 | begin
|
---|
839 | I := ImpPosition[iix] - 6 * ZoomArea;
|
---|
840 | if (I >= 0) and (I < 6) and (C.Built[iix] > 0) then
|
---|
841 | imix[I] := iix;
|
---|
842 | end;
|
---|
843 | PageCount := 0;
|
---|
844 | end;
|
---|
845 | for I := 0 to 5 do
|
---|
846 | if imix[I] >= 0 then
|
---|
847 | begin
|
---|
848 | iix := imix[I];
|
---|
849 | X := xZoomMap + 14 + 72 * (I mod 3);
|
---|
850 | Y := yZoomMap + 14 + 56 * (I div 3);
|
---|
851 | ImpImage(Offscreen.Canvas, X, Y, iix, cGov, AllowChange and
|
---|
852 | (ClientMode < scContact));
|
---|
853 | if IsCityAlive then
|
---|
854 | begin
|
---|
855 | if iix = imColosseum then
|
---|
856 | begin
|
---|
857 | Sprite(Offscreen, HGrSystem, X + 46, Y, 14, 14, 82, 100);
|
---|
858 | end
|
---|
859 | else
|
---|
860 | begin
|
---|
861 | HappyGain := 0;
|
---|
862 | case iix of
|
---|
863 | 0 .. 27, imTemple:
|
---|
864 | HappyGain := 2;
|
---|
865 | imTheater:
|
---|
866 | HappyGain := 4;
|
---|
867 | imCathedral:
|
---|
868 | if MyRO.Wonder[woBach].EffectiveOwner = cOwner then
|
---|
869 | HappyGain := 6
|
---|
870 | else
|
---|
871 | HappyGain := 4;
|
---|
872 | end;
|
---|
873 | if HappyGain > 1 then
|
---|
874 | begin
|
---|
875 | D := 30 div (HappyGain - 1);
|
---|
876 | if D > 10 then
|
---|
877 | D := 10
|
---|
878 | end;
|
---|
879 | for J := 0 to HappyGain - 1 do
|
---|
880 | Sprite(Offscreen, HGrSystem, X + 50, Y + D * J, 10, 10, 132, 126);
|
---|
881 | end;
|
---|
882 | for J := 0 to Imp[iix].Maint - 1 do
|
---|
883 | Sprite(Offscreen, HGrSystem, X - 4, Y + 29 - 3 * J, 10, 10,
|
---|
884 | 132, 115);
|
---|
885 | end;
|
---|
886 | end;
|
---|
887 | if imix[0] >= 0 then
|
---|
888 | Imp0Area.Hint := Phrases.Lookup('IMPROVEMENTS', imix[0])
|
---|
889 | else
|
---|
890 | Imp0Area.Hint := '';
|
---|
891 | if imix[1] >= 0 then
|
---|
892 | Imp1Area.Hint := Phrases.Lookup('IMPROVEMENTS', imix[1])
|
---|
893 | else
|
---|
894 | Imp1Area.Hint := '';
|
---|
895 | if imix[2] >= 0 then
|
---|
896 | Imp2Area.Hint := Phrases.Lookup('IMPROVEMENTS', imix[2])
|
---|
897 | else
|
---|
898 | Imp2Area.Hint := '';
|
---|
899 | if imix[3] >= 0 then
|
---|
900 | Imp3Area.Hint := Phrases.Lookup('IMPROVEMENTS', imix[3])
|
---|
901 | else
|
---|
902 | Imp3Area.Hint := '';
|
---|
903 | if imix[4] >= 0 then
|
---|
904 | Imp4Area.Hint := Phrases.Lookup('IMPROVEMENTS', imix[4])
|
---|
905 | else
|
---|
906 | Imp4Area.Hint := '';
|
---|
907 | if imix[5] >= 0 then
|
---|
908 | Imp5Area.Hint := Phrases.Lookup('IMPROVEMENTS', imix[5])
|
---|
909 | else
|
---|
910 | Imp5Area.Hint := '';
|
---|
911 | end
|
---|
912 | else { if SmallMapMode = smSupportedUnits then }
|
---|
913 | begin
|
---|
914 | LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xZoomMap + 6,
|
---|
915 | yZoomMap + 2, Phrases.Lookup('SUPUNITS'));
|
---|
916 | FreeSupp := C.Size * SupportFree[cGov] shr 1;
|
---|
917 | Cnt := 0;
|
---|
918 | for I := 0 to MyRO.nUn - 1 do
|
---|
919 | if (MyUn[I].Loc >= 0) and (MyUn[I].Home = cix) then
|
---|
920 | with MyModel[MyUn[I].mix] do
|
---|
921 | begin
|
---|
922 | Server(sGetUnitReport, Me, I, UnitReport);
|
---|
923 | if (Cnt >= 6 * Page) and (Cnt < 6 * (Page + 1)) then
|
---|
924 | begin // unit visible in display
|
---|
925 | imix[Cnt - 6 * Page] := I;
|
---|
926 | X := ((Cnt - 6 * Page) mod 3) * 64 + xZoomMap;
|
---|
927 | Y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20;
|
---|
928 | MakeUnitInfo(Me, MyUn[I], UnitInfo);
|
---|
929 | NoMap.SetOutput(Offscreen);
|
---|
930 | NoMap.PaintUnit(X, Y, UnitInfo, MyUn[I].Status);
|
---|
931 |
|
---|
932 | for J := 0 to UnitReport.FoodSupport - 1 do
|
---|
933 | Sprite(Offscreen, HGrSystem, X + 38 + 11 * J, Y + 40, 10,
|
---|
934 | 10, 66, 115);
|
---|
935 | for J := 0 to UnitReport.ProdSupport - 1 do
|
---|
936 | begin
|
---|
937 | if (FreeSupp > 0) and
|
---|
938 | (UnitReport.ReportFlags and urfAlwaysSupport = 0) then
|
---|
939 | begin
|
---|
940 | Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10,
|
---|
941 | 10, 143, 115);
|
---|
942 | Dec(FreeSupp);
|
---|
943 | end
|
---|
944 | else
|
---|
945 | Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10,
|
---|
946 | 10, 88, 115);
|
---|
947 | end;
|
---|
948 | if UnitReport.ReportFlags and urfDeployed <> 0 then
|
---|
949 | for J := 0 to 1 do
|
---|
950 | Sprite(Offscreen, HGrSystem, X + 27 + 11 * J, Y + 40, 10,
|
---|
951 | 10, 154, 126)
|
---|
952 | end // unit visible in display
|
---|
953 | else
|
---|
954 | Dec(FreeSupp, UnitReport.ProdSupport);
|
---|
955 | Inc(Cnt);
|
---|
956 | end;
|
---|
957 | PageCount := (Cnt + 5) div 6;
|
---|
958 | Imp0Area.Hint := '';
|
---|
959 | Imp1Area.Hint := '';
|
---|
960 | Imp2Area.Hint := '';
|
---|
961 | Imp3Area.Hint := '';
|
---|
962 | Imp4Area.Hint := '';
|
---|
963 | Imp5Area.Hint := '';
|
---|
964 | end;
|
---|
965 | PageUpBtn.Visible := PageCount > 1;
|
---|
966 | PageDownBtn.Visible := PageCount > 1;
|
---|
967 |
|
---|
968 | with Offscreen.Canvas do
|
---|
969 | begin
|
---|
970 | { display project now }
|
---|
971 | DLine(Offscreen.Canvas, xView + 9 + xSizeBig, xProd + 2 * wBar + 10,
|
---|
972 | yProd + dyBar + 16, $FFFFFF, $B0B0B0);
|
---|
973 | if ProdHint then
|
---|
974 | begin
|
---|
975 | ScreenTools.Frame(Offscreen.Canvas, xView + 9 - 1, yView + 5 - 1,
|
---|
976 | xView + 9 + xSizeBig, yView + 5 + ySizeBig, $B0B0B0, $FFFFFF);
|
---|
977 | RFrame(Offscreen.Canvas, xView + 9 - 2, yView + 5 - 2,
|
---|
978 | xView + 9 + xSizeBig + 1, yView + 5 + ySizeBig + 1, $FFFFFF, $B0B0B0);
|
---|
979 | with Offscreen.Canvas do
|
---|
980 | begin
|
---|
981 | Brush.Color := $000000;
|
---|
982 | FillRect(Rect(xView + 9, yView + 5, xView + 1 + 72 - 8,
|
---|
983 | yView + 5 + 40));
|
---|
984 | Brush.Style := TBrushStyle.bsClear;
|
---|
985 | end;
|
---|
986 | end
|
---|
987 | else if AllowChange and (C.Status and 7 <> 0) then
|
---|
988 | begin // city type autobuild
|
---|
989 | FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,
|
---|
990 | ySizeBig, (C.Status and 7 - 1 + 3) * xSizeBig, 0, (cix >= 0) and
|
---|
991 | (ClientMode < scContact));
|
---|
992 | end
|
---|
993 | else if C.Project and cpImp = 0 then
|
---|
994 | begin // project is unit
|
---|
995 | FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,
|
---|
996 | ySizeBig, 0, 0, AllowChange and (ClientMode < scContact));
|
---|
997 | with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do
|
---|
998 | Sprite(Offscreen, HGr, xView + 5, yView + 1, 64, 44,
|
---|
999 | pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
|
---|
1000 | end
|
---|
1001 | else
|
---|
1002 | begin // project is building
|
---|
1003 | if ProdHint then
|
---|
1004 | Paintiix := C.Project0 and cpIndex
|
---|
1005 | else
|
---|
1006 | Paintiix := C.Project and cpIndex;
|
---|
1007 | ImpImage(Offscreen.Canvas, xView + 9, yView + 5, Paintiix, cGov,
|
---|
1008 | AllowChange and (ClientMode < scContact));
|
---|
1009 | end;
|
---|
1010 | end;
|
---|
1011 |
|
---|
1012 | if AllowChange and (ClientMode < scContact) then
|
---|
1013 | begin
|
---|
1014 | I := Server(sBuyCityProject - sExecute, Me, cix, nil^);
|
---|
1015 | BuyBtn.Visible := (I = eOk) or (I = eViolation);
|
---|
1016 | end
|
---|
1017 | else
|
---|
1018 | BuyBtn.Visible := False;
|
---|
1019 |
|
---|
1020 | MarkUsedOffscreen(ClientWidth, ClientHeight);
|
---|
1021 | end;
|
---|
1022 |
|
---|
1023 | procedure TCityDlg.FormShow(Sender: TObject);
|
---|
1024 | var
|
---|
1025 | dx, dy, Loc1: Integer;
|
---|
1026 | GetCityData: TGetCityData;
|
---|
1027 | begin
|
---|
1028 | BlinkTime := 5;
|
---|
1029 | if cix >= 0 then
|
---|
1030 | begin { own city }
|
---|
1031 | C := MyCity[cix];
|
---|
1032 | cOwner := Me;
|
---|
1033 | cGov := MyRO.Government;
|
---|
1034 | ProdHint := (cGov <> gAnarchy) and
|
---|
1035 | (Happened and (chProduction or chFounded or chCaptured or
|
---|
1036 | chAllImpsMade) <> 0);
|
---|
1037 | Server(sGetCityAreaInfo, Me, cix, CityAreaInfo);
|
---|
1038 | NextCityBtn.Visible := WindowMode = wmPersistent;
|
---|
1039 | PrevCityBtn.Visible := WindowMode = wmPersistent;
|
---|
1040 | end
|
---|
1041 | else { enemy city }
|
---|
1042 | begin
|
---|
1043 | SmallMapMode := smImprovements;
|
---|
1044 | Server(sGetCity, Me, cLoc, GetCityData);
|
---|
1045 | C := GetCityData.C;
|
---|
1046 | cOwner := GetCityData.Owner;
|
---|
1047 | cGov := MyRO.EnemyReport[cOwner].Government;
|
---|
1048 | Happened := C.Flags and $7FFFFFFF;
|
---|
1049 | ProdHint := False;
|
---|
1050 | Server(sGetEnemyCityAreaInfo, Me, cLoc, CityAreaInfo);
|
---|
1051 |
|
---|
1052 | if C.Project and cpImp = 0 then
|
---|
1053 | begin
|
---|
1054 | emix := MyRO.nEnemyModel - 1;
|
---|
1055 | while (emix > 0) and ((MyRO.EnemyModel[emix].Owner <> cOwner) or
|
---|
1056 | (Integer(MyRO.EnemyModel[emix].mix) <> C.Project and cpIndex)) do
|
---|
1057 | Dec(emix);
|
---|
1058 | if not Assigned(Tribe[cOwner].ModelPicture[C.Project and cpIndex].HGr) then
|
---|
1059 | InitEnemyModel(emix);
|
---|
1060 | end;
|
---|
1061 |
|
---|
1062 | NextCityBtn.Visible := False;
|
---|
1063 | PrevCityBtn.Visible := False;
|
---|
1064 | end;
|
---|
1065 | Page := 0;
|
---|
1066 |
|
---|
1067 | if C.Size < 5 then
|
---|
1068 | SizeClass := 0
|
---|
1069 | else if C.Size < 9 then
|
---|
1070 | SizeClass := 1
|
---|
1071 | else if C.Size < 13 then
|
---|
1072 | SizeClass := 2
|
---|
1073 | else
|
---|
1074 | SizeClass := 3;
|
---|
1075 |
|
---|
1076 | // check if port
|
---|
1077 | IsPort := False;
|
---|
1078 | for dx := -2 to 2 do
|
---|
1079 | for dy := -2 to 2 do
|
---|
1080 | if Abs(dx) + Abs(dy) = 2 then
|
---|
1081 | begin
|
---|
1082 | Loc1 := dLoc(cLoc, dx, dy);
|
---|
1083 | if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
|
---|
1084 | (MyMap[Loc1] and fTerrain < fGrass) then begin
|
---|
1085 | IsPort := True;
|
---|
1086 | Break;
|
---|
1087 | end;
|
---|
1088 | end;
|
---|
1089 |
|
---|
1090 | if WindowMode = wmModal then
|
---|
1091 | begin { center on screen }
|
---|
1092 | Left := (Screen.Width - Width) div 2;
|
---|
1093 | Top := (Screen.Height - Height) div 2;
|
---|
1094 | end;
|
---|
1095 |
|
---|
1096 | Caption := CityName(C.ID);
|
---|
1097 |
|
---|
1098 | InitSmallCityMap;
|
---|
1099 | InitZoomCityMap;
|
---|
1100 | OpenSoundEvent := -1;
|
---|
1101 | OffscreenPaint;
|
---|
1102 | Timer1.Enabled := True;
|
---|
1103 | end;
|
---|
1104 |
|
---|
1105 | procedure TCityDlg.ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal);
|
---|
1106 | begin
|
---|
1107 | if MyMap[Loc] and fOwned <> 0 then
|
---|
1108 | begin // own city
|
---|
1109 | cix := MyRO.nCity - 1;
|
---|
1110 | while (cix >= 0) and (MyCity[cix].Loc <> Loc) do
|
---|
1111 | Dec(cix);
|
---|
1112 | Assert(cix >= 0);
|
---|
1113 | if (Optimize_cixTileChange >= 0) and
|
---|
1114 | (Optimize_TilesBeforeChange and not MyCity[Optimize_cixTileChange].Tiles
|
---|
1115 | <> 0) then
|
---|
1116 | begin
|
---|
1117 | CityOptimizer_ReleaseCityTiles(Optimize_cixTileChange,
|
---|
1118 | Optimize_TilesBeforeChange and
|
---|
1119 | not MyCity[Optimize_cixTileChange].Tiles);
|
---|
1120 | if WindowMode <> wmModal then
|
---|
1121 | MainScreen.UpdateViews;
|
---|
1122 | end;
|
---|
1123 | Optimize_cixTileChange := cix;
|
---|
1124 | Optimize_TilesBeforeChange := MyCity[cix].Tiles;
|
---|
1125 | end
|
---|
1126 | else
|
---|
1127 | cix := -1;
|
---|
1128 | AllowChange := not Supervising and (cix >= 0);
|
---|
1129 | cLoc := Loc;
|
---|
1130 | Happened := ShowEvent;
|
---|
1131 | inherited ShowNewContent(NewMode);
|
---|
1132 | end;
|
---|
1133 |
|
---|
1134 | procedure TCityDlg.FormMouseDown(Sender: TObject; Button: TMouseButton;
|
---|
1135 | Shift: TShiftState; X, Y: Integer);
|
---|
1136 | var
|
---|
1137 | I, qx, qy, dx, dy, fix, NewTiles, Loc1, iix, SellResult: Integer;
|
---|
1138 | Rebuild: Boolean;
|
---|
1139 | begin
|
---|
1140 | if (ssLeft in Shift) and (X >= xSmallMap) and (X < xSmallMap + wSmallMap) and
|
---|
1141 | (Y >= ySmallMap) and (Y < ySmallMap + hSmallMap) then
|
---|
1142 | begin
|
---|
1143 | SmallMapMode := smImprovements;
|
---|
1144 | ZoomArea := (Y - ySmallMap) * 3 div hSmallMap + 3 *
|
---|
1145 | ((X - xSmallMap) * 2 div wSmallMap);
|
---|
1146 | Page := 0;
|
---|
1147 | InitZoomCityMap;
|
---|
1148 | SmartUpdateContent;
|
---|
1149 | Exit;
|
---|
1150 | end;
|
---|
1151 | if (ssLeft in Shift) and (X >= xSupport) and (X < xSupport + wSupport) and
|
---|
1152 | (Y >= ySupport) and (Y < ySupport + hSupport) then
|
---|
1153 | begin
|
---|
1154 | SmallMapMode := smSupportedUnits;
|
---|
1155 | Page := 0;
|
---|
1156 | InitZoomCityMap;
|
---|
1157 | SmartUpdateContent;
|
---|
1158 | Exit;
|
---|
1159 | end;
|
---|
1160 | if not AllowChange then
|
---|
1161 | Exit; // Not an own city
|
---|
1162 |
|
---|
1163 | if (ssLeft in Shift) then
|
---|
1164 | if (ClientMode < scContact) and (X >= xView) and (Y >= yView) and
|
---|
1165 | (X < xView + 73) and (Y < yView + 50) then
|
---|
1166 | if cGov = gAnarchy then
|
---|
1167 | with MainScreen.MessgExDlg do
|
---|
1168 | begin
|
---|
1169 | { MessgText:=Phrases.Lookup('OUTOFCONTROL');
|
---|
1170 | if C.Project and cpImp=0 then
|
---|
1171 | MessgText:=Format(MessgText,[Tribe[cOwner].ModelName[C.Project and cpIndex]])
|
---|
1172 | else MessgText:=Format(MessgText,[Phrases.Lookup('IMPROVEMENTS',C.Project and cpIndex)]); }
|
---|
1173 | MessgText := Phrases.Lookup('NOCHANGEINANARCHY');
|
---|
1174 | Kind := mkOk;
|
---|
1175 | ShowModal;
|
---|
1176 | end
|
---|
1177 | else
|
---|
1178 | begin
|
---|
1179 | if ProdHint then
|
---|
1180 | begin
|
---|
1181 | ProdHint := False;
|
---|
1182 | SmartUpdateContent
|
---|
1183 | end;
|
---|
1184 | ChooseProject;
|
---|
1185 | end
|
---|
1186 | else if (SmallMapMode = smImprovements) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and
|
---|
1187 | (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then
|
---|
1188 | begin
|
---|
1189 | I := 5;
|
---|
1190 | while (I >= 0) and not ((X >= xZoomMap + 14 + 72 * (I mod 3)) and
|
---|
1191 | (X < xZoomMap + 14 + 56 + 72 * (I mod 3)) and
|
---|
1192 | (Y >= yZoomMap + 14 + 56 * (I div 3)) and
|
---|
1193 | (Y < yZoomMap + 14 + 40 + 56 * (I div 3))) do
|
---|
1194 | Dec(I);
|
---|
1195 | if I >= 0 then
|
---|
1196 | begin
|
---|
1197 | iix := imix[I];
|
---|
1198 | if iix >= 0 then
|
---|
1199 | if ssShift in Shift then
|
---|
1200 | MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, iix)
|
---|
1201 | else if (ClientMode < scContact) then
|
---|
1202 | with MainScreen.MessgExDlg do
|
---|
1203 | begin
|
---|
1204 | IconKind := mikImp;
|
---|
1205 | IconIndex := iix;
|
---|
1206 | if (iix = imPalace) or (Imp[iix].Kind = ikWonder) then
|
---|
1207 | begin
|
---|
1208 | MessgText := Phrases.Lookup('IMPROVEMENTS', iix);
|
---|
1209 | if iix = woOracle then
|
---|
1210 | MessgText := MessgText + '\' +
|
---|
1211 | Format(Phrases.Lookup('ORACLEINCOME'), [MyRO.OracleIncome]);
|
---|
1212 | Kind := mkOk;
|
---|
1213 | ShowModal;
|
---|
1214 | end
|
---|
1215 | else
|
---|
1216 | begin
|
---|
1217 | SellResult := Server(sSellCityImprovement - sExecute, Me,
|
---|
1218 | cix, iix);
|
---|
1219 | if SellResult < rExecuted then
|
---|
1220 | begin
|
---|
1221 | if SellResult = eOnlyOnce then
|
---|
1222 | MessgText := Phrases.Lookup('NOSELLAGAIN')
|
---|
1223 | else
|
---|
1224 | MessgText := Phrases.Lookup('OUTOFCONTROL');
|
---|
1225 | MessgText := Format(MessgText,
|
---|
1226 | [Phrases.Lookup('IMPROVEMENTS', iix)]);
|
---|
1227 | Kind := mkOk;
|
---|
1228 | ShowModal;
|
---|
1229 | end
|
---|
1230 | else
|
---|
1231 | begin
|
---|
1232 | if Server(sRebuildCityImprovement - sExecute, Me, cix, iix) < rExecuted
|
---|
1233 | then
|
---|
1234 | begin // no rebuild possible, ask for sell only
|
---|
1235 | Rebuild := False;
|
---|
1236 | MessgText := Phrases.Lookup('IMPROVEMENTS', iix);
|
---|
1237 | if not Phrases2FallenBackToEnglish then
|
---|
1238 | MessgText := Format(Phrases2.Lookup('SELL2'),
|
---|
1239 | [MessgText, Imp[iix].Cost * BuildCostMod
|
---|
1240 | [G.Difficulty[Me]] div 12])
|
---|
1241 | else
|
---|
1242 | MessgText := Format(Phrases.Lookup('SELL'), [MessgText]);
|
---|
1243 | if iix = imSpacePort then
|
---|
1244 | with MyRO.Ship[Me] do
|
---|
1245 | if Parts[0] + Parts[1] + Parts[2] > 0 then
|
---|
1246 | MessgText := MessgText + ' ' +
|
---|
1247 | Phrases.Lookup('SPDESTRUCTQUERY');
|
---|
1248 | Kind := mkYesNo;
|
---|
1249 | ShowModal;
|
---|
1250 | if ModalResult <> mrOK then
|
---|
1251 | iix := -1
|
---|
1252 | end
|
---|
1253 | else
|
---|
1254 | begin
|
---|
1255 | Rebuild := True;
|
---|
1256 | MessgText := Phrases.Lookup('IMPROVEMENTS', iix);
|
---|
1257 | if not Phrases2FallenBackToEnglish then
|
---|
1258 | MessgText := Format(Phrases2.Lookup('DISPOSE2'),
|
---|
1259 | [MessgText, Imp[iix].Cost * BuildCostMod
|
---|
1260 | [G.Difficulty[Me]] div 12 * 2 div 3])
|
---|
1261 | else
|
---|
1262 | MessgText := Format(Phrases.Lookup('DISPOSE'),
|
---|
1263 | [MessgText]);
|
---|
1264 | if iix = imSpacePort then
|
---|
1265 | with MyRO.Ship[Me] do
|
---|
1266 | if Parts[0] + Parts[1] + Parts[2] > 0 then
|
---|
1267 | MessgText := MessgText + ' ' +
|
---|
1268 | Phrases.Lookup('SPDESTRUCTQUERY');
|
---|
1269 | Kind := mkYesNo;
|
---|
1270 | ShowModal;
|
---|
1271 | if ModalResult <> mrOK then
|
---|
1272 | iix := -1
|
---|
1273 | end;
|
---|
1274 | if iix >= 0 then
|
---|
1275 | begin
|
---|
1276 | if Rebuild then
|
---|
1277 | begin
|
---|
1278 | Play('CITY_REBUILDIMP');
|
---|
1279 | Server(sRebuildCityImprovement, Me, cix, iix);
|
---|
1280 | end
|
---|
1281 | else
|
---|
1282 | begin
|
---|
1283 | Play('CITY_SELLIMP');
|
---|
1284 | Server(sSellCityImprovement, Me, cix, iix);
|
---|
1285 | end;
|
---|
1286 | CityOptimizer_CityChange(cix);
|
---|
1287 | InitSmallCityMap;
|
---|
1288 | SmartUpdateContent;
|
---|
1289 | if WindowMode <> wmModal then
|
---|
1290 | MainScreen.UpdateViews;
|
---|
1291 | end;
|
---|
1292 | end;
|
---|
1293 | end;
|
---|
1294 | end;
|
---|
1295 | end;
|
---|
1296 | end
|
---|
1297 | else if (SmallMapMode = smSupportedUnits) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and
|
---|
1298 | (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then
|
---|
1299 | begin
|
---|
1300 | I := 5;
|
---|
1301 | while (I >= 0) and not ((X >= xZoomMap + 64 * (I mod 3)) and
|
---|
1302 | (X < xZoomMap + 64 + 64 * (I mod 3)) and
|
---|
1303 | (Y >= yZoomMap + 20 + 48 * (I div 3)) and
|
---|
1304 | (Y < yZoomMap + 20 + 52 + 48 * (I div 3))) do
|
---|
1305 | Dec(I);
|
---|
1306 | if (I >= 0) and (imix[I] >= 0) then
|
---|
1307 | if ssShift in Shift then
|
---|
1308 | else if (cix >= 0) and (ClientMode < scContact) and
|
---|
1309 | (WindowMode <> wmModal) then
|
---|
1310 | begin
|
---|
1311 | CloseAction := None;
|
---|
1312 | Close;
|
---|
1313 | MainScreen.CityClosed(imix[I], False, True);
|
---|
1314 | end;
|
---|
1315 | end
|
---|
1316 | else if (X >= xmArea - 192) and (X < xmArea + 192) and (Y >= ymArea - 96)
|
---|
1317 | and (Y < ymArea + 96) then
|
---|
1318 | with AreaMap do begin
|
---|
1319 | qx := ((4000 * xxt * yyt) + (X - xmArea) * (yyt * 2) + (Y - ymArea + yyt)
|
---|
1320 | * (xxt * 2)) div (xxt * yyt * 4) - 1000;
|
---|
1321 | qy := ((4000 * xxt * yyt) + (Y - ymArea + yyt) * (xxt * 2) - (X - xmArea)
|
---|
1322 | * (yyt * 2)) div (xxt * yyt * 4) - 1000;
|
---|
1323 | dx := qx - qy;
|
---|
1324 | dy := qx + qy;
|
---|
1325 | if (dx >= -3) and (dx <= 3) and (dy >= -3) and (dy <= 3) and
|
---|
1326 | (dx * dx * dy * dy < 81) and ((dx <> 0) or (dy <> 0)) then
|
---|
1327 | if ssShift in Shift then
|
---|
1328 | begin // terrain help
|
---|
1329 | Loc1 := dLoc(cLoc, dx, dy);
|
---|
1330 | if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) then
|
---|
1331 | HelpOnTerrain(Loc1, WindowModeMakePersistent(FWindowMode))
|
---|
1332 | end
|
---|
1333 | else if (ClientMode < scContact) and (cGov <> gAnarchy) and
|
---|
1334 | (C.Flags and chCaptured = 0) then
|
---|
1335 | begin // toggle exploitation
|
---|
1336 | Assert(not Supervising);
|
---|
1337 | if C.Status and csResourceWeightsMask <> 0 then
|
---|
1338 | begin
|
---|
1339 | with MainScreen.MessgExDlg do
|
---|
1340 | begin
|
---|
1341 | MessgText := Phrases.Lookup('CITYMANAGEOFF');
|
---|
1342 | OpenSound := 'MSG_DEFAULT';
|
---|
1343 | Kind := mkOkCancel;
|
---|
1344 | IconKind := mikFullControl;
|
---|
1345 | ShowModal;
|
---|
1346 | end;
|
---|
1347 | if MainScreen.MessgExDlg.ModalResult = mrOK then
|
---|
1348 | begin
|
---|
1349 | MyCity[cix].Status := MyCity[cix].Status and
|
---|
1350 | not csResourceWeightsMask; // off
|
---|
1351 | C.Status := MyCity[cix].Status;
|
---|
1352 | SmartUpdateContent;
|
---|
1353 | end;
|
---|
1354 | Exit;
|
---|
1355 | end;
|
---|
1356 | fix := (dy + 3) shl 2 + (dx + 3) shr 1;
|
---|
1357 | NewTiles := MyCity[cix].Tiles xor (1 shl fix);
|
---|
1358 | if Server(sSetCityTiles, Me, cix, NewTiles) >= rExecuted then
|
---|
1359 | begin
|
---|
1360 | SmartUpdateContent;
|
---|
1361 | if WindowMode <> wmModal then
|
---|
1362 | MainScreen.UpdateViews;
|
---|
1363 | end;
|
---|
1364 | end;
|
---|
1365 | end
|
---|
1366 | else if (ClientMode < scContact) and (cGov <> gAnarchy) and
|
---|
1367 | (C.Flags and chCaptured = 0) and (X >= xmOpt - 32) and (X < xmOpt + 32)
|
---|
1368 | and (Y >= ymOpt - 32) and (Y < ymOpt + 32) then
|
---|
1369 | begin
|
---|
1370 | I := Sqr(X - xmOpt) + Sqr(Y - ymOpt); // click radius
|
---|
1371 | if I <= 32 * 32 then
|
---|
1372 | begin
|
---|
1373 | if I < 16 * 16 then // inner area clicked
|
---|
1374 | if C.Status and csResourceWeightsMask <> 0 then
|
---|
1375 | I := (C.Status shr 4 and $0F) mod 5 + 1 // rotate except off
|
---|
1376 | else
|
---|
1377 | I := 3 // rwGrowth
|
---|
1378 | else
|
---|
1379 | case Trunc(ArcTan2(X - xmOpt, ymOpt - Y) * 180 / Pi) of
|
---|
1380 | - 25 - 52 * 2 .. -26 - 52:
|
---|
1381 | I := 1;
|
---|
1382 | -25 - 52 .. -26:
|
---|
1383 | I := 2;
|
---|
1384 | -25 .. 25:
|
---|
1385 | I := 3;
|
---|
1386 | 26 .. 25 + 52:
|
---|
1387 | I := 4;
|
---|
1388 | 26 + 52 .. 25 + 52 * 2:
|
---|
1389 | I := 5;
|
---|
1390 | 180 - 26 .. 180, -180 .. -180 + 26:
|
---|
1391 | I := 0;
|
---|
1392 | else
|
---|
1393 | I := -1;
|
---|
1394 | end;
|
---|
1395 | if I >= 0 then
|
---|
1396 | begin
|
---|
1397 | ChangeResourceWeights(I);
|
---|
1398 | SmartUpdateContent;
|
---|
1399 | if WindowMode <> wmModal then
|
---|
1400 | MainScreen.UpdateViews;
|
---|
1401 | end;
|
---|
1402 | end;
|
---|
1403 | end;
|
---|
1404 | end;
|
---|
1405 |
|
---|
1406 | procedure TCityDlg.ChooseProject;
|
---|
1407 | type
|
---|
1408 | TProjectType = (
|
---|
1409 | ptSelect = 0,
|
---|
1410 | ptTrGoods = 1,
|
---|
1411 | ptUn = 2,
|
---|
1412 | ptCaravan = 3,
|
---|
1413 | ptImp = 4,
|
---|
1414 | ptWonder = 6,
|
---|
1415 | ptShip = 7,
|
---|
1416 | ptInvalid = 8
|
---|
1417 | );
|
---|
1418 |
|
---|
1419 | function ProjectType(Project: Integer): TProjectType;
|
---|
1420 | begin
|
---|
1421 | if Project and cpCompleted <> 0 then
|
---|
1422 | Result := ptSelect
|
---|
1423 | else if Project and (cpImp + cpIndex) = cpImp + imTrGoods then
|
---|
1424 | Result := ptTrGoods
|
---|
1425 | else if Project and cpImp = 0 then begin
|
---|
1426 | if MyModel[Project and cpIndex].Kind = mkCaravan then
|
---|
1427 | Result := ptCaravan
|
---|
1428 | else Result := ptUn;
|
---|
1429 | end
|
---|
1430 | else if Project and cpIndex >= nImp then
|
---|
1431 | Result := ptInvalid
|
---|
1432 | else if Imp[Project and cpIndex].Kind = ikWonder then
|
---|
1433 | Result := ptWonder
|
---|
1434 | else if Imp[Project and cpIndex].Kind = ikShipPart then
|
---|
1435 | Result := ptShip
|
---|
1436 | else
|
---|
1437 | Result := ptImp;
|
---|
1438 | end;
|
---|
1439 |
|
---|
1440 | var
|
---|
1441 | NewProject, OldMoney, cix1: Integer;
|
---|
1442 | pt0, pt1: TProjectType;
|
---|
1443 | QueryOk: Boolean;
|
---|
1444 | begin
|
---|
1445 | Assert(not Supervising);
|
---|
1446 | MainScreen.ModalSelectDlg.ShowNewContent_CityProject(wmModal, cix);
|
---|
1447 | if MainScreen.ModalSelectDlg.Result <> -1 then
|
---|
1448 | begin
|
---|
1449 | if MainScreen.ModalSelectDlg.Result and cpType <> 0 then
|
---|
1450 | begin
|
---|
1451 | MyCity[cix].Status := MyCity[cix].Status and not 7 or
|
---|
1452 | (1 + MainScreen.ModalSelectDlg.Result and cpIndex);
|
---|
1453 | AutoBuild(cix, MyData.ImpOrder[MainScreen.ModalSelectDlg.Result and cpIndex]);
|
---|
1454 | end
|
---|
1455 | else
|
---|
1456 | begin
|
---|
1457 | NewProject := MainScreen.ModalSelectDlg.Result;
|
---|
1458 | QueryOk := True;
|
---|
1459 | if (NewProject and cpImp <> 0) and (NewProject and cpIndex >= 28) and
|
---|
1460 | (MyRO.NatBuilt[NewProject and cpIndex] > 0) then
|
---|
1461 | with MainScreen.MessgExDlg do
|
---|
1462 | begin
|
---|
1463 | cix1 := MyRO.nCity - 1;
|
---|
1464 | while (cix1 >= 0) and
|
---|
1465 | (MyCity[cix1].Built[NewProject and cpIndex] = 0) do
|
---|
1466 | Dec(cix1);
|
---|
1467 | MessgText := Format(Phrases.Lookup('DOUBLESTATEIMP'),
|
---|
1468 | [Phrases.Lookup('IMPROVEMENTS', NewProject and cpIndex),
|
---|
1469 | CityName(MyCity[cix1].ID)]);
|
---|
1470 | OpenSound := 'MSG_DEFAULT';
|
---|
1471 | Kind := mkOkCancel;
|
---|
1472 | IconKind := mikImp;
|
---|
1473 | IconIndex := NewProject and cpIndex;
|
---|
1474 | ShowModal;
|
---|
1475 | QueryOk := ModalResult = mrOK;
|
---|
1476 | end;
|
---|
1477 | if not QueryOk then
|
---|
1478 | Exit;
|
---|
1479 |
|
---|
1480 | if (MyCity[cix].Prod > 0) then
|
---|
1481 | begin
|
---|
1482 | pt0 := ProjectType(MyCity[cix].Project0);
|
---|
1483 | pt1 := ProjectType(NewProject);
|
---|
1484 | if (pt0 <> ptSelect) and (pt1 <> ptTrGoods) then
|
---|
1485 | begin
|
---|
1486 | if NewProject and (cpImp or cpIndex) <> MyCity[cix].Project0 and
|
---|
1487 | (cpImp or cpIndex) then
|
---|
1488 | begin // loss of material -- do query
|
---|
1489 | Gtk2Fix;
|
---|
1490 | if (pt1 = ptTrGoods) or (pt1 = ptShip) or (pt1 <> pt0) and
|
---|
1491 | (pt0 <> ptCaravan) then begin
|
---|
1492 | QueryOk := SimpleQuery(mkOkCancel,
|
---|
1493 | Format(Phrases.Lookup('LOSEMAT'), [MyCity[cix].Prod0,
|
---|
1494 | MyCity[cix].Prod0]), 'MSG_DEFAULT') = mrOK
|
---|
1495 | end else
|
---|
1496 | if MyCity[cix].Project and (cpImp or cpIndex) = MyCity[cix]
|
---|
1497 | .Project0 and (cpImp or cpIndex) then begin
|
---|
1498 | QueryOk := SimpleQuery(mkOkCancel, Phrases.Lookup('LOSEMAT3'),
|
---|
1499 | 'MSG_DEFAULT') = mrOK;
|
---|
1500 | end;
|
---|
1501 | end;
|
---|
1502 | end;
|
---|
1503 | end;
|
---|
1504 | if not QueryOk then
|
---|
1505 | Exit;
|
---|
1506 |
|
---|
1507 | OldMoney := MyRO.Money;
|
---|
1508 | MyCity[cix].Status := MyCity[cix].Status and not 7;
|
---|
1509 | if (NewProject and cpImp = 0) and
|
---|
1510 | ((MyCity[cix].Size < 4) and
|
---|
1511 | (MyModel[NewProject and cpIndex].Kind = mkSettler) or
|
---|
1512 | (MyCity[cix].Size < 3) and
|
---|
1513 | ((MyModel[NewProject and cpIndex].Kind = mkSlaves) or
|
---|
1514 | (NewProject and cpConscripts <> 0))) then
|
---|
1515 | if SimpleQuery(mkYesNo, Phrases.Lookup('EMIGRATE'), 'MSG_DEFAULT') <> mrOK
|
---|
1516 | then
|
---|
1517 | NewProject := NewProject or cpDisbandCity;
|
---|
1518 | Server(sSetCityProject, Me, cix, NewProject);
|
---|
1519 | C.Project := MyCity[cix].Project;
|
---|
1520 | if MyRO.Money > OldMoney then
|
---|
1521 | Play('CITY_SELLIMP');
|
---|
1522 | end;
|
---|
1523 | CityOptimizer_CityChange(cix);
|
---|
1524 |
|
---|
1525 | if WindowMode <> wmModal then
|
---|
1526 | MainScreen.UpdateViews;
|
---|
1527 | InitSmallCityMap;
|
---|
1528 | SmartUpdateContent;
|
---|
1529 | end;
|
---|
1530 | end;
|
---|
1531 |
|
---|
1532 | procedure TCityDlg.BuyClick(Sender: TObject);
|
---|
1533 | var
|
---|
1534 | NextProd, Cost: Integer;
|
---|
1535 | begin
|
---|
1536 | if (cix < 0) or (ClientMode >= scContact) then
|
---|
1537 | Exit;
|
---|
1538 | with MyCity[cix], MainScreen.MessgExDlg do
|
---|
1539 | begin
|
---|
1540 | Cost := Report.ProjectCost;
|
---|
1541 | NextProd := Report.Production;
|
---|
1542 | if NextProd < 0 then
|
---|
1543 | NextProd := 0;
|
---|
1544 | Cost := Cost - Prod - NextProd;
|
---|
1545 | if (MyRO.Wonder[woMich].EffectiveOwner = Me) and (Project and cpImp <> 0)
|
---|
1546 | then
|
---|
1547 | Cost := Cost * 2
|
---|
1548 | else
|
---|
1549 | Cost := Cost * 4;
|
---|
1550 | if (Cost <= 0) and (Report.HappinessBalance >= 0) { no disorder } then
|
---|
1551 | begin
|
---|
1552 | MessgText := Phrases.Lookup('READY');
|
---|
1553 | Kind := mkOk;
|
---|
1554 | end
|
---|
1555 | else if Cost > MyRO.Money then
|
---|
1556 | begin
|
---|
1557 | OpenSound := 'MSG_DEFAULT';
|
---|
1558 | MessgText := Format(Phrases.Lookup('NOMONEY'), [Cost, MyRO.Money]);
|
---|
1559 | Kind := mkOk;
|
---|
1560 | end
|
---|
1561 | else
|
---|
1562 | begin
|
---|
1563 | MessgText := Format(Phrases.Lookup('BUY'), [Cost]);
|
---|
1564 | Kind := mkYesNo;
|
---|
1565 | end;
|
---|
1566 | ShowModal;
|
---|
1567 | if (Kind = mkYesNo) and (ModalResult = mrOK) then
|
---|
1568 | begin
|
---|
1569 | if Server(sBuyCityProject, Me, cix, nil^) >= rExecuted then
|
---|
1570 | begin
|
---|
1571 | Play('CITY_BUYPROJECT');
|
---|
1572 | SmartUpdateContent;
|
---|
1573 | if WindowMode <> wmModal then
|
---|
1574 | MainScreen.UpdateViews;
|
---|
1575 | end;
|
---|
1576 | end;
|
---|
1577 | end;
|
---|
1578 | end;
|
---|
1579 |
|
---|
1580 | procedure TCityDlg.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
1581 | begin
|
---|
1582 | Timer1.Enabled := False;
|
---|
1583 | ProdHint := False;
|
---|
1584 | MarkCityLoc := -1;
|
---|
1585 | if Optimize_cixTileChange >= 0 then
|
---|
1586 | begin
|
---|
1587 | if Optimize_TilesBeforeChange and not MyCity[Optimize_cixTileChange]
|
---|
1588 | .Tiles <> 0 then
|
---|
1589 | begin
|
---|
1590 | CityOptimizer_ReleaseCityTiles(Optimize_cixTileChange,
|
---|
1591 | Optimize_TilesBeforeChange and
|
---|
1592 | not MyCity[Optimize_cixTileChange].Tiles);
|
---|
1593 | if WindowMode <> wmModal then
|
---|
1594 | MainScreen.UpdateViews;
|
---|
1595 | end;
|
---|
1596 | Optimize_cixTileChange := -1;
|
---|
1597 | end;
|
---|
1598 | if CloseAction > None then
|
---|
1599 | MainScreen.CityClosed(RestoreUnFocus, CloseAction = StepFocus);
|
---|
1600 | RestoreUnFocus := -1;
|
---|
1601 | inherited;
|
---|
1602 | end;
|
---|
1603 |
|
---|
1604 | procedure TCityDlg.Timer1Timer(Sender: TObject);
|
---|
1605 | begin
|
---|
1606 | if ProdHint then
|
---|
1607 | begin
|
---|
1608 | BlinkTime := (BlinkTime + 1) mod 12;
|
---|
1609 | if BlinkTime = 0 then
|
---|
1610 | with Canvas do
|
---|
1611 | begin
|
---|
1612 | BitBltCanvas(Canvas, xView + 5, yView + 1, 64, 2, Back.Canvas,
|
---|
1613 | xView + 5, yView + 1);
|
---|
1614 | BitBltCanvas(Canvas, xView + 5, yView + 3, 2, 42, Back.Canvas,
|
---|
1615 | xView + 5, yView + 3);
|
---|
1616 | BitBltCanvas(Canvas, xView + 5 + 62, yView + 3, 2, 42,
|
---|
1617 | Back.Canvas, xView + 5 + 62, yView + 3);
|
---|
1618 | ScreenTools.Frame(Canvas, xView + 9 - 1, yView + 5 - 1, xView + 9 + xSizeBig,
|
---|
1619 | yView + 5 + ySizeBig, $B0B0B0, $FFFFFF);
|
---|
1620 | RFrame(Canvas, xView + 9 - 2, yView + 5 - 2, xView + 9 + xSizeBig + 1,
|
---|
1621 | yView + 5 + ySizeBig + 1, $FFFFFF, $B0B0B0);
|
---|
1622 | Brush.Color := $000000;
|
---|
1623 | FillRect(Rect(xView + 9, yView + 5, xView + 1 + 72 - 8,
|
---|
1624 | yView + 5 + 40));
|
---|
1625 | Brush.Style := TBrushStyle.bsClear;
|
---|
1626 | end
|
---|
1627 | else if BlinkTime = 6 then
|
---|
1628 | begin
|
---|
1629 | if AllowChange and (C.Status and 7 <> 0) then
|
---|
1630 | begin // city type autobuild
|
---|
1631 | FrameImage(Canvas, bigimp, xView + 9, yView + 5, xSizeBig, ySizeBig,
|
---|
1632 | (C.Status and 7 - 1 + 3) * xSizeBig, 0, True);
|
---|
1633 | end
|
---|
1634 | else if C.Project and cpImp = 0 then
|
---|
1635 | begin // project is unit
|
---|
1636 | BitBltCanvas(Canvas, xView + 9, yView + 5, xSizeBig, ySizeBig,
|
---|
1637 | Bigimp.Canvas, 0, 0);
|
---|
1638 | with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do
|
---|
1639 | Sprite(Canvas, HGr, xView + 5, yView + 1, 64, 44, pix mod 10 * 65 + 1,
|
---|
1640 | pix div 10 * 49 + 1);
|
---|
1641 | end
|
---|
1642 | else
|
---|
1643 | ImpImage(Canvas, xView + 9, yView + 5, C.Project0 and cpIndex,
|
---|
1644 | cGov, True);
|
---|
1645 | end;
|
---|
1646 | end;
|
---|
1647 | end;
|
---|
1648 |
|
---|
1649 | procedure TCityDlg.FormPaint(Sender: TObject);
|
---|
1650 | begin
|
---|
1651 | inherited;
|
---|
1652 | if OpenSoundEvent >= 0 then
|
---|
1653 | PostMessage(Handle, WM_PLAYSOUND, 0, 0);
|
---|
1654 | end;
|
---|
1655 |
|
---|
1656 | procedure TCityDlg.OnPlaySound(var Msg: TMessage);
|
---|
1657 | begin
|
---|
1658 | if 1 shl OpenSoundEvent = chProduction then
|
---|
1659 | begin
|
---|
1660 | if C.Project0 and cpImp <> 0 then
|
---|
1661 | begin
|
---|
1662 | if C.Project0 and cpIndex >= 28 then
|
---|
1663 | // wonders have already extra message with sound
|
---|
1664 | if Imp[C.Project0 and cpIndex].Kind = ikShipPart then
|
---|
1665 | Play('SHIP_BUILT')
|
---|
1666 | else
|
---|
1667 | Play('CITY_IMPCOMPLETE')
|
---|
1668 | end
|
---|
1669 | else
|
---|
1670 | Play('CITY_UNITCOMPLETE');
|
---|
1671 | end
|
---|
1672 | else
|
---|
1673 | if OpenSoundEvent >= 0 then
|
---|
1674 | Play(CityEventSoundItem[OpenSoundEvent]);
|
---|
1675 | OpenSoundEvent := -2;
|
---|
1676 | end;
|
---|
1677 |
|
---|
1678 | function Prio(iix: Integer): Integer;
|
---|
1679 | begin
|
---|
1680 | case Imp[iix].Kind of
|
---|
1681 | ikWonder:
|
---|
1682 | Result := iix + 10000;
|
---|
1683 | ikNatLocal, ikNatGlobal:
|
---|
1684 | case iix of
|
---|
1685 | imPalace:
|
---|
1686 | Result := 0;
|
---|
1687 | else
|
---|
1688 | Result := iix + 20000;
|
---|
1689 | end;
|
---|
1690 | else
|
---|
1691 | case iix of
|
---|
1692 | imTownHall, imCourt:
|
---|
1693 | Result := iix + 30000;
|
---|
1694 | imAqueduct, imSewer:
|
---|
1695 | Result := iix + 40000;
|
---|
1696 | imTemple, imTheater, imCathedral:
|
---|
1697 | Result := iix + 50000;
|
---|
1698 | else
|
---|
1699 | Result := iix + 90000;
|
---|
1700 | end;
|
---|
1701 | end;
|
---|
1702 | end;
|
---|
1703 |
|
---|
1704 | procedure TCityDlg.NextCityBtnClick(Sender: TObject);
|
---|
1705 | begin
|
---|
1706 | ChangeCity(+1);
|
---|
1707 | end;
|
---|
1708 |
|
---|
1709 | procedure TCityDlg.PrevCityBtnClick(Sender: TObject);
|
---|
1710 | begin
|
---|
1711 | ChangeCity(-1);
|
---|
1712 | end;
|
---|
1713 |
|
---|
1714 | procedure TCityDlg.ChangeCity(D: Integer);
|
---|
1715 | var
|
---|
1716 | cixNew: Integer;
|
---|
1717 | begin
|
---|
1718 | cixNew := cix;
|
---|
1719 | repeat
|
---|
1720 | cixNew := (cixNew + MyRO.nCity + D) mod MyRO.nCity;
|
---|
1721 | until (MyCity[cixNew].Loc >= 0) or (cixNew = cix);
|
---|
1722 | if cixNew <> cix then
|
---|
1723 | MainScreen.ZoomToCity(MyCity[cixNew].Loc);
|
---|
1724 | end;
|
---|
1725 |
|
---|
1726 | procedure TCityDlg.FormKeyDown(Sender: TObject; var Key: Word;
|
---|
1727 | Shift: TShiftState);
|
---|
1728 | begin
|
---|
1729 | if ((Key = VK_UP) or (Key = VK_NUMPAD8)) and (cix >= 0) and
|
---|
1730 | (WindowMode = wmPersistent) then
|
---|
1731 | ChangeCity(-1)
|
---|
1732 | else if ((Key = VK_DOWN) or (Key = VK_NUMPAD2)) and (cix >= 0) and
|
---|
1733 | (WindowMode = wmPersistent) then
|
---|
1734 | ChangeCity(+1)
|
---|
1735 | else
|
---|
1736 | inherited;
|
---|
1737 | end;
|
---|
1738 |
|
---|
1739 | procedure TCityDlg.PageUpBtnClick(Sender: TObject);
|
---|
1740 | begin
|
---|
1741 | if Page > 0 then
|
---|
1742 | begin
|
---|
1743 | Dec(Page);
|
---|
1744 | SmartUpdateContent;
|
---|
1745 | end;
|
---|
1746 | end;
|
---|
1747 |
|
---|
1748 | procedure TCityDlg.PageDownBtnClick(Sender: TObject);
|
---|
1749 | begin
|
---|
1750 | if Page < PageCount - 1 then
|
---|
1751 | begin
|
---|
1752 | Inc(Page);
|
---|
1753 | SmartUpdateContent;
|
---|
1754 | end;
|
---|
1755 | end;
|
---|
1756 |
|
---|
1757 | procedure TCityDlg.ChangeResourceWeights(iResourceWeights: Integer);
|
---|
1758 | var
|
---|
1759 | Advice: TCityTileAdviceData;
|
---|
1760 | begin
|
---|
1761 | Assert(not Supervising);
|
---|
1762 | Assert(cix >= 0);
|
---|
1763 | MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or
|
---|
1764 | (iResourceWeights shl 4);
|
---|
1765 | C.Status := MyCity[cix].Status;
|
---|
1766 | if iResourceWeights > 0 then
|
---|
1767 | begin
|
---|
1768 | Advice.ResourceWeights := OfferedResourceWeights[iResourceWeights];
|
---|
1769 | Server(sGetCityTileAdvice, Me, cix, Advice);
|
---|
1770 | if Advice.Tiles <> MyCity[cix].Tiles then
|
---|
1771 | Server(sSetCityTiles, Me, cix, Advice.Tiles);
|
---|
1772 | end;
|
---|
1773 | end;
|
---|
1774 |
|
---|
1775 | procedure SortImprovements;
|
---|
1776 | var
|
---|
1777 | I, J, K: Integer;
|
---|
1778 | begin
|
---|
1779 | for I := 0 to nImp - 1 do
|
---|
1780 | ImpSorted[I] := I;
|
---|
1781 | for I := 0 to nImp - 2 do
|
---|
1782 | for J := I + 1 to nImp - 1 do
|
---|
1783 | if Prio(ImpSorted[I]) > Prio(ImpSorted[J]) then begin
|
---|
1784 | K := ImpSorted[I];
|
---|
1785 | ImpSorted[I] := ImpSorted[J];
|
---|
1786 | ImpSorted[J] := K;
|
---|
1787 | end;
|
---|
1788 | end;
|
---|
1789 |
|
---|
1790 | initialization
|
---|
1791 |
|
---|
1792 | SortImprovements;
|
---|
1793 |
|
---|
1794 | end.
|
---|