- Timestamp:
- Mar 26, 2021, 2:16:04 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Battle.pas
r313 r330 6 6 uses 7 7 ScreenTools, Protocol, ButtonBase, ButtonA, Types, LCLIntf, LCLType, 8 SysUtils, Classes, Graphics, Controls, Forms, DrawDlg ;8 SysUtils, Classes, Graphics, Controls, Forms, DrawDlg, IsoEngine; 9 9 10 10 type 11 12 { TBattleDlg } 13 11 14 TBattleDlg = class(TDrawDlg) 12 15 OKBtn: TButtonA; 13 16 CancelBtn: TButtonA; 17 procedure FormDestroy(Sender: TObject); 14 18 procedure FormPaint(Sender: TObject); 15 19 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; … … 21 25 procedure OKBtnClick(Sender: TObject); 22 26 procedure CancelBtnClick(Sender: TObject); 27 procedure PaintBattleOutcome(ca: TCanvas; xm, ym, uix, ToLoc: Integer; 28 Forecast: TBattleForecastEx); 29 private 30 IsoMap: TIsoMap; 23 31 public 24 32 uix, ToLoc: Integer; … … 30 38 BattleDlg: TBattleDlg; 31 39 32 procedure PaintBattleOutcome(ca: TCanvas; xm, ym, uix, ToLoc: Integer;33 Forecast: TBattleForecastEx);34 35 40 implementation 36 41 37 42 uses 38 Term, ClientTools , IsoEngine;43 Term, ClientTools; 39 44 40 45 {$R *.lfm} … … 48 53 FirstStrikeColor = $A0A0A0; 49 54 50 procedure PaintBattleOutcome(ca: TCanvas; xm, ym, uix, ToLoc: Integer;55 procedure TBattleDlg.PaintBattleOutcome(ca: TCanvas; xm, ym, uix, ToLoc: Integer; 51 56 Forecast: TBattleForecastEx); 52 57 var … … 172 177 (LADamage - LAAvoidedDamage - TextSize.cy) div 2, LabelText); 173 178 174 NoMap.SetOutput(Buffer);179 IsoMap.SetOutput(Buffer); 175 180 BitBltCanvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm + 8 + 4, 176 181 ym - 8 - 12 - 48); … … 184 189 else Sprite(Buffer,HGrTerrain,0,16,66,32,1+7*(xxt*2+1),1+yyt+2*(2+TerrType-fForest)*(yyt*3+1)); 185 190 end; } 186 NoMap.PaintUnit(1, 0, UnitInfo, 0);191 IsoMap.PaintUnit(1, 0, UnitInfo, 0); 187 192 BitBltCanvas(ca, xm + 8 + 4, ym - 8 - 12 - 48, 66, 48, Buffer.Canvas, 188 193 0, 0); … … 192 197 MakeUnitInfo(me, MyUn[uix], UnitInfo); 193 198 UnitInfo.Flags := UnitInfo.Flags and not unFortified; 194 NoMap.PaintUnit(1, 0, UnitInfo, 0);199 IsoMap.PaintUnit(1, 0, UnitInfo, 0); 195 200 BitBltCanvas(ca, xm - 8 - 4 - 66, ym + 8 + 12, 66, 48, Buffer.Canvas, 0, 0); 196 201 end; { PaintBattleOutcome } … … 198 203 procedure TBattleDlg.FormCreate(Sender: TObject); 199 204 begin 205 IsoMap := TIsoMap.Create; 200 206 OKBtn.Caption := Phrases.Lookup('BTN_YES'); 201 207 CancelBtn.Caption := Phrases.Lookup('BTN_NO'); … … 276 282 end; 277 283 284 procedure TBattleDlg.FormDestroy(Sender: TObject); 285 begin 286 FreeAndNil(IsoMap); 287 end; 288 278 289 procedure TBattleDlg.FormMouseDown(Sender: TObject; Button: TMouseButton; 279 290 Shift: TShiftState; X, Y: Integer); -
trunk/LocalPlayer/CityScreen.pas
r328 r330 407 407 rare: boolean; 408 408 begin 409 with AreaMap do begin 409 410 if Server(sGetCityTileInfo, me, Loc, TileInfo) <> eOk then 410 411 begin … … 442 443 Sprite(offscreen, HGrSystem, x + xxt - 5 + d * (2 * i + 1 - Total), 443 444 y + yyt - 5, 10, 10, xGr, yGr); 445 end; 444 446 end; 445 447 end; … … 593 595 end; 594 596 597 with AreaMap do begin 595 598 rx := (192 + xxt * 2 - 1) div (xxt * 2); 596 599 ry := (96 + yyt * 2 - 1) div (yyt * 2); … … 619 622 Loc1, (dx = 0) and (dy = 0)); 620 623 end; 624 end; 621 625 622 626 if Report.Working > 1 then … … 930 934 y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20; 931 935 MakeUnitInfo(me, MyUn[i], UnitInfo); 932 NoMap.SetOutput(offscreen);933 NoMap.PaintUnit(x, y, UnitInfo, MyUn[i].Status);936 AreaMap.SetOutput(offscreen); 937 AreaMap.PaintUnit(x, y, UnitInfo, MyUn[i].Status); 934 938 935 939 for j := 0 to UnitReport.FoodSupport - 1 do … … 1317 1321 else if (x >= xmArea - 192) and (x < xmArea + 192) and (y >= ymArea - 96) 1318 1322 and (y < ymArea + 96) then 1323 with AreaMap do 1319 1324 begin 1320 1325 qx := ((4000 * xxt * yyt) + (x - xmArea) * (yyt * 2) + (y - ymArea + yyt) -
trunk/LocalPlayer/Enhance.pas
r313 r330 7 7 ScreenTools, BaseWin, Protocol, ClientTools, Term, LCLIntf, LCLType, 8 8 9 SysUtils, Classes, Graphics, Controls, Forms, 9 SysUtils, Classes, Graphics, Controls, Forms, IsoEngine, 10 10 ButtonB, ButtonC, Menus; 11 11 … … 28 28 Popup: TPopupMenu; 29 29 procedure FormCreate(Sender: TObject); 30 procedure FormDestroy(Sender: TObject); 30 31 procedure FormPaint(Sender: TObject); 31 32 procedure FormShow(Sender: TObject); … … 35 36 procedure JobClick(Sender: TObject); 36 37 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 38 private 39 NoMap: TIsoMap; 37 40 public 38 41 procedure ShowNewContent(NewMode: integer; TerrType: integer = -1); … … 47 50 implementation 48 51 49 uses Help; 52 uses 53 Help; 50 54 51 55 {$R *.lfm} … … 57 61 begin 58 62 inherited; 63 NoMap := TIsoMap.Create; 59 64 CaptionRight := CloseBtn.Left; 60 65 CaptionLeft := ToggleBtn.Left + ToggleBtn.Width; … … 85 90 end; 86 91 92 procedure TEnhanceDlg.FormDestroy(Sender: TObject); 93 begin 94 FreeAndNil(NoMap); 95 end; 96 87 97 procedure TEnhanceDlg.FormPaint(Sender: TObject); 88 98 var … … 129 139 while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do 130 140 inc(EndStage); 131 x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage; 141 with NoMap do 142 x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage; 132 143 133 144 TerrType := Page; … … 185 196 end; 186 197 187 if TerrType < fForest then 188 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 189 1 + TerrType * (xxt * 2 + 1), 1 + yyt) 190 else 191 begin 192 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 193 1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1)); 194 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 195 1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) * 196 (yyt * 3 + 1)); 197 end; 198 if TileImp and fTerImp = tiFarm then 199 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 200 1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)) 201 else if TileImp and fTerImp = tiIrrigation then 202 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1, 203 1 + yyt + 12 * (yyt * 3 + 1)); 204 if TileImp and fRR <> 0 then 205 begin 206 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 207 1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 208 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 209 1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 210 end 211 else if TileImp and fRoad <> 0 then 212 begin 213 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 214 1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 215 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 216 1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 217 end; 218 if TileImp and fTerImp = tiMine then 219 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 220 1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)); 221 inc(x, xxt * 2 + 6) 198 with NoMap do begin 199 if TerrType < fForest then 200 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 201 1 + TerrType * (xxt * 2 + 1), 1 + yyt) 202 else 203 begin 204 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 205 1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1)); 206 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 207 1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) * 208 (yyt * 3 + 1)); 209 end; 210 if TileImp and fTerImp = tiFarm then 211 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 212 1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)) 213 else if TileImp and fTerImp = tiIrrigation then 214 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1, 215 1 + yyt + 12 * (yyt * 3 + 1)); 216 if TileImp and fRR <> 0 then 217 begin 218 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 219 1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 220 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 221 1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1)); 222 end 223 else if TileImp and fRoad <> 0 then 224 begin 225 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 226 1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 227 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 228 1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1)); 229 end; 230 if TileImp and fTerImp = tiMine then 231 Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 232 1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1)); 233 inc(x, xxt * 2 + 6) 234 end; 222 235 end; 223 236 -
trunk/LocalPlayer/Help.pas
r328 r330 7 7 Protocol, ScreenTools, BaseWin, StringTables, Math, LCLIntf, LCLType, 8 8 Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, 9 ButtonB, PVSB, Types, fgl ;9 ButtonB, PVSB, Types, fgl, IsoEngine; 10 10 11 11 const … … 102 102 ExtPic, TerrIcon: TBitmap; 103 103 ScrollBar: TPVScrollbar; 104 NoMap: TIsoMap; 104 105 x0: array [-2..180] of Integer; 105 106 procedure PaintTerrIcon(x, y, xSrc, ySrc: Integer); … … 273 274 begin 274 275 inherited; 276 NoMap := TIsoMap.Create; 277 275 278 HistItems := THistItems.Create; 276 279 … … 331 334 // FreeAndNil(CaptionFont); 332 335 FreeAndNil(HistItems); 336 FreeAndNil(NoMap); 333 337 end; 334 338 … … 502 506 procedure THelpDlg.PaintTerrIcon(x, y, xSrc, ySrc: integer); 503 507 begin 504 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig, 505 $000000, $000000); 506 if 2 * yyt < 40 then begin 507 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc); 508 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt, 508 with NoMap do begin 509 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig, 510 $000000, $000000); 511 if 2 * yyt < 40 then begin 512 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc); 513 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt, 514 xSrc, ySrc); 515 end else 516 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc); 517 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt); 518 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc); 519 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt); 520 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt, 509 521 xSrc, ySrc); 510 end else 511 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc); 512 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt); 513 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc); 514 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt); 515 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt, 516 xSrc, ySrc); 522 end; 517 523 end; 518 524 … … 605 611 12 + x0[i], -7 + i * 24, 56, 40, 137, 127); 606 612 1: 607 begin613 with NoMap do begin 608 614 PaintTerrIcon(12 + x0[i], -7 + i * 24, 609 615 1 + 3 * (xxt * 2 + 1), 1 + yyt); … … 618 624 end; 619 625 2: 620 begin626 with NoMap do begin 621 627 PaintTerrIcon(12 + x0[i], -7 + i * 24, 622 628 1 + 7 * (xxt * 2 + 1), 1 + yyt + 4 * (yyt * 3 + 1)); … … 703 709 end; 704 710 pkTer, pkBigTer: 705 begin711 with NoMap do begin 706 712 if HelpLineInfo.Format = pkBigTer then 707 713 y := i * 24 - 3 + yyt … … 758 764 end; 759 765 pkTerImp: 760 begin766 with NoMap do begin 761 767 ofs := 8; 762 768 if HelpLineInfo.Picpix = 5 then -
trunk/LocalPlayer/IsoEngine.pas
r327 r330 5 5 6 6 uses 7 Protocol, ClientTools, ScreenTools, Tribes, {$IFNDEF SCR}Term, {$ENDIF}7 Protocol, ClientTools, ScreenTools, Tribes, 8 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, UPixelPointer, UGraphicSet; 9 10 const 11 TerrainIconLines = 21; 12 TerrainIconCols = 9; 9 13 10 14 type 11 15 TInitEnemyModelEvent = function(emix: integer): boolean; 16 TTileSize = (tsSmall, tsMedium, tsBig); 17 18 TTerrainSpriteSize = array of TRect; 19 20 { TCitiesPictures } 21 22 TCitiesPictures = class 23 Pictures: array [2..3, 0..3] of TCityPicture; 24 procedure Prepare(HGrCities: TGraphicSet; xxt, yyt: Integer); 25 end; 12 26 13 27 { TIsoMap } … … 15 29 TIsoMap = class 16 30 private 31 FTileSize: TTileSize; 17 32 const 18 33 Dirx: array [0..7] of Integer = (1, 2, 1, 0, -1, -2, -1, 0); … … 21 36 function IsShoreTile(Loc: integer): boolean; 22 37 procedure MakeDark(Line: PPixelPointer; Length: Integer); 38 procedure SetTileSize(AValue: TTileSize); 23 39 procedure ShadeOutside(x0, y0, Width, Height, xm, ym: integer); 24 40 protected … … 36 52 DataCanvas: TCanvas; 37 53 MaskCanvas: TCanvas; 54 LandPatch: TBitmap; 55 OceanPatch: TBitmap; 56 Borders: TBitmap; 57 BordersOK: PInteger; 58 CitiesPictures: TCitiesPictures; 38 59 function Connection4(Loc, Mask, Value: integer): integer; 39 60 function Connection8(Loc, Mask: integer): integer; … … 48 69 procedure Sprite(HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer); 49 70 procedure TSprite(xDst, yDst, grix: integer; PureBlack: boolean = false); 71 procedure ApplyTileSize(ATileSize: TTileSize); 50 72 public 73 xxt: Integer; // half of tile size x/y 74 yyt: Integer; // half of tile size x/y 75 TSpriteSize: TTerrainSpriteSize; 76 HGrTerrain: TGraphicSet; 77 HGrCities: TGraphicSet; 78 MapOptions: TMapOptions; 79 pDebugMap: Integer; // -1 for off 51 80 constructor Create; 81 destructor Destroy; override; 82 procedure Reset; 52 83 procedure SetOutput(Output: TBitmap); 53 84 procedure SetPaintBounds(Left, Top, Right, Bottom: integer); … … 63 94 procedure AttackEffect(const ShowMove: TShowMove); 64 95 procedure AttackEnd; 96 procedure ReduceTerrainIconsSize; 65 97 property AdviceLoc: integer read FAdviceLoc write FAdviceLoc; 66 end; 67 68 var 69 NoMap: TIsoMap; 70 MapOptions: TMapOptions; 71 pDebugMap: Integer; // -1 for off 98 property TileSize: TTileSize read FTileSize write SetTileSize; 99 end; 100 101 { TIsoMapCache } 102 103 TIsoMapCache = class 104 LandPatch: TBitmap; 105 OceanPatch: TBitmap; 106 Borders: TBitmap; 107 BordersOk: Integer; 108 TSpriteSize: TTerrainSpriteSize; 109 HGrTerrain: TGraphicSet; 110 HGrCities: TGraphicSet; 111 CitiesPictures: TCitiesPictures; 112 procedure AssignToIsoMap(IsoMap: TIsoMap); 113 constructor Create; 114 destructor Destroy; override; 115 end; 116 117 const 118 DefaultTileSize: TTileSize = tsMedium; 119 TileSizes: array [TTileSize] of TPoint = ((X: 33; Y: 16), (X: 48; Y: 24), 120 (X: 72; Y: 36)); 72 121 73 122 function IsJungle(y: integer): boolean; 74 123 procedure Init(InitEnemyModelHandler: TInitEnemyModelEvent); 75 function ApplyTileSize(ATileSize: TTileSize): boolean; 76 procedure Done; 77 procedure IsoEngineReset; 124 78 125 79 126 implementation 127 128 uses 129 Term; 80 130 81 131 const 82 132 ShoreDither = fGrass; 83 TerrainIconLines = 21;84 TerrainIconCols = 9;85 133 86 134 // sprites indexes … … 111 159 112 160 var 113 BordersOK: integer;114 161 OnInitEnemyModel: TInitEnemyModelEvent; 115 LandPatch: TBitmap;116 OceanPatch: TBitmap;117 Borders: TBitmap;118 TSpriteSize: array [0 .. TerrainIconLines * TerrainIconCols - 1] of TRect;119 162 DebugMap: ^TTileList; 120 CitiesPictures: array [2 .. 3, 0 .. 3] of TCityPicture;121 163 FoW: Boolean; 122 164 ShowLoc: Boolean; … … 127 169 ShowGrWall: Boolean; 128 170 ShowDebug: Boolean; 171 IsoMapCache: array[TTileSize] of TIsoMapCache; 129 172 130 173 function IsJungle(y: integer): boolean; … … 136 179 begin 137 180 OnInitEnemyModel := InitEnemyModelHandler; 138 if NoMap <> nil then 139 FreeAndNil(NoMap); 140 NoMap := TIsoMap.Create; 141 end; 142 143 procedure ReduceTerrainIconsSize; 181 end; 182 183 { TCitiesPictures } 184 185 procedure TCitiesPictures.Prepare(HGrCities: TGraphicSet; xxt, yyt: Integer); 186 var 187 Age: Integer; 188 Size: Integer; 189 begin 190 // prepare age 2+3 cities 191 for age := 2 to 3 do 192 for size := 0 to 3 do 193 with Pictures[Age, Size] do 194 FindPosition(HGrCities, Size * (xxt * 2 + 1), (Age - 2) * (yyt * 3 + 1), 195 xxt * 2 - 1, yyt * 3 - 1, $00FFFF, xShield, yShield); 196 end; 197 198 { TIsoMapCache } 199 200 procedure TIsoMapCache.AssignToIsoMap(IsoMap: TIsoMap); 201 begin 202 IsoMap.HGrTerrain := HGrTerrain; 203 IsoMap.HGrCities := HGrCities; 204 IsoMap.Borders := Borders; 205 IsoMap.BordersOK := @BordersOk; 206 IsoMap.LandPatch := LandPatch; 207 IsoMap.OceanPatch := OceanPatch; 208 IsoMap.TSpriteSize := TSpriteSize; 209 IsoMap.CitiesPictures := CitiesPictures; 210 end; 211 212 constructor TIsoMapCache.Create; 213 begin 214 LandPatch := TBitmap.Create; 215 LandPatch.PixelFormat := pf24bit; 216 OceanPatch := TBitmap.Create; 217 OceanPatch.PixelFormat := pf24bit; 218 Borders := TBitmap.Create; 219 Borders.PixelFormat := pf24bit; 220 HGrTerrain := nil; 221 HGrCities := nil; 222 SetLength(TSpriteSize, TerrainIconLines * TerrainIconCols); 223 CitiesPictures := TCitiesPictures.Create; 224 end; 225 226 destructor TIsoMapCache.Destroy; 227 begin 228 FreeAndNil(CitiesPictures); 229 FreeAndNil(LandPatch); 230 FreeAndNil(OceanPatch); 231 FreeAndNil(Borders); 232 inherited; 233 end; 234 235 procedure TIsoMap.ReduceTerrainIconsSize; 144 236 var 145 237 MaskLine: array of TPixelPointer; … … 206 298 end; 207 299 208 function ApplyTileSize(ATileSize: TTileSize): boolean;300 procedure TIsoMap.ApplyTileSize(ATileSize: TTileSize); 209 301 var 210 302 x: Integer; … … 212 304 xSrc: Integer; 213 305 ySrc: Integer; 214 HGrTerrainNew: TGraphicSet;215 HGrCitiesNew: TGraphicSet;216 Age: Integer;217 Size: Integer;218 306 LandMore: TBitmap; 219 307 OceanMore: TBitmap; 220 308 DitherMask: TBitmap; 221 xxtNew: Integer; 222 yytNew: Integer; 223 begin 224 xxtNew := TileSizes[ATileSize].X; 225 yytNew := TileSizes[ATileSize].Y; 226 result := false; 227 HGrTerrainNew := LoadGraphicSet(Format('Terrain%dx%d.png', 228 [xxtNew * 2, yytNew * 2])); 229 if not Assigned(HGrTerrainNew) then 230 exit; 231 HGrCitiesNew := LoadGraphicSet(Format('Cities%dx%d.png', 232 [xxtNew * 2, yytNew * 2])); 233 if not Assigned(HGrCitiesNew) then 234 exit; 235 xxt := xxtNew; 236 yyt := yytNew; 237 TileSize := ATileSize; 238 HGrTerrain := HGrTerrainNew; 239 HGrCities := HGrCitiesNew; 240 Result := true; 241 242 // prepare age 2+3 cities 243 for age := 2 to 3 do 244 for size := 0 to 3 do 245 with CitiesPictures[age, size] do 246 FindPosition(HGrCities, size * (xxt * 2 + 1), (age - 2) * (yyt * 3 + 1), 247 xxt * 2 - 1, yyt * 3 - 1, $00FFFF, xShield, yShield); 309 FileName: string; 310 begin 311 FTileSize := ATileSize; 312 xxt := TileSizes[ATileSize].X; 313 yyt := TileSizes[ATileSize].Y; 314 315 if Assigned(IsoMapCache[ATileSize]) then begin 316 IsoMapCache[ATileSize].AssignToIsoMap(Self); 317 Exit; 318 end; 319 IsoMapCache[ATileSize] := TIsoMapCache.Create; 320 321 FileName := Format('Terrain%dx%d.png', [xxt * 2, yyt * 2]); 322 IsoMapCache[ATileSize].HGrTerrain := LoadGraphicSet(FileName); 323 if not Assigned(IsoMapCache[ATileSize].HGrTerrain) then 324 raise Exception.Create(FileName + ' not found.'); 325 326 FileName := Format('Cities%dx%d.png', [xxt * 2, yyt * 2]); 327 IsoMapCache[ATileSize].HGrCities := LoadGraphicSet(FileName); 328 if not Assigned(IsoMapCache[ATileSize].HGrCities) then 329 raise Exception.Create(FileName + ' not found.'); 330 331 IsoMapCache[ATileSize].AssignToIsoMap(Self); 332 333 CitiesPictures.Prepare(HGrCities, xxt, yyt); 248 334 249 335 { prepare dithered ground tiles } 250 if not Assigned(LandPatch) then begin251 LandPatch := TBitmap.Create;252 LandPatch.PixelFormat := pf24bit;253 end;254 336 LandPatch.Canvas.Brush.Color := 0; 255 337 LandPatch.SetSize(xxt * 18, yyt * 9); 256 338 LandPatch.Canvas.FillRect(0, 0, LandPatch.Width, LandPatch.Height); 257 if not Assigned(OceanPatch) then begin258 OceanPatch := TBitmap.Create;259 OceanPatch.PixelFormat := pf24bit;260 end;261 339 OceanPatch.Canvas.Brush.Color := 0; 262 340 OceanPatch.SetSize(xxt * 8, yyt * 4); … … 437 515 ReduceTerrainIconsSize; 438 516 439 if not Assigned(Borders) then begin440 Borders := TBitmap.Create;441 Borders.PixelFormat := pf24bit;442 end;443 517 Borders.SetSize(xxt * 2, (yyt * 2) * nPl); 444 518 Borders.Canvas.FillRect(0, 0, Borders.Width, Borders.Height); 445 BordersOK := 0; 446 end; 447 448 procedure Done; 449 begin 450 FreeAndNil(NoMap); 451 FreeAndNil(LandPatch); 452 FreeAndNil(OceanPatch); 453 FreeAndNil(Borders); 454 end; 455 456 procedure IsoEngineReset; 457 begin 458 BordersOK := 0; 519 BordersOK^ := 0; 520 end; 521 522 procedure TIsoMap.Reset; 523 begin 524 BordersOK^ := 0; 459 525 end; 460 526 … … 469 535 DefLoc := -1; 470 536 FAdviceLoc := -1; 537 TileSize := DefaultTileSize; 538 end; 539 540 destructor TIsoMap.Destroy; 541 begin 542 inherited; 471 543 end; 472 544 … … 711 783 else 712 784 begin 713 cpic := CitiesPictures [age, xGr];785 cpic := CitiesPictures.Pictures[age, xGr]; 714 786 xShield := x - xxt + cpic.xShield; 715 787 yShield := y - 2 * yyt + cpic.yShield; … … 1024 1096 begin 1025 1097 if ShowBorder and (Loc >= 0) and (Loc < G.lx * G.ly) and 1026 (Tile and fTerrain <> fUNKNOWN) then 1027 begin 1098 (Tile and fTerrain <> fUNKNOWN) then begin 1028 1099 p1 := MyRO.Territory[Loc]; 1029 if (p1 >= 0) and (ShowMyBorder or (p1 <> me)) then 1030 begin 1031 if BordersOK and (1 shl p1) = 0 then 1032 begin 1100 if (p1 >= 0) and (ShowMyBorder or (p1 <> me)) then begin 1101 if BordersOK^ and (1 shl p1) = 0 then begin 1033 1102 UnshareBitmap(Borders); 1034 1103 BitBltCanvas(Borders.Canvas, 0, p1 * (yyt * 2), xxt * 2, … … 1049 1118 end; 1050 1119 Borders.EndUpdate; 1051 BordersOK := BordersOKor 1 shl p1;1120 BordersOK^ := BordersOK^ or 1 shl p1; 1052 1121 end; 1053 1122 for dy := 0 to 1 do 1054 for dx := 0 to 1 do 1055 begin 1123 for dx := 0 to 1 do begin 1056 1124 Loc1 := dLoc(Loc, dx * 2 - 1, dy * 2 - 1); 1057 1125 begin … … 1071 1139 end; 1072 1140 end; 1073 end 1141 end; 1074 1142 end; 1075 1143 end; … … 1347 1415 Line^.NextPixel; 1348 1416 end; 1417 end; 1418 1419 procedure TIsoMap.SetTileSize(AValue: TTileSize); 1420 begin 1421 if FTileSize = AValue then Exit; 1422 FTileSize := AValue; 1423 ApplyTileSize(AValue); 1349 1424 end; 1350 1425 … … 1641 1716 end; 1642 1717 1643 initialization 1644 1645 NoMap := nil; 1646 LandPatch := nil; 1647 OceanPatch := nil; 1648 Borders := nil; 1718 procedure IsoEngineDone; 1719 var 1720 I: TTileSize; 1721 begin 1722 for I := Low(IsoMapCache) to High(IsoMapCache) do 1723 FreeAndNil(IsoMapCache[I]); 1724 end; 1725 1726 finalization 1727 1728 IsoEngineDone; 1649 1729 1650 1730 end. -
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)); -
trunk/LocalPlayer/UnitStat.pas
r318 r330 7 7 Protocol, ClientTools, Term, ScreenTools, BaseWin, 8 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, 9 ButtonB, ButtonC ;9 ButtonB, ButtonC, IsoEngine; 10 10 11 11 type … … 24 24 procedure FormClose(Sender: TObject; var Action: TCloseAction); 25 25 procedure HelpBtnClick(Sender: TObject); 26 26 private 27 NoMap: TIsoMap; 27 28 public 28 29 procedure CheckAge; … … 51 52 52 53 uses 53 Tribes, IsoEngine,Help, Directories;54 Tribes, Help, Directories; 54 55 55 56 {$R *.lfm} … … 73 74 begin 74 75 inherited; 76 NoMap := TIsoMap.Create; 75 77 AgePrepared := -2; 76 78 TitleHeight := Screen.Height; … … 91 93 FreeAndNil(Template); 92 94 FreeAndNil(Back); 95 FreeAndNil(NoMap); 93 96 end; 94 97 … … 521 524 begin 522 525 if Kind in [dkOwnUnit, dkEnemyUnit, dkEnemyCityDefense] then 523 with ui do526 with ui, NoMap do 524 527 begin 525 528 { Frame(offscreen.canvas,xView-1,yView-1,xView+64,yView+48, -
trunk/Packages/CevoComponents/EOTButton.pas
r323 r330 91 91 procedure TEOTButton.SetIndex(x: integer); 92 92 begin 93 if x <> FIndex then 94 begin 93 if x <> FIndex then begin 95 94 FIndex := x; 96 95 Invalidate; … … 100 99 procedure TEOTButton.SetButtonIndexFast(x: integer); 101 100 begin 102 if Visible and (x <> FIndex) then 103 begin 101 if Visible and (x <> FIndex) then begin 104 102 FIndex := x; 105 103 try 106 Paint 104 Paint; 107 105 except 108 106 end;
Note:
See TracChangeset
for help on using the changeset viewer.