Changeset 150 for trunk/LocalPlayer
- Timestamp:
- Nov 5, 2018, 12:05:53 AM (6 years ago)
- Location:
- trunk/LocalPlayer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/CityScreen.pas
r149 r150 444 444 Offscreen.BeginUpdate; 445 445 PixelPtr.Init(Offscreen, X, Y); 446 for YY := 0 to h- 1 do begin447 for XX := 0 to w- 1 do begin446 for YY := 0 to H - 1 do begin 447 for XX := 0 to W - 1 do begin 448 448 Gray := (Integer(PixelPtr.Pixel^.B) + Integer(PixelPtr.Pixel^.G) + 449 449 Integer(PixelPtr.Pixel^.R)) * 85 shr 8; -
trunk/LocalPlayer/IsoEngine.pas
r73 r150 11 11 type 12 12 TInitEnemyModelEvent = function(emix: integer): boolean; 13 14 { TIsoMap } 13 15 14 16 TIsoMap = class … … 29 31 procedure AttackEnd; 30 32 33 private 34 procedure CityGrid(xm, ym: integer; CityAllowClick: Boolean); 35 function IsShoreTile(Loc: integer): boolean; 36 procedure MakeDark(Line: PPixelPointer; Length: Integer); 37 procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer); 31 38 protected 32 39 FOutput: TBitmap; 33 40 FLeft, FTop, FRight, FBottom, RealTop, RealBottom, AttLoc, DefLoc, 34 41 DefHealth, FAdviceLoc: integer; 35 OutDC,DataDC, MaskDC: HDC;42 DataDC, MaskDC: HDC; 36 43 function Connection4(Loc, Mask, Value: integer): integer; 37 44 function Connection8(Loc, Mask: integer): integer; … … 79 86 ShoreDither = fGrass; 80 87 TerrainIconLines = 21; 88 TerrainIconCols = 9; 89 90 // sprites indexes 91 spDeadLands = 2 * TerrainIconCols + 6; 92 spBlink1 = 1 * TerrainIconCols + 8; 93 spBlink2 = 2 * TerrainIconCols + 8; 94 spPrefStartPos = 1 * TerrainIconCols; 95 spStartPos = 2 * TerrainIconCols; 96 spPlain = 2 * TerrainIconCols + 7; 97 spForest = 3 * TerrainIconCols; 98 spRoad = 9 * TerrainIconCols; 99 spRailRoad = 10 * TerrainIconCols; 100 spCanal = 11 * TerrainIconCols; 101 spIrrigation = 12 * TerrainIconCols; 102 spFarmLand = 12 * TerrainIconCols + 1; 103 spMine = 12 * TerrainIconCols + 2; 104 spFortFront = 12 * TerrainIconCols + 3; 105 spBase = 12 * TerrainIconCols + 4; 106 spSpacePort = 12 * TerrainIconCols + 5; 107 spPollution = 12 * TerrainIconCols + 6; 108 spFortBack = 12 * TerrainIconCols + 7; 109 spRiver = 13 * TerrainIconCols; 110 spJungle = 18 * TerrainIconCols; 81 111 82 112 var … … 531 561 exit; 532 562 533 LCLIntf.BitBlt( OutDC, xDst, yDst, Width, Height, MaskDC, xSrc, ySrc, SRCAND);563 LCLIntf.BitBlt(FOutput.Canvas.Handle, xDst, yDst, Width, Height, MaskDC, xSrc, ySrc, SRCAND); 534 564 if not PureBlack then 535 LCLIntf.BitBlt( OutDC, xDst, yDst, Width, Height, DataDC, xSrc, ySrc,565 LCLIntf.BitBlt(FOutput.Canvas.Handle, xDst, yDst, Width, Height, DataDC, xSrc, ySrc, 536 566 SRCPAINT); 537 567 end; … … 590 620 if Flags and unFortified <> 0 then 591 621 begin 592 { OutDC:=FOutput.Canvas.Handle; 593 DataDC:=GrExt[HGrTerrain].Data.Canvas.Handle; 622 { DataDC:=GrExt[HGrTerrain].Data.Canvas.Handle; 594 623 MaskDC:=GrExt[HGrTerrain].Mask.Canvas.Handle; 595 624 TSprite(x,y+16,12*9+7); } … … 829 858 yLoc := Loc div G.lx; 830 859 if IsJungle(yLoc) then 831 yGr := 18860 yGr := spJungle 832 861 else 833 yGr := 3;862 yGr := spForest; 834 863 Conn := Connection4(Loc, fTerrain, Tile and fTerrain); 835 864 if (yLoc = (G.ly - 2) div 4) or (G.ly - 1 - yLoc = (G.ly + 2) div 4) then … … 838 867 then 839 868 Conn := Conn and not 9; // no connection to north 840 TSprite(x, y, Conn mod 8 + (yGr + Conn div 8) * 9);869 TSprite(x, y, yGr + Conn mod 8 + (Conn div 8) * TerrainIconCols); 841 870 end 842 871 else if Tile and fTerrain in [fHills, fMountains, fForest] then … … 844 873 yGr := 3 + 2 * (Tile and fTerrain - fForest); 845 874 Conn := Connection4(Loc, fTerrain, Tile and fTerrain); 846 TSprite(x, y, Conn mod 8 + (yGr + Conn div 8) * 9);875 TSprite(x, y, Conn mod 8 + (yGr + Conn div 8) * TerrainIconCols); 847 876 end 848 877 else if Tile and fDeadLands <> 0 then 849 TSprite(x, y, 2 * 9 + 6);878 TSprite(x, y, spDeadLands); 850 879 851 880 if ShowObjects then 852 881 begin 853 882 if Tile and fTerImp = tiFarm then 854 TSprite(x, y, 109) { farmland }883 TSprite(x, y, spFarmLand) 855 884 else if Tile and fTerImp = tiIrrigation then 856 TSprite(x, y, 108); // irrigation885 TSprite(x, y, spIrrigation); 857 886 end; 858 887 if Tile and fRiver <> 0 then … … 861 890 Connection4(Loc, fTerrain, fShore) or Connection4(Loc, fTerrain, 862 891 fUNKNOWN); 863 TSprite(x, y, Conn mod 8 + (13 + Conn div 8) * 9);892 TSprite(x, y, spRiver + Conn mod 8 + (Conn div 8) * TerrainIconCols); 864 893 end; 865 894 … … 869 898 for Dir := 0 to 3 do 870 899 if Conn and (1 shl Dir) <> 0 then { river mouths } 871 TSprite(x, y, 15 * 9+ Dir);900 TSprite(x, y, 15 * TerrainIconCols + Dir); 872 901 if ShowObjects then 873 902 begin … … 875 904 for Dir := 0 to 7 do 876 905 if Conn and (1 shl Dir) <> 0 then { canal mouths } 877 TSprite(x, y, 20 * 9+ 1 + Dir);906 TSprite(x, y, 20 * TerrainIconCols + 1 + Dir); 878 907 end 879 908 end; … … 889 918 begin 890 919 if Tile and fCanal <> 0 then 891 TSprite(x, y, 99)920 TSprite(x, y, spCanal) 892 921 end 893 922 else 894 923 for Dir := 0 to 7 do 895 924 if (1 shl Dir) and Conn <> 0 then 896 TSprite(x, y, 100+ Dir);925 TSprite(x, y, spCanal + 1 + Dir); 897 926 end; 898 927 if Tile and (fRR or fCity) <> 0 then … … 904 933 Conn := Connection8(Loc, fRoad or fRR or fCity) and not RRConn; 905 934 if (Conn = 0) and (Tile and (fRR or fCity) = 0) then 906 TSprite(x, y, 81)935 TSprite(x, y, spRoad) 907 936 else if Conn > 0 then 908 937 for Dir := 0 to 7 do 909 938 if (1 shl Dir) and Conn <> 0 then 910 TSprite(x, y, 82+ Dir);939 TSprite(x, y, spRoad + 1 + Dir); 911 940 end; 912 941 // paint railroad connections 913 942 if (Tile and fRR <> 0) and (RRConn = 0) then 914 TSprite(x, y, 90)943 TSprite(x, y, spRailRoad) 915 944 else if RRConn > 0 then 916 945 for Dir := 0 to 7 do 917 946 if (1 shl Dir) and RRConn <> 0 then 918 TSprite(x, y, 91 + Dir);947 TSprite(x, y, spRailRoad + 1 + Dir); 919 948 end; 920 949 end; … … 928 957 UnitInfo: TUnitInfo; 929 958 fog: boolean; 959 SpecialRow: Integer; 960 SpecialCol: Integer; 930 961 931 962 procedure NameCity; … … 960 991 if ShowObjects and (Options and (1 shl moEditMode) = 0) and 961 992 (Tile and fCity <> 0) and (CityInfo.Flags and ciSpacePort <> 0) then 962 TSprite(x + xxt, y - 6, 12 * 9 + 5);993 TSprite(x + xxt, y - 6, spSpacePort); 963 994 end; 964 995 … … 1050 1081 1051 1082 if (Loc >= 0) and (Loc < G.lx * G.ly) and (Loc = FAdviceLoc) then 1052 TSprite(x, y, 7 + 9 * 2);1083 TSprite(x, y, spPlain); 1053 1084 1054 1085 if (Loc >= 0) and (Loc < G.lx * G.ly) and (Tile and fSpecial <> 0) 1055 then { special res sources }1086 then { special resources } 1056 1087 begin 1057 1088 dy := Loc div G.lx; 1058 if Tile and fTerrain < fForest then 1059 TSprite(x, y, Tile and fTerrain + (Tile and fSpecial shr 5) * 9) 1060 else if (Tile and fTerrain = fForest) and IsJungle(dy) then 1061 TSprite(x, y, 8 + 17 * 9 + (Tile and fSpecial shr 5) * 9) 1089 SpecialCol := Tile and fTerrain; 1090 SpecialRow := Tile and fSpecial shr 5; 1091 if SpecialCol < fForest then 1092 TSprite(x, y, SpecialCol + SpecialRow * TerrainIconCols) 1093 else if (SpecialCol = fForest) and IsJungle(dy) then 1094 TSprite(x, y, 8 + 17 * TerrainIconCols + SpecialRow * TerrainIconCols) 1062 1095 else 1063 TSprite(x, y, 8 + 2 * 9 + ((Tile and fTerrain - fForest) * 2 + Tile and 1064 fSpecial shr 5) * 9); 1096 TSprite(x, y, 8 + 2 * TerrainIconCols + (SpecialCol - fForest) * 2 + SpecialRow * TerrainIconCols); 1065 1097 end; 1066 1098 … … 1068 1100 begin 1069 1101 if Tile and fTerImp = tiMine then 1070 TSprite(x, y, 2 + 9 * 12);1102 TSprite(x, y, spMine); 1071 1103 if Tile and fTerImp = tiBase then 1072 TSprite(x, y, 4 + 9 * 12);1104 TSprite(x, y, spBase); 1073 1105 if Tile and fPoll <> 0 then 1074 TSprite(x, y, 6 + 9 * 12);1106 TSprite(x, y, spPollution); 1075 1107 if Tile and fTerImp = tiFort then 1076 1108 begin 1077 TSprite(x, y, 7 + 9 * 12);1109 TSprite(x, y, spFortBack); 1078 1110 if Tile and fObserved = 0 then 1079 TSprite(x, y, 3 + 9 * 12);1111 TSprite(x, y, spFortFront); 1080 1112 end; 1081 1113 end; 1082 1114 if Tile and fDeadLands <> 0 then 1083 TSprite(x, y, (12 + Tile shr 25 and 3) * 9+ 8);1115 TSprite(x, y, (12 + Tile shr 25 and 3) * TerrainIconCols + 8); 1084 1116 1085 1117 if Options and (1 shl moEditMode) <> 0 then … … 1099 1131 1 + yyt + 15 * (yyt * 3 + 1)) 1100 1132 else 1101 TSprite(x, y, 6 + 9* 15, xxt <> 33);1133 TSprite(x, y, 6 + TerrainIconCols * 15, xxt <> 33); 1102 1134 1103 1135 if FoW and (Tile and fObserved = 0) then … … 1112 1144 if (Destination = Loc) and (Destination <> MyUn[UnFocus].Loc) then 1113 1145 if not UseBlink or BlinkOn then 1114 TSprite(x, y, 8 + 9 *1)1146 TSprite(x, y, spBlink1) 1115 1147 else 1116 TSprite(x, y, 8 + 9 *2)1148 TSprite(x, y, spBlink2) 1117 1149 end; 1118 1150 {$ENDIF} … … 1120 1152 begin 1121 1153 if Tile and fPrefStartPos <> 0 then 1122 TSprite(x, y, 0 + 9 * 1)1154 TSprite(x, y, spPrefStartPos) 1123 1155 else if Tile and fStartPos <> 0 then 1124 TSprite(x, y, 0 + 9 * 2);1156 TSprite(x, y, spStartPos); 1125 1157 end 1126 1158 else if ShowObjects then … … 1179 1211 if ShowObjects and (Tile and fTerImp = tiFort) and (Tile and fObserved <> 0) 1180 1212 then 1181 TSprite(x, y, 3 + 9 * 12);1213 TSprite(x, y, spFortFront); 1182 1214 1183 1215 if (Loc >= 0) and (Loc < G.lx * G.ly) then … … 1269 1301 end; 1270 1302 1303 function TIsoMap.IsShoreTile(Loc: integer): boolean; 1304 const 1305 Dirx: array [0 .. 7] of integer = (1, 2, 1, 0, -1, -2, -1, 0); 1306 Diry: array [0 .. 7] of integer = (-1, 0, 1, 2, 1, 0, -1, -2); 1307 var 1308 Dir, ConnLoc: integer; 1309 begin 1310 result := false; 1311 for Dir := 0 to 7 do 1312 begin 1313 ConnLoc := dLoc(Loc, Dirx[Dir], Diry[Dir]); 1314 if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or 1315 ((MyMap[ConnLoc] - 2) and fTerrain < 13) then 1316 result := true 1317 end 1318 end; 1319 1320 procedure TIsoMap.MakeDark(Line: PPixelPointer; Length: Integer); 1321 var 1322 I: Integer; 1323 begin 1324 for I := 0 to Length - 1 do begin 1325 Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7f; 1326 Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7f; 1327 Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7f; 1328 Line^.NextPixel; 1329 end; 1330 end; 1331 1332 procedure TIsoMap.ShadeOutside(x0, y0, x1, y1, xm, ym: integer); 1333 const 1334 rShade = 3.75; 1335 var 1336 y, wBright: integer; 1337 y_n, w_n: single; 1338 Line: TPixelPointer; 1339 begin 1340 FOutput.BeginUpdate; 1341 for y := y0 to y1 - 1 do begin 1342 Line.Init(FOutput, 0, y); 1343 y_n := (y - ym) / yyt; 1344 if abs(y_n) < rShade then begin 1345 // Darken left and right parts of elipsis 1346 w_n := sqrt(sqr(rShade) - sqr(y_n)); 1347 wBright := trunc(w_n * xxt + 0.5); 1348 Line.SetX(x0); 1349 MakeDark(@Line, xm - x0 - wBright); 1350 Line.SetX(xm + wBright); 1351 MakeDark(@Line, x1 - xm - wBright); 1352 end else begin 1353 // Darken entire line 1354 Line.SetX(x0); 1355 MakeDark(@Line, x1 - x0); 1356 end; 1357 end; 1358 FOutput.EndUpdate; 1359 end; 1360 1361 procedure TIsoMap.CityGrid(xm, ym: integer; CityAllowClick: Boolean); 1362 var 1363 i: integer; 1364 begin 1365 with FOutput.Canvas do 1366 begin 1367 if CityAllowClick then 1368 pen.Color := $FFFFFF 1369 else 1370 pen.Color := $000000; 1371 pen.Width := 1; 1372 for i := 0 to 3 do 1373 begin 1374 moveto(xm - xxt * (4 - i), ym + yyt * (1 + i)); 1375 lineto(xm + xxt * (1 + i), ym - yyt * (4 - i)); 1376 moveto(xm - xxt * (4 - i), ym - yyt * (1 + i)); 1377 lineto(xm + xxt * (1 + i), ym + yyt * (4 - i)); 1378 end; 1379 moveto(xm - xxt * 4, ym + yyt * 1); 1380 lineto(xm - xxt * 1, ym + yyt * 4); 1381 moveto(xm + xxt * 1, ym + yyt * 4); 1382 lineto(xm + xxt * 4, ym + yyt * 1); 1383 moveto(xm - xxt * 4, ym - yyt * 1); 1384 lineto(xm - xxt * 1, ym - yyt * 4); 1385 moveto(xm + xxt * 1, ym - yyt * 4); 1386 lineto(xm + xxt * 4, ym - yyt * 1); 1387 pen.Width := 1; 1388 end 1389 end; 1390 1271 1391 procedure TIsoMap.Paint(x, y, Loc, nx, ny, CityLoc, CityOwner: integer; 1272 1392 UseBlink: boolean; CityAllowClick: boolean); 1273 1274 function IsShoreTile(Loc: integer): boolean;1275 const1276 Dirx: array [0 .. 7] of integer = (1, 2, 1, 0, -1, -2, -1, 0);1277 Diry: array [0 .. 7] of integer = (-1, 0, 1, 2, 1, 0, -1, -2);1278 var1279 Dir, ConnLoc: integer;1280 begin1281 result := false;1282 for Dir := 0 to 7 do1283 begin1284 ConnLoc := dLoc(Loc, Dirx[Dir], Diry[Dir]);1285 if (ConnLoc < 0) or (ConnLoc >= G.lx * G.ly) or1286 ((MyMap[ConnLoc] - 2) and fTerrain < 13) then1287 result := true1288 end1289 end;1290 1291 procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer);1292 1293 procedure MakeDark(Line: PPixelPointer; Length: Integer);1294 var1295 I: Integer;1296 begin1297 for I := 0 to Length - 1 do begin1298 Line^.Pixel^.B := (Line^.Pixel^.B shr 1) and $7f;1299 Line^.Pixel^.G := (Line^.Pixel^.G shr 1) and $7f;1300 Line^.Pixel^.R := (Line^.Pixel^.R shr 1) and $7f;1301 Line^.NextPixel;1302 end;1303 end;1304 1305 const1306 rShade = 3.75;1307 var1308 y, wBright: integer;1309 y_n, w_n: single;1310 Line: TPixelPointer;1311 begin1312 FOutput.BeginUpdate;1313 for y := y0 to y1 - 1 do begin1314 Line.Init(FOutput, 0, y);1315 y_n := (y - ym) / yyt;1316 if abs(y_n) < rShade then begin1317 // Darken left and right parts of elipsis1318 w_n := sqrt(sqr(rShade) - sqr(y_n));1319 wBright := trunc(w_n * xxt + 0.5);1320 Line.SetX(x0);1321 MakeDark(@Line, xm - x0 - wBright);1322 Line.SetX(xm + wBright);1323 MakeDark(@Line, x1 - xm - wBright);1324 end else begin1325 // Darken entire line1326 Line.SetX(x0);1327 MakeDark(@Line, x1 - x0);1328 end;1329 end;1330 FOutput.EndUpdate;1331 end;1332 1333 procedure CityGrid(xm, ym: integer);1334 var1335 i: integer;1336 begin1337 with FOutput.Canvas do1338 begin1339 if CityAllowClick then1340 pen.Color := $FFFFFF1341 else1342 pen.Color := $000000;1343 pen.Width := 1;1344 for i := 0 to 3 do1345 begin1346 moveto(xm - xxt * (4 - i), ym + yyt * (1 + i));1347 lineto(xm + xxt * (1 + i), ym - yyt * (4 - i));1348 moveto(xm - xxt * (4 - i), ym - yyt * (1 + i));1349 lineto(xm + xxt * (1 + i), ym + yyt * (4 - i));1350 end;1351 moveto(xm - xxt * 4, ym + yyt * 1);1352 lineto(xm - xxt * 1, ym + yyt * 4);1353 moveto(xm + xxt * 1, ym + yyt * 4);1354 lineto(xm + xxt * 4, ym + yyt * 1);1355 moveto(xm - xxt * 4, ym - yyt * 1);1356 lineto(xm - xxt * 1, ym - yyt * 4);1357 moveto(xm + xxt * 1, ym - yyt * 4);1358 lineto(xm + xxt * 4, ym - yyt * 1);1359 pen.Width := 1;1360 end1361 end;1362 1363 1393 var 1364 1394 dx, dy, xm, ym, ALoc, BLoc, ATer, BTer, Aix, bix: integer; … … 1518 1548 end; 1519 1549 1520 OutDC := FOutput.Canvas.Handle;1521 1550 DataDC := GrExt[HGrTerrain].Data.Canvas.Handle; 1522 1551 MaskDC := GrExt[HGrTerrain].Mask.Canvas.Handle; … … 1548 1577 ym := y + (dy + 1) * yyt + yyt; 1549 1578 ShadeOutside(FLeft, FTop, FRight, FBottom, xm, ym); 1550 CityGrid(xm, ym );1579 CityGrid(xm, ym, CityAllowClick); 1551 1580 for dy := -2 to ny + 1 do 1552 1581 for dx := -2 to nx + 1 do
Note:
See TracChangeset
for help on using the changeset viewer.