Ignore:
Timestamp:
May 9, 2020, 9:35:25 PM (4 years ago)
Author:
chronos
Message:
  • Fixed: Better High DPI scaling on highdpi branch.
Location:
branches/highdpi/LocalPlayer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/LocalPlayer/Help.pas

    r210 r212  
    445445  x, y, dx, dy, xSrc, ySrc, sum, xx: integer;
    446446  Heaven: array [0..nHeaven] of integer;
    447   PaintPtr, CoalPtr: TPixelPointer;
     447  PaintPtr: TPixelPointer;
     448  CoalPtr: TPixelPointer;
    448449  ImpPtr: array [-1..1] of TPixelPointer;
    449450begin
  • branches/highdpi/LocalPlayer/IsoEngine.pas

    r210 r212  
    3434    function IsShoreTile(Loc: integer): boolean;
    3535    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);
    3737  protected
    3838    FOutput: TDpiBitmap;
     
    10151015            1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1));
    10161016          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, ScaleToVcl(0), ScaleToVcl(p1 * (yyt * 2)));
     1018          for dy := 0 to ScaleToVcl(yyt * 2) - 1 do begin
     1019            for dx := 0 to ScaleToVcl(xxt * 2) - 1 do begin
    10211020              if PixelPtr.Pixel^.B = 99 then begin
    10221021                PixelPtr.Pixel^.B := Tribe[p1].Color shr 16 and $FF;
     
    10261025              PixelPtr.NextPixel;
    10271026            end;
     1027            PixelPtr.NextLine;
    10281028          end;
    10291029          Borders.EndUpdate;
     
    13301330end;
    13311331
    1332 procedure TIsoMap.ShadeOutside(x0, y0, x1, y1, xm, ym: integer);
     1332procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: integer);
    13331333const
    13341334  rShade = 3.75;
     
    13391339begin
    13401340  FOutput.BeginUpdate;
    1341   for y := y0 to y1 - 1 do begin
    1342     Line := PixelPointer(FOutput, 0, y);
    1343     y_n := (y - ym) / yyt;
    1344     if abs(y_n) < rShade then begin
     1341  Line := PixelPointer(FOutput, ScaleToVcl(x0), ScaleToVcl(y0));
     1342  for y := 0 to ScaleToVcl(Height) - 1 do begin
     1343    y_n := (ScaleFromVcl(y) + y0 - ym) / yyt;
     1344    if Abs(y_n) < rShade then begin
    13451345      // 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);
     1346      w_n := Sqrt(Sqr(rShade) - Sqr(y_n));
     1347      wBright := Trunc(w_n * xxt + 0.5);
     1348      Line.SetX(0);
     1349      MakeDark(@Line, ScaleToVcl(xm - wBright));
     1350      Line.SetX(ScaleToVcl(xm + wBright));
     1351      MakeDark(@Line, ScaleToVcl(Width - xm - wBright));
    13521352    end else begin
    13531353      // Darken entire line
    1354       Line.SetX(x0);
    1355       MakeDark(@Line, x1 - x0);
     1354      Line.SetX(0);
     1355      MakeDark(@Line, ScaleToVcl(Width));
    13561356    end;
     1357    Line.NextLine;
    13571358  end;
    13581359  FOutput.EndUpdate;
     
    15761577    xm := x + (dx + 1) * xxt;
    15771578    ym := y + (dy + 1) * yyt + yyt;
    1578     ShadeOutside(FLeft, FTop, FRight, FBottom, xm, ym);
     1579    ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym);
    15791580    CityGrid(xm, ym, CityAllowClick);
    15801581    for dy := -2 to ny + 1 do
  • branches/highdpi/LocalPlayer/Term.pas

    r210 r212  
    532532  SmallScreen, GameOK, MapValid, skipped, idle: boolean;
    533533
    534   SaveOption: array [0 .. nSaveOption - 1] of integer;
    535   MiniColors: array [0 .. 11, 0 .. 1] of TColor;
     534  SaveOption: array [0..nSaveOption - 1] of integer;
     535  MiniColors: array [0..fTerrain, 0..1] of TColor;
    536536  MainMap: TIsoMap;
    537537  CurrentMoveInfo: record AfterMovePaintRadius, AfterAttackExpeller: integer;
     
    40774077  MiniPixel := PixelPointer(Mini);
    40784078  PrevMiniPixel := PixelPointer(Mini);
    4079   for y := 0 to G.ly - 1 do
    4080   begin
    4081     for x := 0 to G.lx - 1 do
    4082       if MyMap[x + G.lx * y] and fTerrain <> fUNKNOWN then
    4083       begin
    4084         Loc := x + G.lx * y;
     4079  for y := 0 to ScaleToVcl(G.ly) - 1 do
     4080  begin
     4081    for x := 0 to ScaleToVcl(G.lx) - 1 do
     4082      if MyMap[ScaleFromVcl(x) + G.lx * ScaleFromVcl(y)] and fTerrain <> fUNKNOWN then
     4083      begin
     4084        Loc := ScaleFromVcl(x) + G.lx * ScaleFromVcl(y);
    40854085        for i := 0 to 1 do
    40864086        begin
    4087           xm := ((x - xwMini) * 2 + i + y and 1 - hw + G.lx * 5) mod (G.lx * 2);
     4087          xm := ((x - ScaleToVcl(xwMini)) * 2 + i + y and 1 - ScaleToVcl(hw) +
     4088            ScaleToVcl(G.lx) * 5) mod (ScaleToVcl(G.lx) * 2);
    40884089          MiniPixel.SetXY(xm, y);
    40894090          cm := MiniColors[MyMap[Loc] and fTerrain, i];
     
    50795080        dx := 0;
    50805081        dy := 0;
    5081         if Mouse.CursorPos.y < DpiScreen.height - PanelHeight then
    5082           if Mouse.CursorPos.x = 0 then
     5082        if DpiMouse.CursorPos.y < DpiScreen.height - PanelHeight then
     5083          if DpiMouse.CursorPos.x = 0 then
    50835084            dx := -speed // scroll left
    5084           else if Mouse.CursorPos.x = DpiScreen.width - 1 then
     5085          else if DpiMouse.CursorPos.x = DpiScreen.width - 1 then
    50855086            dx := speed; // scroll right
    5086         if Mouse.CursorPos.y = 0 then
     5087        if DpiMouse.CursorPos.y = 0 then
    50875088          dy := -speed // scroll up
    5088         else if (Mouse.CursorPos.y = DpiScreen.height - 1) and
    5089           (Mouse.CursorPos.x >= TerrainBtn.Left + TerrainBtn.width) and
    5090           (Mouse.CursorPos.x < xRightPanel + 10 - 8) then
     5089        else if (DpiMouse.CursorPos.y = DpiScreen.height - 1) and
     5090          (DpiMouse.CursorPos.x >= TerrainBtn.Left + TerrainBtn.width) and
     5091          (DpiMouse.CursorPos.x < xRightPanel + 10 - 8) then
    50915092          dy := speed; // scroll down
    50925093        if (dx <> 0) or (dy <> 0) then
Note: See TracChangeset for help on using the changeset viewer.