Changeset 326 for trunk/LocalPlayer/Term.pas
- Timestamp:
- Mar 24, 2021, 12:08:28 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Term.pas
r325 r326 14 14 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, DrawDlg, Types, 15 15 Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area, 16 UGraphicSet ;16 UGraphicSet, UMiniMap; 17 17 18 18 const … … 253 253 trix: array [0 .. 63] of Integer; 254 254 AILogo: array [0 .. nPl - 1] of TBitmap; 255 Mini : TBitmap;255 MiniMap: TMiniMap; 256 256 Panel: TBitmap; 257 257 TopBar: TBitmap; … … 274 274 procedure ArrangeMidPanel; 275 275 procedure MainOffscreenPaint; 276 procedure Mini Paint;276 procedure MiniMapPaint; 277 277 procedure PaintAll; 278 278 procedure PaintAllMaps; … … 1266 1266 procedure TMainScreen.SetMapOptions; 1267 1267 begin 1268 MiniMap.Options := MapOptionChecked; 1268 1269 IsoEngine.Options := MapOptionChecked; 1269 1270 if ClientMode = cEditMap then … … 2586 2587 GameMode := Command; 2587 2588 GrExt.ResetPixUsed; 2588 IsoEngine .Reset;2589 IsoEngineReset; 2589 2590 Tribes.Init; 2590 2591 GetTribeList; … … 2639 2640 CityDlg.Reset; 2640 2641 2641 Mini .SetSize(G.lx * 2, G.ly);2642 MiniMap.Size := Point(G.lx, G.ly); 2642 2643 for i := 0 to nPl - 1 do 2643 2644 begin … … 2842 2843 MyData := G.RO[NewPlayer].Data; 2843 2844 SetTroopLoc(-1); 2844 Mini Paint;2845 MiniMapPaint; 2845 2846 InitAllEnemyModels; // necessary for correct replay 2846 2847 if not EndTurn(true) then … … 3524 3525 end; 3525 3526 3526 Mini := TBitmap.Create; 3527 Mini.PixelFormat := pf24bit; 3527 MiniMap := TMiniMap.Create; 3528 3528 Panel := TBitmap.Create; 3529 3529 Panel.PixelFormat := pf24bit; … … 3560 3560 FreeAndNil(sb); 3561 3561 FreeAndNil(TopBar); 3562 FreeAndNil(Mini );3562 FreeAndNil(MiniMap); 3563 3563 FreeAndNil(Buffer); 3564 3564 FreeAndNil(Panel); … … 4106 4106 end; 4107 4107 4108 procedure TMainScreen.MiniPaint;4109 var4110 uix, cix, x, y, Loc, i, hw, xm, cm, cmPolOcean, cmPolNone: integer;4111 PrevMiniPixel: TPixelPointer;4112 MiniPixel: TPixelPointer;4113 TerrainTile: Cardinal;4114 begin4115 if not Assigned(MyMap) then Exit;4116 cmPolOcean := HGrSystem.Data.Canvas.Pixels[101, 67];4117 cmPolNone := HGrSystem.Data.Canvas.Pixels[102, 67];4118 hw := MapWidth div (xxt * 2);4119 with Mini.Canvas do begin4120 Brush.Color := $000000;4121 FillRect(Rect(0, 0, Mini.width, Mini.height));4122 end;4123 Mini.BeginUpdate;4124 MiniPixel := PixelPointer(Mini);4125 PrevMiniPixel := PixelPointer(Mini);4126 for y := 0 to ScaleToNative(G.ly) - 1 do begin4127 for x := 0 to ScaleToNative(G.lx) - 1 do begin4128 Loc := ScaleFromNative(x) + G.lx * ScaleFromNative(y);4129 if (MyMap[Loc] and fTerrain) <> fUNKNOWN then begin4130 for i := 0 to 1 do begin4131 xm := ((x - ScaleToNative(xwMini)) * 2 + i + y and 1 - ScaleToNative(hw) +4132 ScaleToNative(G.lx) * 5) mod (ScaleToNative(G.lx) * 2);4133 MiniPixel.SetXY(xm, y);4134 TerrainTile := MyMap[Loc] and fTerrain;4135 if TerrainTile > 11 then TerrainTile := 0;4136 cm := MiniColors[TerrainTile, i];4137 if ClientMode = cEditMap then4138 begin4139 if MyMap[Loc] and (fPrefStartPos or fStartPos) <> 0 then4140 cm := $FFFFFF;4141 end4142 else if MyMap[Loc] and fCity <> 0 then4143 begin4144 cix := MyRO.nCity - 1;4145 while (cix >= 0) and (MyCity[cix].Loc <> Loc) do4146 dec(cix);4147 if cix >= 0 then4148 cm := Tribe[me].Color4149 else4150 begin4151 cix := MyRO.nEnemyCity - 1;4152 while (cix >= 0) and (MyRO.EnemyCity[cix].Loc <> Loc) do4153 dec(cix);4154 if cix >= 0 then4155 cm := Tribe[MyRO.EnemyCity[cix].Owner].Color4156 end;4157 cm := $808080 or cm shr 1; { increase brightness }4158 if y > 0 then begin4159 // 2x2 city dot covers two lines4160 PrevMiniPixel.SetXY(xm, y - 1);4161 PrevMiniPixel.Pixel^.B := cm shr 16;4162 PrevMiniPixel.Pixel^.G := cm shr 8 and $FF;4163 PrevMiniPixel.Pixel^.R := cm and $FF;4164 end;4165 end4166 else if (i = 0) and (MyMap[Loc] and fUnit <> 0) then4167 begin4168 uix := MyRO.nUn - 1;4169 while (uix >= 0) and (MyUn[uix].Loc <> Loc) do4170 dec(uix);4171 if uix >= 0 then4172 cm := Tribe[me].Color4173 else4174 begin4175 uix := MyRO.nEnemyUn - 1;4176 while (uix >= 0) and (MyRO.EnemyUn[uix].Loc <> Loc) do4177 dec(uix);4178 if uix >= 0 then4179 cm := Tribe[MyRO.EnemyUn[uix].Owner].Color4180 end;4181 cm := $808080 or cm shr 1; { increase brightness }4182 end4183 else if MapOptionChecked and (1 shl moPolitical) <> 0 then4184 begin4185 if MyMap[Loc] and fTerrain < fGrass then4186 cm := cmPolOcean4187 else if MyRO.Territory[Loc] < 0 then4188 cm := cmPolNone4189 else4190 cm := Tribe[MyRO.Territory[Loc]].Color;4191 end;4192 MiniPixel.Pixel^.B := cm shr 16;4193 MiniPixel.Pixel^.G := cm shr 8 and $FF;4194 MiniPixel.Pixel^.R := cm and $FF;4195 end;4196 end;4197 end;4198 end;4199 Mini.EndUpdate;4200 end;4201 4202 4108 {$IFDEF LINUX} 4203 4109 // Can't do scrolling of DC under Linux, then fallback into BitBlt. … … 4327 4233 end; 4328 4234 4235 procedure TMainScreen.MiniMapPaint; 4236 begin 4237 MiniMap.Paint(MyMap, MapWidth, ClientMode, xxt, xwMini); 4238 end; 4239 4329 4240 procedure TMainScreen.PaintAll; 4330 4241 begin … … 4332 4243 xwMini := xw; 4333 4244 ywMini := yw; 4334 Mini Paint;4245 MiniMapPaint; 4335 4246 PanelPaint; 4336 4247 end; … … 4341 4252 xwMini := xw; 4342 4253 ywMini := yw; 4343 Mini Paint;4254 MiniMapPaint; 4344 4255 CopyMiniToPanel; 4345 4256 RectInvalidate(xMini + 2, TopBarHeight + MapHeight - overlap + yMini + 2, … … 4351 4262 begin 4352 4263 BitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 4353 Mini .Canvas, 0, 0);4264 MiniMap.Bitmap.Canvas, 0, 0); 4354 4265 if MarkCityLoc >= 0 then 4355 4266 Sprite(Panel, HGrSystem, xMini - 2 + (4 * G.lx + 2 * (MarkCityLoc mod G.lx) … … 4358 4269 CityMark2.Height, CityMark2.Left, CityMark2.Top) 4359 4270 else if ywmax <= 0 then 4360 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2, 4271 Frame(Panel.Canvas, 4272 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2, 4361 4273 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + 2 + G.ly - 1, 4362 4274 MainTexture.clMark, MainTexture.clMark) 4363 4275 else 4364 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (xxt * 2), 4365 yMini + 2 + yw, xMini + 1 + G.lx + MapWidth div (xxt * 2), 4366 yMini + yw + MapHeight div yyt, MainTexture.clMark, MainTexture.clMark); 4276 Frame(Panel.Canvas, 4277 xMini + 2 + G.lx - MapWidth div (xxt * 2), yMini + 2 + yw, 4278 xMini + 1 + G.lx + MapWidth div (xxt * 2), yMini + yw + MapHeight div yyt, 4279 MainTexture.clMark, MainTexture.clMark); 4367 4280 end; 4368 4281 … … 5092 5005 xwMini := xw; 5093 5006 ywMini := yw; 5094 Mini Paint;5007 MiniMapPaint; 5095 5008 CopyMiniToPanel; 5096 5009 RectInvalidate(xMini + 2, TopBarHeight + MapHeight - overlap + yMini + 2, … … 5298 5211 BrushLoc := MouseLoc; 5299 5212 PaintLoc(MouseLoc, 2); 5300 Mini Paint;5213 MiniMapPaint; 5301 5214 BitBltCanvas(Panel.Canvas, xMini + 2, yMini + 2, G.lx * 2, G.ly, 5302 Mini .Canvas, 0, 0);5215 MiniMap.Bitmap.Canvas, 0, 0); 5303 5216 if ywmax <= 0 then 5304 5217 Frame(Panel.Canvas, xMini + 2 + G.lx - MapWidth div (2 * xxt), … … 7570 7483 yw := ywmax; 7571 7484 end; 7572 BitBltCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, Mini .Canvas, 0, 0);7485 BitBltCanvas(Buffer.Canvas, 0, 0, G.lx * 2, G.ly, MiniMap.Bitmap.Canvas, 0, 0); 7573 7486 if ywmax <= 0 then 7574 7487 Frame(Buffer.Canvas, x - xMini - 2 - MapWidth div (xxt * 2), 0, … … 7600 7513 xwMini := xw; 7601 7514 ywMini := yw; 7602 Mini Paint;7515 MiniMapPaint; 7603 7516 PanelPaint; 7604 7517 end; … … 7881 7794 end 7882 7795 else if Flag = tfAllTechs then 7883 TellNewModels 7796 TellNewModels; 7884 7797 end; 7885 7798 end; … … 7892 7805 MapOptionChecked := MapOptionChecked xor (1 shl (Tag shr 8)); 7893 7806 SetMapOptions; 7894 ButtonIndex := MapOptionChecked shr (Tag shr 8) and 1 + 2 7807 ButtonIndex := MapOptionChecked shr (Tag shr 8) and 1 + 2; 7895 7808 end; 7896 7809 if Sender = MapBtn0 then 7897 7810 begin 7898 Mini Paint;7899 PanelPaint 7811 MiniMapPaint; 7812 PanelPaint; 7900 7813 end // update mini map only 7901 7814 else
Note:
See TracChangeset
for help on using the changeset viewer.