Changeset 465 for branches/highdpi/LocalPlayer/CityScreen.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/CityScreen.pas
r405 r465 5 5 6 6 uses 7 UDpiControls, {$IFDEF LINUX}LMessages,{$ENDIF}8 Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin,9 LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,10 Button A, ButtonC, Area, GraphType, UTexture;7 UDpiControls, {$IFDEF UNIX}LMessages,{$ENDIF} 8 Protocol, ClientTools, ScreenTools, IsoEngine, BaseWin, LCLIntf, LCLType, 9 Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, ButtonA, 10 ButtonC, Area, GraphType, Texture; 11 11 12 12 const … … 39 39 procedure FormDestroy(Sender: TObject); 40 40 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 41 Shift: TShiftState; x, y: integer);41 Shift: TShiftState; X, Y: Integer); 42 42 procedure BuyClick(Sender: TObject); 43 43 procedure CloseBtnClick(Sender: TObject); … … 49 49 procedure PrevCityBtnClick(Sender: TObject); 50 50 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 51 // procedure AdviceBtnClick(Sender: TObject);52 51 procedure PageUpBtnClick(Sender: TObject); 53 52 procedure PageDownBtnClick(Sender: TObject); 54 53 private 55 c: TCity;54 C: TCity; 56 55 Report: TCityReportNew; 57 56 cOwner: Integer; … … 70 69 Optimize_cixTileChange: Integer; 71 70 Optimize_TilesBeforeChange: Integer; 72 Happened: cardinal;73 imix: array [0 .. 15] of integer;71 Happened: Cardinal; 72 imix: array [0 .. 15] of Integer; 74 73 CityAreaInfo: TCityAreaInfo; 75 74 AreaMap: TIsoMap; … … 89 88 procedure InitZoomCityMap; 90 89 procedure ChooseProject; 91 procedure ChangeCity( d: integer);92 procedure ChangeResourceWeights(iResourceWeights: integer);90 procedure ChangeCity(D: Integer); 91 procedure ChangeResourceWeights(iResourceWeights: Integer); 93 92 procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND; 94 93 public 95 RestoreUnFocus: integer;94 RestoreUnFocus: Integer; 96 95 CloseAction: TCityCloseAction; 97 96 procedure OffscreenPaint; override; 98 procedure ShowNewContent(NewMode , Loc: integer; ShowEvent: cardinal);97 procedure ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal); 99 98 procedure Reset; 100 99 procedure CheckAge; 101 100 end; 102 101 103 var104 CityDlg: TCityDlg;105 106 102 107 103 implementation 108 104 109 105 uses 110 Select, Messg, MessgEx, Help, Tribes, Directories, Math, Sound ;106 Select, Messg, MessgEx, Help, Tribes, Directories, Math, Sound, Term; 111 107 112 108 {$R *.lfm} … … 148 144 wZoomEnvironment = 68; 149 145 150 ImpPosition: array [28 .. nImp - 1] of integer = (-1, // imTrGoods 146 ImpPosition: array [28 .. nImp - 1] of Integer = ( 147 -1, // imTrGoods 151 148 21, // imBarracks 152 149 6, // imGranary … … 192 189 193 190 var 194 ImpSorted: array [0 .. nImp - 1] of integer;191 ImpSorted: array [0 .. nImp - 1] of Integer; 195 192 196 193 procedure TCityDlg.FormCreate(Sender: TObject); … … 201 198 NoMap := TIsoMap.Create; 202 199 AreaMap := TIsoMap.Create; 203 AreaMap.SetOutput( offscreen);200 AreaMap.SetOutput(Offscreen); 204 201 AreaMap.SetPaintBounds(xmArea - 192, ymArea - 96 - 32, xmArea + 192, 205 202 ymArea + 96); 206 SmallMapMode := smImprovements; 207 ZoomArea := 1; 208 ProdHint := false; 203 Reset; 204 ProdHint := False; 209 205 RestoreUnFocus := -1; 210 206 OpenSoundEvent := -1; … … 279 275 280 276 UnshareBitmap(Back); 281 DpiBit Canvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,277 DpiBitBltCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight, 282 278 MainTexture.Image.Canvas, 0, 0); 283 279 ImageOp_B(Back, Template, 0, 0, 0, 0, ClientWidth, ClientHeight); … … 292 288 procedure TCityDlg.InitSmallCityMap; 293 289 var 294 i, iix, cli1, Color0, Color1, Color2: integer;290 I, iix, cli1, Color0, Color1, Color2: Integer; 295 291 begin 296 292 if cix >= 0 then 297 c:= MyCity[cix];293 C := MyCity[cix]; 298 294 case MyMap[cLoc] and fTerrain of 299 295 fPrairie: cli1 := cliPrairie; … … 307 303 Color2 := Colors.Canvas.Pixels[clkAge0 + Age, cliHouse]; 308 304 SmallCityMap.Canvas.FillRect(0, 0, SmallCityMap.Width, SmallCityMap.Height); 309 DpiBit Canvas(SmallCityMap.Canvas, 0, 0, 83, hSmallMap,305 DpiBitBltCanvas(SmallCityMap.Canvas, 0, 0, 83, hSmallMap, 310 306 SmallCityMapTemplate.Canvas, 83 * SizeClass, 0); 311 307 if IsPort then 312 308 begin 313 DpiBit Canvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap,309 DpiBitBltCanvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap, 314 310 SmallCityMapTemplate.Canvas, 332 + 15, 0); 315 311 ImageOp_CCC(SmallCityMap, 0, 0, 83, hSmallMap, Color0, Color1, Color2); … … 319 315 else 320 316 begin 321 DpiBit Canvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap,317 DpiBitBltCanvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap, 322 318 SmallCityMapTemplate.Canvas, 332, 0); 323 319 ImageOp_CCC(SmallCityMap, 0, 0, wSmallMap, hSmallMap, Color0, … … 328 324 begin 329 325 Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImp]; 330 for i:= 0 to 29 do326 for I := 0 to 29 do 331 327 begin 332 328 for iix := nWonder to nImp - 1 do 333 if (ImpPosition[iix] = i) and (c.Built[iix] > 0) then329 if (ImpPosition[iix] = I) and (C.Built[iix] > 0) then 334 330 begin 335 FillRect(Rect(5 + 16 * ( i mod 3) + 48 * (idiv 18),336 3 + 12 * ( i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (idiv 18),337 11 + 12 * ( imod 18 div 3)));338 break;331 FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18), 332 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18), 333 11 + 12 * (I mod 18 div 3))); 334 Break; 339 335 end; 340 336 end; 341 i:= 30;337 I := 30; 342 338 for iix := 0 to nImp do 343 if ( c.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then339 if (C.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then 344 340 begin 345 FillRect(Rect(5 + 16 * ( i mod 3) + 48 * (idiv 18),346 3 + 12 * ( i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (idiv 18),347 11 + 12 * ( imod 18 div 3)));348 inc(i);349 if i= 36 then350 break; // area is full341 FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18), 342 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18), 343 11 + 12 * (I mod 18 div 3))); 344 Inc(I); 345 if I = 36 then 346 Break; // area is full 351 347 end; 352 if c.Project and cpImp <> 0 then353 begin 354 iix := c.Project and cpIndex;348 if C.Project and cpImp <> 0 then 349 begin 350 iix := C.Project and cpIndex; 355 351 if iix <> imTrGoods then 356 352 begin 357 353 if (iix >= nWonder) and (ImpPosition[iix] >= 0) then 358 i:= ImpPosition[iix];359 if i< 36 then354 I := ImpPosition[iix]; 355 if I < 36 then 360 356 begin 361 brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImpProject];362 FillRect(Rect(5 + 16 * ( i mod 3) + 48 * (idiv 18),363 3 + 12 * ( i mod 18 div 3), 13 + 16 * (i mod 3) + 48 * (idiv 18),364 11 + 12 * ( imod 18 div 3)));357 Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImpProject]; 358 FillRect(Rect(5 + 16 * (I mod 3) + 48 * (I div 18), 359 3 + 12 * (I mod 18 div 3), 13 + 16 * (I mod 3) + 48 * (I div 18), 360 11 + 12 * (I mod 18 div 3))); 365 361 end; 366 362 end; 367 363 end; 368 brush.style := bsClear;364 Brush.style := bsClear; 369 365 end; 370 366 end; … … 373 369 begin 374 370 UnshareBitmap(ZoomCityMap); 375 DpiBit Canvas(ZoomCityMap.Canvas, 0, 0, wZoomMap, hZoomMap,371 DpiBitBltCanvas(ZoomCityMap.Canvas, 0, 0, wZoomMap, hZoomMap, 376 372 Back.Canvas, xZoomMap, yZoomMap); 377 373 if SmallMapMode = smImprovements then begin … … 383 379 112 * (ZoomArea - 3), wZoomMap - wZoomEnvironment, hZoomMap); 384 380 ImageOp_B(ZoomCityMap, CityMapTemplate, wZoomMap - wZoomEnvironment, 0, 385 1504 + wZoomEnvironment * byte(IsPort), 112 * (ZoomArea - 3),381 1504 + wZoomEnvironment * Byte(IsPort), 112 * (ZoomArea - 3), 386 382 wZoomEnvironment, hZoomMap); 387 383 end; … … 391 387 procedure TCityDlg.OffscreenPaint; 392 388 393 procedure FillBar( x, y, pos, Growth, max, Kind: integer;394 IndicateComplete: boolean);389 procedure FillBar(X, Y, Pos, Growth, Max, Kind: Integer; 390 IndicateComplete: Boolean); 395 391 begin 396 392 BarTex.Assign(MainTexture); … … 399 395 BarTex.ColorBevelShade := BarTex.ColorBevelLight; 400 396 end; 401 PaintRelativeProgressBar( offscreen.Canvas, Kind, x - 3, y, wBar - 4, pos,402 Growth, max, IndicateComplete, BarTex);403 end; 404 405 procedure PaintResources( x, y, Loc: integer; Add4Happy: boolean);397 PaintRelativeProgressBar(Offscreen.Canvas, Kind, X - 3, Y, wBar - 4, Pos, 398 Growth, Max, IndicateComplete, BarTex); 399 end; 400 401 procedure PaintResources(X, Y, Loc: Integer; Add4Happy: Boolean); 406 402 var 407 d, i, Total, xGr, yGr: integer;403 D, I, Total, xGr, yGr: Integer; 408 404 TileInfo: TTileInfo; 409 rare: boolean;405 rare: Boolean; 410 406 begin 411 407 with AreaMap do begin 412 if Server(sGetCityTileInfo, me, Loc, TileInfo) <> eOk then413 begin 414 assert(cix < 0);415 exit408 if Server(sGetCityTileInfo, Me, Loc, TileInfo) <> eOk then 409 begin 410 Assert(cix < 0); 411 Exit 416 412 end; 417 413 Total := TileInfo.Food + TileInfo.Prod + TileInfo.Trade; 418 414 rare := MyMap[Loc] and $06000000 > 0; 419 415 if rare then 420 inc(Total);416 Inc(Total); 421 417 if Add4Happy then 422 inc(Total, 4);418 Inc(Total, 4); 423 419 if Total > 1 then 424 d:= (xxt - 11) div (Total - 1);425 if d< 1 then426 d:= 1;427 if d> 4 then428 d:= 4;429 for i:= 0 to Total - 1 do420 D := (xxt - 11) div (Total - 1); 421 if D < 1 then 422 D := 1; 423 if D > 4 then 424 D := 4; 425 for I := 0 to Total - 1 do 430 426 begin 431 427 yGr := 115; 432 if Add4Happy and ( i>= Total - 4) then428 if Add4Happy and (I >= Total - 4) then 433 429 begin 434 430 xGr := 132; 435 431 yGr := 126 436 432 end 437 else if rare and ( i= Total - 1) then433 else if rare and (I = Total - 1) then 438 434 xGr := 66 + 110 439 else if i>= TileInfo.Food + TileInfo.Prod then435 else if I >= TileInfo.Food + TileInfo.Prod then 440 436 xGr := 66 + 44 441 else if i>= TileInfo.Prod then437 else if I >= TileInfo.Prod then 442 438 xGr := 66 443 439 else 444 440 xGr := 66 + 22; 445 Sprite( offscreen, HGrSystem, x + xxt - 5 + d * (2 * i+ 1 - Total),446 y+ yyt - 5, 10, 10, xGr, yGr);441 Sprite(Offscreen, HGrSystem, X + xxt - 5 + D * (2 * I + 1 - Total), 442 Y + yyt - 5, 10, 10, xGr, yGr); 447 443 end; 448 444 end; 449 445 end; 450 446 var 451 line, MessageCount: integer;452 453 procedure CheckMessage(Flag: integer);447 Line, MessageCount: Integer; 448 449 procedure CheckMessage(Flag: Integer); 454 450 var 455 i, test: integer;456 s: string;451 I, Test: Integer; 452 S: string; 457 453 begin 458 454 if Happened and Flag <> 0 then 459 455 begin 460 i:= 0;461 test := 1;462 while test < Flag do456 I := 0; 457 Test := 1; 458 while Test < Flag do 463 459 begin 464 inc(i);465 inc(test, test)460 Inc(I); 461 Inc(Test, Test); 466 462 end; 467 463 468 464 if AllowChange and (Sounds <> nil) and (OpenSoundEvent = -1) then 469 465 begin 470 s := CityEventSoundItem[i];471 if s<> '' then472 s := Sounds.Lookup(s);473 if (Flag = chProduction) or ( s <> '') and (s[1] <> '*') and (s[1] <> '[')466 S := CityEventSoundItem[I]; 467 if S <> '' then 468 S := Sounds.Lookup(S); 469 if (Flag = chProduction) or (S <> '') and (S[1] <> '*') and (S[1] <> '[') 474 470 then 475 OpenSoundEvent := i471 OpenSoundEvent := I; 476 472 end; 477 473 478 s := CityEventName(i);474 S := CityEventName(I); 479 475 { if Flag=chNoGrowthWarning then 480 if c.Built[imAqueduct]=0 then481 s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])482 else s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); }483 RisedTextOut( offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount +484 16 * line, s);485 inc(line)476 if C.Built[imAqueduct]=0 then 477 S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)]) 478 else S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); } 479 RisedTextOut(Offscreen.Canvas, xmOpt + 40, ymOpt - 1 - 8 * MessageCount + 480 16 * Line, S); 481 Inc(Line); 486 482 end; 487 483 end; 488 484 489 485 var 490 x, y, xGr, i, j, iix, d, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,491 HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: integer;492 av: integer;493 PrName, s: string;486 X, Y, xGr, I, J, iix, D, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix, 487 HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: Integer; 488 av: Integer; 489 PrName, S: string; 494 490 UnitInfo: TUnitInfo; 495 491 UnitReport: TUnitReport; 496 IsCityAlive, CanGrow: boolean;492 IsCityAlive, CanGrow: Boolean; 497 493 begin 498 494 inherited; 499 495 if cix >= 0 then 500 c:= MyCity[cix];496 C := MyCity[cix]; 501 497 Report.HypoTiles := -1; 502 498 Report.HypoTaxRate := -1; 503 499 Report.HypoLuxuryRate := -1; 504 500 if cix >= 0 then 505 Server(sGetCityReportNew, me, cix, Report) // own city501 Server(sGetCityReportNew, Me, cix, Report) // own city 506 502 else 507 Server(sGetEnemyCityReportNew, me, cLoc, Report); // enemy city508 TrueFood := c.Food;509 TrueProd := c.Prod;510 TruePoll := c.Pollution;511 if supervising or (cix < 0) then503 Server(sGetEnemyCityReportNew, Me, cLoc, Report); // enemy city 504 TrueFood := C.Food; 505 TrueProd := C.Prod; 506 TruePoll := C.Pollution; 507 if Supervising or (cix < 0) then 512 508 begin // normalize city from after-turn state 513 dec(TrueFood, Report.FoodSurplus);509 Dec(TrueFood, Report.FoodSurplus); 514 510 if TrueFood < 0 then 515 511 TrueFood := 0; // shouldn't happen 516 dec(TrueProd, Report.Production);512 Dec(TrueProd, Report.Production); 517 513 if TrueProd < 0 then 518 514 TrueProd := 0; // shouldn't happen 519 dec(TruePoll, Report.AddPollution);515 Dec(TruePoll, Report.AddPollution); 520 516 if TruePoll < 0 then 521 517 TruePoll := 0; // shouldn't happen 522 518 end; 523 IsCityAlive := (cGov <> gAnarchy) and ( c.Flags and chCaptured = 0);519 IsCityAlive := (cGov <> gAnarchy) and (C.Flags and chCaptured = 0); 524 520 if not IsCityAlive then 525 Report.Working := c.Size;521 Report.Working := C.Size; 526 522 527 523 RedTex.Assign(MainTexture); … … 531 527 RedTex.ColorTextShade := $0000FF; 532 528 533 DpiBit Canvas(offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0);529 DpiBitBltCanvas(Offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0); 534 530 535 531 Offscreen.Canvas.Font.Assign(UniFont[ftCaption]); 536 RisedTextOut( offscreen.Canvas, 42, 7, Caption);537 with offscreen.Canvas do532 RisedTextOut(Offscreen.Canvas, 42, 7, Caption); 533 with Offscreen.Canvas do 538 534 begin // city size 539 brush.Color := $000000;535 Brush.Color := $000000; 540 536 FillRect(Rect(8 + 1, 7 + 1, 36 + 1, 32 + 1)); 541 brush.Color := $FFFFFF;537 Brush.Color := $FFFFFF; 542 538 FillRect(Rect(8, 7, 36, 32)); 543 brush.style := bsClear;539 Brush.style := bsClear; 544 540 Font.Color := $000000; 545 s := inttostr(c.Size);546 TextOut(8 + 14 - textwidth(s) div 2, 7, s);541 S := IntToStr(C.Size); 542 TextOut(8 + 14 - TextWidth(S) div 2, 7, S); 547 543 end; 548 544 Offscreen.Canvas.Font.Assign(UniFont[ftSmall]); … … 552 548 MakeRed(Offscreen, 18, 280, 298, 40); 553 549 if cGov = gAnarchy then 554 s:= Phrases.Lookup('GOVERNMENT', gAnarchy)550 S := Phrases.Lookup('GOVERNMENT', gAnarchy) 555 551 else { if c.Flags and chCaptured<>0 then } 556 s:= Phrases.Lookup('CITYEVENTS', 14);557 RisedTextOut( offscreen.Canvas, 167 - BiColorTextWidth(offscreen.Canvas, s)558 div 2, ymOpt - 9, s);552 S := Phrases.Lookup('CITYEVENTS', 14); 553 RisedTextOut(Offscreen.Canvas, 167 - BiColorTextWidth(Offscreen.Canvas, S) 554 div 2, ymOpt - 9, S); 559 555 end 560 556 else if AllowChange then 561 557 begin 562 OptiType := c.Status shr 4 and $0F;563 Sprite( offscreen, HGrSystem2, xmOpt - 32, ymOpt - 32, 64, 64,558 OptiType := C.Status shr 4 and $0F; 559 Sprite(Offscreen, HGrSystem2, xmOpt - 32, ymOpt - 32, 64, 64, 564 560 1 + OptiType mod 3 * 64, 217 + OptiType div 3 * 64); 565 561 566 562 { display messages now } 567 563 MessageCount := 0; 568 for i:= 0 to 31 do569 if Happened and ($FFFFFFFF - chCaptured) and (1 shl i) <> 0 then570 inc(MessageCount);564 for I := 0 to 31 do 565 if Happened and ($FFFFFFFF - chCaptured) and (1 shl I) <> 0 then 566 Inc(MessageCount); 571 567 if MessageCount > 3 then 572 568 MessageCount := 3; 573 569 if MessageCount > 0 then 574 570 begin 575 MakeBlue( offscreen, 74, 280, 242, 40);576 line := 0;577 for i:= 0 to nCityEventPriority - 1 do578 if line < MessageCount then579 CheckMessage(CityEventPriority[ i]);571 MakeBlue(Offscreen, 74, 280, 242, 40); 572 Line := 0; 573 for I := 0 to nCityEventPriority - 1 do 574 if Line < MessageCount then 575 CheckMessage(CityEventPriority[I]); 580 576 end 581 577 else 582 578 begin 583 s:= Phrases.Lookup('CITYMANAGETYPE', OptiType);584 j := pos('\', s);585 if j= 0 then586 LoweredTextout( offscreen.Canvas, -1, MainTexture, xmOpt + 40,587 ymOpt - 9, s)579 S := Phrases.Lookup('CITYMANAGETYPE', OptiType); 580 J := Pos('\', S); 581 if J = 0 then 582 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, 583 ymOpt - 9, S) 588 584 else 589 585 begin 590 LoweredTextout( offscreen.Canvas, -1, MainTexture, xmOpt + 40,591 ymOpt - 17, copy(s, 1, j- 1));592 LoweredTextout( offscreen.Canvas, -1, MainTexture, xmOpt + 40, ymOpt - 1,593 copy(s, j+ 1, 255));586 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, 587 ymOpt - 17, Copy(S, 1, J - 1)); 588 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xmOpt + 40, ymOpt - 1, 589 Copy(S, J + 1, 255)); 594 590 end; 595 591 end; … … 601 597 AreaMap.Paint(xmArea - xxt * 2 * rx, ymArea - yyt * 2 * ry - 3 * yyt, 602 598 dLoc(cLoc, -2 * rx + 1, -2 * ry - 1), 4 * rx - 1, 4 * ry + 1, cLoc, cOwner, 603 false, AllowChange and IsCityAlive and604 ( c.Status and csResourceWeightsMask = 0));605 DpiBit Canvas(offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas,599 False, AllowChange and IsCityAlive and 600 (C.Status and csResourceWeightsMask = 0)); 601 DpiBitBltCanvas(Offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas, 606 602 xmArea + 102, 42); 607 603 … … 615 611 ((Loc1 < 0) or (Loc1 >= G.lx * G.ly) or (MyMap[Loc1] and fCity = 0)) 616 612 then 617 Sprite( offscreen, HGrTerrain, xmArea - xxt + xxt * dx,613 Sprite(Offscreen, HGrTerrain, xmArea - xxt + xxt * dx, 618 614 ymArea - yyt + yyt * dy, xxt * 2, yyt * 2, 1 + 5 * (xxt * 2 + 1), 619 615 1 + yyt + 15 * (yyt * 3 + 1)); 620 if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and c.Tiles <> 0) then616 if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and C.Tiles <> 0) then 621 617 PaintResources(xmArea - xxt + xxt * dx, ymArea - yyt + yyt * dy, 622 618 Loc1, (dx = 0) and (dy = 0)); … … 625 621 626 622 if Report.Working > 1 then 627 d:= (xService - (xmArea - 192) - 8 - 32) div (Report.Working - 1);628 if d> 28 then629 d:= 28;630 for i:= Report.Working - 1 downto 0 do623 D := (xService - (xmArea - 192) - 8 - 32) div (Report.Working - 1); 624 if D > 28 then 625 D := 28; 626 for I := Report.Working - 1 downto 0 do 631 627 begin 632 628 if IsCityAlive then … … 634 630 else 635 631 xGr := 141; 636 DpiBit Canvas(offscreen.Canvas, xmArea - 192 + 5 + i * d, ymArea - 96 - 29,632 DpiBitBltCanvas(Offscreen.Canvas, xmArea - 192 + 5 + I * D, ymArea - 96 - 29, 637 633 27, 30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow } 638 Sprite( offscreen, HGrSystem, xmArea - 192 + 4 + i * d, ymArea - 96 - 30, 27,634 Sprite(Offscreen, HGrSystem, xmArea - 192 + 4 + I * D, ymArea - 96 - 30, 27, 639 635 30, xGr, 171); 640 636 end; 641 if c.Size - Report.Working > 1 then642 d := (xmArea + 192 - xService - 32) div (c.Size - Report.Working - 1);643 if d> 28 then644 d:= 28;645 for i := 0 to c.Size - Report.Working - 1 do637 if C.Size - Report.Working > 1 then 638 D := (xmArea + 192 - xService - 32) div (C.Size - Report.Working - 1); 639 if D > 28 then 640 D := 28; 641 for I := 0 to C.Size - Report.Working - 1 do 646 642 begin 647 643 xGr := 1 + 112; 648 DpiBit Canvas(offscreen.Canvas, xmArea + 192 - 27 + 1 - i * d, 29 + 1, 27,644 DpiBitBltCanvas(Offscreen.Canvas, xmArea + 192 - 27 + 1 - I * D, 29 + 1, 27, 649 645 30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow } 650 Sprite( offscreen, HGrSystem, xmArea + 192 - 27 - i * d, 29, 27, 30,646 Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 - I * D, 29, 27, 30, 651 647 xGr, 171); 652 Sprite( offscreen, HGrSystem, xmArea + 192 - 27 + 4 - i * d, 29 + 32, 10,648 Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 4 - I * D, 29 + 32, 10, 653 649 10, 121, 126); 654 Sprite( offscreen, HGrSystem, xmArea + 192 - 27 + 13 - i * d, 29 + 32, 10,650 Sprite(Offscreen, HGrSystem, xmArea + 192 - 27 + 13 - I * D, 29 + 32, 10, 655 651 10, 121, 126); 656 652 // Sprite(offscreen,HGrSystem,xmArea+192-31+18-i*d,ymArea-96-80+32,10,10,88,115); 657 653 end; 658 654 659 if c.Project and cpImp = 0 then660 PrName := Tribe[cOwner].ModelName[ c.Project and cpIndex]655 if C.Project and cpImp = 0 then 656 PrName := Tribe[cOwner].ModelName[C.Project and cpIndex] 661 657 else 662 PrName := Phrases.Lookup('IMPROVEMENTS', c.Project and cpIndex);658 PrName := Phrases.Lookup('IMPROVEMENTS', C.Project and cpIndex); 663 659 PrCost := Report.ProjectCost; 664 660 … … 667 663 begin 668 664 if cGov = gFundamentalism then 669 CountBar( offscreen, xHapp, yHapp + dyBar, wBar, 17,665 CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17, 670 666 Phrases.Lookup('FAITH'), Report.CollectedControl, MainTexture) 671 667 else 672 668 begin 673 CountBar( offscreen, xHapp, yHapp + dyBar, wBar, 17,669 CountBar(Offscreen, xHapp, yHapp + dyBar, wBar, 17, 674 670 Phrases.Lookup('HAPPINESS'), Report.Morale, MainTexture); 675 CountBar( offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16,671 CountBar(Offscreen, xHapp, yHapp + 2 * dyBar, wBar, 16, 676 672 Phrases.Lookup('CONTROL'), Report.CollectedControl, MainTexture); 677 673 end; 678 CountBar( offscreen, xHapp, yHapp, wBar, 8, Phrases.Lookup('LUX'),674 CountBar(Offscreen, xHapp, yHapp, wBar, 8, Phrases.Lookup('LUX'), 679 675 Report.Luxury, MainTexture); 680 CountBar( offscreen, xHapp + dxBar, yHapp, wBar, 19,676 CountBar(Offscreen, xHapp + dxBar, yHapp, wBar, 19, 681 677 Phrases.Lookup('UNREST'), 2 * Report.Deployed, MainTexture); 682 CountBar( offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17,683 Phrases.Lookup('HAPPINESSDEMAND'), c.Size, MainTexture);678 CountBar(Offscreen, xHapp + dxBar, yHapp + dyBar, wBar, 17, 679 Phrases.Lookup('HAPPINESSDEMAND'), C.Size, MainTexture); 684 680 if Report.HappinessBalance >= 0 then 685 CountBar( offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17,681 CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 17, 686 682 Phrases.Lookup('HAPPINESSPLUS'), Report.HappinessBalance, MainTexture) 687 683 else 688 684 begin 689 685 MakeRed(Offscreen, xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38); 690 CountBar( offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18,686 CountBar(Offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18, 691 687 Phrases.Lookup('LACK'), -Report.HappinessBalance, RedTex); 692 688 end; … … 696 692 if IsCityAlive then 697 693 begin 698 CountBar( offscreen, xFood, yFood + dyBar div 2, wBar, 0,694 CountBar(Offscreen, xFood, yFood + dyBar div 2, wBar, 0, 699 695 Phrases.Lookup('FOOD'), Report.CollectedFood, MainTexture); 700 CountBar( offscreen, xFood + dxBar, yFood + dyBar, wBar, 0,701 Phrases.Lookup('DEMAND'), 2 * c.Size, MainTexture);702 CountBar( offscreen, xFood + dxBar, yFood, wBar, 0,696 CountBar(Offscreen, xFood + dxBar, yFood + dyBar, wBar, 0, 697 Phrases.Lookup('DEMAND'), 2 * C.Size, MainTexture); 698 CountBar(Offscreen, xFood + dxBar, yFood, wBar, 0, 703 699 Phrases.Lookup('SUPPORT'), Report.FoodSupport, MainTexture); 704 700 if Report.FoodSurplus >= 0 then 705 if (cGov = gFuture) or ( c.Size >= NeedAqueductSize) and701 if (cGov = gFuture) or (C.Size >= NeedAqueductSize) and 706 702 (Report.FoodSurplus < 2) then 707 CountBar( offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6,703 CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 6, 708 704 Phrases.Lookup('PROFIT'), Report.FoodSurplus, MainTexture) 709 705 else 710 CountBar( offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0,706 CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 0, 711 707 Phrases.Lookup('SURPLUS'), Report.FoodSurplus, MainTexture) 712 708 else 713 709 begin 714 710 MakeRed(Offscreen, xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38); 715 CountBar( offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1,711 CountBar(Offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1, 716 712 Phrases.Lookup('LACK'), -Report.FoodSurplus, RedTex); 717 713 end; 718 714 end; 719 CanGrow := ( c.Size < MaxCitySize) and (cGov <> gFuture) and720 (Report.FoodSurplus > 0) and (( c.Size < NeedAqueductSize) or721 ( c.Built[imAqueduct] = 1) and (c.Size < NeedSewerSize) or722 ( c.Built[imSewer] = 1));715 CanGrow := (C.Size < MaxCitySize) and (cGov <> gFuture) and 716 (Report.FoodSurplus > 0) and ((C.Size < NeedAqueductSize) or 717 (C.Built[imAqueduct] = 1) and (C.Size < NeedSewerSize) or 718 (C.Built[imSewer] = 1)); 723 719 FillBar(xFood + 3, yFood + 102, TrueFood, 724 CutCityFoodSurplus(Report.FoodSurplus, IsCityAlive, cGov, c.Size),720 CutCityFoodSurplus(Report.FoodSurplus, IsCityAlive, cGov, C.Size), 725 721 Report.Storage, 1, CanGrow); 726 LoweredTextout( offscreen.Canvas, -1, MainTexture, xFood + 3 - 5,722 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xFood + 3 - 5, 727 723 yFood + 102 - 20, Format('%d/%d', [TrueFood, Report.Storage])); 728 LoweredTextout( offscreen.Canvas, -1, MainTexture, xFood - 2, yFood + 66,724 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xFood - 2, yFood + 66, 729 725 Phrases.Lookup('STORAGE')); 730 726 … … 732 728 if IsCityAlive then 733 729 begin 734 CountBar( offscreen, xProd, yProd, wBar, 2, Phrases.Lookup('MATERIAL'),730 CountBar(Offscreen, xProd, yProd, wBar, 2, Phrases.Lookup('MATERIAL'), 735 731 Report.CollectedMaterial, MainTexture); 736 CountBar( offscreen, xProd + dxBar, yProd, wBar, 2,732 CountBar(Offscreen, xProd + dxBar, yProd, wBar, 2, 737 733 Phrases.Lookup('SUPPORT'), Report.MaterialSupport, MainTexture); 738 734 if Report.Production >= 0 then 739 if c.Project and (cpImp + cpIndex) = cpImp + imTrGoods then740 CountBar( offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6,735 if C.Project and (cpImp + cpIndex) = cpImp + imTrGoods then 736 CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 6, 741 737 Phrases.Lookup('PROFIT'), Report.Production, MainTexture) 742 738 else 743 CountBar( offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2,739 CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 2, 744 740 Phrases.Lookup('PROD'), Report.Production, MainTexture) 745 741 else 746 742 begin 747 743 MakeRed(Offscreen, xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38); 748 CountBar( offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3,744 CountBar(Offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3, 749 745 Phrases.Lookup('LACK'), -Report.Production, RedTex); 750 746 end; 751 747 end; 752 if c.Project and (cpImp + cpIndex) <> cpImp + imTrGoods then753 with offscreen.Canvas do754 begin 755 i:= Report.Production;756 if ( i< 0) or not IsCityAlive then757 i:= 0;758 FillBar(xProd + 3, yProd + 16 + 63, TrueProd, i, PrCost, 4, true);759 LoweredTextout( offscreen.Canvas, -1, MainTexture, xProd + 3 - 5,748 if C.Project and (cpImp + cpIndex) <> cpImp + imTrGoods then 749 with Offscreen.Canvas do 750 begin 751 I := Report.Production; 752 if (I < 0) or not IsCityAlive then 753 I := 0; 754 FillBar(xProd + 3, yProd + 16 + 63, TrueProd, I, PrCost, 4, True); 755 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xProd + 3 - 5, 760 756 yProd + 16 + 43, Format('%d/%d', [TrueProd, PrCost])); 761 if BiColorTextWidth( offscreen.Canvas, PrName) > wBar + dxBar then757 if BiColorTextWidth(Offscreen.Canvas, PrName) > wBar + dxBar then 762 758 begin 763 759 repeat 764 Delete(PrName, length(PrName), 1)765 until BiColorTextWidth( offscreen.Canvas, PrName) <= wBar + dxBar;760 Delete(PrName, Length(PrName), 1) 761 until BiColorTextWidth(Offscreen.Canvas, PrName) <= wBar + dxBar; 766 762 PrName := PrName + '.' 767 763 end; 768 764 end; 769 RisedTextOut( offscreen.Canvas, xProd - 2, yProd + 36, PrName);765 RisedTextOut(Offscreen.Canvas, xProd - 2, yProd + 36, PrName); 770 766 771 767 // pollution section … … 773 769 begin 774 770 FillBar(xPoll + 3, yPoll + 20, TruePoll, Report.AddPollution, 775 MaxPollution, 3, true);776 RisedTextOut( offscreen.Canvas, xPoll + 3 - 5, yPoll + 20 - 20,771 MaxPollution, 3, True); 772 RisedTextOut(Offscreen.Canvas, xPoll + 3 - 5, yPoll + 20 - 20, 777 773 Phrases.Lookup('POLL')); 778 774 end; … … 781 777 if IsCityAlive and (Report.CollectedTrade > 0) then 782 778 begin 783 CountBar( offscreen, xTrade, yTrade + dyBar div 2, wBar, 4,779 CountBar(Offscreen, xTrade, yTrade + dyBar div 2, wBar, 4, 784 780 Phrases.Lookup('TRADE'), Report.CollectedTrade, MainTexture); 785 CountBar( offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5,781 CountBar(Offscreen, xTrade + dxBar, yTrade + 2 * dyBar, wBar, 5, 786 782 Phrases.Lookup('CORR'), Report.Corruption, MainTexture); 787 CountBar( offscreen, xTrade + dxBar, yTrade, wBar, 6, Phrases.Lookup('TAX'),783 CountBar(Offscreen, xTrade + dxBar, yTrade, wBar, 6, Phrases.Lookup('TAX'), 788 784 Report.Tax, MainTexture); 789 CountBar( offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12,785 CountBar(Offscreen, xTrade + dxBar, yTrade + dyBar, wBar, 12, 790 786 Phrases.Lookup('SCIENCE'), Report.Science, MainTexture); 791 787 end; 792 788 793 789 // small map 794 DpiBit Canvas(offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap,790 DpiBitBltCanvas(Offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap, 795 791 SmallCityMap.Canvas, 0, 0); 796 792 if SmallMapMode = smImprovements then 797 Frame( offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3),793 Frame(Offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3), 798 794 ySmallMap + 24 * (ZoomArea mod 3), xSmallMap + 48 * (ZoomArea div 3) + 49, 799 795 ySmallMap + 24 * (ZoomArea mod 3) + 25, MainTexture.ColorMark, 800 796 MainTexture.ColorMark); 801 Frame( offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap,797 Frame(Offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap, 802 798 ySmallMap + hSmallMap, $B0B0B0, $FFFFFF); 803 RFrame( offscreen.Canvas, xSmallMap - 2, ySmallMap - 2, xSmallMap + wSmallMap +799 RFrame(Offscreen.Canvas, xSmallMap - 2, ySmallMap - 2, xSmallMap + wSmallMap + 804 800 1, ySmallMap + hSmallMap + 1, $FFFFFF, $B0B0B0); 805 801 806 Frame( offscreen.Canvas, xSupport - 1, ySupport - 1, xSupport + wSupport,802 Frame(Offscreen.Canvas, xSupport - 1, ySupport - 1, xSupport + wSupport, 807 803 ySupport + hSupport, $B0B0B0, $FFFFFF); 808 RFrame( offscreen.Canvas, xSupport - 2, ySupport - 2, xSupport + wSupport + 1,804 RFrame(Offscreen.Canvas, xSupport - 2, ySupport - 2, xSupport + wSupport + 1, 809 805 ySupport + hSupport + 1, $FFFFFF, $B0B0B0); 810 x:= xSupport + wSupport div 2;811 y:= ySupport + hSupport div 2;806 X := xSupport + wSupport div 2; 807 Y := ySupport + hSupport div 2; 812 808 if SmallMapMode = smSupportedUnits then 813 809 begin 814 offscreen.Canvas.brush.Color := MainTexture.ColorMark;815 offscreen.Canvas.FillRect(Rect(x - 27, y - 6, x + 27, y+ 6));816 offscreen.Canvas.brush.style := bsClear;817 end; 818 Sprite( offscreen, HGrSystem, x - 16, y- 5, 10, 10, 88, 115);819 Sprite( offscreen, HGrSystem, x - 5, y- 5, 10, 10, 66, 115);820 Sprite( offscreen, HGrSystem, x + 6, y- 5, 10, 10, 154, 126);821 822 DpiBit Canvas(offscreen.Canvas, xZoomMap, yZoomMap, wZoomMap, hZoomMap,810 Offscreen.Canvas.Brush.Color := MainTexture.ColorMark; 811 Offscreen.Canvas.FillRect(Rect(X - 27, Y - 6, X + 27, Y + 6)); 812 Offscreen.Canvas.Brush.style := bsClear; 813 end; 814 Sprite(Offscreen, HGrSystem, X - 16, Y - 5, 10, 10, 88, 115); 815 Sprite(Offscreen, HGrSystem, X - 5, Y - 5, 10, 10, 66, 115); 816 Sprite(Offscreen, HGrSystem, X + 6, Y - 5, 10, 10, 154, 126); 817 818 DpiBitBltCanvas(Offscreen.Canvas, xZoomMap, yZoomMap, wZoomMap, hZoomMap, 823 819 ZoomCityMap.Canvas, 0, 0); 824 820 825 for i:= 0 to 5 do826 imix[ i] := -1;821 for I := 0 to 5 do 822 imix[I] := -1; 827 823 if SmallMapMode = smImprovements then 828 824 begin … … 831 827 Cnt := 0; 832 828 for iix := 0 to nImp - 1 do 833 if ((iix < nWonder) or (ImpPosition[iix] < 0)) and ( c.Built[iix] > 0) then829 if ((iix < nWonder) or (ImpPosition[iix] < 0)) and (C.Built[iix] > 0) then 834 830 begin 835 i:= Cnt - Page * 6;836 if ( i >= 0) and (i< 6) then837 imix[ i] := iix;838 inc(Cnt);831 I := Cnt - Page * 6; 832 if (I >= 0) and (I < 6) then 833 imix[I] := iix; 834 Inc(Cnt); 839 835 end; 840 836 PageCount := (Cnt + 5) div 6; … … 844 840 for iix := nWonder to nImp - 1 do 845 841 begin 846 i:= ImpPosition[iix] - 6 * ZoomArea;847 if ( i >= 0) and (i < 6) and (c.Built[iix] > 0) then848 imix[ i] := iix;842 I := ImpPosition[iix] - 6 * ZoomArea; 843 if (I >= 0) and (I < 6) and (C.Built[iix] > 0) then 844 imix[I] := iix; 849 845 end; 850 846 PageCount := 0; 851 847 end; 852 for i:= 0 to 5 do853 if imix[ i] >= 0 then848 for I := 0 to 5 do 849 if imix[I] >= 0 then 854 850 begin 855 iix := imix[ i];856 x := xZoomMap + 14 + 72 * (imod 3);857 y := yZoomMap + 14 + 56 * (idiv 3);858 ImpImage( offscreen.Canvas, x, y, iix, cGov, AllowChange and851 iix := imix[I]; 852 X := xZoomMap + 14 + 72 * (I mod 3); 853 Y := yZoomMap + 14 + 56 * (I div 3); 854 ImpImage(Offscreen.Canvas, X, Y, iix, cGov, AllowChange and 859 855 (ClientMode < scContact)); 860 856 if IsCityAlive then … … 862 858 if iix = imColosseum then 863 859 begin 864 Sprite( offscreen, HGrSystem, x + 46, y, 14, 14, 82, 100);860 Sprite(Offscreen, HGrSystem, X + 46, Y, 14, 14, 82, 100); 865 861 end 866 862 else … … 880 876 if HappyGain > 1 then 881 877 begin 882 d:= 30 div (HappyGain - 1);883 if d> 10 then884 d:= 10878 D := 30 div (HappyGain - 1); 879 if D > 10 then 880 D := 10 885 881 end; 886 for j:= 0 to HappyGain - 1 do887 Sprite( offscreen, HGrSystem, x + 50, y + d * j, 10, 10, 132, 126);882 for J := 0 to HappyGain - 1 do 883 Sprite(Offscreen, HGrSystem, X + 50, Y + D * J, 10, 10, 132, 126); 888 884 end; 889 for j:= 0 to Imp[iix].Maint - 1 do890 Sprite( offscreen, HGrSystem, x - 4, y + 29 - 3 * j, 10, 10,885 for J := 0 to Imp[iix].Maint - 1 do 886 Sprite(Offscreen, HGrSystem, X - 4, Y + 29 - 3 * J, 10, 10, 891 887 132, 115); 892 888 end … … 919 915 else { if SmallMapMode = smSupportedUnits then } 920 916 begin 921 LoweredTextout( offscreen.Canvas, -1, MainTexture, xZoomMap + 6,917 LoweredTextout(Offscreen.Canvas, -1, MainTexture, xZoomMap + 6, 922 918 yZoomMap + 2, Phrases.Lookup('SUPUNITS')); 923 FreeSupp := c.Size * SupportFree[cGov] shr 1;919 FreeSupp := C.Size * SupportFree[cGov] shr 1; 924 920 Cnt := 0; 925 for i:= 0 to MyRO.nUn - 1 do926 if (MyUn[ i].Loc >= 0) and (MyUn[i].Home = cix) then927 with MyModel[MyUn[ i].mix] do921 for I := 0 to MyRO.nUn - 1 do 922 if (MyUn[I].Loc >= 0) and (MyUn[I].Home = cix) then 923 with MyModel[MyUn[I].mix] do 928 924 begin 929 Server(sGetUnitReport, me, i, UnitReport);925 Server(sGetUnitReport, Me, I, UnitReport); 930 926 if (Cnt >= 6 * Page) and (Cnt < 6 * (Page + 1)) then 931 927 begin // unit visible in display 932 imix[Cnt - 6 * Page] := i;933 x:= ((Cnt - 6 * Page) mod 3) * 64 + xZoomMap;934 y:= ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20;935 MakeUnitInfo( me, MyUn[i], UnitInfo);936 NoMap.SetOutput( offscreen);937 NoMap.PaintUnit( x, y, UnitInfo, MyUn[i].Status);938 939 for j:= 0 to UnitReport.FoodSupport - 1 do940 Sprite( offscreen, HGrSystem, x + 38 + 11 * j, y+ 40, 10,928 imix[Cnt - 6 * Page] := I; 929 X := ((Cnt - 6 * Page) mod 3) * 64 + xZoomMap; 930 Y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20; 931 MakeUnitInfo(Me, MyUn[I], UnitInfo); 932 NoMap.SetOutput(Offscreen); 933 NoMap.PaintUnit(X, Y, UnitInfo, MyUn[I].Status); 934 935 for J := 0 to UnitReport.FoodSupport - 1 do 936 Sprite(Offscreen, HGrSystem, X + 38 + 11 * J, Y + 40, 10, 941 937 10, 66, 115); 942 for j:= 0 to UnitReport.ProdSupport - 1 do938 for J := 0 to UnitReport.ProdSupport - 1 do 943 939 begin 944 940 if (FreeSupp > 0) and 945 941 (UnitReport.ReportFlags and urfAlwaysSupport = 0) then 946 942 begin 947 Sprite( offscreen, HGrSystem, x + 16 - 11 * j, y+ 40, 10,943 Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10, 948 944 10, 143, 115); 949 dec(FreeSupp);945 Dec(FreeSupp); 950 946 end 951 947 else 952 Sprite( offscreen, HGrSystem, x + 16 - 11 * j, y+ 40, 10,948 Sprite(Offscreen, HGrSystem, X + 16 - 11 * J, Y + 40, 10, 953 949 10, 88, 115); 954 950 end; 955 951 if UnitReport.ReportFlags and urfDeployed <> 0 then 956 for j:= 0 to 1 do957 Sprite( offscreen, HGrSystem, x + 27 + 11 * j, y+ 40, 10,952 for J := 0 to 1 do 953 Sprite(Offscreen, HGrSystem, X + 27 + 11 * J, Y + 40, 10, 958 954 10, 154, 126) 959 955 end // unit visible in display 960 956 else 961 dec(FreeSupp, UnitReport.ProdSupport);962 inc(Cnt);957 Dec(FreeSupp, UnitReport.ProdSupport); 958 Inc(Cnt); 963 959 end; 964 960 PageCount := (Cnt + 5) div 6; … … 973 969 PageDownBtn.Visible := PageCount > 1; 974 970 975 with offscreen.Canvas do971 with Offscreen.Canvas do 976 972 begin 977 973 { display project now } 978 DLine( offscreen.Canvas, xView + 9 + xSizeBig, xProd + 2 * wBar + 10,974 DLine(Offscreen.Canvas, xView + 9 + xSizeBig, xProd + 2 * wBar + 10, 979 975 yProd + dyBar + 16, $FFFFFF, $B0B0B0); 980 976 if ProdHint then 981 977 begin 982 ScreenTools.Frame( offscreen.Canvas, xView + 9 - 1, yView + 5 - 1,978 ScreenTools.Frame(Offscreen.Canvas, xView + 9 - 1, yView + 5 - 1, 983 979 xView + 9 + xSizeBig, yView + 5 + ySizeBig, $B0B0B0, $FFFFFF); 984 RFrame( offscreen.Canvas, xView + 9 - 2, yView + 5 - 2,980 RFrame(Offscreen.Canvas, xView + 9 - 2, yView + 5 - 2, 985 981 xView + 9 + xSizeBig + 1, yView + 5 + ySizeBig + 1, $FFFFFF, $B0B0B0); 986 with offscreen.Canvas do982 with Offscreen.Canvas do 987 983 begin 988 brush.Color := $000000;984 Brush.Color := $000000; 989 985 FillRect(Rect(xView + 9, yView + 5, xView + 1 + 72 - 8, 990 986 yView + 5 + 40)); 991 brush.style := bsClear;987 Brush.style := bsClear; 992 988 end; 993 989 end 994 else if AllowChange and ( c.Status and 7 <> 0) then990 else if AllowChange and (C.Status and 7 <> 0) then 995 991 begin // city type autobuild 996 FrameImage( offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,997 ySizeBig, ( c.Status and 7 - 1 + 3) * xSizeBig, 0, (cix >= 0) and992 FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig, 993 ySizeBig, (C.Status and 7 - 1 + 3) * xSizeBig, 0, (cix >= 0) and 998 994 (ClientMode < scContact)); 999 995 end 1000 else if c.Project and cpImp = 0 then996 else if C.Project and cpImp = 0 then 1001 997 begin // project is unit 1002 FrameImage( offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig,998 FrameImage(Offscreen.Canvas, bigimp, xView + 9, yView + 5, xSizeBig, 1003 999 ySizeBig, 0, 0, AllowChange and (ClientMode < scContact)); 1004 with Tribe[cOwner].ModelPicture[ c.Project and cpIndex] do1005 Sprite( offscreen, HGr, xView + 5, yView + 1, 64, 44,1000 with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do 1001 Sprite(Offscreen, HGr, xView + 5, yView + 1, 64, 44, 1006 1002 pix mod 10 * 65 + 1, pix div 10 * 49 + 1); 1007 1003 end … … 1009 1005 begin // project is building 1010 1006 if ProdHint then 1011 Paintiix := c.Project0 and cpIndex1007 Paintiix := C.Project0 and cpIndex 1012 1008 else 1013 Paintiix := c.Project and cpIndex;1014 ImpImage( offscreen.Canvas, xView + 9, yView + 5, Paintiix, cGov,1009 Paintiix := C.Project and cpIndex; 1010 ImpImage(Offscreen.Canvas, xView + 9, yView + 5, Paintiix, cGov, 1015 1011 AllowChange and (ClientMode < scContact)); 1016 1012 end; … … 1019 1015 if AllowChange and (ClientMode < scContact) then 1020 1016 begin 1021 i := Server(sBuyCityProject - sExecute, me, cix, nil^);1022 BuyBtn.Visible := ( i = eOk) or (i= eViolation);1017 I := Server(sBuyCityProject - sExecute, Me, cix, nil^); 1018 BuyBtn.Visible := (I = eOk) or (I = eViolation); 1023 1019 end 1024 1020 else 1025 BuyBtn.Visible := false;1021 BuyBtn.Visible := False; 1026 1022 1027 1023 MarkUsedOffscreen(ClientWidth, ClientHeight); 1028 end; { OffscreenPaint }1024 end; 1029 1025 1030 1026 procedure TCityDlg.FormShow(Sender: TObject); 1031 1027 var 1032 dx, dy, Loc1: integer;1028 dx, dy, Loc1: Integer; 1033 1029 GetCityData: TGetCityData; 1034 1030 begin … … 1036 1032 if cix >= 0 then 1037 1033 begin { own city } 1038 c:= MyCity[cix];1039 cOwner := me;1034 C := MyCity[cix]; 1035 cOwner := Me; 1040 1036 cGov := MyRO.Government; 1041 1037 ProdHint := (cGov <> gAnarchy) and 1042 1038 (Happened and (chProduction or chFounded or chCaptured or 1043 1039 chAllImpsMade) <> 0); 1044 Server(sGetCityAreaInfo, me, cix, CityAreaInfo);1040 Server(sGetCityAreaInfo, Me, cix, CityAreaInfo); 1045 1041 NextCityBtn.Visible := WindowMode = wmPersistent; 1046 1042 PrevCityBtn.Visible := WindowMode = wmPersistent; … … 1049 1045 begin 1050 1046 SmallMapMode := smImprovements; 1051 Server(sGetCity, me, cLoc, GetCityData);1052 c := GetCityData.c;1047 Server(sGetCity, Me, cLoc, GetCityData); 1048 C := GetCityData.C; 1053 1049 cOwner := GetCityData.Owner; 1054 1050 cGov := MyRO.EnemyReport[cOwner].Government; 1055 Happened := c.Flags and $7FFFFFFF;1056 ProdHint := false;1057 Server(sGetEnemyCityAreaInfo, me, cLoc, CityAreaInfo);1058 1059 if c.Project and cpImp = 0 then1051 Happened := C.Flags and $7FFFFFFF; 1052 ProdHint := False; 1053 Server(sGetEnemyCityAreaInfo, Me, cLoc, CityAreaInfo); 1054 1055 if C.Project and cpImp = 0 then 1060 1056 begin 1061 1057 emix := MyRO.nEnemyModel - 1; 1062 1058 while (emix > 0) and ((MyRO.EnemyModel[emix].Owner <> cOwner) or 1063 ( integer(MyRO.EnemyModel[emix].mix) <> c.Project and cpIndex)) do1064 dec(emix);1065 if not Assigned(Tribe[cOwner].ModelPicture[ c.Project and cpIndex].HGr) then1059 (Integer(MyRO.EnemyModel[emix].mix) <> C.Project and cpIndex)) do 1060 Dec(emix); 1061 if not Assigned(Tribe[cOwner].ModelPicture[C.Project and cpIndex].HGr) then 1066 1062 InitEnemyModel(emix); 1067 1063 end; 1068 1064 1069 NextCityBtn.Visible := false;1070 PrevCityBtn.Visible := false;1065 NextCityBtn.Visible := False; 1066 PrevCityBtn.Visible := False; 1071 1067 end; 1072 1068 Page := 0; 1073 1069 1074 if c.Size < 5 then1070 if C.Size < 5 then 1075 1071 SizeClass := 0 1076 else if c.Size < 9 then1072 else if C.Size < 9 then 1077 1073 SizeClass := 1 1078 else if c.Size < 13 then1074 else if C.Size < 13 then 1079 1075 SizeClass := 2 1080 1076 else … … 1082 1078 1083 1079 // check if port 1084 IsPort := false;1080 IsPort := False; 1085 1081 for dx := -2 to 2 do 1086 1082 for dy := -2 to 2 do 1087 if abs(dx) + abs(dy) = 2 then1083 if Abs(dx) + Abs(dy) = 2 then 1088 1084 begin 1089 1085 Loc1 := dLoc(cLoc, dx, dy); 1090 1086 if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and 1091 1087 (MyMap[Loc1] and fTerrain < fGrass) then 1092 IsPort := true;1088 IsPort := True; 1093 1089 end; 1094 1090 … … 1099 1095 end; 1100 1096 1101 Caption := CityName( c.ID);1097 Caption := CityName(C.ID); 1102 1098 1103 1099 InitSmallCityMap; … … 1105 1101 OpenSoundEvent := -1; 1106 1102 OffscreenPaint; 1107 Timer1.Enabled := true;1108 end; 1109 1110 procedure TCityDlg.ShowNewContent(NewMode , Loc: integer; ShowEvent: cardinal);1103 Timer1.Enabled := True; 1104 end; 1105 1106 procedure TCityDlg.ShowNewContent(NewMode: TWindowMode; Loc: Integer; ShowEvent: Cardinal); 1111 1107 begin 1112 1108 if MyMap[Loc] and fOwned <> 0 then … … 1114 1110 cix := MyRO.nCity - 1; 1115 1111 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 1116 dec(cix);1117 assert(cix >= 0);1112 Dec(cix); 1113 Assert(cix >= 0); 1118 1114 if (Optimize_cixTileChange >= 0) and 1119 1115 (Optimize_TilesBeforeChange and not MyCity[Optimize_cixTileChange].Tiles … … 1131 1127 else 1132 1128 cix := -1; 1133 AllowChange := not supervising and (cix >= 0);1129 AllowChange := not Supervising and (cix >= 0); 1134 1130 cLoc := Loc; 1135 1131 Happened := ShowEvent; … … 1138 1134 1139 1135 procedure TCityDlg.FormMouseDown(Sender: TObject; Button: TMouseButton; 1140 Shift: TShiftState; x, y: integer);1136 Shift: TShiftState; X, Y: Integer); 1141 1137 var 1142 i, qx, qy, dx, dy, fix, NewTiles, Loc1, iix, SellResult: integer;1143 Rebuild: boolean;1144 begin 1145 if (ssLeft in Shift) and ( x >= xSmallMap) and (x< xSmallMap + wSmallMap) and1146 ( y >= ySmallMap) and (y< ySmallMap + hSmallMap) then1138 I, qx, qy, dx, dy, fix, NewTiles, Loc1, iix, SellResult: Integer; 1139 Rebuild: Boolean; 1140 begin 1141 if (ssLeft in Shift) and (X >= xSmallMap) and (X < xSmallMap + wSmallMap) and 1142 (Y >= ySmallMap) and (Y < ySmallMap + hSmallMap) then 1147 1143 begin 1148 1144 SmallMapMode := smImprovements; 1149 ZoomArea := ( y- ySmallMap) * 3 div hSmallMap + 3 *1150 (( x- xSmallMap) * 2 div wSmallMap);1145 ZoomArea := (Y - ySmallMap) * 3 div hSmallMap + 3 * 1146 ((X - xSmallMap) * 2 div wSmallMap); 1151 1147 Page := 0; 1152 1148 InitZoomCityMap; 1153 1149 SmartUpdateContent; 1154 exit;1155 end; 1156 if (ssLeft in Shift) and ( x >= xSupport) and (x< xSupport + wSupport) and1157 ( y >= ySupport) and (y< ySupport + hSupport) then1150 Exit; 1151 end; 1152 if (ssLeft in Shift) and (X >= xSupport) and (X < xSupport + wSupport) and 1153 (Y >= ySupport) and (Y < ySupport + hSupport) then 1158 1154 begin 1159 1155 SmallMapMode := smSupportedUnits; … … 1161 1157 InitZoomCityMap; 1162 1158 SmartUpdateContent; 1163 exit;1159 Exit; 1164 1160 end; 1165 1161 if not AllowChange then 1166 exit; // not an own city1162 Exit; // Not an own city 1167 1163 1168 1164 if (ssLeft in Shift) then 1169 if (ClientMode < scContact) and ( x >= xView) and (y>= yView) and1170 ( x < xView + 73) and (y< yView + 50) then1165 if (ClientMode < scContact) and (X >= xView) and (Y >= yView) and 1166 (X < xView + 73) and (Y < yView + 50) then 1171 1167 if cGov = gAnarchy then 1172 with M essgExDlg do1168 with MainScreen.MessgExDlg do 1173 1169 begin 1174 1170 { MessgText:=Phrases.Lookup('OUTOFCONTROL'); 1175 if c.Project and cpImp=0 then1176 MessgText:=Format(MessgText,[Tribe[cOwner].ModelName[ c.Project and cpIndex]])1177 else MessgText:=Format(MessgText,[Phrases.Lookup('IMPROVEMENTS', c.Project and cpIndex)]); }1171 if C.Project and cpImp=0 then 1172 MessgText:=Format(MessgText,[Tribe[cOwner].ModelName[C.Project and cpIndex]]) 1173 else MessgText:=Format(MessgText,[Phrases.Lookup('IMPROVEMENTS',C.Project and cpIndex)]); } 1178 1174 MessgText := Phrases.Lookup('NOCHANGEINANARCHY'); 1179 1175 Kind := mkOk; … … 1184 1180 if ProdHint then 1185 1181 begin 1186 ProdHint := false;1182 ProdHint := False; 1187 1183 SmartUpdateContent 1188 1184 end; 1189 1185 ChooseProject; 1190 1186 end 1191 else if (SmallMapMode = smImprovements) and ( x >= xZoomMap) and (x< xZoomMap + wZoomMap) and1192 ( y >= yZoomMap) and (y< yZoomMap + hZoomMap) then1193 begin 1194 i:= 5;1195 while ( i >= 0) and not((x >= xZoomMap + 14 + 72 * (imod 3)) and1196 ( x < xZoomMap + 14 + 56 + 72 * (imod 3)) and1197 ( y >= yZoomMap + 14 + 56 * (idiv 3)) and1198 ( y < yZoomMap + 14 + 40 + 56 * (idiv 3))) do1199 dec(i);1200 if i>= 0 then1187 else if (SmallMapMode = smImprovements) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and 1188 (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then 1189 begin 1190 I := 5; 1191 while (I >= 0) and not((X >= xZoomMap + 14 + 72 * (I mod 3)) and 1192 (X < xZoomMap + 14 + 56 + 72 * (I mod 3)) and 1193 (Y >= yZoomMap + 14 + 56 * (I div 3)) and 1194 (Y < yZoomMap + 14 + 40 + 56 * (I div 3))) do 1195 Dec(I); 1196 if I >= 0 then 1201 1197 begin 1202 iix := imix[ i];1198 iix := imix[I]; 1203 1199 if iix >= 0 then 1204 1200 if ssShift in Shift then 1205 HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp, iix)1201 MainScreen.HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkImp, iix) 1206 1202 else if (ClientMode < scContact) then 1207 with M essgExDlg do1203 with MainScreen.MessgExDlg do 1208 1204 begin 1209 1205 IconKind := mikImp; … … 1220 1216 else 1221 1217 begin 1222 SellResult := Server(sSellCityImprovement - sExecute, me,1218 SellResult := Server(sSellCityImprovement - sExecute, Me, 1223 1219 cix, iix); 1224 1220 if SellResult < rExecuted then … … 1235 1231 else 1236 1232 begin 1237 if Server(sRebuildCityImprovement - sExecute, me, cix, iix) < rExecuted1233 if Server(sRebuildCityImprovement - sExecute, Me, cix, iix) < rExecuted 1238 1234 then 1239 1235 begin // no rebuild possible, ask for sell only 1240 Rebuild := false;1236 Rebuild := False; 1241 1237 MessgText := Phrases.Lookup('IMPROVEMENTS', iix); 1242 1238 if not Phrases2FallenBackToEnglish then 1243 1239 MessgText := Format(Phrases2.Lookup('SELL2'), 1244 1240 [MessgText, Imp[iix].Cost * BuildCostMod 1245 [G.Difficulty[ me]] div 12])1241 [G.Difficulty[Me]] div 12]) 1246 1242 else 1247 1243 MessgText := Format(Phrases.Lookup('SELL'), [MessgText]); 1248 1244 if iix = imSpacePort then 1249 with MyRO.Ship[ me] do1245 with MyRO.Ship[Me] do 1250 1246 if Parts[0] + Parts[1] + Parts[2] > 0 then 1251 1247 MessgText := MessgText + ' ' + … … 1258 1254 else 1259 1255 begin 1260 Rebuild := true;1256 Rebuild := True; 1261 1257 MessgText := Phrases.Lookup('IMPROVEMENTS', iix); 1262 1258 if not Phrases2FallenBackToEnglish then 1263 1259 MessgText := Format(Phrases2.Lookup('DISPOSE2'), 1264 1260 [MessgText, Imp[iix].Cost * BuildCostMod 1265 [G.Difficulty[ me]] div 12 * 2 div 3])1261 [G.Difficulty[Me]] div 12 * 2 div 3]) 1266 1262 else 1267 1263 MessgText := Format(Phrases.Lookup('DISPOSE'), 1268 1264 [MessgText]); 1269 1265 if iix = imSpacePort then 1270 with MyRO.Ship[ me] do1266 with MyRO.Ship[Me] do 1271 1267 if Parts[0] + Parts[1] + Parts[2] > 0 then 1272 1268 MessgText := MessgText + ' ' + … … 1282 1278 begin 1283 1279 Play('CITY_REBUILDIMP'); 1284 Server(sRebuildCityImprovement, me, cix, iix);1280 Server(sRebuildCityImprovement, Me, cix, iix); 1285 1281 end 1286 1282 else 1287 1283 begin 1288 1284 Play('CITY_SELLIMP'); 1289 Server(sSellCityImprovement, me, cix, iix);1285 Server(sSellCityImprovement, Me, cix, iix); 1290 1286 end; 1291 1287 CityOptimizer_CityChange(cix); … … 1300 1296 end; 1301 1297 end 1302 else if (SmallMapMode = smSupportedUnits) and ( x >= xZoomMap) and (x< xZoomMap + wZoomMap) and1303 ( y >= yZoomMap) and (y< yZoomMap + hZoomMap) then1304 begin 1305 i:= 5;1306 while ( i >= 0) and not((x >= xZoomMap + 64 * (imod 3)) and1307 ( x < xZoomMap + 64 + 64 * (imod 3)) and1308 ( y >= yZoomMap + 20 + 48 * (idiv 3)) and1309 ( y < yZoomMap + 20 + 52 + 48 * (idiv 3))) do1310 dec(i);1311 if ( i >= 0) and (imix[i] >= 0) then1298 else if (SmallMapMode = smSupportedUnits) and (X >= xZoomMap) and (X < xZoomMap + wZoomMap) and 1299 (Y >= yZoomMap) and (Y < yZoomMap + hZoomMap) then 1300 begin 1301 I := 5; 1302 while (I >= 0) and not((X >= xZoomMap + 64 * (I mod 3)) and 1303 (X < xZoomMap + 64 + 64 * (I mod 3)) and 1304 (Y >= yZoomMap + 20 + 48 * (I div 3)) and 1305 (Y < yZoomMap + 20 + 52 + 48 * (I div 3))) do 1306 Dec(I); 1307 if (I >= 0) and (imix[I] >= 0) then 1312 1308 if ssShift in Shift then 1313 1309 else if (cix >= 0) and (ClientMode < scContact) and … … 1316 1312 CloseAction := None; 1317 1313 Close; 1318 MainScreen.CityClosed(imix[ i], false, true);1314 MainScreen.CityClosed(imix[I], False, True); 1319 1315 end; 1320 1316 end 1321 else if ( x >= xmArea - 192) and (x < xmArea + 192) and (y>= ymArea - 96)1322 and ( y< ymArea + 96) then1317 else if (X >= xmArea - 192) and (X < xmArea + 192) and (Y >= ymArea - 96) 1318 and (Y < ymArea + 96) then 1323 1319 with AreaMap do begin 1324 qx := ((4000 * xxt * yyt) + ( x - xmArea) * (yyt * 2) + (y- ymArea + yyt)1320 qx := ((4000 * xxt * yyt) + (X - xmArea) * (yyt * 2) + (Y - ymArea + yyt) 1325 1321 * (xxt * 2)) div (xxt * yyt * 4) - 1000; 1326 qy := ((4000 * xxt * yyt) + ( y - ymArea + yyt) * (xxt * 2) - (x- xmArea)1322 qy := ((4000 * xxt * yyt) + (Y - ymArea + yyt) * (xxt * 2) - (X - xmArea) 1327 1323 * (yyt * 2)) div (xxt * yyt * 4) - 1000; 1328 1324 dx := qx - qy; … … 1334 1330 Loc1 := dLoc(cLoc, dx, dy); 1335 1331 if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) then 1336 HelpOnTerrain(Loc1, FWindowMode or wmPersistent)1332 HelpOnTerrain(Loc1, WindowModeMakePersistent(FWindowMode)) 1337 1333 end 1338 1334 else if (ClientMode < scContact) and (cGov <> gAnarchy) and 1339 ( c.Flags and chCaptured = 0) then1335 (C.Flags and chCaptured = 0) then 1340 1336 begin // toggle exploitation 1341 assert(not supervising);1342 if c.Status and csResourceWeightsMask <> 0 then1337 Assert(not Supervising); 1338 if C.Status and csResourceWeightsMask <> 0 then 1343 1339 begin 1344 with M essgExDlg do1340 with MainScreen.MessgExDlg do 1345 1341 begin 1346 1342 MessgText := Phrases.Lookup('CITYMANAGEOFF'); … … 1350 1346 ShowModal; 1351 1347 end; 1352 if M essgExDlg.ModalResult = mrOK then1348 if MainScreen.MessgExDlg.ModalResult = mrOK then 1353 1349 begin 1354 1350 MyCity[cix].Status := MyCity[cix].Status and 1355 1351 not csResourceWeightsMask; // off 1356 c.Status := MyCity[cix].Status;1352 C.Status := MyCity[cix].Status; 1357 1353 SmartUpdateContent; 1358 1354 end; 1359 exit;1355 Exit; 1360 1356 end; 1361 1357 fix := (dy + 3) shl 2 + (dx + 3) shr 1; 1362 1358 NewTiles := MyCity[cix].Tiles xor (1 shl fix); 1363 if Server(sSetCityTiles, me, cix, NewTiles) >= rExecuted then1359 if Server(sSetCityTiles, Me, cix, NewTiles) >= rExecuted then 1364 1360 begin 1365 1361 SmartUpdateContent; … … 1370 1366 end 1371 1367 else if (ClientMode < scContact) and (cGov <> gAnarchy) and 1372 ( c.Flags and chCaptured = 0) and (x >= xmOpt - 32) and (x< xmOpt + 32)1373 and ( y >= ymOpt - 32) and (y< ymOpt + 32) then1374 begin 1375 i := sqr(x - xmOpt) + sqr(y- ymOpt); // click radius1376 if i<= 32 * 32 then1368 (C.Flags and chCaptured = 0) and (X >= xmOpt - 32) and (X < xmOpt + 32) 1369 and (Y >= ymOpt - 32) and (Y < ymOpt + 32) then 1370 begin 1371 I := sqr(X - xmOpt) + sqr(Y - ymOpt); // click radius 1372 if I <= 32 * 32 then 1377 1373 begin 1378 if i< 16 * 16 then // inner area clicked1379 if c.Status and csResourceWeightsMask <> 0 then1380 i := (c.Status shr 4 and $0F) mod 5 + 1 // rotate except off1374 if I < 16 * 16 then // inner area clicked 1375 if C.Status and csResourceWeightsMask <> 0 then 1376 I := (C.Status shr 4 and $0F) mod 5 + 1 // rotate except off 1381 1377 else 1382 i:= 3 // rwGrowth1378 I := 3 // rwGrowth 1383 1379 else 1384 case trunc(arctan2( x - xmOpt, ymOpt - y) * 180 / pi) of1380 case trunc(arctan2(X - xmOpt, ymOpt - Y) * 180 / pi) of 1385 1381 - 25 - 52 * 2 .. -26 - 52: 1386 i:= 1;1382 I := 1; 1387 1383 -25 - 52 .. -26: 1388 i:= 2;1384 I := 2; 1389 1385 -25 .. 25: 1390 i:= 3;1386 I := 3; 1391 1387 26 .. 25 + 52: 1392 i:= 4;1388 I := 4; 1393 1389 26 + 52 .. 25 + 52 * 2: 1394 i:= 5;1390 I := 5; 1395 1391 180 - 26 .. 180, -180 .. -180 + 26: 1396 i:= 0;1392 I := 0; 1397 1393 else 1398 i:= -1;1394 I := -1; 1399 1395 end; 1400 if i>= 0 then1396 if I >= 0 then 1401 1397 begin 1402 ChangeResourceWeights( i);1398 ChangeResourceWeights(I); 1403 1399 SmartUpdateContent; 1404 1400 if WindowMode <> wmModal then … … 1407 1403 end; 1408 1404 end; 1409 end; { FormMouseDown }1405 end; 1410 1406 1411 1407 procedure TCityDlg.ChooseProject; … … 1422 1418 ); 1423 1419 1424 function ProjectType(Project: integer): TProjectType;1420 function ProjectType(Project: Integer): TProjectType; 1425 1421 begin 1426 1422 if Project and cpCompleted <> 0 then … … 1444 1440 1445 1441 var 1446 NewProject, OldMoney, cix1: integer;1442 NewProject, OldMoney, cix1: Integer; 1447 1443 pt0, pt1: TProjectType; 1448 QueryOk: boolean;1449 begin 1450 Assert(not supervising);1451 M odalSelectDlg.ShowNewContent_CityProject(wmModal, cix);1452 if M odalSelectDlg.result <> -1 then1453 begin 1454 if M odalSelectDlg.result and cpType <> 0 then1444 QueryOk: Boolean; 1445 begin 1446 Assert(not Supervising); 1447 MainScreen.ModalSelectDlg.ShowNewContent_CityProject(wmModal, cix); 1448 if MainScreen.ModalSelectDlg.Result <> -1 then 1449 begin 1450 if MainScreen.ModalSelectDlg.Result and cpType <> 0 then 1455 1451 begin 1456 1452 MyCity[cix].Status := MyCity[cix].Status and not 7 or 1457 (1 + M odalSelectDlg.result and cpIndex);1458 AutoBuild(cix, MyData.ImpOrder[M odalSelectDlg.result and cpIndex]);1453 (1 + MainScreen.ModalSelectDlg.Result and cpIndex); 1454 AutoBuild(cix, MyData.ImpOrder[MainScreen.ModalSelectDlg.Result and cpIndex]); 1459 1455 end 1460 1456 else 1461 1457 begin 1462 NewProject := M odalSelectDlg.Result;1458 NewProject := MainScreen.ModalSelectDlg.Result; 1463 1459 QueryOk := True; 1464 1460 if (NewProject and cpImp <> 0) and (NewProject and cpIndex >= 28) and 1465 1461 (MyRO.NatBuilt[NewProject and cpIndex] > 0) then 1466 with M essgExDlg do1462 with MainScreen.MessgExDlg do 1467 1463 begin 1468 1464 cix1 := MyRO.nCity - 1; … … 1521 1517 then 1522 1518 NewProject := NewProject or cpDisbandCity; 1523 Server(sSetCityProject, me, cix, NewProject);1524 c.Project := MyCity[cix].Project;1519 Server(sSetCityProject, Me, cix, NewProject); 1520 C.Project := MyCity[cix].Project; 1525 1521 if MyRO.Money > OldMoney then 1526 1522 Play('CITY_SELLIMP'); … … 1537 1533 procedure TCityDlg.BuyClick(Sender: TObject); 1538 1534 var 1539 NextProd, Cost: integer;1535 NextProd, Cost: Integer; 1540 1536 begin 1541 1537 if (cix < 0) or (ClientMode >= scContact) then 1542 exit;1543 with MyCity[cix], M essgExDlg do1538 Exit; 1539 with MyCity[cix], MainScreen.MessgExDlg do 1544 1540 begin 1545 1541 Cost := Report.ProjectCost; … … 1548 1544 NextProd := 0; 1549 1545 Cost := Cost - Prod - NextProd; 1550 if (MyRO.Wonder[woMich].EffectiveOwner = me) and (Project and cpImp <> 0)1546 if (MyRO.Wonder[woMich].EffectiveOwner = Me) and (Project and cpImp <> 0) 1551 1547 then 1552 1548 Cost := Cost * 2 … … 1572 1568 if (Kind = mkYesNo) and (ModalResult = mrOK) then 1573 1569 begin 1574 if Server(sBuyCityProject, me, cix, nil^) >= rExecuted then1570 if Server(sBuyCityProject, Me, cix, nil^) >= rExecuted then 1575 1571 begin 1576 1572 Play('CITY_BUYPROJECT'); … … 1585 1581 procedure TCityDlg.FormClose(Sender: TObject; var Action: TCloseAction); 1586 1582 begin 1587 Timer1.Enabled := false;1588 ProdHint := false;1583 Timer1.Enabled := False; 1584 ProdHint := False; 1589 1585 MarkCityLoc := -1; 1590 1586 if Optimize_cixTileChange >= 0 then … … 1615 1611 with Canvas do 1616 1612 begin 1617 DpiBit Canvas(Canvas, xView + 5, yView + 1, 64, 2, Back.Canvas,1613 DpiBitBltCanvas(Canvas, xView + 5, yView + 1, 64, 2, Back.Canvas, 1618 1614 xView + 5, yView + 1); 1619 DpiBit Canvas(Canvas, xView + 5, yView + 3, 2, 42, Back.Canvas,1615 DpiBitBltCanvas(Canvas, xView + 5, yView + 3, 2, 42, Back.Canvas, 1620 1616 xView + 5, yView + 3); 1621 DpiBit Canvas(Canvas, xView + 5 + 62, yView + 3, 2, 42,1617 DpiBitBltCanvas(Canvas, xView + 5 + 62, yView + 3, 2, 42, 1622 1618 Back.Canvas, xView + 5 + 62, yView + 3); 1623 1619 ScreenTools.Frame(Canvas, xView + 9 - 1, yView + 5 - 1, xView + 9 + xSizeBig, … … 1632 1628 else if BlinkTime = 6 then 1633 1629 begin 1634 if AllowChange and ( c.Status and 7 <> 0) then1630 if AllowChange and (C.Status and 7 <> 0) then 1635 1631 begin // city type autobuild 1636 1632 FrameImage(Canvas, bigimp, xView + 9, yView + 5, xSizeBig, ySizeBig, 1637 ( c.Status and 7 - 1 + 3) * xSizeBig, 0, true);1633 (C.Status and 7 - 1 + 3) * xSizeBig, 0, True); 1638 1634 end 1639 else if c.Project and cpImp = 0 then1635 else if C.Project and cpImp = 0 then 1640 1636 begin // project is unit 1641 DpiBit Canvas(Canvas, xView + 9, yView + 5, xSizeBig, ySizeBig,1637 DpiBitBltCanvas(Canvas, xView + 9, yView + 5, xSizeBig, ySizeBig, 1642 1638 Bigimp.Canvas, 0, 0); 1643 with Tribe[cOwner].ModelPicture[ c.Project and cpIndex] do1639 with Tribe[cOwner].ModelPicture[C.Project and cpIndex] do 1644 1640 Sprite(Canvas, HGr, xView + 5, yView + 1, 64, 44, pix mod 10 * 65 + 1, 1645 1641 pix div 10 * 49 + 1); 1646 1642 end 1647 1643 else 1648 ImpImage(Canvas, xView + 9, yView + 5, c.Project0 and cpIndex,1649 cGov, true);1644 ImpImage(Canvas, xView + 9, yView + 5, C.Project0 and cpIndex, 1645 cGov, True); 1650 1646 end; 1651 1647 end; … … 1663 1659 if 1 shl OpenSoundEvent = chProduction then 1664 1660 begin 1665 if c.Project0 and cpImp <> 0 then1666 begin 1667 if c.Project0 and cpIndex >= 28 then1661 if C.Project0 and cpImp <> 0 then 1662 begin 1663 if C.Project0 and cpIndex >= 28 then 1668 1664 // wonders have already extra message with sound 1669 if Imp[ c.Project0 and cpIndex].Kind = ikShipPart then1665 if Imp[C.Project0 and cpIndex].Kind = ikShipPart then 1670 1666 Play('SHIP_BUILT') 1671 1667 else … … 1681 1677 end; 1682 1678 1683 function Prio(iix: integer): integer;1679 function Prio(iix: Integer): Integer; 1684 1680 begin 1685 1681 case Imp[iix].Kind of 1686 1682 ikWonder: 1687 result := iix + 10000;1683 Result := iix + 10000; 1688 1684 ikNatLocal, ikNatGlobal: 1689 1685 case iix of 1690 1686 imPalace: 1691 result := 0;1687 Result := 0; 1692 1688 else 1693 result := iix + 20000;1689 Result := iix + 20000; 1694 1690 end; 1695 1691 else 1696 1692 case iix of 1697 1693 imTownHall, imCourt: 1698 result := iix + 30000;1694 Result := iix + 30000; 1699 1695 imAqueduct, imSewer: 1700 result := iix + 40000;1696 Result := iix + 40000; 1701 1697 imTemple, imTheater, imCathedral: 1702 result := iix + 50000;1703 else 1704 result := iix + 90000;1698 Result := iix + 50000; 1699 else 1700 Result := iix + 90000; 1705 1701 end; 1706 1702 end; … … 1717 1713 end; 1718 1714 1719 procedure TCityDlg.ChangeCity( d: integer);1715 procedure TCityDlg.ChangeCity(D: Integer); 1720 1716 var 1721 cixNew: integer;1717 cixNew: Integer; 1722 1718 begin 1723 1719 cixNew := cix; 1724 1720 repeat 1725 cixNew := (cixNew + MyRO.nCity + d) mod MyRO.nCity;1721 cixNew := (cixNew + MyRO.nCity + D) mod MyRO.nCity; 1726 1722 until (MyCity[cixNew].Loc >= 0) or (cixNew = cix); 1727 1723 if cixNew <> cix then … … 1742 1738 end; 1743 1739 1744 { procedure TCityDlg.AdviceBtnClick(Sender: TObject);1745 begin1746 AdvisorDlg.GiveCityAdvice(cix);1747 end; }1748 1749 1740 procedure TCityDlg.PageUpBtnClick(Sender: TObject); 1750 1741 begin 1751 1742 if Page > 0 then 1752 1743 begin 1753 dec(Page);1744 Dec(Page); 1754 1745 SmartUpdateContent; 1755 1746 end; … … 1760 1751 if Page < PageCount - 1 then 1761 1752 begin 1762 inc(Page);1753 Inc(Page); 1763 1754 SmartUpdateContent; 1764 1755 end; 1765 1756 end; 1766 1757 1767 procedure TCityDlg.ChangeResourceWeights(iResourceWeights: integer);1758 procedure TCityDlg.ChangeResourceWeights(iResourceWeights: Integer); 1768 1759 var 1769 1760 Advice: TCityTileAdviceData; 1770 1761 begin 1771 assert(not supervising);1772 assert(cix >= 0);1762 Assert(not Supervising); 1763 Assert(cix >= 0); 1773 1764 MyCity[cix].Status := MyCity[cix].Status and not csResourceWeightsMask or 1774 1765 (iResourceWeights shl 4); 1775 c.Status := MyCity[cix].Status;1766 C.Status := MyCity[cix].Status; 1776 1767 if iResourceWeights > 0 then 1777 1768 begin 1778 1769 Advice.ResourceWeights := OfferedResourceWeights[iResourceWeights]; 1779 Server(sGetCityTileAdvice, me, cix, Advice);1770 Server(sGetCityTileAdvice, Me, cix, Advice); 1780 1771 if Advice.Tiles <> MyCity[cix].Tiles then 1781 Server(sSetCityTiles, me, cix, Advice.Tiles);1772 Server(sSetCityTiles, Me, cix, Advice.Tiles); 1782 1773 end; 1783 1774 end; … … 1785 1776 procedure SortImprovements; 1786 1777 var 1787 i, j, k: integer;1788 begin 1789 for i:= 0 to nImp - 1 do1790 ImpSorted[ i] := i;1791 for i:= 0 to nImp - 2 do1792 for j := i+ 1 to nImp - 1 do1793 if Prio(ImpSorted[ i]) > Prio(ImpSorted[j]) then begin1794 k := ImpSorted[i];1795 ImpSorted[ i] := ImpSorted[j];1796 ImpSorted[ j] := k;1778 I, J, K: Integer; 1779 begin 1780 for I := 0 to nImp - 1 do 1781 ImpSorted[I] := I; 1782 for I := 0 to nImp - 2 do 1783 for J := I + 1 to nImp - 1 do 1784 if Prio(ImpSorted[I]) > Prio(ImpSorted[J]) then begin 1785 K := ImpSorted[I]; 1786 ImpSorted[I] := ImpSorted[J]; 1787 ImpSorted[J] := K; 1797 1788 end; 1798 1789 end;
Note:
See TracChangeset
for help on using the changeset viewer.