Changeset 349 for branches/highdpi/LocalPlayer/Term.pas
- Timestamp:
- Apr 6, 2021, 8:11:02 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Term.pas
r303 r349 13 13 Protocol, Tribes, PVSB, ClientTools, ScreenTools, BaseWin, Messg, ButtonBase, 14 14 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, DrawDlg, Types, 15 Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area; 15 Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area, 16 UGraphicSet, UMiniMap, IsoEngine; 16 17 17 18 const 18 19 WM_EOT = WM_USER; 19 20 20 pltsNormal = 0;21 pltsBlink = 1;22 23 21 type 22 TPaintLocTempStyle = (pltsNormal, pltsBlink); 23 24 TSoundBlock = (sbStart, sbWonder, sbScience, sbContact, sbTurn); 25 TSoundBlocks = set of TSoundBlock; 24 26 25 27 { TMainScreen } … … 224 226 procedure MovieSpeedBtnClick(Sender: TObject); 225 227 private 226 xw, yw, xwd, ywd, xwMini, ywMini, xMidPanel, xRightPanel, xTroop, xTerrain, 227 xMini, yMini, ywmax, ywcenter, TroopLoc, TrCnt, TrRow, TrPitch, MapWidth, 228 MapOffset, MapHeight, BlinkTime, BrushLoc, EditLoc, xMouse, 229 yMouse: integer; 228 xw: Integer; // Base map x 229 yw: Integer; // Base map y 230 xwd: Integer; 231 ywd: Integer; 232 xwMini: Integer; 233 ywMini: Integer; 234 xMidPanel: Integer; 235 xRightPanel: Integer; 236 xTroop: Integer; 237 xTerrain: Integer; 238 xMini: Integer; 239 yMini: Integer; 240 ywmax: Integer; 241 ywcenter: Integer; 242 TroopLoc: Integer; 243 TrCnt: Integer; 244 TrRow: Integer; 245 TrPitch: Integer; 246 MapWidth: Integer; 247 MapOffset: Integer; 248 MapHeight: Integer; 249 BlinkTime: Integer; 250 BrushLoc: Integer; 251 EditLoc: Integer; 252 xMouse: Integer; 253 yMouse: Integer; 230 254 BrushType: Cardinal; 231 trix: array [0 .. 63] of integer;255 trix: array [0 .. 63] of Integer; 232 256 AILogo: array [0 .. nPl - 1] of TDpiBitmap; 233 Mini, Panel, TopBar: TDpiBitmap; 257 MiniMap: TMiniMap; 258 Panel: TDpiBitmap; 259 TopBar: TDpiBitmap; 234 260 sb: TPVScrollbar; 235 Closable, RepaintOnResize, Tracking, TurnComplete, Edited, GoOnPhase, 236 HaveStrategyAdvice, FirstMovieTurn: boolean; 261 Closable: Boolean; 262 RepaintOnResize: Boolean; 263 Tracking: Boolean; 264 TurnComplete: Boolean; 265 Edited: Boolean; 266 GoOnPhase: Boolean; 267 HaveStrategyAdvice: Boolean; 268 FirstMovieTurn: Boolean; 237 269 PrevWindowState: TWindowState; 238 270 CurrentWindowState: TWindowState; 271 MainMap: TIsoMap; 272 NoMap: TIsoMap; 273 NoMapPanel: TIsoMap; 239 274 function ChooseUnusedTribe: integer; 240 275 procedure GetTribeList; 241 276 procedure InitModule; 277 procedure DoneModule; 242 278 procedure InitTurn(NewPlayer: integer); 279 procedure SaveMenuItemsState; 243 280 procedure ScrollBarUpdate(Sender: TObject); 244 281 procedure ArrangeMidPanel; 245 282 procedure MainOffscreenPaint; 246 procedure Mini Paint;283 procedure MiniMapPaint; 247 284 procedure PaintAll; 248 285 procedure PaintAllMaps; … … 251 288 procedure NextUnit(NearLoc: integer; AutoTurn: boolean); 252 289 procedure Scroll(dx, dy: integer); 290 procedure SetMapPos(Loc: integer; MapPos: TPoint); 253 291 procedure Centre(Loc: integer); 254 292 procedure SetTroopLoc(Loc: integer); … … 256 294 procedure PaintLoc(Loc: integer; Radius: integer = 0); 257 295 procedure PaintLoc_BeforeMove(FromLoc: integer); 258 procedure PaintLocTemp(Loc: integer; Style: integer= pltsNormal);296 procedure PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle = pltsNormal); 259 297 procedure PaintBufferToScreen(xMap, yMap, width, height: integer); 260 298 procedure PaintDestination; … … 275 313 procedure SetDebugMap(p: integer); 276 314 procedure SetViewpoint(p: integer); 277 function LocationOfScreenPixel(x, y: integer): integer; 278 procedure SetTileSize(x, y: integer); 315 function LocationOfScreenPixel(x, y: integer): Integer; 316 function GetCenterLoc: Integer; 317 procedure SetTileSizeCenter(TileSize: TTileSize); 318 procedure SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 279 319 procedure RectInvalidate(Left, Top, Rigth, Bottom: integer); 280 320 procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange); … … 284 324 procedure OnScroll(var Msg: TMessage); message WM_VSCROLL; 285 325 procedure OnEOT(var Msg: TMessage); message WM_EOT; 286 procedure SoundPreload(Check: integer);326 procedure SoundPreload(Check: TSoundBlocks); 287 327 procedure UpdateKeyShortcuts; 288 328 procedure SetFullScreen(Active: Boolean); 329 procedure PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer); 289 330 public 290 331 UsedOffscreenWidth, UsedOffscreenHeight: integer; … … 311 352 FileName: ShortString; 312 353 end; 354 313 355 TCityNameInfo = record 314 356 ID: integer; 315 357 NewName: ShortString; 316 358 end; 359 317 360 TModelNameInfo = record 318 361 mix: integer; 319 362 NewName: ShortString; 320 363 end; 321 TPriceSet = Set of $00 .. $FF; 364 365 TPriceSet = set of $00 .. $FF; 322 366 323 367 const … … 388 432 // lines of system icons in icons.bmp before improvements 389 433 390 // save options apart from what's defined by SaveOption391 soTellAI = 30;392 soExtraMask = $40000000;393 394 434 nCityEventPriority = 16; 395 435 CityEventPriority: array [0 .. nCityEventPriority - 1] of integer = … … 404 444 'CITY_WONDEREX', 'CITY_EMDELAY', 'CITY_FOUNDED', 'CITY_FOUNDED', '', 405 445 'CITY_INVALIDTYPE'); 406 407 // sound blocks for preload408 sbStart = $01;409 sbWonder = $02;410 sbScience = $04;411 sbContact = $08;412 sbTurn = $10;413 sbAll = $FF;414 446 415 447 type … … 425 457 EnhancementJobs: TEnhancementJobs; 426 458 ImpOrder: array [0 .. nCityType - 1] of TImpOrder; 427 ToldWonders: array [0 .. 27] of TWonderInfo;459 ToldWonders: array [0 .. nWonder - 1] of TWonderInfo; 428 460 ToldTech: array [0 .. nAdv - 1] of ShortInt; 461 end; 462 463 TDipMem = record 464 pContact: Integer; 465 SentCommand: Integer; 466 FormerTreaty: Integer; 467 SentOffer: TOffer; 468 DeliveredPrices: TPriceSet; 469 ReceivedPrices: TPriceSet; 470 end; 471 472 TCurrentMoveInfo = record 473 AfterMovePaintRadius: Integer; 474 AfterAttackExpeller: Integer; 475 DoShow: Boolean; 476 IsAlly: Boolean; 429 477 end; 430 478 … … 433 481 AdvIcon: array [0 .. nAdv - 1] of Integer; 434 482 { icons displayed with the technologies } 435 xxt, yyt, // half of tile size x/y436 483 GameMode: Integer; 437 484 ClientMode: Integer; 438 485 Age: Integer; 439 486 UnFocus: Integer; 440 OptionChecked: Integer;441 MapOptionChecked: Integer;487 OptionChecked: TSaveOptions; 488 MapOptionChecked: TMapOptions; 442 489 nLostArmy: Integer; 443 490 ScienceSum: Integer; 444 491 TaxSum: Integer; 445 SoundPreloadDone: Integer;492 SoundPreloadDone: TSoundBlocks; 446 493 MarkCityLoc: Integer; 447 HGrTerrain: Integer;448 HGrCities: Integer;449 494 MovieSpeed: Integer; 450 495 CityRepMask: Cardinal; … … 461 506 TribeOriginal: array [0 .. nPl - 1] of Boolean; 462 507 LostArmy: array [0 .. nPl * nMmax - 1] of Integer; 463 DipMem: array [0 .. nPl - 1] of record 464 pContact: Integer; 465 SentCommand: Integer; 466 FormerTreaty: Integer; 467 SentOffer: TOffer; 468 DeliveredPrices: TPriceSet; 469 ReceivedPrices: TPriceSet; 470 end; 508 DipMem: array [0 .. nPl - 1] of TDipMem; 471 509 472 510 function CityEventName(i: integer): string; … … 485 523 486 524 uses 487 Directories, IsoEngine,CityScreen, Draft, MessgEx, Select, CityType, Help,525 Directories, CityScreen, Draft, MessgEx, Select, CityType, Help, 488 526 UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego, UPixelPointer, Sound, 489 527 Battle, Rates, TechTree, Registry, Global, UKeyBindings; … … 530 568 flImmUpdate = $0002; 531 569 532 nSaveOption = 22;533 534 570 var 535 Jump: array [0 .. nPl - 1] of integer; 536 pTurn, pLogo, UnStartLoc, ToldSlavery: integer; 537 SmallScreen, GameOK, MapValid, skipped, idle: boolean; 538 539 SaveOption: array [0..nSaveOption - 1] of integer; 540 MiniColors: array [0..11, 0..1] of TColor; 541 MainMap: TIsoMap; 542 CurrentMoveInfo: record AfterMovePaintRadius, AfterAttackExpeller: integer; 543 DoShow, IsAlly: boolean; 544 end; 571 Jump: array [0 .. nPl - 1] of Integer; 572 pTurn: Integer; 573 pLogo: Integer; 574 UnStartLoc: Integer; 575 ToldSlavery: Integer; 576 SmallScreen: Boolean; 577 GameOK: Boolean; 578 MapValid: Boolean; 579 Skipped: Boolean; 580 Idle: Boolean; 581 582 SaveOption: array of Integer; 583 CurrentMoveInfo: TCurrentMoveInfo; 545 584 546 585 function CityEventName(i: integer): string; … … 757 796 for emix := 0 to MyRO.nEnemyModel - 1 do 758 797 with MyRO.EnemyModel[emix] do 759 if Tribe[Owner].ModelPicture[mix].HGr = 0then798 if not Assigned(Tribe[Owner].ModelPicture[mix].HGr) then 760 799 InitEnemyModel(emix); 761 800 end; … … 840 879 while MyData.ToldModels < MyRO.nModel do 841 880 begin { new Unit class available } 842 if (ModelPicture[MyData.ToldModels].HGr > 0) and881 if Assigned(ModelPicture[MyData.ToldModels].HGr) and 843 882 (MyModel[MyData.ToldModels].Kind <> mkSelfDeveloped) then 844 883 begin // save picture of DevModel 845 884 ModelPicture[MyData.ToldModels + 1] := ModelPicture[MyData.ToldModels]; 846 885 ModelName[MyData.ToldModels + 1] := ModelName[MyData.ToldModels]; 847 ModelPicture[MyData.ToldModels].HGr := 0848 end; 849 if ModelPicture[MyData.ToldModels].HGr = 0then886 ModelPicture[MyData.ToldModels].HGr := nil; 887 end; 888 if not Assigned(ModelPicture[MyData.ToldModels].HGr) then 850 889 InitMyModel(MyData.ToldModels, true); 851 890 { only run if no researched model } … … 878 917 Server(cSetModelName + (Length(ModelNameInfo.NewName) + 1 + 4 + 3) 879 918 div 4, me, 0, ModelNameInfo); 880 end 919 end; 881 920 end; 882 921 if MyModel[MyData.ToldModels].Kind = mkSettler then … … 890 929 end; 891 930 892 procedure PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer);931 procedure TMainScreen.PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer); 893 932 894 933 procedure TSprite(xDst, yDst, xSrc, ySrc: integer); 895 934 begin 896 Sprite(dst, HGrTerrain, x + xDst, y + yDst, xxt * 2, yyt * 3, 897 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 935 with NoMapPanel do 936 Sprite(dst, HGrTerrain, x + xDst, y + yDst, xxt * 2, yyt * 3, 937 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 898 938 end; 899 939 900 940 procedure TSprite4(xSrc, ySrc: integer); 901 941 begin 902 Sprite(dst, HGrTerrain, x + xxt, y + yyt + 2, xxt * 2, yyt * 2 - 2, 903 1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1)); 904 Sprite(dst, HGrTerrain, x + 4, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 905 5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 906 Sprite(dst, HGrTerrain, x + xxt * 2, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 907 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 908 Sprite(dst, HGrTerrain, x + xxt, y + yyt * 3, xxt * 2, yyt * 2 - 2, 909 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 942 with NoMapPanel do begin 943 Sprite(dst, HGrTerrain, x + xxt, y + yyt + 2, xxt * 2, yyt * 2 - 2, 944 1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1)); 945 Sprite(dst, HGrTerrain, x + 4, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 946 5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 947 Sprite(dst, HGrTerrain, x + xxt * 2, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 948 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 949 Sprite(dst, HGrTerrain, x + xxt, y + yyt * 3, xxt * 2, yyt * 2 - 2, 950 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 951 end; 910 952 end; 911 953 … … 913 955 cix, ySrc, Tile: integer; 914 956 begin 915 Tile := MyMap[Loc]; 916 if Tile and fCity <> 0 then 917 begin 918 if MyRO.Tech[adRailroad] >= tsApplicable then 919 Tile := Tile or fRR 957 with NoMapPanel do begin 958 Tile := MyMap[Loc]; 959 if Tile and fCity <> 0 then 960 begin 961 if MyRO.Tech[adRailroad] >= tsApplicable then 962 Tile := Tile or fRR 963 else 964 Tile := Tile or fRoad; 965 if Tile and fOwned <> 0 then 966 begin 967 cix := MyRO.nCity - 1; 968 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 969 dec(cix); 970 assert(cix >= 0); 971 if MyCity[cix].Built[imSupermarket] > 0 then 972 Tile := Tile or tiFarm 973 else 974 Tile := Tile or tiIrrigation; 975 end 976 else Tile := Tile or tiIrrigation; 977 end; 978 979 if Tile and fTerrain >= fForest then 980 TSprite4(2, 2) 920 981 else 921 Tile := Tile or fRoad; 922 if Tile and fOwned <> 0 then 923 begin 924 cix := MyRO.nCity - 1; 925 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 926 dec(cix); 927 assert(cix >= 0); 928 if MyCity[cix].Built[imSupermarket] > 0 then 929 Tile := Tile or tiFarm 982 TSprite4(Tile and fTerrain, 0); 983 if Tile and fTerrain >= fForest then 984 begin 985 if (Tile and fTerrain = fForest) and IsJungle(Loc div G.lx) then 986 ySrc := 18 930 987 else 931 Tile := Tile or tiIrrigation; 932 end 933 else 934 Tile := Tile or tiIrrigation; 935 end; 936 937 if Tile and fTerrain >= fForest then 938 TSprite4(2, 2) 939 else 940 TSprite4(Tile and fTerrain, 0); 941 if Tile and fTerrain >= fForest then 942 begin 943 if (Tile and fTerrain = fForest) and IsJungle(Loc div G.lx) then 944 ySrc := 18 945 else 946 ySrc := 3 + 2 * (Tile and fTerrain - fForest); 947 TSprite(xxt, 0, 6, ySrc); 948 TSprite(0, yyt, 3, ySrc); 949 TSprite((xxt * 2), yyt, 4, ySrc + 1); 950 TSprite(xxt, (yyt * 2), 1, ySrc + 1); 951 end; 952 953 // irrigation 954 case Tile and fTerImp of 955 tiIrrigation: 956 begin 988 ySrc := 3 + 2 * (Tile and fTerrain - fForest); 989 TSprite(xxt, 0, 6, ySrc); 990 TSprite(0, yyt, 3, ySrc); 991 TSprite((xxt * 2), yyt, 4, ySrc + 1); 992 TSprite(xxt, (yyt * 2), 1, ySrc + 1); 993 end; 994 995 // irrigation 996 case Tile and fTerImp of 997 tiIrrigation: begin 957 998 TSprite(xxt, 0, 0, 12); 958 999 TSprite(xxt * 2, yyt, 0, 12); 959 1000 end; 960 tiFarm: 961 begin 1001 tiFarm: begin 962 1002 TSprite(xxt, 0, 1, 12); 963 1003 TSprite(xxt * 2, yyt, 1, 12); 964 end 965 end; 966 967 // river/canal/road/railroad 968 if Tile and fRiver <> 0 then 969 begin 970 TSprite(0, yyt, 2, 14); 971 TSprite(xxt, (yyt * 2), 2, 14); 972 end; 973 if Tile and fCanal <> 0 then 974 begin 975 TSprite(xxt, 0, 7, 11); 976 TSprite(xxt, 0, 3, 11); 977 TSprite(xxt * 2, yyt, 7, 11); 978 TSprite(xxt * 2, yyt, 3, 11); 979 end; 980 if Tile and fRR <> 0 then 981 begin 982 TSprite((xxt * 2), yyt, 1, 10); 983 TSprite((xxt * 2), yyt, 5, 10); 984 TSprite(xxt, (yyt * 2), 1, 10); 985 TSprite(xxt, (yyt * 2), 5, 10); 986 end 987 else if Tile and fRoad <> 0 then 988 begin 989 TSprite((xxt * 2), yyt, 8, 9); 990 TSprite((xxt * 2), yyt, 5, 9); 991 TSprite(xxt, (yyt * 2), 1, 9); 992 TSprite(xxt, (yyt * 2), 5, 9); 993 end; 994 995 if Tile and fPoll <> 0 then 996 TSprite(xxt, (yyt * 2), 6, 12); 997 998 // special 999 if Tile and (fTerrain or fSpecial) = fGrass or fSpecial1 then 1000 TSprite4(2, 1) 1001 else if Tile and fSpecial <> 0 then 1002 if Tile and fTerrain < fForest then 1003 TSprite(0, yyt, Tile and fTerrain, Tile and fSpecial shr 5) 1004 else if (Tile and fTerrain = fForest) and IsJungle(Loc div G.lx) then 1005 TSprite(0, yyt, 8, 17 + Tile and fSpecial shr 5) 1006 else 1007 TSprite(0, yyt, 8, 2 + (Tile and fTerrain - fForest) * 2 + Tile and 1008 fSpecial shr 5) 1009 else if Tile and fDeadLands <> 0 then 1010 begin 1011 TSprite4(6, 2); 1012 TSprite(xxt, yyt, 8, 12 + Tile shr 25 and 3); 1013 end; 1014 1015 // other improvements 1016 case Tile and fTerImp of 1017 tiMine: 1018 TSprite(xxt, 0, 2, 12); 1019 tiFort: 1020 begin 1004 end; 1005 end; 1006 1007 // river/canal/road/railroad 1008 if Tile and fRiver <> 0 then begin 1009 TSprite(0, yyt, 2, 14); 1010 TSprite(xxt, (yyt * 2), 2, 14); 1011 end; 1012 if Tile and fCanal <> 0 then begin 1013 TSprite(xxt, 0, 7, 11); 1014 TSprite(xxt, 0, 3, 11); 1015 TSprite(xxt * 2, yyt, 7, 11); 1016 TSprite(xxt * 2, yyt, 3, 11); 1017 end; 1018 if Tile and fRR <> 0 then begin 1019 TSprite((xxt * 2), yyt, 1, 10); 1020 TSprite((xxt * 2), yyt, 5, 10); 1021 TSprite(xxt, (yyt * 2), 1, 10); 1022 TSprite(xxt, (yyt * 2), 5, 10); 1023 end 1024 else if Tile and fRoad <> 0 then begin 1025 TSprite((xxt * 2), yyt, 8, 9); 1026 TSprite((xxt * 2), yyt, 5, 9); 1027 TSprite(xxt, (yyt * 2), 1, 9); 1028 TSprite(xxt, (yyt * 2), 5, 9); 1029 end; 1030 1031 if Tile and fPoll <> 0 then 1032 TSprite(xxt, (yyt * 2), 6, 12); 1033 1034 // special 1035 if Tile and (fTerrain or fSpecial) = fGrass or fSpecial1 then TSprite4(2, 1) 1036 else if Tile and fSpecial <> 0 then 1037 if Tile and fTerrain < fForest then 1038 TSprite(0, yyt, Tile and fTerrain, Tile and fSpecial shr 5) 1039 else if (Tile and fTerrain = fForest) and IsJungle(Loc div G.lx) then 1040 TSprite(0, yyt, 8, 17 + Tile and fSpecial shr 5) 1041 else 1042 TSprite(0, yyt, 8, 2 + (Tile and fTerrain - fForest) * 2 + Tile and 1043 fSpecial shr 5) 1044 else if Tile and fDeadLands <> 0 then begin 1045 TSprite4(6, 2); 1046 TSprite(xxt, yyt, 8, 12 + Tile shr 25 and 3); 1047 end; 1048 1049 // other improvements 1050 case Tile and fTerImp of 1051 tiMine: TSprite(xxt, 0, 2, 12); 1052 tiFort: begin 1021 1053 TSprite(xxt, 0, 7, 12); 1022 1054 TSprite(xxt, 0, 3, 12); 1023 1055 end; 1024 tiBase:1025 TSprite(xxt, 0, 4, 12);1056 tiBase: TSprite(xxt, 0, 4, 12); 1057 end; 1026 1058 end; 1027 1059 end; … … 1041 1073 begin 1042 1074 result := false; 1043 exit 1075 exit; 1044 1076 end; 1045 1077 ChosenResearch := ModalSelectDlg.result; … … 1048 1080 DraftDlg.ShowNewContent(wmModal); 1049 1081 if DraftDlg.ModalResult <> mrOK then 1050 Tribe[me].ModelPicture[MyRO.nModel].HGr := 01082 Tribe[me].ModelPicture[MyRO.nModel].HGr := nil 1051 1083 end; 1052 1084 until (ChosenResearch <> adMilitary) or (DraftDlg.ModalResult = mrOK); … … 1232 1264 procedure TMainScreen.SetMapOptions; 1233 1265 begin 1234 IsoEngine.Options := MapOptionChecked; 1266 MiniMap.MapOptions := MapOptionChecked; 1267 MapOptions := MapOptionChecked; 1235 1268 if ClientMode = cEditMap then 1236 IsoEngine.Options := IsoEngine.Options or (1 shl moEditMode);1269 MapOptions := MapOptions + [moEditMode]; 1237 1270 if mLocCodes.Checked then 1238 IsoEngine.Options := IsoEngine.Options or (1 shl moLocCodes);1271 MapOptions := MapOptions + [moLocCodes]; 1239 1272 end; 1240 1273 … … 1321 1354 end; 1322 1355 1323 procedure TMainScreen.SoundPreload(Check: integer);1356 procedure TMainScreen.SoundPreload(Check: TSoundBlocks); 1324 1357 const 1325 1358 nStartBlock = 27; … … 1357 1390 mi: TModelInfo; 1358 1391 begin 1359 if Check and sbStart and not SoundPreloadDone <> 0 then 1360 begin 1392 if (sbStart in Check) and not (sbStart in SoundPreloadDone) then begin 1361 1393 for i := 0 to nStartBlock - 1 do 1362 1394 PreparePlay(StartBlock[i]); 1363 SoundPreloadDone := SoundPreloadDone or sbStart; 1364 end; 1365 if Check and sbWonder and not SoundPreloadDone <> 0 then 1366 begin 1395 SoundPreloadDone := SoundPreloadDone + [sbStart]; 1396 end; 1397 if (sbWonder in Check) and not (sbWonder in SoundPreloadDone) then begin 1367 1398 need := false; 1368 for i := 0 to 27do1369 if MyRO.Wonder[i].CityID <> -1then1399 for i := 0 to nWonder - 1 do 1400 if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then 1370 1401 need := true; 1371 if need then 1372 begin 1402 if need then begin 1373 1403 for i := 0 to nWonderBlock - 1 do 1374 1404 PreparePlay(WonderBlock[i]); 1375 SoundPreloadDone := SoundPreloadDone or sbWonder; 1376 end; 1377 end; 1378 if (Check and sbScience and not SoundPreloadDone <> 0) and 1379 (MyRO.Tech[adScience] >= tsApplicable) then 1380 begin 1405 SoundPreloadDone := SoundPreloadDone + [sbWonder]; 1406 end; 1407 end; 1408 if ((sbScience in Check) and not (sbScience in SoundPreloadDone)) and 1409 (MyRO.Tech[adScience] >= tsApplicable) then begin 1381 1410 for i := 0 to nScienceBlock - 1 do 1382 1411 PreparePlay(ScienceBlock[i]); 1383 SoundPreloadDone := SoundPreloadDone or sbScience; 1384 end; 1385 if (Check and sbContact and not SoundPreloadDone <> 0) and 1386 (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then 1387 begin 1412 SoundPreloadDone := SoundPreloadDone + [sbScience]; 1413 end; 1414 if ((sbContact in Check) and not (sbContact in SoundPreloadDone)) and 1415 (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then begin 1388 1416 for i := 0 to nContactBlock - 1 do 1389 1417 PreparePlay(ContactBlock[i]); 1390 SoundPreloadDone := SoundPreloadDone or sbContact; 1391 end; 1392 if Check and sbTurn <> 0 then 1393 begin 1418 SoundPreloadDone := SoundPreloadDone + [sbContact]; 1419 end; 1420 if sbTurn in Check then begin 1394 1421 if MyRO.Happened and phShipComplete <> 0 then 1395 1422 PreparePlay('MSG_YOUWIN'); … … 1462 1489 $FF - Tribe[i].Color and $FF) * 2; 1463 1490 if TestColorDistance < ColorDistance then 1464 ColorDistance := TestColorDistance 1491 ColorDistance := TestColorDistance; 1465 1492 end; 1466 1493 if ColorDistance > BestColorDistance then 1467 1494 begin 1468 1495 CountBest := 0; 1469 BestColorDistance := ColorDistance 1496 BestColorDistance := ColorDistance; 1470 1497 end; 1471 1498 if ColorDistance = BestColorDistance then … … 1473 1500 inc(CountBest); 1474 1501 if DelphiRandom(CountBest) = 0 then 1475 result := j 1502 result := j; 1476 1503 end; 1477 1504 end; … … 1544 1571 begin 1545 1572 MostCost := TestCost; 1546 IconIndex := imShipComp + i 1573 IconIndex := imShipComp + i; 1547 1574 end; 1548 1575 end; … … 1556 1583 procedure TMainScreen.InitModule; 1557 1584 var 1558 x, y,i, j, Domain: integer;1585 i, j, Domain: integer; 1559 1586 begin 1560 1587 { search icons for advances: } … … 1580 1607 else 1581 1608 AdvIcon[i] := 86 + Domain; 1582 for j := 28to nImp - 1 do1609 for j := nWonder to nImp - 1 do 1583 1610 if Imp[j].Preq = i then 1584 1611 AdvIcon[i] := j; 1585 for j := 28to nImp - 1 do1612 for j := nWonder to nImp - 1 do 1586 1613 if (Imp[j].Preq = i) and (Imp[j].Kind <> ikCommon) then 1587 1614 AdvIcon[i] := j; … … 1589 1616 if i = JobPreq[j] then 1590 1617 AdvIcon[i] := 84; 1591 for j := 0 to 27do1618 for j := 0 to nWonder - 1 do 1592 1619 if Imp[j].Preq = i then 1593 1620 AdvIcon[i] := j; … … 1607 1634 TribeNames := tstringlist.Create; 1608 1635 1609 for x := 0 to 11 do1610 for y := 0 to 1 do1611 MiniColors[x, y] := GrExt[HGrSystem].Data.Canvas.Pixels[66 + x, 67 + y];1612 1636 IsoEngine.Init(InitEnemyModel); 1613 if not IsoEngine.ApplyTileSize(xxt, yyt) and ((xxt <> 48) or (yyt <> 24) or (xxt <> 72))1614 then1615 ApplyTileSize(48, 24);1616 1637 // non-default tile size is missing a file, switch to default 1617 MainMap := TIsoMap.Create;1618 1638 MainMap.SetOutput(offscreen); 1619 1639 … … 1622 1642 SmallImp.PixelFormat := pf24bit; 1623 1643 InitSmallImp; 1624 SoundPreloadDone := 0;1644 SoundPreloadDone := []; 1625 1645 StartRunning := false; 1626 1646 StayOnTop_Ensured := false; … … 1628 1648 sb := TPVScrollbar.Create(Self); 1629 1649 sb.OnUpdate := ScrollBarUpdate; 1650 end; 1651 1652 procedure TMainScreen.DoneModule; 1653 begin 1654 FreeAndNil(SmallImp); 1655 FreeAndNil(UnusedTribeFiles); 1656 FreeAndNil(TribeNames); 1657 // AdvisorDlg.DeInit; 1630 1658 end; 1631 1659 … … 1644 1672 Icon: imRecycling), (Adv: adComputers; Icon: imResLab), 1645 1673 (Adv: adSpaceFlight; Icon: woMIR)); 1674 sbAll = [sbStart, sbWonder, sbScience, sbContact, sbTurn]; 1646 1675 var 1647 1676 p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1, … … 1812 1841 Loc1 := MyCity[0].Loc; 1813 1842 if (ClientMode = cTurn) and (MyRO.Turn = 0) then 1814 begin // move city out of center to not be covered by welcome screen1843 with MainMap do begin // move city out of center to not be covered by welcome screen 1815 1844 dx := MapWidth div (xxt * 5); 1816 1845 if dx > 5 then … … 2020 2049 end; 2021 2050 2022 for i := 0 to 27do2051 for i := 0 to nWonder - 1 do 2023 2052 begin 2024 2053 OwnWonder := false; … … 2029 2058 if MyRO.Wonder[i].CityID <> MyData.ToldWonders[i].CityID then 2030 2059 begin 2031 if MyRO.Wonder[i].CityID = -2then2060 if MyRO.Wonder[i].CityID = WonderDestroyed then 2032 2061 with MessgExDlg do 2033 2062 begin { tell about destroyed wonders } … … 2081 2110 end 2082 2111 else if (MyRO.Wonder[i].EffectiveOwner <> MyData.ToldWonders[i] 2083 .EffectiveOwner) and (MyRO.Wonder[i].CityID > -2) then2112 .EffectiveOwner) and (MyRO.Wonder[i].CityID > WonderDestroyed) then 2084 2113 if MyRO.Wonder[i].EffectiveOwner < 0 then 2085 2114 begin … … 2192 2221 if (MyRO.Turn > 0) and (Loc >= 0) and (Flags and chCaptured = 0) and 2193 2222 (WondersOnly = (Flags and chProduction <> 0) and 2194 (Project0 and cpImp <> 0) and (Project0 and cpIndex < 28)) then2223 (Project0 and cpImp <> 0) and (Project0 and cpIndex < nWonder)) then 2195 2224 begin 2196 2225 if WondersOnly then … … 2509 2538 end; 2510 2539 2511 cReleaseModule: 2512 begin 2513 FreeAndNil(SmallImp); 2514 FreeAndNil(UnusedTribeFiles); 2515 FreeAndNil(TribeNames); 2516 FreeAndNil(MainMap); 2517 IsoEngine.Done; 2518 // AdvisorDlg.DeInit; 2519 end; 2540 cReleaseModule: DoneModule; 2520 2541 2521 2542 cHelpOnly, cStartHelp, cStartCredits: … … 2546 2567 ClientMode := -1; 2547 2568 SetMapOptions; 2548 IsoEngine.pDebugMap := -1;2569 MainMap.pDebugMap := -1; 2549 2570 idle := false; 2550 2571 FillChar(Jump, SizeOf(Jump), 0); … … 2552 2573 Jump[0] := 999999; 2553 2574 GameMode := Command; 2554 for i := 0 to nGrExt - 1 do2555 FillChar(GrExt[i].pixUsed, GrExt[i].Data.height div 49 * 10, 0);2556 IsoEngine.Reset;2575 GrExt.ResetPixUsed; 2576 MainMap.Reset; 2577 NoMap.Reset; 2557 2578 Tribes.Init; 2558 2579 GetTribeList; … … 2574 2595 inc(ToldAlive, 1 shl i); 2575 2596 PeaceEvaHappened := 0; 2576 for i := 0 to 27do2597 for i := 0 to nWonder - 1 do 2577 2598 with ToldWonders[i] do 2578 2599 begin … … 2582 2603 FillChar(ToldTech, SizeOf(ToldTech), Byte(tsNA)); 2583 2604 if G.Difficulty[p1] > 0 then 2584 SoundPreload( sbStart);2605 SoundPreload([sbStart]); 2585 2606 end; 2586 2607 … … 2607 2628 CityDlg.Reset; 2608 2629 2609 Mini .SetSize(G.lx * 2, G.ly);2630 MiniMap.Size := Point(G.lx, G.ly); 2610 2631 for i := 0 to nPl - 1 do 2611 2632 begin … … 2791 2812 ItsMeAgain(p1); 2792 2813 for mix := 0 to MyRO.nModel - 1 do 2793 if Tribe[me].ModelPicture[mix].HGr = 0then2814 if not Assigned(Tribe[me].ModelPicture[mix].HGr) then 2794 2815 InitMyModel(mix, true); 2795 2816 end; … … 2810 2831 MyData := G.RO[NewPlayer].Data; 2811 2832 SetTroopLoc(-1); 2812 Mini Paint;2833 MiniMapPaint; 2813 2834 InitAllEnemyModels; // necessary for correct replay 2814 2835 if not EndTurn(true) then … … 2871 2892 ClientMode := cEditMap; 2872 2893 SetMapOptions; 2873 IsoEngine.pDebugMap := -1;2894 MainMap.pDebugMap := -1; 2874 2895 ItsMeAgain(0); 2875 2896 MyData := nil; … … 3081 3102 begin 3082 3103 CurrentMoveInfo.DoShow := false; 3083 if not idle and ( Tribe[Owner].ModelPicture[mix].HGr = 0) then3104 if not idle and (not Assigned(Tribe[Owner].ModelPicture[mix].HGr)) then 3084 3105 InitEnemyModel(emix); 3085 3106 … … 3276 3297 begin 3277 3298 ToLoc := dLoc(FromLoc, dx, dy); 3278 if Tribe[Owner].ModelPicture[mix].HGr = 0then3299 if not Assigned(Tribe[Owner].ModelPicture[mix].HGr) then 3279 3300 InitEnemyModel(emix); 3280 3301 … … 3367 3388 cRefreshDebugMap: 3368 3389 begin 3369 if integer(Data) = IsoEngine.pDebugMap then3390 if integer(Data) = MainMap.pDebugMap then 3370 3391 begin 3371 3392 MapValid := false; … … 3409 3430 if TribeOriginal[NewPlayer] then 3410 3431 Tribe[NewPlayer].ModelName[mix] := NewName; 3411 end 3412 end 3432 end; 3433 end; 3413 3434 end; 3414 3435 … … 3419 3440 i, j: integer; 3420 3441 begin 3442 NoMap := TIsoMap.Create; 3443 MainMap := TIsoMap.Create; 3444 NoMapPanel := TIsoMap.Create; 3445 3421 3446 KeyBindings.LoadFromRegistry(HKEY_CURRENT_USER, AppRegistryKey + '\KeyBindings'); 3422 3447 UpdateKeyShortcuts; … … 3425 3450 BaseWin.CreateOffscreen(Offscreen); 3426 3451 3427 // define which menu settings to save 3452 // define which menu settings to save 3453 SetLength(SaveOption, 22); 3428 3454 SaveOption[0] := mAlEffectiveMovesOnly.Tag; 3429 3455 SaveOption[1] := mEnMoves.Tag; … … 3457 3483 for i := 0 to ComponentCount - 1 do 3458 3484 if Components[i].Tag and $FF <> 0 then 3459 if Components[i] is TDpiMenuItem then 3460 begin 3485 if Components[i] is TDpiMenuItem then begin 3461 3486 TDpiMenuItem(Components[i]).Caption := Phrases.Lookup('CONTROLS', 3462 3487 -1 + Components[i].Tag and $FF); 3463 for j := 0 to nSaveOption- 1 do3488 for j := 0 to Length(SaveOption) - 1 do 3464 3489 if Components[i].Tag and $FF = SaveOption[j] then 3465 TDpiMenuItem(Components[i]).Checked := ((1 shl j) and OptionChecked) <> 0; 3466 end 3467 else if Components[i] is TButtonBase then 3468 begin 3490 TDpiMenuItem(Components[i]).Checked := TSaveOption(j) in OptionChecked; 3491 end else 3492 if Components[i] is TButtonBase then begin 3469 3493 TButtonBase(Components[i]).Hint := Phrases.Lookup('CONTROLS', 3470 3494 -1 + Components[i].Tag and $FF); … … 3472 3496 (TButtonC(Components[i]).ButtonIndex <> 1) then 3473 3497 TButtonC(Components[i]).ButtonIndex := 3474 MapOptionCheckedshr (Components[i].Tag shr 8) and 1 + 23498 Integer(MapOptionChecked) shr (Components[i].Tag shr 8) and 1 + 2 3475 3499 end; 3476 3500 … … 3492 3516 end; 3493 3517 3494 Mini := TDpiBitmap.Create; 3495 Mini.PixelFormat := pf24bit; 3518 MiniMap := TMiniMap.Create; 3496 3519 Panel := TDpiBitmap.Create; 3497 3520 Panel.PixelFormat := pf24bit; … … 3504 3527 Buffer := TDpiBitmap.Create; 3505 3528 Buffer.PixelFormat := pf24bit; 3506 if 2 * lxmax > 3 * xSizeBig then 3507 Buffer.width := 2 * lxmax 3508 else 3509 Buffer.width := 3 * xSizeBig; 3510 if lymax > 3 * ySizeBig then 3511 Buffer.height := lymax 3512 else 3513 Buffer.height := 3 * ySizeBig; 3529 if 2 * lxmax > 3 * xSizeBig then Buffer.width := 2 * lxmax 3530 else Buffer.width := 3 * xSizeBig; 3531 if lymax > 3 * ySizeBig then Buffer.height := lymax 3532 else Buffer.height := 3 * ySizeBig; 3514 3533 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 3515 3534 for i := 0 to nPl - 1 do … … 3517 3536 Canvas.Font.Assign(UniFont[ftSmall]); 3518 3537 InitButtons; 3519 EOT.Template := Templates ;3538 EOT.Template := Templates.Data; 3520 3539 end; 3521 3540 … … 3528 3547 FreeAndNil(sb); 3529 3548 FreeAndNil(TopBar); 3530 FreeAndNil(Mini );3549 FreeAndNil(MiniMap); 3531 3550 FreeAndNil(Buffer); 3532 3551 FreeAndNil(Panel); … … 3535 3554 FreeAndNil(AILogo[I]); 3536 3555 FreeAndNil(Offscreen); 3556 FreeAndNil(MainMap); 3557 FreeAndNil(NoMap); 3558 FreeAndNil(NoMapPanel); 3537 3559 end; 3538 3560 3539 3561 procedure TMainScreen.FormMouseWheel(Sender: TObject; Shift: TShiftState; 3540 3562 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 3541 begin 3542 if sb.ProcessMouseWheel(WheelDelta) then begin 3543 PanelPaint; 3544 Update; 3563 var 3564 MouseLoc: Integer; 3565 begin 3566 if (MousePos.Y > ClientHeight - MidPanelHeight) and 3567 (MousePos.Y < ClientHeight) then begin 3568 if sb.ProcessMouseWheel(WheelDelta) then begin 3569 PanelPaint; 3570 Update; 3571 end; 3572 end else begin 3573 if (WheelDelta > 0) and (MainMap.TileSize < High(TTileSize)) then begin 3574 MouseLoc := LocationOfScreenPixel(MousePos.X, MousePos.Y); 3575 SetTileSize(Succ(MainMap.TileSize), MouseLoc, Point(MousePos.X, MousePos.Y)); 3576 end 3577 else if (WheelDelta < 0) and (MainMap.TileSize > Low(TTileSize)) then begin 3578 MouseLoc := LocationOfScreenPixel(MousePos.X, MousePos.Y); 3579 SetTileSize(Pred(MainMap.TileSize), MouseLoc, Point(MousePos.X, MousePos.Y)); 3580 end; 3545 3581 end; 3546 3582 end; … … 3551 3587 begin 3552 3588 SmallScreen := ClientWidth < 1024; 3553 MaxMapWidth := (G.lx * 2 - 3) * xxt; 3554 // avoide the same tile being visible left and right 3555 if ClientWidth <= MaxMapWidth then 3556 begin 3557 MapWidth := ClientWidth; 3558 MapOffset := 0; 3559 end 3560 else 3561 begin 3562 MapWidth := MaxMapWidth; 3563 MapOffset := (ClientWidth - MapWidth) div 2; 3564 end; 3565 MapHeight := ClientHeight - TopBarHeight - PanelHeight + overlap; 3566 Panel.SetSize(ClientWidth, PanelHeight); 3567 TopBar.SetSize(ClientWidth, TopBarHeight); 3568 MiniFrame := (lxmax_xxx - G.ly) div 2; 3569 xMidPanel := (G.lx + MiniFrame) * 2 + 1; 3570 xRightPanel := ClientWidth - LeftPanelWidth - 10; 3571 if ClientMode = cEditMap then 3572 TrPitch := 2 * xxt 3573 else 3574 TrPitch := 66; 3575 xMini := MiniFrame - 5; 3576 yMini := (PanelHeight - 26 - lxmax_xxx) div 2 + MiniFrame; 3577 ywmax := (G.ly - MapHeight div yyt + 1) and not 1; 3578 ywcenter := -((MapHeight - yyt * (G.ly - 1)) div (4 * yyt)) * 2; 3589 with MainMap do begin 3590 MaxMapWidth := (G.lx * 2 - 3) * xxt; 3591 // avoide the same tile being visible left and right 3592 if ClientWidth <= MaxMapWidth then begin 3593 MapWidth := ClientWidth; 3594 MapOffset := 0; 3595 end else begin 3596 MapWidth := MaxMapWidth; 3597 MapOffset := (ClientWidth - MapWidth) div 2; 3598 end; 3599 MapHeight := ClientHeight - TopBarHeight - PanelHeight + overlap; 3600 Panel.SetSize(ClientWidth, PanelHeight); 3601 TopBar.SetSize(ClientWidth, TopBarHeight); 3602 MiniFrame := (lxmax_xxx - G.ly) div 2; 3603 xMidPanel := (G.lx + MiniFrame) * 2 + 1; 3604 xRightPanel := ClientWidth - LeftPanelWidth - 10; 3605 if ClientMode = cEditMap then 3606 TrPitch := 2 * xxt 3607 else 3608 TrPitch := 66; 3609 xMini := MiniFrame - 5; 3610 yMini := (PanelHeight - 26 - lxmax_xxx) div 2 + MiniFrame; 3611 ywmax := (G.ly - MapHeight div yyt + 1) and not 1; 3612 ywcenter := -((MapHeight - yyt * (G.ly - 1)) div (4 * yyt)) * 2; 3613 end; 3579 3614 // only for ywmax<=0 3580 3615 if ywmax <= 0 then … … 3678 3713 xTroop := xMidPanel + 15 3679 3714 else 3680 begin3715 with MainMap do begin 3681 3716 if supervising then 3682 3717 xTerrain := xMidPanel + 2 * xxt + 14 … … 3947 3982 xs, ys, xl, yl: integer; 3948 3983 begin 3949 xl := nx * xxt + xxt; 3950 yl := ny * yyt + yyt * 2; 3951 xs := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 3952 // |xs+xl/2-MapWidth/2| -> min 3953 while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) < 3954 abs(2 * xs + xl - MapWidth) do 3955 inc(xs, G.lx * (xxt * 2)); 3956 ys := (y0 - yw) * yyt - yyt; 3957 if xs + xl > MapWidth then 3958 xl := MapWidth - xs; 3959 if ys + yl > MapHeight then 3960 yl := MapHeight - ys; 3961 if (xl <= 0) or (yl <= 0) then 3962 exit; 3963 if Options and prPaint <> 0 then 3964 begin 3965 if Options and prAutoBounds <> 0 then 3966 MainMap.SetPaintBounds(xs, ys, xs + xl, ys + yl); 3967 MainMap.Paint(xs, ys, x0 + G.lx * y0, nx, ny, -1, -1); 3968 end; 3969 if Options and prInvalidate <> 0 then 3970 RectInvalidate(MapOffset + xs, TopBarHeight + ys, MapOffset + xs + xl, 3971 TopBarHeight + ys + yl) 3984 with MainMap do begin 3985 xl := nx * xxt + xxt; 3986 yl := ny * yyt + yyt * 2; 3987 xs := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 3988 // |xs+xl/2-MapWidth/2| -> min 3989 while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) < 3990 abs(2 * xs + xl - MapWidth) do 3991 inc(xs, G.lx * (xxt * 2)); 3992 ys := (y0 - yw) * yyt - yyt; 3993 if xs + xl > MapWidth then 3994 xl := MapWidth - xs; 3995 if ys + yl > MapHeight then 3996 yl := MapHeight - ys; 3997 if (xl <= 0) or (yl <= 0) then 3998 exit; 3999 if Options and prPaint <> 0 then begin 4000 if Options and prAutoBounds <> 0 then 4001 MainMap.SetPaintBounds(xs, ys, xs + xl, ys + yl); 4002 MainMap.Paint(xs, ys, x0 + G.lx * y0, nx, ny, -1, -1); 4003 end; 4004 if Options and prInvalidate <> 0 then 4005 RectInvalidate(MapOffset + xs, TopBarHeight + ys, MapOffset + xs + xl, 4006 TopBarHeight + ys + yl) 4007 end; 3972 4008 end; 3973 4009 … … 3976 4012 yLoc, x0: integer; 3977 4013 begin 3978 if MapValid then 3979 begin 4014 if MapValid then begin 3980 4015 yLoc := (Loc + G.lx * 1024) div G.lx - 1024; 3981 4016 x0 := (Loc + (yLoc and 1 - 2 * Radius + G.lx * 1024) div 2) mod G.lx; … … 3984 4019 prPaint or prAutoBounds or prInvalidate); 3985 4020 Update; 3986 end 3987 end; 3988 3989 procedure TMainScreen.PaintLocTemp(Loc: integer; Style: integer);4021 end; 4022 end; 4023 4024 procedure TMainScreen.PaintLocTemp(Loc: integer; Style: TPaintLocTempStyle); 3990 4025 var 3991 4026 y0, x0, xMap, yMap: integer; 3992 4027 begin 3993 if not MapValid then 3994 exit; 3995 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 3996 y0 := Loc div G.lx; 3997 x0 := Loc mod G.lx; 3998 xMap := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 3999 // |xMap+xxt-MapWidth/2| -> min 4000 while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) < 4001 abs(2 * xMap + 2 * xxt - MapWidth) do 4002 inc(xMap, G.lx * (xxt * 2)); 4003 yMap := (y0 - yw) * yyt - yyt; 4004 NoMap.SetOutput(Buffer); 4005 NoMap.SetPaintBounds(0, 0, 2 * xxt, 3 * yyt); 4006 NoMap.Paint(0, 0, Loc, 1, 1, -1, -1, Style = pltsBlink); 4007 PaintBufferToScreen(xMap, yMap, 2 * xxt, 3 * yyt); 4028 with NoMap do begin 4029 if not MapValid then 4030 exit; 4031 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 4032 y0 := Loc div G.lx; 4033 x0 := Loc mod G.lx; 4034 xMap := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 4035 // |xMap+xxt-MapWidth/2| -> min 4036 while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) < 4037 abs(2 * xMap + 2 * xxt - MapWidth) do 4038 inc(xMap, G.lx * (xxt * 2)); 4039 yMap := (y0 - yw) * yyt - yyt; 4040 NoMap.SetOutput(Buffer); 4041 NoMap.SetPaintBounds(0, 0, 2 * xxt, 3 * yyt); 4042 NoMap.Paint(0, 0, Loc, 1, 1, -1, -1, Style = pltsBlink); 4043 PaintBufferToScreen(xMap, yMap, 2 * xxt, 3 * yyt); 4044 end; 4008 4045 end; 4009 4046 … … 4033 4070 else 4034 4071 DpiBitCanvas(Canvas, xMap + MapOffset, TopBarHeight, width, 4035 height + yMap, Buffer.Canvas, 0, -yMap) 4072 height + yMap, Buffer.Canvas, 0, -yMap); 4036 4073 end 4037 4074 else … … 4043 4080 DpiBitCanvas(Canvas, xMap + MapOffset, TopBarHeight + yMap, width, 4044 4081 height, Buffer.Canvas, 0, 0); 4045 end 4082 end; 4046 4083 end; 4047 4084 … … 4071 4108 end; 4072 4109 4073 procedure TMainScreen.MiniPaint; 4074 var 4075 uix, cix, x, y, Loc, i, hw, xm, cm, cmPolOcean, cmPolNone: integer; 4076 PrevMiniPixel: TPixelPointer; 4077 MiniPixel: TPixelPointer; 4078 TerrainTile: Cardinal; 4079 begin 4080 cmPolOcean := GrExt[HGrSystem].Data.Canvas.Pixels[101, 67]; 4081 cmPolNone := GrExt[HGrSystem].Data.Canvas.Pixels[102, 67]; 4082 hw := MapWidth div (xxt * 2); 4083 with Mini.Canvas do 4084 begin 4085 Brush.Color := $000000; 4086 FillRect(Rect(0, 0, Mini.width, Mini.height)); 4087 end; 4088 Mini.BeginUpdate; 4089 MiniPixel := PixelPointer(Mini); 4090 PrevMiniPixel := PixelPointer(Mini); 4091 for y := 0 to ScaleToNative(G.ly) - 1 do 4092 begin 4093 for x := 0 to ScaleToNative(G.lx) - 1 do 4094 if MyMap[ScaleFromNative(x) + G.lx * ScaleFromNative(y)] and fTerrain <> fUNKNOWN then 4095 begin 4096 Loc := ScaleFromNative(x) + G.lx * ScaleFromNative(y); 4097 for i := 0 to 1 do 4098 begin 4099 xm := ((x - ScaleToNative(xwMini)) * 2 + i + y and 1 - ScaleToNative(hw) + 4100 ScaleToNative(G.lx) * 5) mod (ScaleToNative(G.lx) * 2); 4101 MiniPixel.SetXY(xm, y); 4102 TerrainTile := MyMap[Loc] and fTerrain; 4103 if TerrainTile > 11 then TerrainTile := 0; 4104 cm := MiniColors[TerrainTile, i]; 4105 if ClientMode = cEditMap then 4106 begin 4107 if MyMap[Loc] and (fPrefStartPos or fStartPos) <> 0 then 4108 cm := $FFFFFF; 4109 end 4110 else if MyMap[Loc] and fCity <> 0 then 4111 begin 4112 cix := MyRO.nCity - 1; 4113 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 4114 dec(cix); 4115 if cix >= 0 then 4116 cm := Tribe[me].Color 4117 else 4118 begin 4119 cix := MyRO.nEnemyCity - 1; 4120 while (cix >= 0) and (MyRO.EnemyCity[cix].Loc <> Loc) do 4121 dec(cix); 4122 if cix >= 0 then 4123 cm := Tribe[MyRO.EnemyCity[cix].Owner].Color 4124 end; 4125 cm := $808080 or cm shr 1; { increase brightness } 4126 if y > 0 then begin 4127 // 2x2 city dot covers two lines 4128 PrevMiniPixel.SetXY(xm, y - 1); 4129 PrevMiniPixel.Pixel^.B := cm shr 16; 4130 PrevMiniPixel.Pixel^.G := cm shr 8 and $FF; 4131 PrevMiniPixel.Pixel^.R := cm and $FF; 4132 end 4133 end 4134 else if (i = 0) and (MyMap[Loc] and fUnit <> 0) then 4135 begin 4136 uix := MyRO.nUn - 1; 4137 while (uix >= 0) and (MyUn[uix].Loc <> Loc) do 4138 dec(uix); 4139 if uix >= 0 then 4140 cm := Tribe[me].Color 4141 else 4142 begin 4143 uix := MyRO.nEnemyUn - 1; 4144 while (uix >= 0) and (MyRO.EnemyUn[uix].Loc <> Loc) do 4145 dec(uix); 4146 if uix >= 0 then 4147 cm := Tribe[MyRO.EnemyUn[uix].Owner].Color 4148 end; 4149 cm := $808080 or cm shr 1; { increase brightness } 4150 end 4151 else if MapOptionChecked and (1 shl moPolitical) <> 0 then 4152 begin 4153 if MyMap[Loc] and fTerrain < fGrass then 4154 cm := cmPolOcean 4155 else if MyRO.Territory[Loc] < 0 then 4156 cm := cmPolNone 4157 else 4158 cm := Tribe[MyRO.Territory[Loc]].Color; 4159 end; 4160 MiniPixel.Pixel^.B := cm shr 16; 4161 MiniPixel.Pixel^.G := cm shr 8 and $FF; 4162 MiniPixel.Pixel^.R := cm and $FF; 4163 end; 4164 end; 4165 end; 4166 Mini.EndUpdate; 4167 end; 4110 {$IFDEF LINUX} 4111 // Can't do scrolling of DC under Linux, then fallback into BitBlt. 4112 function DpiScrollDC(Canvas: TDpiCanvas; dx: longint; dy: longint; const lprcScroll:TRect; const lprcClip:TRect; hrgnUpdate:HRGN; lprcUpdate: PRect):Boolean; 4113 begin 4114 Result := DpiBitCanvas(Canvas, lprcScroll.Left + dx, lprcScroll.Top + dy, lprcScroll.Right - lprcScroll.Left, lprcScroll.Bottom - lprcScroll.Top, 4115 Canvas, lprcScroll.Left, lprcScroll.Top); 4116 end; 4117 {$ENDIF} 4168 4118 4169 4119 procedure TMainScreen.MainOffscreenPaint; … … 4180 4130 Brush.Style := bsClear; 4181 4131 OffscreenUser := self; 4182 exit 4132 exit; 4183 4133 end; 4184 4134 … … 4195 4145 end; 4196 4146 4197 if xw - xwd > G.lx div 2 then 4198 xwd := xwd + G.lx 4199 else if xwd - xw > G.lx div 2 then 4200 xwd := xwd - G.lx; 4201 if not MapValid or (xw - xwd > MapWidth div (xxt * 2)) or 4202 (xwd - xw > MapWidth div (xxt * 2)) or (yw - ywd > MapHeight div yyt) or 4203 (ywd - yw > MapHeight div yyt) then 4204 begin 4205 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4206 ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt, 4207 prPaint or prInvalidate) 4208 end 4209 else 4210 begin 4211 if (xwd = xw) and (ywd = yw) then 4212 exit; { map window not moved } 4213 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4214 rec := Rect(0, 0, MapWidth, MapHeight); 4215 DpiScrollDC(offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4216 rec, rec, 0, nil); 4217 for DoInvalidate := false to FastScrolling do 4218 begin 4219 if DoInvalidate then 4220 begin 4221 rec.Bottom := MapHeight - overlap; 4222 DpiScrollDC(Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec, 4223 rec, 0, nil); 4224 ProcessOptions := prInvalidate; 4225 end 4226 else 4227 ProcessOptions := prPaint or prAutoBounds; 4228 if yw < ywd then 4229 begin 4230 ProcessRect(xw, yw, MapWidth div xxt, ywd - yw - 1, ProcessOptions); 4231 if xw < xwd then 4232 ProcessRect(xw, ywd, (xwd - xw) * 2 - 1, MapHeight div yyt - ywd + yw, 4147 with MainMap do begin 4148 if xw - xwd > G.lx div 2 then 4149 xwd := xwd + G.lx 4150 else if xwd - xw > G.lx div 2 then 4151 xwd := xwd - G.lx; 4152 if not MapValid or (xw - xwd > MapWidth div (xxt * 2)) or 4153 (xwd - xw > MapWidth div (xxt * 2)) or (yw - ywd > MapHeight div yyt) or 4154 (ywd - yw > MapHeight div yyt) then 4155 begin 4156 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4157 ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt, 4158 prPaint or prInvalidate); 4159 end else begin 4160 if (xwd = xw) and (ywd = yw) then 4161 exit; { map window not moved } 4162 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4163 rec := Rect(0, 0, MapWidth, MapHeight); 4164 {$IFDEF WINDOWS} 4165 DpiScrollDC(offscreen.Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4166 rec, rec, 0, nil); 4167 {$ENDIF} 4168 {$IFDEF LINUX} 4169 DpiScrollDC(offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4170 rec, rec, 0, nil); 4171 {$ENDIF} 4172 for DoInvalidate := false to FastScrolling do begin 4173 if DoInvalidate then begin 4174 rec.Bottom := MapHeight - overlap; 4175 {$IFDEF WINDOWS} 4176 DpiScrollDC(Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec, 4177 rec, 0, nil); 4178 {$ENDIF} 4179 {$IFDEF LINUX} 4180 DpiScrollDC(Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4181 rec, rec, 0, nil); 4182 {$ENDIF} 4183 ProcessOptions := prInvalidate; 4184 end 4185 else ProcessOptions := prPaint or prAutoBounds; 4186 if yw < ywd then begin 4187 ProcessRect(xw, yw, MapWidth div xxt, ywd - yw - 1, ProcessOptions); 4188 if xw < xwd then 4189 ProcessRect(xw, ywd, (xwd - xw) * 2 - 1, MapHeight div yyt - ywd + yw, 4190 ProcessOptions) 4191 else if xw > xwd then 4192 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, ywd, 4193 (xw - xwd) * 2 + 1, MapHeight div yyt - ywd + yw, ProcessOptions) 4194 end 4195 else if yw > ywd then begin 4196 if DoInvalidate then 4197 RectInvalidate(MapOffset, TopBarHeight + MapHeight - overlap - 4198 (yw - ywd) * yyt, MapOffset + MapWidth, TopBarHeight + MapHeight 4199 - overlap) 4200 else 4201 ProcessRect(xw, (ywd + MapHeight div (yyt * 2) * 2), MapWidth div xxt, 4202 yw - ywd + 1, ProcessOptions); 4203 if xw < xwd then 4204 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt - yw + ywd - 4205 2, ProcessOptions) 4206 else if xw > xwd then 4207 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, yw, 4208 (xw - xwd) * 2 + 1, MapHeight div yyt - yw + ywd - 2, 4209 ProcessOptions); 4210 end 4211 else if xw < xwd then 4212 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt, 4233 4213 ProcessOptions) 4234 4214 else if xw > xwd then 4235 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, ywd,4236 (xw - xwd) * 2 + 1, MapHeight div yyt - ywd + yw, ProcessOptions)4237 end4238 else if yw > ywd then4239 begin4240 if DoInvalidate then4241 RectInvalidate(MapOffset, TopBarHeight + MapHeight - overlap -4242 (yw - ywd) * yyt, MapOffset + MapWidth, TopBarHeight + MapHeight4243 - overlap)4244 else4245 ProcessRect(xw, (ywd + MapHeight div (yyt * 2) * 2), MapWidth div xxt,4246 yw - ywd + 1, ProcessOptions);4247 if xw < xwd then4248 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt - yw + ywd -4249 2, ProcessOptions)4250 else if xw > xwd then4251 4215 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, yw, 4252 (xw - xwd) * 2 + 1, MapHeight div yyt - yw + ywd - 2, 4253 ProcessOptions) 4254 end 4255 else if xw < xwd then 4256 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt, 4257 ProcessOptions) 4258 else if xw > xwd then 4259 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, yw, 4260 (xw - xwd) * 2 + 1, MapHeight div yyt, ProcessOptions); 4261 end; 4262 if not FastScrolling then 4263 RectInvalidate(MapOffset, TopBarHeight, MapOffset + MapWidth, 4264 TopBarHeight + MapHeight - overlap); 4265 RectInvalidate(xMidPanel, TopBarHeight + MapHeight - overlap, xRightPanel, 4266 TopBarHeight + MapHeight) 4216 (xw - xwd) * 2 + 1, MapHeight div yyt, ProcessOptions); 4217 end; 4218 if not FastScrolling then 4219 RectInvalidate(MapOffset, TopBarHeight, MapOffset + MapWidth, 4220 TopBarHeight + MapHeight - overlap); 4221 RectInvalidate(xMidPanel, TopBarHeight + MapHeight - overlap, xRightPanel, 4222 TopBarHeight + MapHeight); 4223 end; 4267 4224 end; 4268 4225 // if (xwd<>xw) or (ywd<>yw) then … … 4273 4230 end; 4274 4231 4232 procedure TMainScreen.MiniMapPaint; 4233 begin 4234 with MainMap do 4235 MiniMap.Paint(MyMap, MapWidth, ClientMode, xxt, xwMini); 4236 end; 4237 4275 4238 procedure TMainScreen.PaintAll; 4276 4239 begin … … 4278 4241 xwMini := xw; 4279 4242 ywMini := yw; 4280 Mini Paint;4243 MiniMapPaint; 4281 4244 PanelPaint; 4282 4245 end; … … 4287 4250 xwMini := xw; 4288 4251 ywMini := yw; 4289 Mini Paint;4252 MiniMapPaint; 4290 4253 CopyMiniToPanel; 4291 4254 RectInvalidate(xMini + 2, TopBarHeight + MapHeight - overlap + yMini + 2, … … 4296 4259 procedure TMainScreen.CopyMiniToPanel; 4297 4260 begin 4298 DpiBitCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 4299 Mini.Canvas, 0, 0); 4300 if MarkCityLoc >= 0 then 4301 Sprite(Panel, HGrSystem, xMini - 2 + (4 * G.lx + 2 * (MarkCityLoc mod G.lx) 4302 + (G.lx - MapWidth div (xxt * 2)) - 2 * xwd) mod (2 * G.lx) + 4303 MarkCityLoc div G.lx and 1, yMini - 3 + MarkCityLoc div G.lx, 10, 4304 10, 77, 47) 4305 else if ywmax <= 0 then 4306 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2, 4307 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + 2 + G.ly - 1, 4308 MainTexture.clMark, MainTexture.clMark) 4309 else 4310 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (xxt * 2), 4311 yMini + 2 + yw, xMini + 1 + G.lx + MapWidth div (xxt * 2), 4312 yMini + yw + MapHeight div yyt, MainTexture.clMark, MainTexture.clMark); 4261 with MainMap do begin 4262 DpiBitCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 4263 MiniMap.Bitmap.Canvas, 0, 0); 4264 if MarkCityLoc >= 0 then 4265 Sprite(Panel, HGrSystem, xMini - 2 + (4 * G.lx + 2 * (MarkCityLoc mod G.lx) 4266 + (G.lx - MapWidth div (xxt * 2)) - 2 * xwd) mod (2 * G.lx) + 4267 MarkCityLoc div G.lx and 1, yMini - 3 + MarkCityLoc div G.lx, CityMark2.Width, 4268 CityMark2.Height, CityMark2.Left, CityMark2.Top) 4269 else if ywmax <= 0 then 4270 Frame(Panel.Canvas, 4271 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2, 4272 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + 2 + G.ly - 1, 4273 MainTexture.clMark, MainTexture.clMark) 4274 else 4275 Frame(Panel.Canvas, 4276 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2 + yw, 4277 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + yw + MapHeight div yyt, 4278 MainTexture.clMark, MainTexture.clMark); 4279 end; 4313 4280 end; 4314 4281 … … 4336 4303 Prio: boolean; 4337 4304 begin 4305 if not Assigned(MyRO) then Exit; 4338 4306 with Panel.Canvas do 4339 4307 begin … … 4386 4354 $FFFFFF, $B0B0B0); 4387 4355 DpiBitCanvas(Panel.Canvas, ClientWidth - xPalace, yPalace, xSizeBig, 4388 ySizeBig, GrExt[HGrSystem2].Data.Canvas, 70, 123);4356 ySizeBig, HGrSystem2.Data.Canvas, 70, 123); 4389 4357 end 4390 4358 else if MyRO.NatBuilt[imPalace] > 0 then … … 4497 4465 end; 4498 4466 end; 4499 if xSrcBase >= 0 then 4467 with MainMap do begin 4468 if xSrcBase >= 0 then 4469 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2, 4470 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1), 4471 1 + ySrcBase * (yyt * 3 + 1)); 4500 4472 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2, 4501 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1), 4502 1 + ySrcBase * (yyt * 3 + 1)); 4503 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2, 4504 yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 4505 if BrushTypes[i] = BrushType then 4506 begin 4507 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + x, 4508 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + x, 4509 yTroop + 2 * yyt + 11, $000000, $000000); 4510 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + x, 4511 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + x, 4512 yTroop + 2 * yyt + 10, MainTexture.clMark, MainTexture.clMark); 4513 end 4473 yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 4474 if BrushTypes[i] = BrushType then begin 4475 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + x, 4476 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + x, 4477 yTroop + 2 * yyt + 11, $000000, $000000); 4478 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + x, 4479 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + x, 4480 yTroop + 2 * yyt + 10, MainTexture.clMark, MainTexture.clMark); 4481 end; 4482 end; 4514 4483 end; 4515 4484 inc(Count) … … 4571 4540 Brush.Style := bsClear; 4572 4541 if UnFocus >= 0 then 4573 with MyUn[UnFocus], MyModel[mix] do 4542 with MyUn[UnFocus] do 4543 with MyModel[mix] do 4574 4544 begin { display info about selected unit } 4575 4545 if Job = jCity then … … 4600 4570 BiColorTextWidth(Panel.Canvas, s) div 2, PanelHeight - 23, s); 4601 4571 4602 FrameImage(Panel.Canvas, GrExt[HGrSystem].Data,4572 FrameImage(Panel.Canvas, HGrSystem.Data, 4603 4573 xMidPanel + 7 + xUnitText, yTroop + 15, 12, 14, 4604 4574 121 + Exp div ExpCost * 13, 28); … … 4676 4646 xTroop + 63 + x, yTroop + 46, 8, MainTexture.clMark); 4677 4647 end; 4678 NoMap .SetOutput(Panel);4679 NoMap .PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo,4648 NoMapPanel.SetOutput(Panel); 4649 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo, 4680 4650 unx.Status); 4681 4651 if (ClientMode < scContact) and … … 4694 4664 xTroop + x + 34 - BiColorTextWidth(Panel.Canvas, s) 4695 4665 div 2, yTroop - 16, s); 4696 end 4666 end; 4697 4667 end; 4698 4668 inc(Count) … … 4700 4670 end; // for uix:=0 to MyRO.nUn-1 4701 4671 assert(Count = TrCnt); 4702 end 4672 end; 4703 4673 end 4704 4674 else … … 4712 4682 trix[i - TrRow * sb.Position] := i; 4713 4683 x := (i - TrRow * sb.Position) * TrPitch; 4714 NoMap .SetOutput(Panel);4715 NoMap .PaintUnit(xTroop + 2 + x, yTroop + 1,4684 NoMapPanel.SetOutput(Panel); 4685 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, 4716 4686 MyRO.EnemyUn[MyRO.nEnemyUn + i], 0); 4717 4687 end; … … 4720 4690 if not SmallScreen or supervising then 4721 4691 begin // show terrain and improvements 4722 PaintZoomedTile(Panel, xTerrain - xxt * 2, 110 - yyt * 3, TroopLoc);4723 if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then4724 begin4692 with NoMapPanel do 4693 PaintZoomedTile(Panel, xTerrain - xxt * 2, 110 - yyt * 3, TroopLoc); 4694 if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then begin 4725 4695 JobFocus := MyUn[UnFocus].Job; 4726 4696 Server(sGetJobProgress, me, MyUn[UnFocus].Loc, JobProgressData); … … 4770 4740 (PanelHeight - 1), Left + width, Top + height - self.ClientHeight + 4771 4741 PanelHeight, MainTexture.clBevelShade, MainTexture.clBevelLight) 4772 end { if TroopLoc>=0 }4742 end; { if TroopLoc>=0 } 4773 4743 end; 4774 4744 … … 4800 4770 (PanelHeight - 1), Left + width, Top + height - self.ClientHeight + 4801 4771 PanelHeight, MainTexture.clBevelShade, MainTexture.clBevelLight); 4802 end 4772 end; 4803 4773 end; 4804 4774 EOT.SetBack(Panel.Canvas, EOT.Left, EOT.Top - (ClientHeight - PanelHeight)); … … 4828 4798 end; 4829 4799 if GameMode <> cMovie then 4830 ImageOp_BCC(TopBar, Templates , 2, 1, 145, 38, 36, 36, $BFBF20, $4040DF);4800 ImageOp_BCC(TopBar, Templates.Data, Point(2, 1), MenuLogo.BoundsRect, $BFBF20, $4040DF); 4831 4801 if MyRO.nCity > 0 then 4832 4802 begin … … 4844 4814 4845 4815 // treasury section 4846 ImageOp_BCC(TopBar, Templates , xTreasurySection + 8, 1, 145, 1, 36, 36,4816 ImageOp_BCC(TopBar, Templates.Data, Point(xTreasurySection + 8, 1), TreasuryIcon.BoundsRect, 4847 4817 $40A040, $4030C0); 4848 4818 s := IntToStr(TrueMoney); … … 4851 4821 if MyRO.Government <> gAnarchy then 4852 4822 begin 4853 ImageOp_BCC(TopBar, Templates , xTreasurySection + 48, 22, 124, 1, 14, 14,4823 ImageOp_BCC(TopBar, Templates.Data, Point(xTreasurySection + 48, 22), ChangeIcon.BoundsRect, 4854 4824 $0000C0, $0080C0); 4855 4825 if TaxSum >= 0 then … … 4862 4832 4863 4833 // research section 4864 ImageOp_BCC(TopBar, Templates , xResearchSection + 8, 1, 145, 75, 36, 36,4834 ImageOp_BCC(TopBar, Templates.Data, Point(xResearchSection + 8, 1), ResearchIcon.BoundsRect, 4865 4835 $FF0000, $00FFE0); 4866 4836 if MyData.FarTech <> adNexus then … … 4913 4883 if (MyData.FarTech <> adNexus) and (ScienceSum > 0) then 4914 4884 begin 4915 ImageOp_BCC(TopBar, Templates ,xResearchSection + 48 + CostFactor + 11,4916 22 , 124, 1, 14, 14, $0000C0, $0080C0);4885 ImageOp_BCC(TopBar, Templates.Data, Point(xResearchSection + 48 + CostFactor + 11, 4886 22), ChangeIcon.BoundsRect, $0000C0, $0080C0); 4917 4887 s := Format(Phrases.Lookup('TECHGAIN'), [ScienceSum]); 4918 4888 LoweredTextOut(TopBar.Canvas, -1, MainTexture, xResearchSection + 48 + 4919 4889 CostFactor + 26, 18, s); 4920 end 4890 end; 4921 4891 end; 4922 4892 if ClientMode <> cEditMap then … … 4930 4900 end; 4931 4901 RectInvalidate(0, 0, ClientWidth, TopBarHeight); 4932 end; { PanelPaint }4902 end; 4933 4903 4934 4904 procedure TMainScreen.FocusOnLoc(Loc: integer; Options: integer = 0); … … 4937 4907 Outside, Changed: boolean; 4938 4908 begin 4939 dx := G.lx + 1 - (xw - Loc + G.lx * 1024 + 1) mod G.lx; 4940 Outside := (dx >= (MapWidth + 1) div (xxt * 2) - 2) or (ywmax > 0) and 4941 ((yw > 0) and (Loc div G.lx <= yw + 1) or (yw < ywmax) and 4942 (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2)); 4909 with MainMap do begin 4910 dx := G.lx + 1 - (xw - Loc + G.lx * 1024 + 1) mod G.lx; 4911 Outside := (dx >= (MapWidth + 1) div (xxt * 2) - 2) or (ywmax > 0) and 4912 ((yw > 0) and (Loc div G.lx <= yw + 1) or (yw < ywmax) and 4913 (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2)); 4914 end; 4943 4915 Changed := true; 4944 if Outside then 4945 begin 4916 if Outside then begin 4946 4917 Centre(Loc); 4947 PaintAllMaps 4918 PaintAllMaps; 4948 4919 end 4949 4920 else if not MapValid then … … 4980 4951 begin 4981 4952 NewFocus := uix; 4982 Break 4953 Break; 4983 4954 end 4984 4955 else … … 4988 4959 begin 4989 4960 NewFocus := uix; 4990 Dist := TestDist 4991 end 4992 end 4961 Dist := TestDist; 4962 end; 4963 end; 4993 4964 end; 4994 4965 if GotoOnly then … … 5020 4991 PanelPaint; 5021 4992 end; 5022 end; { NextUnit }4993 end; 5023 4994 5024 4995 procedure TMainScreen.Scroll(dx, dy: integer); … … 5036 5007 xwMini := xw; 5037 5008 ywMini := yw; 5038 Mini Paint;5009 MiniMapPaint; 5039 5010 CopyMiniToPanel; 5040 5011 RectInvalidate(xMini + 2, TopBarHeight + MapHeight - overlap + yMini + 2, … … 5046 5017 procedure TMainScreen.Timer1Timer(Sender: TObject); 5047 5018 var 5048 dx, dy, speed: integer;5019 dx, dy, ScrollSpeed: integer; 5049 5020 begin 5050 5021 if idle and (me >= 0) and (GameMode <> cMovie) then … … 5060 5031 PaintLocTemp(MyUn[UnFocus].Loc) 5061 5032 else if TurnComplete and not supervising then 5062 EOT.SetButtonIndexFast(eotBlinkOn) 5063 end 5033 EOT.SetButtonIndexFast(eotBlinkOn); 5034 end; 5064 5035 end 5065 5036 else … … 5067 5038 if DpiApplication.Active and not mScrollOff.Checked then 5068 5039 begin 5069 if mScrollFast.Checked then 5070 speed := 2 5071 else 5072 speed := 1; 5040 if mScrollFast.Checked then ScrollSpeed := 2 5041 else ScrollSpeed := 1; 5073 5042 dx := 0; 5074 5043 dy := 0; 5075 5044 if DpiMouse.CursorPos.y < DpiScreen.height - PanelHeight then 5076 5045 if DpiMouse.CursorPos.x = 0 then 5077 dx := - speed // scroll left5078 else if DpiMouse.CursorPos.x >= DpiScreen.width - 1 then5079 dx := speed; // scroll right5046 dx := -ScrollSpeed // scroll left 5047 else if DpiMouse.CursorPos.x = DpiScreen.width - 1 then 5048 dx := ScrollSpeed; // scroll right 5080 5049 if DpiMouse.CursorPos.y = 0 then 5081 dy := - speed // scroll up5082 else if (DpiMouse.CursorPos.y >= DpiScreen.height - 1) and5050 dy := -ScrollSpeed // scroll up 5051 else if (DpiMouse.CursorPos.y = DpiScreen.height - 1) and 5083 5052 (DpiMouse.CursorPos.x >= TerrainBtn.Left + TerrainBtn.width) and 5084 5053 (DpiMouse.CursorPos.x < xRightPanel + 10 - 8) then 5085 dy := speed; // scroll down5054 dy := ScrollSpeed; // scroll down 5086 5055 if (dx <> 0) or (dy <> 0) then 5087 5056 begin … … 5090 5059 DpiScreen.ActiveForm.OnDeactivate(nil); 5091 5060 Scroll(dx, dy); 5092 end 5061 end; 5093 5062 end; 5094 5063 … … 5104 5073 // if MoveHintToLoc>=0 then 5105 5074 // ShowMoveHint(MoveHintToLoc, true); 5106 end 5075 end; 5107 5076 end 5108 5077 else if TurnComplete and not supervising then … … 5111 5080 EOT.SetButtonIndexFast(eotBlinkOff) 5112 5081 else if BlinkTime = BlinkOffTime then 5113 EOT.SetButtonIndexFast(eotBlinkOn) 5114 end 5115 end 5082 EOT.SetButtonIndexFast(eotBlinkOn); 5083 end; 5084 end; 5085 end; 5086 5087 procedure TMainScreen.SetMapPos(Loc: integer; MapPos: TPoint); 5088 begin 5089 with MainMap do begin 5090 if FastScrolling and MapValid then 5091 Update; 5092 // necessary because ScrollDC for form canvas is called after 5093 xw := (Loc mod G.lx) - (MapPos.X - ((xxt * 2) * ((Loc div G.lx) and 1)) div 2) 5094 div (xxt * 2); 5095 xw := (xw + G.lx) mod G.lx; 5096 if ywmax <= 0 then yw := ywcenter 5097 else begin 5098 yw := (Loc div G.lx - (MapPos.Y * 2) div (yyt * 2) + 1) and not 1; 5099 if yw < 0 then yw := 0 5100 else if yw > ywmax then yw := ywmax; 5101 end; 5102 end; 5116 5103 end; 5117 5104 5118 5105 procedure TMainScreen.Centre(Loc: integer); 5119 5106 begin 5120 if FastScrolling and MapValid then 5121 Update; 5122 // necessary because ScrollDC for form canvas is called after 5123 xw := (Loc mod G.lx - (MapWidth - xxt * 2 * ((Loc div G.lx) and 1)) 5124 div (xxt * 4) + G.lx) mod G.lx; 5125 if ywmax <= 0 then 5126 yw := ywcenter 5127 else 5128 begin 5129 yw := (Loc div G.lx - MapHeight div (yyt * 2) + 1) and not 1; 5130 if yw < 0 then 5131 yw := 0 5132 else if yw > ywmax then 5133 yw := ywmax; 5134 end 5107 SetMapPos(Loc, Point(MapWidth div 2, MapHeight div 2)); 5135 5108 end; 5136 5109 … … 5162 5135 PanelPaint; 5163 5136 ShowNewContent(wmPersistent, Loc, ShowEvent); 5164 end 5165 end; 5166 5167 function TMainScreen.LocationOfScreenPixel(x, y: integer): integer;5137 end; 5138 end; 5139 5140 function TMainScreen.LocationOfScreenPixel(x, y: integer): Integer; 5168 5141 var 5169 5142 qx, qy: integer; 5170 5143 begin 5171 qx := (x * (yyt * 2) + y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1; 5172 qy := (y * (xxt * 2) - x * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt) 5173 div (xxt * yyt * 4) - 999; 5174 result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * 5175 (yw + qx + qy); 5144 with MainMap do begin 5145 qx := (x * (yyt * 2) + y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1; 5146 qy := (y * (xxt * 2) - x * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt) 5147 div (xxt * yyt * 4) - 999; 5148 Result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * 5149 (yw + qx + qy); 5150 end; 5151 end; 5152 5153 function TMainScreen.GetCenterLoc: Integer; 5154 begin 5155 Result := (xw + MapWidth div (MainMap.xxt * 4)) mod G.lx + 5156 (yw + MapHeight div (MainMap.yyt * 2)) * G.lx; 5176 5157 end; 5177 5158 … … 5242 5223 BrushLoc := MouseLoc; 5243 5224 PaintLoc(MouseLoc, 2); 5244 Mini Paint;5225 MiniMapPaint; 5245 5226 DpiBitCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 5246 Mini.Canvas, 0, 0); 5247 if ywmax <= 0 then 5248 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5249 yMini + 2, xMini + 1 + G.lx + MapWidth div (2 * xxt), 5250 yMini + 2 + G.ly - 1, MainTexture.clMark, MainTexture.clMark) 5251 else 5252 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5253 yMini + 2 + yw, xMini + 2 + G.lx + MapWidth div (2 * xxt) - 1, 5254 yMini + 2 + yw + MapHeight div yyt - 2, MainTexture.clMark, 5255 MainTexture.clMark); 5227 MiniMap.Bitmap.Canvas, 0, 0); 5228 with MainMap do begin 5229 if ywmax <= 0 then 5230 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5231 yMini + 2, xMini + 1 + G.lx + MapWidth div (2 * xxt), 5232 yMini + 2 + G.ly - 1, MainTexture.clMark, MainTexture.clMark) 5233 else 5234 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5235 yMini + 2 + yw, xMini + 2 + G.lx + MapWidth div (2 * xxt) - 1, 5236 yMini + 2 + yw + MapHeight div yyt - 2, MainTexture.clMark, 5237 MainTexture.clMark); 5238 end; 5256 5239 RectInvalidate(xMini + 2, TopBarHeight + MapHeight - overlap + yMini + 2, 5257 5240 xMini + 2 + G.lx * 2, TopBarHeight + MapHeight - overlap + yMini 5258 + 2 + G.ly) 5241 + 2 + G.ly); 5259 5242 end 5260 5243 else if MyMap[MouseLoc] and fCity <> 0 then { city clicked } … … 5269 5252 UnitStatDlg.ShowNewContent_EnemyCity(wmPersistent, MouseLoc); 5270 5253 DoCenter := false; 5271 end 5254 end; 5272 5255 end 5273 5256 else if MyMap[MouseLoc] and fUnit <> 0 then { unit clicked } … … 5291 5274 end; 5292 5275 if i = 0 then 5293 uix := UnFocus 5276 uix := UnFocus; 5294 5277 end 5295 5278 else … … 5317 5300 begin 5318 5301 Centre(MouseLoc); 5319 PaintAllMaps 5320 end 5302 PaintAllMaps; 5303 end; 5321 5304 end 5322 5305 else if (ClientMode <> cEditMap) and (Button = mbRight) and … … 5338 5321 MyRO.EnemyModel[emix].mix, MouseLoc) >= rExecuted) then 5339 5322 begin 5340 if Tribe[p1].ModelPicture[MyRO.EnemyModel[emix].mix].HGr = 0then5323 if not Assigned(Tribe[p1].ModelPicture[MyRO.EnemyModel[emix].mix].HGr) then 5341 5324 InitEnemyModel(emix); 5342 5325 m2 := TDpiMenuItem.Create(m); … … 5368 5351 Status := Status and ($FFFF - usStay - usRecover - usGoto - usEnhance) 5369 5352 or usWaiting; 5370 MoveUnit(dx, dy, muAutoNext) { simple move }5353 MoveUnit(dx, dy, muAutoNext); { simple move } 5371 5354 end 5372 5355 else if GetMoveAdvice(UnFocus, MouseLoc, MoveAdviceData) >= rExecuted … … 5393 5376 if BattleDlg.ModalResult <> mrOK then 5394 5377 exit; 5395 end 5378 end; 5396 5379 end; 5397 5380 DestinationMarkON := false; … … 5400 5383 usWaiting; 5401 5384 MoveToLoc(MouseLoc, false); { goto } 5402 end 5403 end 5385 end; 5386 end; 5404 5387 end 5405 5388 else if (Button = mbMiddle) and (UnFocus >= 0) and … … 5414 5397 MoveToLoc(MouseLoc, true); { goto } 5415 5398 if (UnFocus = uix) and (MyUn[uix].Loc = MouseLoc) then 5416 MenuClick(mEnhance) 5399 MenuClick(mEnhance); 5417 5400 end 5418 5401 else if (Button = mbLeft) and (ssShift in Shift) and … … 5449 5432 BattleDlg.IsSuicideQuery := false; 5450 5433 BattleDlg.Show; 5451 end 5452 end 5434 end; 5435 end; 5453 5436 end; 5454 5437 … … 5891 5874 if CityCaptured and (MyMap[ToLoc] and fCity = 0) then 5892 5875 begin // city destroyed 5893 for i := 0 to 27do { tell about destroyed wonders }5894 if (MyRO.Wonder[i].CityID = -2) and (MyData.ToldWonders[i].CityID <> -2)5876 for i := 0 to nWonder - 1 do { tell about destroyed wonders } 5877 if (MyRO.Wonder[i].CityID = WonderDestroyed) and (MyData.ToldWonders[i].CityID <> WonderDestroyed) 5895 5878 then 5896 5879 with MessgExDlg do … … 5913 5896 begin // city captured 5914 5897 ListDlg.AddCity; 5915 for i := 0 to 27do { tell about capture of wonders }5898 for i := 0 to nWonder - 1 do { tell about capture of wonders } 5916 5899 if MyRO.City[MyRO.nCity - 1].Built[i] > 0 then 5917 5900 with MessgExDlg do … … 6030 6013 xw1 := xw + G.lx; 6031 6014 // ((xFromLoc-xw1)*2+yFromLoc and 1+1)*xxt+dx*xxt/2-MapWidth/2 -> min 6032 while abs(((xFromLoc - xw1 + G.lx) * 2 + yFromLoc and 1 + 1) * xxt * 2 + dx 6033 * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt 6034 * 2 + dx * xxt - MapWidth) do 6035 dec(xw1, G.lx); 6036 6037 xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu); 6038 yTo := (yToLoc - yw) * yyt + (yyt - yyu_anchor); 6039 xFrom := (xFromLoc - xw1) * (xxt * 2) + yFromLoc and 1 * xxt + (xxt - xxu); 6040 yFrom := (yFromLoc - yw) * yyt + (yyt - yyu_anchor); 6041 if xFrom < xTo then 6042 begin 6043 xMin := xFrom; 6044 xRange := xTo - xFrom 6045 end 6046 else 6047 begin 6048 xMin := xTo; 6049 xRange := xFrom - xTo 6050 end; 6051 if yFrom < yTo then 6052 begin 6053 yMin := yFrom; 6054 yRange := yTo - yFrom 6055 end 6056 else 6057 begin 6058 yMin := yTo; 6059 yRange := yFrom - yTo 6060 end; 6061 inc(xRange, xxt * 2); 6062 inc(yRange, yyt * 3); 6015 with MainMap do begin 6016 while abs(((xFromLoc - xw1 + G.lx) * 2 + yFromLoc and 1 + 1) * xxt * 2 + dx 6017 * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt 6018 * 2 + dx * xxt - MapWidth) do 6019 dec(xw1, G.lx); 6020 6021 xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu); 6022 yTo := (yToLoc - yw) * yyt + (yyt - yyu_anchor); 6023 xFrom := (xFromLoc - xw1) * (xxt * 2) + yFromLoc and 1 * xxt + (xxt - xxu); 6024 yFrom := (yFromLoc - yw) * yyt + (yyt - yyu_anchor); 6025 if xFrom < xTo then begin 6026 xMin := xFrom; 6027 xRange := xTo - xFrom 6028 end else begin 6029 xMin := xTo; 6030 xRange := xFrom - xTo 6031 end; 6032 if yFrom < yTo then begin 6033 yMin := yFrom; 6034 yRange := yTo - yFrom 6035 end else begin 6036 yMin := yTo; 6037 yRange := yFrom - yTo 6038 end; 6039 inc(xRange, xxt * 2); 6040 inc(yRange, yyt * 3); 6041 end; 6063 6042 6064 6043 MainOffscreenPaint; … … 6162 6141 begin 6163 6142 assert(false); 6164 Break 6143 Break; 6165 6144 end; 6166 6145 until false; … … 6188 6167 NextUnit(UnStartLoc, true) 6189 6168 end; 6190 end 6191 end 6192 end 6169 end; 6170 end; 6171 end; 6193 6172 end; 6194 6173 … … 6207 6186 if ssShift in Shift then 6208 6187 begin 6209 xMouse := (xwMini + (x - (xMini + 2) + MapWidth div (xxt * 2) + G.lx) 6210 div 2) mod G.lx; 6188 with MainMap do 6189 xMouse := (xwMini + (x - (xMini + 2) + MapWidth div (xxt * 2) + G.lx) 6190 div 2) mod G.lx; 6211 6191 MouseLoc := xMouse + G.lx * (y - (yMini + 2)); 6212 6192 if MyMap[MouseLoc] and fTerrain <> fUNKNOWN then … … 6215 6195 if (p1 = me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then 6216 6196 NatStatDlg.ShowNewContent(wmPersistent, p1); 6217 end 6197 end; 6218 6198 end 6219 6199 else … … 6310 6290 CheckTerrainBtnVisible; 6311 6291 PanelPaint; 6312 end 6292 end; 6313 6293 end 6314 6294 else if Server(sGetUnits, me, TroopLoc, TrCnt) >= rExecuted then … … 6319 6299 UnitStatDlg.ShowNewContent_EnemyUnit(wmPersistent, 6320 6300 MyRO.nEnemyUn + trix[i]); // unit info 6321 end 6322 end 6301 end; 6302 end; 6323 6303 end; 6324 6304 … … 6412 6392 procedure TMainScreen.SetDebugMap(p: integer); 6413 6393 begin 6414 IsoEngine.pDebugMap := p;6415 IsoEngine.Options := IsoEngine.Options and not(1 shl moLocCodes);6394 MainMap.pDebugMap := p; 6395 MapOptions := MapOptions - [moLocCodes]; 6416 6396 mLocCodes.Checked := false; 6417 6397 MapValid := false; … … 6421 6401 procedure TMainScreen.SetViewpoint(p: integer); 6422 6402 var 6423 i: integer;6403 i: Integer; 6424 6404 begin 6425 6405 if supervising and (G.RO[0].Turn > 0) and … … 6432 6412 SumCities(TaxSum, ScienceSum); 6433 6413 for i := 0 to MyRO.nModel - 1 do 6434 if Tribe[me].ModelPicture[i].HGr = 0then6435 InitMyModel(i, true);6414 if not Assigned(Tribe[me].ModelPicture[i].HGr) then 6415 InitMyModel(i, True); 6436 6416 6437 6417 SetTroopLoc(-1); 6438 6418 PanelPaint; 6439 MapValid := false;6419 MapValid := False; 6440 6420 PaintAllMaps; 6441 6421 end; … … 7222 7202 // check if city types already usefull: 7223 7203 if MyRO.nCity > 0 then 7224 for i := 28to nImp - 1 do7204 for i := nWonder to nImp - 1 do 7225 7205 if (i <> imTrGoods) and (Imp[i].Kind = ikCommon) and 7226 7206 (Imp[i].Preq <> preNA) and … … 7275 7255 m.ShortCut := ShortCut(48 + p1, [ssAlt]); 7276 7256 m.RadioItem := true; 7277 if m.Tag = IsoEngine.pDebugMap then7257 if m.Tag = MainMap.pDebugMap then 7278 7258 m.Checked := true; 7279 7259 mDebugMap.Add(m); 7280 7260 end; 7281 7261 end; 7282 mSmallTiles.Checked := xxt = 33;7283 mNormalTiles.Checked := xxt = 48;7284 mBigTiles.Checked := xxt = 72;7262 mSmallTiles.Checked := MainMap.TileSize = tsSmall; 7263 mNormalTiles.Checked := MainMap.TileSize = tsMedium; 7264 mBigTiles.Checked := MainMap.TileSize = tsBig; 7285 7265 end 7286 7266 else if Popup = StatPopup then … … 7301 7281 mEUnitStat.Enabled := MyRO.nEnemyModel > 0; 7302 7282 { mWonders.Enabled:= false; 7303 for i:=0 to 27 do if MyRO.Wonder[i].CityID<>-1then7283 for i:=0 to nWonder - 1 do if MyRO.Wonder[i].CityID <> WonderNotBuiltYet then 7304 7284 mWonders.Enabled:=true; } 7305 7285 mDiagram.Enabled := MyRO.Turn >= 2; … … 7473 7453 FocusOnLoc(TroopLoc, flRepaintPanel) 7474 7454 else 7475 PanelPaint 7455 PanelPaint; 7476 7456 end 7477 7457 else if StepFocus then … … 7480 7460 begin 7481 7461 SetTroopLoc(-1); 7482 PanelPaint 7462 PanelPaint; 7483 7463 end; 7484 7464 end; … … 7496 7476 begin 7497 7477 if Tracking and (ssLeft in Shift) then 7498 begin7478 with MainMap do begin 7499 7479 if (x >= xMini + 2) and (y >= yMini + 2) and (x < xMini + 2 + 2 * G.lx) and 7500 7480 (y < yMini + 2 + G.ly) then … … 7514 7494 yw := ywmax; 7515 7495 end; 7516 DpiBitCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, Mini .Canvas, 0, 0);7496 DpiBitCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0); 7517 7497 if ywmax <= 0 then 7518 7498 Frame(Buffer.Canvas, x - xMini - 2 - MapWidth div (xxt * 2), 0, … … 7544 7524 xwMini := xw; 7545 7525 ywMini := yw; 7546 Mini Paint;7526 MiniMapPaint; 7547 7527 PanelPaint; 7548 7528 end; … … 7737 7717 var 7738 7718 Reg: TRegistry; 7739 DefaultOptionChecked: Integer;7740 begin 7741 DefaultOptionChecked := 1 shl 1 + 1 shl 7 + 1 shl 10 + 1 shl 12 + 1 shl 14 +7742 1 shl 18 + 1 shl 19;7719 DefaultOptionChecked: TSaveOptions; 7720 begin 7721 DefaultOptionChecked := [soEnMoves, soSlowMoves, soNames, soRepScreens, 7722 soSoundOn, soScrollOff, soAlSlowMoves]; 7743 7723 Reg := TRegistry.Create; 7744 7724 with Reg do try 7745 7725 OpenKey(AppRegistryKey, False); 7746 if ValueExists('TileWidth') then xxt := ReadInteger('TileWidth') div 2 7747 else xxt := 48; 7748 if ValueExists('TileHeight') then yyt := ReadInteger('TileHeight') div 2 7749 else yyt := 24; 7750 if ValueExists('OptionChecked') then OptionChecked := ReadInteger('OptionChecked') 7726 if ValueExists('TileSize') then MainMap.TileSize := TTileSize(ReadInteger('TileSize')) 7727 else MainMap.TileSize := tsMedium; 7728 NoMap.TileSize := MainMap.TileSize; 7729 if ValueExists('OptionChecked') then OptionChecked := TSaveOptions(ReadInteger('OptionChecked')) 7751 7730 else OptionChecked := DefaultOptionChecked; 7752 if ValueExists('MapOptionChecked') then MapOptionChecked := ReadInteger('MapOptionChecked')7753 else MapOptionChecked := 1 shl moCityNames;7731 if ValueExists('MapOptionChecked') then MapOptionChecked := TMapOptions(ReadInteger('MapOptionChecked')) 7732 else MapOptionChecked := [moCityNames]; 7754 7733 if ValueExists('CityReport') then CityRepMask := Cardinal(ReadInteger('CityReport')) 7755 7734 else CityRepMask := Cardinal(not chPopIncrease and not chNoGrowthWarning and 7756 7735 not chCaptured); 7757 if OptionChecked and (7 shl 16) = 0 then 7758 OptionChecked := OptionChecked or (1 shl 16); 7736 if (not (soScrollFast in OptionChecked)) and (not (soScrollSlow in OptionChecked)) and 7737 (not (soScrollOff in OptionChecked)) then 7738 OptionChecked := OptionChecked + [soScrollSlow]; 7759 7739 // old regver with no scrolling 7760 7740 finally … … 7762 7742 end; 7763 7743 7764 if 1 shl 13 and OptionChecked <> 0then7744 if soSoundOff in OptionChecked then 7765 7745 SoundMode := smOff 7766 else if 1 shl 15 and OptionChecked <> 0then7746 else if soSoundOnAlt in OptionChecked then 7767 7747 SoundMode := smOnAlt 7768 7748 else … … 7825 7805 end 7826 7806 else if Flag = tfAllTechs then 7827 TellNewModels 7807 TellNewModels; 7828 7808 end; 7829 7809 end; … … 7834 7814 with TButtonC(Sender) do 7835 7815 begin 7836 MapOptionChecked := MapOptionChecked xor (1 shl (Tag shr 8));7816 MapOptionChecked := TMapOptions(Integer(MapOptionChecked) xor (1 shl (Tag shr 8))); 7837 7817 SetMapOptions; 7838 ButtonIndex := MapOptionChecked shr (Tag shr 8) and 1 + 27818 ButtonIndex := Integer(MapOptionChecked) shr (Tag shr 8) and 1 + 2; 7839 7819 end; 7840 7820 if Sender = MapBtn0 then 7841 7821 begin 7842 Mini Paint;7843 PanelPaint 7822 MiniMapPaint; 7823 PanelPaint; 7844 7824 end // update mini map only 7845 7825 else … … 7854 7834 if TButtonBase(Sender).Down then 7855 7835 begin 7856 MapOptionChecked := MapOptionChecked or (1 shl moGreatWall);7836 MapOptionChecked := MapOptionChecked + [moGreatWall]; 7857 7837 TButtonBase(Sender).Hint := ''; 7858 7838 end 7859 7839 else 7860 7840 begin 7861 MapOptionChecked := MapOptionChecked and not(1 shl moGreatWall);7841 MapOptionChecked := MapOptionChecked - [moGreatWall]; 7862 7842 TButtonBase(Sender).Hint := Phrases.Lookup('CONTROLS', 7863 7843 -1 + TButtonBase(Sender).Tag and $FF); … … 7872 7852 if TButtonBase(Sender).Down then 7873 7853 begin 7874 MapOptionChecked := MapOptionChecked or (1 shl moBareTerrain);7854 MapOptionChecked := MapOptionChecked + [moBareTerrain]; 7875 7855 TButtonBase(Sender).Hint := ''; 7876 7856 end 7877 7857 else 7878 7858 begin 7879 MapOptionChecked := MapOptionChecked and not(1 shl moBareTerrain);7859 MapOptionChecked := MapOptionChecked - [moBareTerrain]; 7880 7860 TButtonBase(Sender).Hint := Phrases.Lookup('CONTROLS', 7881 7861 -1 + TButtonBase(Sender).Tag and $FF); … … 7976 7956 procedure TMainScreen.mSmallTilesClick(Sender: TObject); 7977 7957 begin 7978 SetTileSize (33, 16);7958 SetTileSizeCenter(tsSmall); 7979 7959 end; 7980 7960 7981 7961 procedure TMainScreen.mNormalTilesClick(Sender: TObject); 7982 7962 begin 7983 SetTileSize (48, 24);7963 SetTileSizeCenter(tsMedium); 7984 7964 end; 7985 7965 7986 7966 procedure TMainScreen.mBigTilesClick(Sender: TObject); 7987 7967 begin 7988 SetTileSize(72, 36); 7989 end; 7990 7991 procedure TMainScreen.SetTileSize(x, y: integer); 7968 SetTileSizeCenter(tsBig); 7969 end; 7970 7971 procedure TMainScreen.SetTileSizeCenter(TileSize: TTileSize); 7972 begin 7973 SetTileSize(TileSize, GetCenterLoc, Point(MapWidth div 2, MapHeight div 2)); 7974 end; 7975 7976 procedure TMainScreen.SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 7992 7977 var 7993 i, CenterLoc: integer; 7994 begin 7995 CenterLoc := (xw + MapWidth div (xxt * 4)) mod G.lx + 7996 (yw + MapHeight div (yyt * 2)) * G.lx; 7997 IsoEngine.ApplyTileSize(x, y); 7978 i: integer; 7979 begin 7980 MainMap.TileSize := TileSize; 7981 NoMap.TileSize := TileSize; 7998 7982 FormResize(nil); 7999 Centre(CenterLoc);7983 SetMapPos(Loc, MapPos); 8000 7984 PaintAllMaps; 8001 7985 for i := 0 to DpiScreen.FormCount - 1 do … … 8004 7988 end; 8005 7989 7990 procedure TMainScreen.SaveMenuItemsState; 7991 var 7992 i, j: integer; 7993 begin 7994 if soTellAI in OptionChecked then OptionChecked := [soTellAI] 7995 else OptionChecked := []; 7996 for i := 0 to ComponentCount - 1 do 7997 if Components[i] is TDpiMenuItem then 7998 for j := 0 to Length(SaveOption) - 1 do 7999 if TDpiMenuItem(Components[i]).Checked and 8000 (TDpiMenuItem(Components[i]).Tag = SaveOption[j]) then 8001 OptionChecked := OptionChecked + [TSaveOption(j)]; 8002 end; 8003 8006 8004 procedure TMainScreen.SaveSettings; 8007 8005 var 8008 i, j: integer;8009 8006 Reg: TRegistry; 8010 8007 begin 8011 OptionChecked := OptionChecked and soExtraMask; 8012 for i := 0 to ComponentCount - 1 do 8013 if Components[i] is TDpiMenuItem then 8014 for j := 0 to nSaveOption - 1 do 8015 if TDpiMenuItem(Components[i]).Checked and 8016 (TDpiMenuItem(Components[i]).Tag = SaveOption[j]) then 8017 inc(OptionChecked, 1 shl j); 8008 SaveMenuItemsState; 8018 8009 8019 8010 Reg := TRegistry.Create; … … 8021 8012 try 8022 8013 OpenKey(AppRegistryKey, true); 8023 WriteInteger('TileWidth', xxt * 2); 8024 WriteInteger('TileHeight', yyt * 2); 8025 WriteInteger('OptionChecked', OptionChecked); 8026 WriteInteger('MapOptionChecked', MapOptionChecked); 8014 WriteInteger('TileSize', Integer(MainMap.TileSize)); 8015 WriteInteger('OptionChecked', Integer(OptionChecked)); 8016 WriteInteger('MapOptionChecked', Integer(MapOptionChecked)); 8027 8017 WriteInteger('CityReport', integer(CityRepMask)); 8028 8018 finally
Note:
See TracChangeset
for help on using the changeset viewer.