Changeset 330 for trunk/LocalPlayer/Term.pas
- Timestamp:
- Mar 26, 2021, 2:16:04 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Term.pas
r329 r330 14 14 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, DrawDlg, Types, 15 15 Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area, 16 UGraphicSet, UMiniMap ;16 UGraphicSet, UMiniMap, IsoEngine; 17 17 18 18 const … … 21 21 type 22 22 TPaintLocTempStyle = (pltsNormal, pltsBlink); 23 TTileSize = (tsSmall, tsMedium, tsBig);24 23 25 24 TSoundBlock = (sbStart, sbWonder, sbScience, sbContact, sbTurn); … … 270 269 PrevWindowState: TWindowState; 271 270 CurrentWindowState: TWindowState; 271 MainMap: TIsoMap; 272 NoMap: TIsoMap; 273 NoMapPanel: TIsoMap; 272 274 function ChooseUnusedTribe: integer; 273 275 procedure GetTribeList; 274 276 procedure InitModule; 277 procedure DoneModule; 275 278 procedure InitTurn(NewPlayer: integer); 276 279 procedure SaveMenuItemsState; … … 321 324 procedure UpdateKeyShortcuts; 322 325 procedure SetFullScreen(Active: Boolean); 326 procedure PaintZoomedTile(dst: TBitmap; x, y, Loc: integer); 323 327 public 324 328 UsedOffscreenWidth, UsedOffscreenHeight: integer; … … 438 442 'CITY_INVALIDTYPE'); 439 443 440 TileSizes: array [TTileSize] of TPoint = ((X: 33; Y: 16), (X: 48; Y: 24),441 (X: 72; Y: 36));442 443 444 type 444 445 TPersistentData = record … … 477 478 AdvIcon: array [0 .. nAdv - 1] of Integer; 478 479 { icons displayed with the technologies } 479 xxt: Integer; // half of tile size x/y480 yyt: Integer; // half of tile size x/y481 TileSize: TTileSize;482 480 GameMode: Integer; 483 481 ClientMode: Integer; … … 491 489 SoundPreloadDone: TSoundBlocks; 492 490 MarkCityLoc: Integer; 493 HGrTerrain: TGraphicSet;494 HGrCities: TGraphicSet;495 491 MovieSpeed: Integer; 496 492 CityRepMask: Cardinal; … … 524 520 525 521 uses 526 Directories, IsoEngine,CityScreen, Draft, MessgEx, Select, CityType, Help,522 Directories, CityScreen, Draft, MessgEx, Select, CityType, Help, 527 523 UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego, UPixelPointer, Sound, 528 524 Battle, Rates, TechTree, Registry, Global, UKeyBindings; … … 582 578 583 579 SaveOption: array of Integer; 584 MainMap: TIsoMap;585 580 CurrentMoveInfo: TCurrentMoveInfo; 586 581 … … 925 920 end; 926 921 927 procedure PaintZoomedTile(dst: TBitmap; x, y, Loc: integer);922 procedure TMainScreen.PaintZoomedTile(dst: TBitmap; x, y, Loc: integer); 928 923 929 924 procedure TSprite(xDst, yDst, xSrc, ySrc: integer); 930 925 begin 931 Sprite(dst, HGrTerrain, x + xDst, y + yDst, xxt * 2, yyt * 3, 932 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 926 with NoMapPanel do 927 Sprite(dst, HGrTerrain, x + xDst, y + yDst, xxt * 2, yyt * 3, 928 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 933 929 end; 934 930 935 931 procedure TSprite4(xSrc, ySrc: integer); 936 932 begin 937 Sprite(dst, HGrTerrain, x + xxt, y + yyt + 2, xxt * 2, yyt * 2 - 2, 938 1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1)); 939 Sprite(dst, HGrTerrain, x + 4, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 940 5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 941 Sprite(dst, HGrTerrain, x + xxt * 2, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 942 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 943 Sprite(dst, HGrTerrain, x + xxt, y + yyt * 3, xxt * 2, yyt * 2 - 2, 944 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 933 with NoMapPanel do begin 934 Sprite(dst, HGrTerrain, x + xxt, y + yyt + 2, xxt * 2, yyt * 2 - 2, 935 1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1)); 936 Sprite(dst, HGrTerrain, x + 4, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 937 5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 938 Sprite(dst, HGrTerrain, x + xxt * 2, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 939 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 940 Sprite(dst, HGrTerrain, x + xxt, y + yyt * 3, xxt * 2, yyt * 2 - 2, 941 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); 942 end; 945 943 end; 946 944 … … 948 946 cix, ySrc, Tile: integer; 949 947 begin 950 Tile := MyMap[Loc]; 951 if Tile and fCity <> 0 then 952 begin 953 if MyRO.Tech[adRailroad] >= tsApplicable then 954 Tile := Tile or fRR 948 with NoMapPanel do begin 949 Tile := MyMap[Loc]; 950 if Tile and fCity <> 0 then 951 begin 952 if MyRO.Tech[adRailroad] >= tsApplicable then 953 Tile := Tile or fRR 954 else 955 Tile := Tile or fRoad; 956 if Tile and fOwned <> 0 then 957 begin 958 cix := MyRO.nCity - 1; 959 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 960 dec(cix); 961 assert(cix >= 0); 962 if MyCity[cix].Built[imSupermarket] > 0 then 963 Tile := Tile or tiFarm 964 else 965 Tile := Tile or tiIrrigation; 966 end 967 else Tile := Tile or tiIrrigation; 968 end; 969 970 if Tile and fTerrain >= fForest then 971 TSprite4(2, 2) 955 972 else 956 Tile := Tile or fRoad; 957 if Tile and fOwned <> 0 then 958 begin 959 cix := MyRO.nCity - 1; 960 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do 961 dec(cix); 962 assert(cix >= 0); 963 if MyCity[cix].Built[imSupermarket] > 0 then 964 Tile := Tile or tiFarm 973 TSprite4(Tile and fTerrain, 0); 974 if Tile and fTerrain >= fForest then 975 begin 976 if (Tile and fTerrain = fForest) and IsJungle(Loc div G.lx) then 977 ySrc := 18 965 978 else 966 Tile := Tile or tiIrrigation; 967 end 968 else 969 Tile := Tile or tiIrrigation; 970 end; 971 972 if Tile and fTerrain >= fForest then 973 TSprite4(2, 2) 974 else 975 TSprite4(Tile and fTerrain, 0); 976 if Tile and fTerrain >= fForest then 977 begin 978 if (Tile and fTerrain = fForest) and IsJungle(Loc div G.lx) then 979 ySrc := 18 980 else 981 ySrc := 3 + 2 * (Tile and fTerrain - fForest); 982 TSprite(xxt, 0, 6, ySrc); 983 TSprite(0, yyt, 3, ySrc); 984 TSprite((xxt * 2), yyt, 4, ySrc + 1); 985 TSprite(xxt, (yyt * 2), 1, ySrc + 1); 986 end; 987 988 // irrigation 989 case Tile and fTerImp of 990 tiIrrigation: 991 begin 979 ySrc := 3 + 2 * (Tile and fTerrain - fForest); 980 TSprite(xxt, 0, 6, ySrc); 981 TSprite(0, yyt, 3, ySrc); 982 TSprite((xxt * 2), yyt, 4, ySrc + 1); 983 TSprite(xxt, (yyt * 2), 1, ySrc + 1); 984 end; 985 986 // irrigation 987 case Tile and fTerImp of 988 tiIrrigation: begin 992 989 TSprite(xxt, 0, 0, 12); 993 990 TSprite(xxt * 2, yyt, 0, 12); 994 991 end; 995 tiFarm: 996 begin 992 tiFarm: begin 997 993 TSprite(xxt, 0, 1, 12); 998 994 TSprite(xxt * 2, yyt, 1, 12); 999 end 1000 end; 1001 1002 // river/canal/road/railroad 1003 if Tile and fRiver <> 0 then 1004 begin 1005 TSprite(0, yyt, 2, 14); 1006 TSprite(xxt, (yyt * 2), 2, 14); 1007 end; 1008 if Tile and fCanal <> 0 then 1009 begin 1010 TSprite(xxt, 0, 7, 11); 1011 TSprite(xxt, 0, 3, 11); 1012 TSprite(xxt * 2, yyt, 7, 11); 1013 TSprite(xxt * 2, yyt, 3, 11); 1014 end; 1015 if Tile and fRR <> 0 then 1016 begin 1017 TSprite((xxt * 2), yyt, 1, 10); 1018 TSprite((xxt * 2), yyt, 5, 10); 1019 TSprite(xxt, (yyt * 2), 1, 10); 1020 TSprite(xxt, (yyt * 2), 5, 10); 1021 end 1022 else if Tile and fRoad <> 0 then 1023 begin 1024 TSprite((xxt * 2), yyt, 8, 9); 1025 TSprite((xxt * 2), yyt, 5, 9); 1026 TSprite(xxt, (yyt * 2), 1, 9); 1027 TSprite(xxt, (yyt * 2), 5, 9); 1028 end; 1029 1030 if Tile and fPoll <> 0 then 1031 TSprite(xxt, (yyt * 2), 6, 12); 1032 1033 // special 1034 if Tile and (fTerrain or fSpecial) = fGrass or fSpecial1 then 1035 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 1045 begin 1046 TSprite4(6, 2); 1047 TSprite(xxt, yyt, 8, 12 + Tile shr 25 and 3); 1048 end; 1049 1050 // other improvements 1051 case Tile and fTerImp of 1052 tiMine: 1053 TSprite(xxt, 0, 2, 12); 1054 tiFort: 1055 begin 995 end; 996 end; 997 998 // river/canal/road/railroad 999 if Tile and fRiver <> 0 then begin 1000 TSprite(0, yyt, 2, 14); 1001 TSprite(xxt, (yyt * 2), 2, 14); 1002 end; 1003 if Tile and fCanal <> 0 then begin 1004 TSprite(xxt, 0, 7, 11); 1005 TSprite(xxt, 0, 3, 11); 1006 TSprite(xxt * 2, yyt, 7, 11); 1007 TSprite(xxt * 2, yyt, 3, 11); 1008 end; 1009 if Tile and fRR <> 0 then begin 1010 TSprite((xxt * 2), yyt, 1, 10); 1011 TSprite((xxt * 2), yyt, 5, 10); 1012 TSprite(xxt, (yyt * 2), 1, 10); 1013 TSprite(xxt, (yyt * 2), 5, 10); 1014 end 1015 else if Tile and fRoad <> 0 then begin 1016 TSprite((xxt * 2), yyt, 8, 9); 1017 TSprite((xxt * 2), yyt, 5, 9); 1018 TSprite(xxt, (yyt * 2), 1, 9); 1019 TSprite(xxt, (yyt * 2), 5, 9); 1020 end; 1021 1022 if Tile and fPoll <> 0 then 1023 TSprite(xxt, (yyt * 2), 6, 12); 1024 1025 // special 1026 if Tile and (fTerrain or fSpecial) = fGrass or fSpecial1 then TSprite4(2, 1) 1027 else if Tile and fSpecial <> 0 then 1028 if Tile and fTerrain < fForest then 1029 TSprite(0, yyt, Tile and fTerrain, Tile and fSpecial shr 5) 1030 else if (Tile and fTerrain = fForest) and IsJungle(Loc div G.lx) then 1031 TSprite(0, yyt, 8, 17 + Tile and fSpecial shr 5) 1032 else 1033 TSprite(0, yyt, 8, 2 + (Tile and fTerrain - fForest) * 2 + Tile and 1034 fSpecial shr 5) 1035 else if Tile and fDeadLands <> 0 then begin 1036 TSprite4(6, 2); 1037 TSprite(xxt, yyt, 8, 12 + Tile shr 25 and 3); 1038 end; 1039 1040 // other improvements 1041 case Tile and fTerImp of 1042 tiMine: TSprite(xxt, 0, 2, 12); 1043 tiFort: begin 1056 1044 TSprite(xxt, 0, 7, 12); 1057 1045 TSprite(xxt, 0, 3, 12); 1058 1046 end; 1059 tiBase:1060 TSprite(xxt, 0, 4, 12);1047 tiBase: TSprite(xxt, 0, 4, 12); 1048 end; 1061 1049 end; 1062 1050 end; … … 1268 1256 begin 1269 1257 MiniMap.MapOptions := MapOptionChecked; 1270 IsoEngine.MapOptions := MapOptionChecked;1258 MainMap.MapOptions := MapOptionChecked; 1271 1259 if ClientMode = cEditMap then 1272 IsoEngine.MapOptions := IsoEngine.MapOptions + [moEditMode];1260 MainMap.MapOptions := MainMap.MapOptions + [moEditMode]; 1273 1261 if mLocCodes.Checked then 1274 IsoEngine.MapOptions := IsoEngine.MapOptions + [moLocCodes];1262 MainMap.MapOptions := MainMap.MapOptions + [moLocCodes]; 1275 1263 end; 1276 1264 … … 1638 1626 1639 1627 IsoEngine.Init(InitEnemyModel); 1640 if not IsoEngine.ApplyTileSize(TileSize) and (TileSize <> tsMedium) then1641 ApplyTileSize(tsMedium);1642 1628 // non-default tile size is missing a file, switch to default 1643 MainMap := TIsoMap.Create;1644 1629 MainMap.SetOutput(offscreen); 1645 1630 … … 1654 1639 sb := TPVScrollbar.Create(Self); 1655 1640 sb.OnUpdate := ScrollBarUpdate; 1641 end; 1642 1643 procedure TMainScreen.DoneModule; 1644 begin 1645 FreeAndNil(SmallImp); 1646 FreeAndNil(UnusedTribeFiles); 1647 FreeAndNil(TribeNames); 1648 // AdvisorDlg.DeInit; 1656 1649 end; 1657 1650 … … 1839 1832 Loc1 := MyCity[0].Loc; 1840 1833 if (ClientMode = cTurn) and (MyRO.Turn = 0) then 1841 begin // move city out of center to not be covered by welcome screen1834 with MainMap do begin // move city out of center to not be covered by welcome screen 1842 1835 dx := MapWidth div (xxt * 5); 1843 1836 if dx > 5 then … … 2536 2529 end; 2537 2530 2538 cReleaseModule: 2539 begin 2540 FreeAndNil(SmallImp); 2541 FreeAndNil(UnusedTribeFiles); 2542 FreeAndNil(TribeNames); 2543 FreeAndNil(MainMap); 2544 IsoEngine.Done; 2545 // AdvisorDlg.DeInit; 2546 end; 2531 cReleaseModule: DoneModule; 2547 2532 2548 2533 cHelpOnly, cStartHelp, cStartCredits: … … 2573 2558 ClientMode := -1; 2574 2559 SetMapOptions; 2575 IsoEngine.pDebugMap := -1;2560 MainMap.pDebugMap := -1; 2576 2561 idle := false; 2577 2562 FillChar(Jump, SizeOf(Jump), 0); … … 2580 2565 GameMode := Command; 2581 2566 GrExt.ResetPixUsed; 2582 IsoEngineReset; 2567 MainMap.Reset; 2568 NoMap.Reset; 2583 2569 Tribes.Init; 2584 2570 GetTribeList; … … 2897 2883 ClientMode := cEditMap; 2898 2884 SetMapOptions; 2899 IsoEngine.pDebugMap := -1;2885 MainMap.pDebugMap := -1; 2900 2886 ItsMeAgain(0); 2901 2887 MyData := nil; … … 3393 3379 cRefreshDebugMap: 3394 3380 begin 3395 if integer(Data) = IsoEngine.pDebugMap then3381 if integer(Data) = MainMap.pDebugMap then 3396 3382 begin 3397 3383 MapValid := false; … … 3445 3431 i, j: integer; 3446 3432 begin 3433 NoMap := TIsoMap.Create; 3434 MainMap := TIsoMap.Create; 3435 NoMapPanel := TIsoMap.Create; 3436 3447 3437 KeyBindings.LoadFromRegistry(HKEY_CURRENT_USER, AppRegistryKey + '\KeyBindings'); 3448 3438 UpdateKeyShortcuts; … … 3559 3549 FreeAndNil(AILogo[I]); 3560 3550 FreeAndNil(Offscreen); 3551 FreeAndNil(MainMap); 3552 FreeAndNil(NoMap); 3553 FreeAndNil(NoMapPanel); 3561 3554 end; 3562 3555 … … 3568 3561 Update; 3569 3562 end else begin 3570 if (WheelDelta > 0) and (TileSize < High(TTileSize)) then SetTileSize(Succ(TileSize)) 3571 else if (WheelDelta < 0) and (TileSize > Low(TTileSize)) then SetTileSize(Pred(TileSize)); 3563 if (WheelDelta > 0) and (MainMap.TileSize < High(TTileSize)) then 3564 SetTileSize(Succ(MainMap.TileSize)) 3565 else if (WheelDelta < 0) and (MainMap.TileSize > Low(TTileSize)) then 3566 SetTileSize(Pred(MainMap.TileSize)); 3572 3567 end; 3573 3568 end; … … 3578 3573 begin 3579 3574 SmallScreen := ClientWidth < 1024; 3580 MaxMapWidth := (G.lx * 2 - 3) * xxt; 3581 // avoide the same tile being visible left and right 3582 if ClientWidth <= MaxMapWidth then 3583 begin 3584 MapWidth := ClientWidth; 3585 MapOffset := 0; 3586 end 3587 else 3588 begin 3589 MapWidth := MaxMapWidth; 3590 MapOffset := (ClientWidth - MapWidth) div 2; 3591 end; 3592 MapHeight := ClientHeight - TopBarHeight - PanelHeight + overlap; 3593 Panel.SetSize(ClientWidth, PanelHeight); 3594 TopBar.SetSize(ClientWidth, TopBarHeight); 3595 MiniFrame := (lxmax_xxx - G.ly) div 2; 3596 xMidPanel := (G.lx + MiniFrame) * 2 + 1; 3597 xRightPanel := ClientWidth - LeftPanelWidth - 10; 3598 if ClientMode = cEditMap then 3599 TrPitch := 2 * xxt 3600 else 3601 TrPitch := 66; 3602 xMini := MiniFrame - 5; 3603 yMini := (PanelHeight - 26 - lxmax_xxx) div 2 + MiniFrame; 3604 ywmax := (G.ly - MapHeight div yyt + 1) and not 1; 3605 ywcenter := -((MapHeight - yyt * (G.ly - 1)) div (4 * yyt)) * 2; 3575 with MainMap do begin 3576 MaxMapWidth := (G.lx * 2 - 3) * xxt; 3577 // avoide the same tile being visible left and right 3578 if ClientWidth <= MaxMapWidth then begin 3579 MapWidth := ClientWidth; 3580 MapOffset := 0; 3581 end else begin 3582 MapWidth := MaxMapWidth; 3583 MapOffset := (ClientWidth - MapWidth) div 2; 3584 end; 3585 MapHeight := ClientHeight - TopBarHeight - PanelHeight + overlap; 3586 Panel.SetSize(ClientWidth, PanelHeight); 3587 TopBar.SetSize(ClientWidth, TopBarHeight); 3588 MiniFrame := (lxmax_xxx - G.ly) div 2; 3589 xMidPanel := (G.lx + MiniFrame) * 2 + 1; 3590 xRightPanel := ClientWidth - LeftPanelWidth - 10; 3591 if ClientMode = cEditMap then 3592 TrPitch := 2 * xxt 3593 else 3594 TrPitch := 66; 3595 xMini := MiniFrame - 5; 3596 yMini := (PanelHeight - 26 - lxmax_xxx) div 2 + MiniFrame; 3597 ywmax := (G.ly - MapHeight div yyt + 1) and not 1; 3598 ywcenter := -((MapHeight - yyt * (G.ly - 1)) div (4 * yyt)) * 2; 3599 end; 3606 3600 // only for ywmax<=0 3607 3601 if ywmax <= 0 then … … 3705 3699 xTroop := xMidPanel + 15 3706 3700 else 3707 begin3701 with MainMap do begin 3708 3702 if supervising then 3709 3703 xTerrain := xMidPanel + 2 * xxt + 14 … … 3974 3968 xs, ys, xl, yl: integer; 3975 3969 begin 3976 xl := nx * xxt + xxt; 3977 yl := ny * yyt + yyt * 2; 3978 xs := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 3979 // |xs+xl/2-MapWidth/2| -> min 3980 while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) < 3981 abs(2 * xs + xl - MapWidth) do 3982 inc(xs, G.lx * (xxt * 2)); 3983 ys := (y0 - yw) * yyt - yyt; 3984 if xs + xl > MapWidth then 3985 xl := MapWidth - xs; 3986 if ys + yl > MapHeight then 3987 yl := MapHeight - ys; 3988 if (xl <= 0) or (yl <= 0) then 3989 exit; 3990 if Options and prPaint <> 0 then 3991 begin 3992 if Options and prAutoBounds <> 0 then 3993 MainMap.SetPaintBounds(xs, ys, xs + xl, ys + yl); 3994 MainMap.Paint(xs, ys, x0 + G.lx * y0, nx, ny, -1, -1); 3995 end; 3996 if Options and prInvalidate <> 0 then 3997 RectInvalidate(MapOffset + xs, TopBarHeight + ys, MapOffset + xs + xl, 3998 TopBarHeight + ys + yl) 3970 with MainMap do begin 3971 xl := nx * xxt + xxt; 3972 yl := ny * yyt + yyt * 2; 3973 xs := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 3974 // |xs+xl/2-MapWidth/2| -> min 3975 while abs(2 * (xs + G.lx * (xxt * 2)) + xl - MapWidth) < 3976 abs(2 * xs + xl - MapWidth) do 3977 inc(xs, G.lx * (xxt * 2)); 3978 ys := (y0 - yw) * yyt - yyt; 3979 if xs + xl > MapWidth then 3980 xl := MapWidth - xs; 3981 if ys + yl > MapHeight then 3982 yl := MapHeight - ys; 3983 if (xl <= 0) or (yl <= 0) then 3984 exit; 3985 if Options and prPaint <> 0 then begin 3986 if Options and prAutoBounds <> 0 then 3987 MainMap.SetPaintBounds(xs, ys, xs + xl, ys + yl); 3988 MainMap.Paint(xs, ys, x0 + G.lx * y0, nx, ny, -1, -1); 3989 end; 3990 if Options and prInvalidate <> 0 then 3991 RectInvalidate(MapOffset + xs, TopBarHeight + ys, MapOffset + xs + xl, 3992 TopBarHeight + ys + yl) 3993 end; 3999 3994 end; 4000 3995 … … 4003 3998 yLoc, x0: integer; 4004 3999 begin 4005 if MapValid then 4006 begin 4000 if MapValid then begin 4007 4001 yLoc := (Loc + G.lx * 1024) div G.lx - 1024; 4008 4002 x0 := (Loc + (yLoc and 1 - 2 * Radius + G.lx * 1024) div 2) mod G.lx; … … 4011 4005 prPaint or prAutoBounds or prInvalidate); 4012 4006 Update; 4013 end 4007 end; 4014 4008 end; 4015 4009 … … 4018 4012 y0, x0, xMap, yMap: integer; 4019 4013 begin 4020 if not MapValid then 4021 exit; 4022 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 4023 y0 := Loc div G.lx; 4024 x0 := Loc mod G.lx; 4025 xMap := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 4026 // |xMap+xxt-MapWidth/2| -> min 4027 while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) < 4028 abs(2 * xMap + 2 * xxt - MapWidth) do 4029 inc(xMap, G.lx * (xxt * 2)); 4030 yMap := (y0 - yw) * yyt - yyt; 4031 NoMap.SetOutput(Buffer); 4032 NoMap.SetPaintBounds(0, 0, 2 * xxt, 3 * yyt); 4033 NoMap.Paint(0, 0, Loc, 1, 1, -1, -1, Style = pltsBlink); 4034 PaintBufferToScreen(xMap, yMap, 2 * xxt, 3 * yyt); 4014 with NoMap do begin 4015 if not MapValid then 4016 exit; 4017 Buffer.Canvas.Font.Assign(UniFont[ftSmall]); 4018 y0 := Loc div G.lx; 4019 x0 := Loc mod G.lx; 4020 xMap := (x0 - xw) * (xxt * 2) + y0 and 1 * xxt - G.lx * (xxt * 2); 4021 // |xMap+xxt-MapWidth/2| -> min 4022 while abs(2 * (xMap + G.lx * (xxt * 2)) + 2 * xxt - MapWidth) < 4023 abs(2 * xMap + 2 * xxt - MapWidth) do 4024 inc(xMap, G.lx * (xxt * 2)); 4025 yMap := (y0 - yw) * yyt - yyt; 4026 NoMap.SetOutput(Buffer); 4027 NoMap.SetPaintBounds(0, 0, 2 * xxt, 3 * yyt); 4028 NoMap.Paint(0, 0, Loc, 1, 1, -1, -1, Style = pltsBlink); 4029 PaintBufferToScreen(xMap, yMap, 2 * xxt, 3 * yyt); 4030 end; 4035 4031 end; 4036 4032 … … 4060 4056 else 4061 4057 BitBltCanvas(Canvas, xMap + MapOffset, TopBarHeight, width, 4062 height + yMap, Buffer.Canvas, 0, -yMap) 4058 height + yMap, Buffer.Canvas, 0, -yMap); 4063 4059 end 4064 4060 else … … 4070 4066 BitBltCanvas(Canvas, xMap + MapOffset, TopBarHeight + yMap, width, 4071 4067 height, Buffer.Canvas, 0, 0); 4072 end 4068 end; 4073 4069 end; 4074 4070 … … 4135 4131 end; 4136 4132 4137 if xw - xwd > G.lx div 2 then 4138 xwd := xwd + G.lx 4139 else if xwd - xw > G.lx div 2 then 4140 xwd := xwd - G.lx; 4141 if not MapValid or (xw - xwd > MapWidth div (xxt * 2)) or 4142 (xwd - xw > MapWidth div (xxt * 2)) or (yw - ywd > MapHeight div yyt) or 4143 (ywd - yw > MapHeight div yyt) then 4144 begin 4145 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4146 ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt, 4147 prPaint or prInvalidate); 4148 end 4149 else 4150 begin 4151 if (xwd = xw) and (ywd = yw) then 4152 exit; { map window not moved } 4153 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4154 rec := Rect(0, 0, MapWidth, MapHeight); 4133 with MainMap do begin 4134 if xw - xwd > G.lx div 2 then 4135 xwd := xwd + G.lx 4136 else if xwd - xw > G.lx div 2 then 4137 xwd := xwd - G.lx; 4138 if not MapValid or (xw - xwd > MapWidth div (xxt * 2)) or 4139 (xwd - xw > MapWidth div (xxt * 2)) or (yw - ywd > MapHeight div yyt) or 4140 (ywd - yw > MapHeight div yyt) then 4141 begin 4142 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4143 ProcessRect(xw, yw, MapWidth div xxt, MapHeight div yyt, 4144 prPaint or prInvalidate); 4145 end else begin 4146 if (xwd = xw) and (ywd = yw) then 4147 exit; { map window not moved } 4148 offscreen.Canvas.Font.Assign(UniFont[ftSmall]); 4149 rec := Rect(0, 0, MapWidth, MapHeight); 4155 4150 {$IFDEF WINDOWS} 4156 ScrollDC(offscreen.Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4157 rec, rec, 0, nil);4151 ScrollDC(offscreen.Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4152 rec, rec, 0, nil); 4158 4153 {$ENDIF} 4159 4154 {$IFDEF LINUX} 4160 ScrollDC(offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4161 rec, rec, 0, nil);4155 ScrollDC(offscreen.Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4156 rec, rec, 0, nil); 4162 4157 {$ENDIF} 4163 for DoInvalidate := false to FastScrolling do 4164 begin 4165 if DoInvalidate then 4166 begin 4167 rec.Bottom := MapHeight - overlap; 4158 for DoInvalidate := false to FastScrolling do begin 4159 if DoInvalidate then begin 4160 rec.Bottom := MapHeight - overlap; 4168 4161 {$IFDEF WINDOWS} 4169 ScrollDC(Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec,4170 rec, 0, nil);4162 ScrollDC(Canvas.Handle, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, rec, 4163 rec, 0, nil); 4171 4164 {$ENDIF} 4172 4165 {$IFDEF LINUX} 4173 ScrollDC(Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt,4174 rec, rec, 0, nil);4166 ScrollDC(Canvas, (xwd - xw) * (xxt * 2), (ywd - yw) * yyt, 4167 rec, rec, 0, nil); 4175 4168 {$ENDIF} 4176 ProcessOptions := prInvalidate; 4177 end 4178 else 4179 ProcessOptions := prPaint or prAutoBounds; 4180 if yw < ywd then 4181 begin 4182 ProcessRect(xw, yw, MapWidth div xxt, ywd - yw - 1, ProcessOptions); 4183 if xw < xwd then 4184 ProcessRect(xw, ywd, (xwd - xw) * 2 - 1, MapHeight div yyt - ywd + yw, 4169 ProcessOptions := prInvalidate; 4170 end 4171 else ProcessOptions := prPaint or prAutoBounds; 4172 if yw < ywd then begin 4173 ProcessRect(xw, yw, MapWidth div xxt, ywd - yw - 1, ProcessOptions); 4174 if xw < xwd then 4175 ProcessRect(xw, ywd, (xwd - xw) * 2 - 1, MapHeight div yyt - ywd + yw, 4176 ProcessOptions) 4177 else if xw > xwd then 4178 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, ywd, 4179 (xw - xwd) * 2 + 1, MapHeight div yyt - ywd + yw, ProcessOptions) 4180 end 4181 else if yw > ywd then begin 4182 if DoInvalidate then 4183 RectInvalidate(MapOffset, TopBarHeight + MapHeight - overlap - 4184 (yw - ywd) * yyt, MapOffset + MapWidth, TopBarHeight + MapHeight 4185 - overlap) 4186 else 4187 ProcessRect(xw, (ywd + MapHeight div (yyt * 2) * 2), MapWidth div xxt, 4188 yw - ywd + 1, ProcessOptions); 4189 if xw < xwd then 4190 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt - yw + ywd - 4191 2, ProcessOptions) 4192 else if xw > xwd then 4193 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, yw, 4194 (xw - xwd) * 2 + 1, MapHeight div yyt - yw + ywd - 2, 4195 ProcessOptions); 4196 end 4197 else if xw < xwd then 4198 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt, 4185 4199 ProcessOptions) 4186 4200 else if xw > xwd then 4187 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, ywd,4188 (xw - xwd) * 2 + 1, MapHeight div yyt - ywd + yw, ProcessOptions)4189 end4190 else if yw > ywd then4191 begin4192 if DoInvalidate then4193 RectInvalidate(MapOffset, TopBarHeight + MapHeight - overlap -4194 (yw - ywd) * yyt, MapOffset + MapWidth, TopBarHeight + MapHeight4195 - overlap)4196 else4197 ProcessRect(xw, (ywd + MapHeight div (yyt * 2) * 2), MapWidth div xxt,4198 yw - ywd + 1, ProcessOptions);4199 if xw < xwd then4200 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt - yw + ywd -4201 2, ProcessOptions)4202 else if xw > xwd then4203 4201 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, yw, 4204 (xw - xwd) * 2 + 1, MapHeight div yyt - yw + ywd - 2, 4205 ProcessOptions) 4206 end 4207 else if xw < xwd then 4208 ProcessRect(xw, yw, (xwd - xw) * 2 - 1, MapHeight div yyt, 4209 ProcessOptions) 4210 else if xw > xwd then 4211 ProcessRect((xwd + MapWidth div (xxt * 2)) mod G.lx, yw, 4212 (xw - xwd) * 2 + 1, MapHeight div yyt, ProcessOptions); 4213 end; 4214 if not FastScrolling then 4215 RectInvalidate(MapOffset, TopBarHeight, MapOffset + MapWidth, 4216 TopBarHeight + MapHeight - overlap); 4217 RectInvalidate(xMidPanel, TopBarHeight + MapHeight - overlap, xRightPanel, 4218 TopBarHeight + MapHeight); 4202 (xw - xwd) * 2 + 1, MapHeight div yyt, ProcessOptions); 4203 end; 4204 if not FastScrolling then 4205 RectInvalidate(MapOffset, TopBarHeight, MapOffset + MapWidth, 4206 TopBarHeight + MapHeight - overlap); 4207 RectInvalidate(xMidPanel, TopBarHeight + MapHeight - overlap, xRightPanel, 4208 TopBarHeight + MapHeight); 4209 end; 4219 4210 end; 4220 4211 // if (xwd<>xw) or (ywd<>yw) then … … 4227 4218 procedure TMainScreen.MiniMapPaint; 4228 4219 begin 4229 MiniMap.Paint(MyMap, MapWidth, ClientMode, xxt, xwMini); 4220 with MainMap do 4221 MiniMap.Paint(MyMap, MapWidth, ClientMode, xxt, xwMini); 4230 4222 end; 4231 4223 … … 4253 4245 procedure TMainScreen.CopyMiniToPanel; 4254 4246 begin 4255 BitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 4256 MiniMap.Bitmap.Canvas, 0, 0); 4257 if MarkCityLoc >= 0 then 4258 Sprite(Panel, HGrSystem, xMini - 2 + (4 * G.lx + 2 * (MarkCityLoc mod G.lx) 4259 + (G.lx - MapWidth div (xxt * 2)) - 2 * xwd) mod (2 * G.lx) + 4260 MarkCityLoc div G.lx and 1, yMini - 3 + MarkCityLoc div G.lx, CityMark2.Width, 4261 CityMark2.Height, CityMark2.Left, CityMark2.Top) 4262 else if ywmax <= 0 then 4263 Frame(Panel.Canvas, 4264 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2, 4265 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + 2 + G.ly - 1, 4266 MainTexture.clMark, MainTexture.clMark) 4267 else 4268 Frame(Panel.Canvas, 4269 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2 + yw, 4270 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + yw + MapHeight div yyt, 4271 MainTexture.clMark, MainTexture.clMark); 4247 with MainMap do begin 4248 BitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 4249 MiniMap.Bitmap.Canvas, 0, 0); 4250 if MarkCityLoc >= 0 then 4251 Sprite(Panel, HGrSystem, xMini - 2 + (4 * G.lx + 2 * (MarkCityLoc mod G.lx) 4252 + (G.lx - MapWidth div (xxt * 2)) - 2 * xwd) mod (2 * G.lx) + 4253 MarkCityLoc div G.lx and 1, yMini - 3 + MarkCityLoc div G.lx, CityMark2.Width, 4254 CityMark2.Height, CityMark2.Left, CityMark2.Top) 4255 else if ywmax <= 0 then 4256 Frame(Panel.Canvas, 4257 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2, 4258 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + 2 + G.ly - 1, 4259 MainTexture.clMark, MainTexture.clMark) 4260 else 4261 Frame(Panel.Canvas, 4262 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2 + yw, 4263 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + yw + MapHeight div yyt, 4264 MainTexture.clMark, MainTexture.clMark); 4265 end; 4272 4266 end; 4273 4267 … … 4457 4451 end; 4458 4452 end; 4459 if xSrcBase >= 0 then 4453 with MainMap do begin 4454 if xSrcBase >= 0 then 4455 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2, 4456 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1), 4457 1 + ySrcBase * (yyt * 3 + 1)); 4460 4458 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2, 4461 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1), 4462 1 + ySrcBase * (yyt * 3 + 1)); 4463 Sprite(Panel, HGrTerrain, xTroop + 2 + x, yTroop + 9 - yyt, xxt * 2, 4464 yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 4465 if BrushTypes[i] = BrushType then 4466 begin 4467 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + x, 4468 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + x, 4469 yTroop + 2 * yyt + 11, $000000, $000000); 4470 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + x, 4471 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + x, 4472 yTroop + 2 * yyt + 10, MainTexture.clMark, MainTexture.clMark); 4473 end 4459 yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); 4460 if BrushTypes[i] = BrushType then begin 4461 ScreenTools.Frame(Panel.Canvas, xTroop + 2 + x, 4462 yTroop + 7 - yyt div 2, xTroop + 2 * xxt + x, 4463 yTroop + 2 * yyt + 11, $000000, $000000); 4464 ScreenTools.Frame(Panel.Canvas, xTroop + 1 + x, 4465 yTroop + 6 - yyt div 2, xTroop + 2 * xxt - 1 + x, 4466 yTroop + 2 * yyt + 10, MainTexture.clMark, MainTexture.clMark); 4467 end; 4468 end; 4474 4469 end; 4475 4470 inc(Count) … … 4637 4632 xTroop + 63 + x, yTroop + 46, 8, MainTexture.clMark); 4638 4633 end; 4639 NoMap .SetOutput(Panel);4640 NoMap .PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo,4634 NoMapPanel.SetOutput(Panel); 4635 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, UnitInfo, 4641 4636 unx.Status); 4642 4637 if (ClientMode < scContact) and … … 4655 4650 xTroop + x + 34 - BiColorTextWidth(Panel.Canvas, s) 4656 4651 div 2, yTroop - 16, s); 4657 end 4652 end; 4658 4653 end; 4659 4654 inc(Count) … … 4661 4656 end; // for uix:=0 to MyRO.nUn-1 4662 4657 assert(Count = TrCnt); 4663 end 4658 end; 4664 4659 end 4665 4660 else … … 4673 4668 trix[i - TrRow * sb.Position] := i; 4674 4669 x := (i - TrRow * sb.Position) * TrPitch; 4675 NoMap .SetOutput(Panel);4676 NoMap .PaintUnit(xTroop + 2 + x, yTroop + 1,4670 NoMapPanel.SetOutput(Panel); 4671 NoMapPanel.PaintUnit(xTroop + 2 + x, yTroop + 1, 4677 4672 MyRO.EnemyUn[MyRO.nEnemyUn + i], 0); 4678 4673 end; … … 4681 4676 if not SmallScreen or supervising then 4682 4677 begin // show terrain and improvements 4683 PaintZoomedTile(Panel, xTerrain - xxt * 2, 110 - yyt * 3, TroopLoc);4684 if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then4685 begin4678 with NoMapPanel do 4679 PaintZoomedTile(Panel, xTerrain - xxt * 2, 110 - yyt * 3, TroopLoc); 4680 if (UnFocus >= 0) and (MyUn[UnFocus].Job <> jNone) then begin 4686 4681 JobFocus := MyUn[UnFocus].Job; 4687 4682 Server(sGetJobProgress, me, MyUn[UnFocus].Loc, JobProgressData); … … 4731 4726 (PanelHeight - 1), Left + width, Top + height - self.ClientHeight + 4732 4727 PanelHeight, MainTexture.clBevelShade, MainTexture.clBevelLight) 4733 end { if TroopLoc>=0 }4728 end; { if TroopLoc>=0 } 4734 4729 end; 4735 4730 … … 4761 4756 (PanelHeight - 1), Left + width, Top + height - self.ClientHeight + 4762 4757 PanelHeight, MainTexture.clBevelShade, MainTexture.clBevelLight); 4763 end 4758 end; 4764 4759 end; 4765 4760 EOT.SetBack(Panel.Canvas, EOT.Left, EOT.Top - (ClientHeight - PanelHeight)); … … 4898 4893 Outside, Changed: boolean; 4899 4894 begin 4900 dx := G.lx + 1 - (xw - Loc + G.lx * 1024 + 1) mod G.lx; 4901 Outside := (dx >= (MapWidth + 1) div (xxt * 2) - 2) or (ywmax > 0) and 4902 ((yw > 0) and (Loc div G.lx <= yw + 1) or (yw < ywmax) and 4903 (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2)); 4895 with MainMap do begin 4896 dx := G.lx + 1 - (xw - Loc + G.lx * 1024 + 1) mod G.lx; 4897 Outside := (dx >= (MapWidth + 1) div (xxt * 2) - 2) or (ywmax > 0) and 4898 ((yw > 0) and (Loc div G.lx <= yw + 1) or (yw < ywmax) and 4899 (Loc div G.lx >= yw + (MapHeight - 1) div yyt - 2)); 4900 end; 4904 4901 Changed := true; 4905 if Outside then 4906 begin 4902 if Outside then begin 4907 4903 Centre(Loc); 4908 4904 PaintAllMaps; … … 5077 5073 procedure TMainScreen.Centre(Loc: integer); 5078 5074 begin 5079 if FastScrolling and MapValid then 5080 Update; 5081 // necessary because ScrollDC for form canvas is called after 5082 xw := (Loc mod G.lx - (MapWidth - xxt * 2 * ((Loc div G.lx) and 1)) 5083 div (xxt * 4) + G.lx) mod G.lx; 5084 if ywmax <= 0 then 5085 yw := ywcenter 5086 else 5087 begin 5088 yw := (Loc div G.lx - MapHeight div (yyt * 2) + 1) and not 1; 5089 if yw < 0 then 5090 yw := 0 5091 else if yw > ywmax then 5092 yw := ywmax; 5075 with MainMap do begin 5076 if FastScrolling and MapValid then 5077 Update; 5078 // necessary because ScrollDC for form canvas is called after 5079 xw := (Loc mod G.lx - (MapWidth - xxt * 2 * ((Loc div G.lx) and 1)) 5080 div (xxt * 4) + G.lx) mod G.lx; 5081 if ywmax <= 0 then 5082 yw := ywcenter 5083 else begin 5084 yw := (Loc div G.lx - MapHeight div (yyt * 2) + 1) and not 1; 5085 if yw < 0 then 5086 yw := 0 5087 else if yw > ywmax then 5088 yw := ywmax; 5089 end; 5093 5090 end; 5094 5091 end; … … 5121 5118 PanelPaint; 5122 5119 ShowNewContent(wmPersistent, Loc, ShowEvent); 5123 end 5120 end; 5124 5121 end; 5125 5122 … … 5128 5125 qx, qy: integer; 5129 5126 begin 5130 qx := (x * (yyt * 2) + y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1; 5131 qy := (y * (xxt * 2) - x * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt) 5132 div (xxt * yyt * 4) - 999; 5133 result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * 5134 (yw + qx + qy); 5127 with MainMap do begin 5128 qx := (x * (yyt * 2) + y * (xxt * 2) + xxt * yyt * 2) div (xxt * yyt * 4) - 1; 5129 qy := (y * (xxt * 2) - x * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt) 5130 div (xxt * yyt * 4) - 999; 5131 result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * 5132 (yw + qx + qy); 5133 end; 5135 5134 end; 5136 5135 … … 5204 5203 BitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 5205 5204 MiniMap.Bitmap.Canvas, 0, 0); 5206 if ywmax <= 0 then 5207 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5208 yMini + 2, xMini + 1 + G.lx + MapWidth div (2 * xxt), 5209 yMini + 2 + G.ly - 1, MainTexture.clMark, MainTexture.clMark) 5210 else 5211 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5212 yMini + 2 + yw, xMini + 2 + G.lx + MapWidth div (2 * xxt) - 1, 5213 yMini + 2 + yw + MapHeight div yyt - 2, MainTexture.clMark, 5214 MainTexture.clMark); 5205 with MainMap do begin 5206 if ywmax <= 0 then 5207 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5208 yMini + 2, xMini + 1 + G.lx + MapWidth div (2 * xxt), 5209 yMini + 2 + G.ly - 1, MainTexture.clMark, MainTexture.clMark) 5210 else 5211 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), 5212 yMini + 2 + yw, xMini + 2 + G.lx + MapWidth div (2 * xxt) - 1, 5213 yMini + 2 + yw + MapHeight div yyt - 2, MainTexture.clMark, 5214 MainTexture.clMark); 5215 end; 5215 5216 RectInvalidate(xMini + 2, TopBarHeight + MapHeight - overlap + yMini + 2, 5216 5217 xMini + 2 + G.lx * 2, TopBarHeight + MapHeight - overlap + yMini … … 5989 5990 xw1 := xw + G.lx; 5990 5991 // ((xFromLoc-xw1)*2+yFromLoc and 1+1)*xxt+dx*xxt/2-MapWidth/2 -> min 5991 while abs(((xFromLoc - xw1 + G.lx) * 2 + yFromLoc and 1 + 1) * xxt * 2 + dx 5992 * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt 5993 * 2 + dx * xxt - MapWidth) do 5994 dec(xw1, G.lx); 5995 5996 xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu); 5997 yTo := (yToLoc - yw) * yyt + (yyt - yyu_anchor); 5998 xFrom := (xFromLoc - xw1) * (xxt * 2) + yFromLoc and 1 * xxt + (xxt - xxu); 5999 yFrom := (yFromLoc - yw) * yyt + (yyt - yyu_anchor); 6000 if xFrom < xTo then 6001 begin 6002 xMin := xFrom; 6003 xRange := xTo - xFrom 6004 end 6005 else 6006 begin 6007 xMin := xTo; 6008 xRange := xFrom - xTo 6009 end; 6010 if yFrom < yTo then 6011 begin 6012 yMin := yFrom; 6013 yRange := yTo - yFrom 6014 end 6015 else 6016 begin 6017 yMin := yTo; 6018 yRange := yFrom - yTo 6019 end; 6020 inc(xRange, xxt * 2); 6021 inc(yRange, yyt * 3); 5992 with MainMap do begin 5993 while abs(((xFromLoc - xw1 + G.lx) * 2 + yFromLoc and 1 + 1) * xxt * 2 + dx 5994 * xxt - MapWidth) < abs(((xFromLoc - xw1) * 2 + yFromLoc and 1 + 1) * xxt 5995 * 2 + dx * xxt - MapWidth) do 5996 dec(xw1, G.lx); 5997 5998 xTo := (xToLoc - xw1) * (xxt * 2) + yToLoc and 1 * xxt + (xxt - xxu); 5999 yTo := (yToLoc - yw) * yyt + (yyt - yyu_anchor); 6000 xFrom := (xFromLoc - xw1) * (xxt * 2) + yFromLoc and 1 * xxt + (xxt - xxu); 6001 yFrom := (yFromLoc - yw) * yyt + (yyt - yyu_anchor); 6002 if xFrom < xTo then begin 6003 xMin := xFrom; 6004 xRange := xTo - xFrom 6005 end else begin 6006 xMin := xTo; 6007 xRange := xFrom - xTo 6008 end; 6009 if yFrom < yTo then begin 6010 yMin := yFrom; 6011 yRange := yTo - yFrom 6012 end else begin 6013 yMin := yTo; 6014 yRange := yFrom - yTo 6015 end; 6016 inc(xRange, xxt * 2); 6017 inc(yRange, yyt * 3); 6018 end; 6022 6019 6023 6020 MainOffscreenPaint; … … 6121 6118 begin 6122 6119 assert(false); 6123 Break 6120 Break; 6124 6121 end; 6125 6122 until false; … … 6147 6144 NextUnit(UnStartLoc, true) 6148 6145 end; 6149 end 6150 end 6151 end 6146 end; 6147 end; 6148 end; 6152 6149 end; 6153 6150 … … 6166 6163 if ssShift in Shift then 6167 6164 begin 6168 xMouse := (xwMini + (x - (xMini + 2) + MapWidth div (xxt * 2) + G.lx) 6169 div 2) mod G.lx; 6165 with MainMap do 6166 xMouse := (xwMini + (x - (xMini + 2) + MapWidth div (xxt * 2) + G.lx) 6167 div 2) mod G.lx; 6170 6168 MouseLoc := xMouse + G.lx * (y - (yMini + 2)); 6171 6169 if MyMap[MouseLoc] and fTerrain <> fUNKNOWN then … … 6174 6172 if (p1 = me) or (p1 >= 0) and (MyRO.Treaty[p1] >= trNone) then 6175 6173 NatStatDlg.ShowNewContent(wmPersistent, p1); 6176 end 6174 end; 6177 6175 end 6178 6176 else … … 6269 6267 CheckTerrainBtnVisible; 6270 6268 PanelPaint; 6271 end 6269 end; 6272 6270 end 6273 6271 else if Server(sGetUnits, me, TroopLoc, TrCnt) >= rExecuted then … … 6278 6276 UnitStatDlg.ShowNewContent_EnemyUnit(wmPersistent, 6279 6277 MyRO.nEnemyUn + trix[i]); // unit info 6280 end 6281 end 6278 end; 6279 end; 6282 6280 end; 6283 6281 … … 6371 6369 procedure TMainScreen.SetDebugMap(p: integer); 6372 6370 begin 6373 IsoEngine.pDebugMap := p;6374 IsoEngine.MapOptions := IsoEngine.MapOptions - [moLocCodes];6371 MainMap.pDebugMap := p; 6372 MainMap.MapOptions := MainMap.MapOptions - [moLocCodes]; 6375 6373 mLocCodes.Checked := false; 6376 6374 MapValid := false; … … 7234 7232 m.ShortCut := ShortCut(48 + p1, [ssAlt]); 7235 7233 m.RadioItem := true; 7236 if m.Tag = IsoEngine.pDebugMap then7234 if m.Tag = MainMap.pDebugMap then 7237 7235 m.Checked := true; 7238 7236 mDebugMap.Add(m); 7239 7237 end; 7240 7238 end; 7241 mSmallTiles.Checked := TileSize = tsSmall;7242 mNormalTiles.Checked := TileSize = tsMedium;7243 mBigTiles.Checked := TileSize = tsBig;7239 mSmallTiles.Checked := MainMap.TileSize = tsSmall; 7240 mNormalTiles.Checked := MainMap.TileSize = tsMedium; 7241 mBigTiles.Checked := MainMap.TileSize = tsBig; 7244 7242 end 7245 7243 else if Popup = StatPopup then … … 7432 7430 FocusOnLoc(TroopLoc, flRepaintPanel) 7433 7431 else 7434 PanelPaint 7432 PanelPaint; 7435 7433 end 7436 7434 else if StepFocus then … … 7439 7437 begin 7440 7438 SetTroopLoc(-1); 7441 PanelPaint 7439 PanelPaint; 7442 7440 end; 7443 7441 end; … … 7455 7453 begin 7456 7454 if Tracking and (ssLeft in Shift) then 7457 begin7455 with MainMap do begin 7458 7456 if (x >= xMini + 2) and (y >= yMini + 2) and (x < xMini + 2 + 2 * G.lx) and 7459 7457 (y < yMini + 2 + G.ly) then … … 7703 7701 with Reg do try 7704 7702 OpenKey(AppRegistryKey, False); 7705 if ValueExists('TileSize') then TileSize := TTileSize(ReadInteger('TileSize')) 7706 else TileSize := tsMedium; 7707 xxt := TileSizes[TileSize].X; 7708 yyt := TileSizes[TileSize].Y; 7703 if ValueExists('TileSize') then MainMap.TileSize := TTileSize(ReadInteger('TileSize')) 7704 else MainMap.TileSize := tsMedium; 7705 NoMap.TileSize := MainMap.TileSize; 7709 7706 if ValueExists('OptionChecked') then OptionChecked := TSaveOptions(ReadInteger('OptionChecked')) 7710 7707 else OptionChecked := DefaultOptionChecked; … … 7953 7950 i, CenterLoc: integer; 7954 7951 begin 7955 CenterLoc := (xw + MapWidth div (xxt * 4)) mod G.lx + 7956 (yw + MapHeight div (yyt * 2)) * G.lx; 7957 IsoEngine.ApplyTileSize(TileSize); 7952 CenterLoc := (xw + MapWidth div (MainMap.xxt * 4)) mod G.lx + 7953 (yw + MapHeight div (MainMap.yyt * 2)) * G.lx; 7954 MainMap.TileSize := TileSize; 7955 NoMap.TileSize := TileSize; 7958 7956 FormResize(nil); 7959 7957 Centre(CenterLoc); … … 7988 7986 try 7989 7987 OpenKey(AppRegistryKey, true); 7990 WriteInteger('TileSize', Integer( TileSize));7988 WriteInteger('TileSize', Integer(MainMap.TileSize)); 7991 7989 WriteInteger('OptionChecked', Integer(OptionChecked)); 7992 7990 WriteInteger('MapOptionChecked', Integer(MapOptionChecked));
Note:
See TracChangeset
for help on using the changeset viewer.