Changeset 245 for trunk/LocalPlayer
- Timestamp:
- May 21, 2020, 7:58:42 PM (5 years ago)
- Location:
- trunk/LocalPlayer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Help.pas
r206 r245 441 441 const 442 442 nHeaven = 28; 443 maxsum = 9 * 9 * 255 * 75 div 100;443 MaxSum = 9 * 9 * 255 * 75 div 100; 444 444 var 445 445 x, y, dx, dy, xSrc, ySrc, sum, xx: integer; … … 457 457 xSrc := iix mod 7 * xSizeBig; 458 458 ySrc := (iix div 7 + 1) * ySizeBig; 459 for y := 0 to ySizeBig* 2 - 1 do460 if (( y0 + y) >= 0) and ((y0 + y) < InnerHeight) then begin461 PaintPtr := PixelPointer(OffScreen, 0, y0+ y);462 CoalPtr := PixelPointer(Templates, 0, yCoal+ y);459 for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do 460 if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin 461 PaintPtr := PixelPointer(OffScreen, 0, ScaleToNative(y0) + y); 462 CoalPtr := PixelPointer(Templates, 0, ScaleToNative(yCoal) + y); 463 463 for dy := -1 to 1 do 464 if ((Max(y + dy, 0) shr 1) >= 0) and ((Max(y + dy, 0) shr 1) < ySizeBig) then465 ImpPtr[dy] := PixelPointer(BigImp, 0, ySrc + (Max(y + dy, 0) shr 1));466 for x := 0 to xSizeBig* 2 - 1 do begin464 if ((Max(y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then 465 ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleToNative(ySrc) + (Max(y + ScaleToNative(dy), 0) shr 1)); 466 for x := 0 to ScaleToNative(xSizeBig) * 2 - 1 do begin 467 467 sum := 0; 468 468 for dx := -1 to 1 do begin 469 xx := xSrc + Max((x + dx), 0) shr 1;469 xx := ScaleToNative(xSrc) + Max((x + ScaleToNative(dx)), 0) shr 1; 470 470 for dy := -1 to 1 do begin 471 471 ImpPtr[dy].SetX(xx); 472 if ((y + dy) shr 1 < 0) or ((y + dy) shr 1 >= ySizeBig) or473 ((x + dx) shr 1 < 0) or ((x + dx) shr 1 >= xSizeBig) or474 ((y + dy) shr 1 < nHeaven) and472 if ((y + ScaleToNative(dy)) shr 1 < 0) or ((y + ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or 473 ((x + ScaleToNative(dx)) shr 1 < 0) or ((x + ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or 474 ((y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and 475 475 (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 + 476 ImpPtr[dy].Pixel^.R = Heaven[( y+ dy) shr 1]) then476 ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y) + dy) shr 1]) then 477 477 sum := sum + 9 * 255 478 478 else … … 481 481 end; 482 482 end; 483 if sum < maxsum then begin // no saturation484 CoalPtr.SetX( xCoal+ x);485 sum := 1 shl 22 - ( maxsum - sum) * (256 - CoalPtr.Pixel^.B * 2);483 if sum < MaxSum then begin // no saturation 484 CoalPtr.SetX(ScaleToNative(xCoal) + x); 485 sum := 1 shl 22 - (MaxSum - sum) * (256 - CoalPtr.Pixel^.B * 2); 486 486 PaintPtr.SetX(x0 + x); 487 487 PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22; -
trunk/LocalPlayer/IsoEngine.pas
r206 r245 34 34 function IsShoreTile(Loc: integer): boolean; 35 35 procedure MakeDark(Line: PPixelPointer; Length: Integer); 36 procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer);36 procedure ShadeOutside(x0, y0, Width, Height, xm, ym: integer); 37 37 protected 38 38 FOutput: TBitmap; … … 1015 1015 1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1)); 1016 1016 Borders.BeginUpdate; 1017 for dy := 0 to yyt * 2 - 1 do 1018 begin 1019 PixelPtr := PixelPointer(Borders, 0, p1 * (yyt * 2) + dy); 1020 for dx := 0 to xxt * 2 - 1 do begin 1017 PixelPtr := PixelPointer(Borders, ScaleToNative(0), ScaleToNative(p1 * (yyt * 2))); 1018 for dy := 0 to ScaleToNative(yyt * 2) - 1 do begin 1019 for dx := 0 to ScaleToNative(xxt * 2) - 1 do begin 1021 1020 if PixelPtr.Pixel^.B = 99 then begin 1022 1021 PixelPtr.Pixel^.B := Tribe[p1].Color shr 16 and $FF; … … 1026 1025 PixelPtr.NextPixel; 1027 1026 end; 1027 PixelPtr.NextLine; 1028 1028 end; 1029 1029 Borders.EndUpdate; … … 1330 1330 end; 1331 1331 1332 procedure TIsoMap.ShadeOutside(x0, y0, x1, y1, xm, ym: integer);1332 procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: integer); 1333 1333 const 1334 1334 rShade = 3.75; … … 1339 1339 begin 1340 1340 FOutput.BeginUpdate; 1341 for y := y0 to y1 - 1 do begin1342 Line := PixelPointer(FOutput, 0, y);1343 y_n := ( y- ym) / yyt;1341 Line := PixelPointer(FOutput, ScaleToNative(x0), ScaleToNative(y0)); 1342 for y := 0 to ScaleToNative(Height) - 1 do begin 1343 y_n := (ScaleFromNative(y) + y0 - ym) / yyt; 1344 1344 if abs(y_n) < rShade then begin 1345 1345 // Darken left and right parts of elipsis 1346 1346 w_n := sqrt(sqr(rShade) - sqr(y_n)); 1347 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);1348 Line.SetX(0); 1349 MakeDark(@Line, ScaleToNative(xm - wBright)); 1350 Line.SetX(ScaleToNative(xm + wBright)); 1351 MakeDark(@Line, ScaleToNative(Width - xm - wBright)); 1352 1352 end else begin 1353 1353 // Darken entire line 1354 Line.SetX( x0);1355 MakeDark(@Line, x1 - x0);1354 Line.SetX(0); 1355 MakeDark(@Line, ScaleToNative(Width)); 1356 1356 end; 1357 Line.NextLine; 1357 1358 end; 1358 1359 FOutput.EndUpdate; … … 1576 1577 xm := x + (dx + 1) * xxt; 1577 1578 ym := y + (dy + 1) * yyt + yyt; 1578 ShadeOutside(FLeft, FTop, FRight , FBottom, xm, ym);1579 ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym); 1579 1580 CityGrid(xm, ym, CityAllowClick); 1580 1581 for dy := -2 to ny + 1 do -
trunk/LocalPlayer/MessgEx.pas
r227 r245 237 237 Screwed: array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of single; 238 238 SrcPtr: TPixelPointer; 239 begin 239 Width: Integer; 240 Height: Integer; 241 begin 242 Width := 56; 243 Height := 40; 240 244 if IconIndex >= 0 then begin 241 245 xIcon := IconIndex mod 7 * xSizeBig; 242 246 yIcon := (IconIndex + SystemIconLines * 7) div 7 * ySizeBig; 243 247 // prepare screwed icon 244 fillchar(Screwed, sizeof(Screwed), 0);248 FillChar(Screwed, sizeof(Screwed), 0); 245 249 BigImp.BeginUpdate; 246 for iy := 0 to 39 do begin247 for ix := 0 to 55do begin248 SrcPtr := PixelPointer(BigImp, ix + xIcon, iy + yIcon);249 xR := ix * (37 + iy * 5 / 40) / 56;250 SrcPtr := PixelPointer(BigImp, ScaleToNative(xIcon), ScaleToNative(yIcon)); 251 for iy := 0 to ScaleToNative(Height) - 1 do begin 252 for ix := 0 to ScaleToNative(Width) - 1 do begin 253 xR := ScaleFromNative(ix) * (37 + ScaleFromNative(iy) * 5 / Height) / Width; 250 254 xDst := Trunc(xR); 251 255 xR := Frac(xR); 252 x1 := (120 - ix) * (120 - ix) - 10000;253 yR := iy * 18 / 40+ x1 * x1 / 4000000;256 x1 := (120 - ScaleFromNative(ix)) * (120 - ScaleFromNative(ix)) - 10000; 257 yR := ScaleFromNative(iy) * 18 / Height + x1 * x1 / 4000000; 254 258 yDst := Trunc(yR); 255 259 yR := Frac(yR); … … 272 276 Screwed[xDst + dx, yDst + dy, 3] := Screwed[xDst + dx, yDst + dy, 273 277 3] + share; 274 end; 275 end; 278 end; 279 SrcPtr.NextPixel; 280 end; 281 SrcPtr.NextLine; 276 282 end; 277 283 BigImp.EndUpdate; -
trunk/LocalPlayer/Term.pas
r227 r245 554 554 Sharpen = 80; 555 555 type 556 TBuffer = array [0 .. 99999, 0 .. 2] of integer;556 TBuffer = array [0 .. 99999, 0 .. 2] of Integer; 557 557 var 558 sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch, xdivider,559 ydivider: integer;560 resampled: ^TBuffer;558 Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch: Integer; 559 xdivider, ydivider: Integer; 560 Resampled: ^TBuffer; 561 561 PixelPtr: TPixelPointer; 562 562 begin 563 nx := BigImp. width div xSizeBig * xSizeSmall;564 ny := BigImp. height div ySizeBig * ySizeSmall;563 nx := BigImp.Width div xSizeBig * xSizeSmall; 564 ny := BigImp.Height div ySizeBig * ySizeSmall; 565 565 566 566 // resample icons 567 GetMem( resampled, nx * ny * 12);568 FillChar( resampled^, nx * ny * 12, 0);567 GetMem(Resampled, nx * ny * 12); 568 FillChar(Resampled^, nx * ny * 12, 0); 569 569 BigImp.BeginUpdate; 570 for ix := 0 to BigImp.width div xSizeBig - 1 do 571 for iy := 0 to BigImp.height div ySizeBig - 1 do 572 for y := 0 to ySizeBig - 2 * cut - 1 do 573 begin 574 ydivider := (y * ySizeSmall div (ySizeBig - 2 * cut) + 1) * 575 (ySizeBig - 2 * cut) - y * ySizeSmall; 570 for ix := 0 to BigImp.Width div xSizeBig - 1 do 571 for iy := 0 to BigImp.Height div ySizeBig - 1 do begin 572 PixelPtr := PixelPointer(BigImp, ScaleToNative(ix * xSizeBig), 573 ScaleToNative(cut + iy * ySizeBig)); 574 for y := 0 to ScaleToNative(ySizeBig - 2 * cut) - 1 do begin 575 ydivider := (ScaleFromNative(y) * ySizeSmall div (ySizeBig - 2 * cut) + 1) * 576 (ySizeBig - 2 * cut) - ScaleFromNative(y) * ySizeSmall; 576 577 if ydivider > ySizeSmall then 577 578 ydivider := ySizeSmall; 578 PixelPtr := PixelPointer(BigImp, 0, cut + iy * ySizeBig + y); 579 for x := 0 to xSizeBig - 1 do 580 begin 581 ir := ix * xSizeSmall + iy * nx * ySizeSmall + x * 582 xSizeSmall div xSizeBig + y * 579 for x := 0 to ScaleToNative(xSizeBig) - 1 do begin 580 ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative(x) * 581 xSizeSmall div xSizeBig + ScaleFromNative(y) * 583 582 ySizeSmall div (ySizeBig - 2 * cut) * nx; 584 xdivider := ( x * xSizeSmall div xSizeBig + 1) * xSizeBig - x*585 xSize Small;583 xdivider := (ScaleFromNative(x) * xSizeSmall div xSizeBig + 1) * 584 xSizeBig - ScaleFromNative(x) * xSizeSmall; 586 585 if xdivider > xSizeSmall then 587 586 xdivider := xSizeSmall; 588 for ch := 0 to 2 do 589 begin 590 PixelPtr.SetX(ix * xSizeBig + x); 587 for ch := 0 to 2 do begin 591 588 c := PixelPtr.Pixel^.Planes[ch]; 592 inc(resampled[ir, ch], c * xdivider * ydivider);589 Inc(Resampled[ir, ch], c * xdivider * ydivider); 593 590 if xdivider < xSizeSmall then 594 inc(resampled[ir + 1, ch], c * (xSizeSmall - xdivider) *591 Inc(Resampled[ir + 1, ch], c * (xSizeSmall - xdivider) * 595 592 ydivider); 596 593 if ydivider < ySizeSmall then 597 inc(resampled[ir + nx, ch],594 Inc(Resampled[ir + nx, ch], 598 595 c * xdivider * (ySizeSmall - ydivider)); 599 596 if (xdivider < xSizeSmall) and (ydivider < ySizeSmall) then 600 inc(resampled[ir + nx + 1, ch], c * (xSizeSmall - xdivider) *597 Inc(Resampled[ir + nx + 1, ch], c * (xSizeSmall - xdivider) * 601 598 (ySizeSmall - ydivider)); 602 599 end; 600 PixelPtr.NextPixel; 603 601 end; 602 PixelPtr.NextLine; 604 603 end; 604 end; 605 605 BigImp.EndUpdate; 606 606 607 // sharpen resampled icons607 // Sharpen Resampled icons 608 608 SmallImp.SetSize(nx, ny); 609 609 SmallImp.BeginUpdate; 610 for y := 0 to ny - 1 do begin611 PixelPtr := PixelPointer(SmallImp, 0, y);612 for x := 0 to nx - 1 do610 PixelPtr := PixelPointer(SmallImp); 611 for y := 0 to ScaleToNative(ny) - 1 do begin 612 for x := 0 to ScaleToNative(nx) - 1 do begin 613 613 for ch := 0 to 2 do begin 614 sum := 0;614 Sum := 0; 615 615 Cnt := 0; 616 616 for dy := -1 to 1 do 617 if ((dy >= 0) or ( ymod ySizeSmall > 0)) and618 ((dy <= 0) or ( ymod ySizeSmall < ySizeSmall - 1)) then617 if ((dy >= 0) or (ScaleFromNative(y) mod ySizeSmall > 0)) and 618 ((dy <= 0) or (ScaleFromNative(y) mod ySizeSmall < ySizeSmall - 1)) then 619 619 for dx := -1 to 1 do 620 if ((dx >= 0) or ( xmod xSizeSmall > 0)) and621 ((dx <= 0) or ( xmod xSizeSmall < xSizeSmall - 1)) then620 if ((dx >= 0) or (ScaleFromNative(x) mod xSizeSmall > 0)) and 621 ((dx <= 0) or (ScaleFromNative(x) mod xSizeSmall < xSizeSmall - 1)) then 622 622 begin 623 inc(sum, resampled[x + dx + nx * (y+ dy), ch]);624 inc(Cnt);623 Inc(Sum, Resampled[ScaleFromNative(x) + dx + nx * (ScaleFromNative(y) + dy), ch]); 624 Inc(Cnt); 625 625 end; 626 sum := ((Cnt * Sharpen + 800) * resampled[x + nx * y, ch] - sum *626 Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(x) + nx * ScaleFromNative(y), ch] - Sum * 627 627 Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * cut)); 628 if sum < 0 then sum := 0; 629 if sum > 255 then sum := 255; 630 PixelPtr.SetX(x); 631 PixelPtr.Pixel^.Planes[ch] := sum; 628 if Sum < 0 then Sum := 0; 629 if Sum > 255 then Sum := 255; 630 PixelPtr.Pixel^.Planes[ch] := Sum; 632 631 end; 632 PixelPtr.NextPixel; 633 end; 634 PixelPtr.NextLine; 633 635 end; 634 636 SmallImp.EndUpdate; 635 FreeMem( resampled);637 FreeMem(Resampled); 636 638 end; 637 639 … … 4066 4068 MiniPixel := PixelPointer(Mini); 4067 4069 PrevMiniPixel := PixelPointer(Mini); 4068 for y := 0 to G.ly- 1 do4069 begin 4070 for x := 0 to G.lx- 1 do4071 if MyMap[ x + G.lx * y] and fTerrain <> fUNKNOWN then4072 begin 4073 Loc := x + G.lx * y;4070 for y := 0 to ScaleToNative(G.ly) - 1 do 4071 begin 4072 for x := 0 to ScaleToNative(G.lx) - 1 do 4073 if MyMap[ScaleFromNative(x) + G.lx * ScaleFromNative(y)] and fTerrain <> fUNKNOWN then 4074 begin 4075 Loc := ScaleFromNative(x) + G.lx * ScaleFromNative(y); 4074 4076 for i := 0 to 1 do 4075 4077 begin 4076 xm := ((x - xwMini) * 2 + i + y and 1 - hw + G.lx * 5) mod (G.lx * 2); 4078 xm := ((x - ScaleToNative(xwMini)) * 2 + i + y and 1 - ScaleToNative(hw) + 4079 ScaleToNative(G.lx) * 5) mod (ScaleToNative(G.lx) * 2); 4077 4080 MiniPixel.SetXY(xm, y); 4078 4081 cm := MiniColors[MyMap[Loc] and fTerrain, i]; -
trunk/LocalPlayer/Wonders.pas
r230 r245 104 104 Ch: Integer; 105 105 Line: array [0..3] of TPixelPointer; 106 begin 106 Width: Integer; 107 Height: Integer; 108 begin 109 Width := ScaleToNative(180); 110 Height := ScaleToNative(128); 107 111 Offscreen.BeginUpdate; 108 Line[0] := PixelPointer(Offscreen, Center.X, Center.Y);109 Line[1] := PixelPointer(Offscreen, Center.X, Center.Y- 1);110 Line[2] := PixelPointer(Offscreen, Center.X - 1, Center.Y);111 Line[3] := PixelPointer(Offscreen, Center.X - 1, Center.Y- 1);112 for Y := 0 to 127do begin113 for X := 0 to 179do begin114 r := X * X * ( 32 * 32) + Y * Y * (45 * 45);115 ax := ((1 shl 16 div 32) * 45) * Y;116 if (r < 8 * 128 * 180 * 180) and117 ((r >= 32 * 64 * 90 * 90) and (ax < amax2 * X) and112 Line[0] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y)); 113 Line[1] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y) - 1); 114 Line[2] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y)); 115 Line[3] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y) - 1); 116 for Y := 0 to Height - 1 do begin 117 for X := 0 to Width - 1 do begin 118 r := X * X * ((Height div 4) * (Height div 4)) + Y * Y * ((Width div 4) * (Width div 4)); 119 ax := ((1 shl 16 div (Height div 4)) * (Width div 4)) * Y; 120 if (r < ScaleToNative(8) * Height * Width * Width) and 121 ((r >= (Height div 4) * (Height div 2) * (Width div 2) * (Width div 2)) and (ax < amax2 * X) and 118 122 ((ax < amax0 * X) or (ax > amin2 * X)) or (ax > amin1 * X) and 119 123 ((ax < amax1 * X) or (ax > amin3 * X))) then begin … … 156 160 x0Src := (i mod 7) * xSizeBig; 157 161 y0Src := (i div 7 + SystemIconLines) * ySizeBig; 158 Src := PixelPointer(BigImp, x0Src, y0Src);159 Dst := PixelPointer(Offscreen, x0Dst, y0Dst);160 for Y := 0 to ySizeBig- 1 do begin161 for X := 0 to xSizeBig- 1 do begin162 Src := PixelPointer(BigImp, ScaleToNative(x0Src), ScaleToNative(y0Src)); 163 Dst := PixelPointer(Offscreen, ScaleToNative(x0Dst), ScaleToNative(y0Dst)); 164 for Y := 0 to ScaleToNative(ySizeBig) - 1 do begin 165 for X := 0 to ScaleToNative(xSizeBig) - 1 do begin 162 166 Darken := ((255 - Src.Pixel^.B) * 3 + (255 - Src.Pixel^.G) * 163 167 15 + (255 - Src.Pixel^.R) * 9) div 128; … … 229 233 ySizeBig + 6, (wMaintexture - ClientWidth) div 2, 230 234 (hMaintexture - ClientHeight) div 2); 231 //DarkIcon(I);235 DarkIcon(I); 232 236 end; 233 237 -2: // destroyed
Note:
See TracChangeset
for help on using the changeset viewer.