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