Changeset 326 for trunk/UMiniMap.pas
- Timestamp:
- Mar 24, 2021, 12:08:28 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UMiniMap.pas
r320 r326 22 22 Colors: array [0 .. 11, 0 .. 1] of TColor; 23 23 Mode: TMiniMode; 24 Options: Integer; 24 25 procedure LoadFromLogFile(FileName: string; var LastTurn: Integer; DefaultSize: TPoint); 25 26 procedure LoadFromMapFile(FileName: string; var nMapLandTiles, nMapStartPositions: Integer); 26 27 procedure PaintRandom(Brightness, StartLandMass: Integer; WorldSize: TPoint); 27 28 procedure PaintFile(SaveMap: TMapArray); 29 procedure Paint(MyMap: PTileList; MapWidth: Integer; ClientMode: Integer; 30 xxt, xwMini: Integer); 28 31 constructor Create; 29 32 destructor Destroy; override; … … 34 37 35 38 uses 36 ScreenTools, UPixelPointer, Global, GameServer; 39 ScreenTools, UPixelPointer, Global, GameServer, IsoEngine, Tribes, ClientTools; 40 41 const 42 // save map tile flags 43 smOwned = $20; 44 smUnit = $40; 45 smCity = $80; 37 46 38 47 { TMiniMap } … … 169 178 xm := (x * 2 + i + y and 1) mod (ScaleToNative(Size.X) * 2); 170 179 MiniPixel.SetX(xm); 171 cm := Colors 172 [Map[ScaleFromNative(x) * lxmax div Size.X + lxmax * 180 cm := Colors[Map[ScaleFromNative(x) * lxmax div Size.X + lxmax * 173 181 ((ScaleFromNative(y) * (lymax - 1) + Size.Y div 2) div (Size.Y - 1))] and 174 182 fTerrain, i]; … … 205 213 if Tile and fTerrain = fUNKNOWN then 206 214 cm := $000000 207 else if Tile and smCity <> 0 then 208 begin 209 if Tile and smOwned <> 0 then 210 cm := OwnColor 211 else 212 cm := EnemyColor; 215 else if Tile and smCity <> 0 then begin 216 if Tile and smOwned <> 0 then cm := OwnColor 217 else cm := EnemyColor; 213 218 if y > 0 then begin 214 219 // 2x2 city dot covers two lines … … 219 224 end; 220 225 end 221 else if (i = 0) and (Tile and smUnit <> 0) then 222 if Tile and smOwned <> 0 then 223 cm := OwnColor 224 else cm := EnemyColor 225 else 226 else if (i = 0) and (Tile and smUnit <> 0) then begin 227 if Tile and smOwned <> 0 then cm := OwnColor 228 else cm := EnemyColor; 229 end else 226 230 cm := Colors[Tile and fTerrain, i]; 227 231 MiniPixel.Pixel^.B := (cm shr 16) and $ff; … … 237 241 end; 238 242 243 procedure TMiniMap.Paint(MyMap: PTileList; MapWidth: Integer; ClientMode: Integer; 244 xxt, xwMini: Integer); 245 var 246 x, y, Loc, i, hw, xm, cm, cmPolOcean, cmPolNone: integer; 247 PrevMiniPixel: TPixelPointer; 248 MiniPixel: TPixelPointer; 249 TerrainTile: Cardinal; 250 MyCity: PCity; 251 EnemyCity: PCityInfo; 252 MyUnit: PUn; 253 EnemyUnit: PUnitInfo; 254 begin 255 if not Assigned(MyMap) then Exit; 256 cmPolOcean := HGrSystem.Data.Canvas.Pixels[101, 67]; 257 cmPolNone := HGrSystem.Data.Canvas.Pixels[102, 67]; 258 hw := MapWidth div (xxt * 2); 259 with Bitmap.Canvas do begin 260 Brush.Color := $000000; 261 FillRect(Rect(0, 0, Bitmap.Width, Bitmap.Height)); 262 end; 263 Bitmap.PixelFormat := pf24bit; 264 Bitmap.SetSize(Size.X * 2, Size.Y); 265 Bitmap.BeginUpdate; 266 MiniPixel := PixelPointer(Bitmap); 267 PrevMiniPixel := PixelPointer(Bitmap, 0, -1); 268 for y := 0 to ScaleToNative(Size.Y) - 1 do begin 269 for x := 0 to ScaleToNative(Size.X) - 1 do begin 270 Loc := ScaleFromNative(x) + Size.X * ScaleFromNative(y); 271 if (MyMap[Loc] and fTerrain) <> fUNKNOWN then begin 272 for i := 0 to 1 do begin 273 xm := ((x - ScaleToNative(xwMini)) * 2 + i + y and 1 - ScaleToNative(hw) + 274 ScaleToNative(Size.X) * 5) mod (ScaleToNative(Size.X) * 2); 275 MiniPixel.SetX(xm); 276 TerrainTile := MyMap[Loc] and fTerrain; 277 if TerrainTile > 11 then TerrainTile := 0; 278 cm := Colors[TerrainTile, i]; 279 if ClientMode = cEditMap then begin 280 if MyMap[Loc] and (fPrefStartPos or fStartPos) <> 0 then 281 cm := $FFFFFF; 282 end 283 else if MyMap[Loc] and fCity <> 0 then begin 284 // City 285 MyCity := GetMyCityByLoc(Loc); 286 if Assigned(MyCity) then cm := Tribe[me].Color 287 else begin 288 EnemyCity := GetEnemyCityByLoc(Loc); 289 if Assigned(EnemyCity) then 290 cm := Tribe[EnemyCity^.Owner].Color; 291 end; 292 cm := $808080 or cm shr 1; { increase brightness } 293 if y > 0 then begin 294 // 2x2 city dot covers two lines 295 PrevMiniPixel.SetX(xm); 296 PrevMiniPixel.Pixel^.B := (cm shr 16) and $ff; 297 PrevMiniPixel.Pixel^.G := (cm shr 8) and $ff; 298 PrevMiniPixel.Pixel^.R := (cm shr 0) and $ff; 299 end; 300 end 301 else if (i = 0) and (MyMap[Loc] and fUnit <> 0) then begin 302 // Unit 303 MyUnit := GetMyUnitByLoc(Loc); 304 if Assigned(MyUnit) then cm := Tribe[me].Color 305 else begin 306 EnemyUnit := GetEnemyUnitByLoc(Loc); 307 if Assigned(EnemyUnit) then 308 cm := Tribe[EnemyUnit.Owner].Color; 309 end; 310 cm := $808080 or cm shr 1; { increase brightness } 311 end 312 else if Options and (1 shl moPolitical) <> 0 then begin 313 // Political 314 if MyMap[Loc] and fTerrain < fGrass then 315 cm := cmPolOcean 316 else if MyRO.Territory[Loc] < 0 then 317 cm := cmPolNone 318 else 319 cm := Tribe[MyRO.Territory[Loc]].Color; 320 end; 321 MiniPixel.Pixel^.B := (cm shr 16) and $ff; 322 MiniPixel.Pixel^.G := (cm shr 8) and $ff; 323 MiniPixel.Pixel^.R := (cm shr 0) and $ff; 324 end; 325 end; 326 end; 327 MiniPixel.NextLine; 328 PrevMiniPixel.NextLine; 329 end; 330 Bitmap.EndUpdate; 331 end; 332 239 333 240 334 end.
Note:
See TracChangeset
for help on using the changeset viewer.