Ignore:
Timestamp:
Nov 30, 2023, 10:16:14 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Updated high dpi branch from trunk.
  • Modified: Use generics.collections instead of fgl.
  • Modified: Compile with Delphi syntax.
File:
1 edited

Legend:

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

    r349 r465  
    3030  end;
    3131
    32 var
    33   TechTreeDlg: TTechTreeDlg;
    34 
    3532
    3633implementation
     
    5552  yLegendPitch = 32;
    5653
    57 function min(a, b: Integer): Integer;
    58 begin
    59   if a < b then
    60     result := a
     54function Min(A, B: Integer): Integer;
     55begin
     56  if A < B then
     57    Result := A
    6158  else
    62     result := b;
    63 end;
    64 
    65 function max(a, b: Integer): Integer;
    66 begin
    67   if a > b then
    68     result := a
     59    Result := B;
     60end;
     61
     62function Max(A, B: Integer): Integer;
     63begin
     64  if A > B then
     65    Result := A
    6966  else
    70     result := b;
     67    Result := B;
    7168end;
    7269
     
    8481procedure TTechTreeDlg.FormPaint(Sender: TObject);
    8582var
    86   X, w: Integer;
     83  X, W: Integer;
    8784begin
    8885  with Canvas do begin
    8986    // black border
    90     brush.color := $000000;
    91     fillrect(rect(0, 0, BlackBorder, ClientHeight));
    92     fillrect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder));
    93     fillrect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight));
    94     fillrect(rect(BlackBorder, ClientHeight - BlackBorder,
     87    Brush.Color := $000000;
     88    FillRect(rect(0, 0, BlackBorder, ClientHeight));
     89    FillRect(rect(BlackBorder, 0, ClientWidth - BlackBorder, BlackBorder));
     90    FillRect(rect(ClientWidth - BlackBorder, 0, ClientWidth, ClientHeight));
     91    FillRect(rect(BlackBorder, ClientHeight - BlackBorder,
    9592      ClientWidth - BlackBorder, ClientHeight));
    9693
    9794    // texturize empty space
    98     brush.color := $FFFFFF;
     95    Brush.Color := $FFFFFF;
    9996    if xOffset > 0 then
    10097      FillRectSeamless(Canvas, BlackBorder, BlackBorder, BlackBorder + xOffset,
     
    105102        ClientWidth - BlackBorder, ClientHeight - BlackBorder,
    106103        -BlackBorder - xOffset, -BlackBorder - yOffset, Paper);
    107     X := max(BlackBorder, BlackBorder + xOffset);
    108     w := min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder);
     104    X := Max(BlackBorder, BlackBorder + xOffset);
     105    W := Min(BlackBorder + xOffset + Image.width, ClientWidth - BlackBorder);
    109106    if yOffset > 0 then
    110       FillRectSeamless(Canvas, X, BlackBorder, w, BlackBorder + yOffset,
     107      FillRectSeamless(Canvas, X, BlackBorder, W, BlackBorder + yOffset,
    111108        -BlackBorder - xOffset, -BlackBorder - yOffset, Paper);
    112109    if yOffset + Image.height < ClientHeight - 2 * BlackBorder then
    113       FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, w,
     110      FillRectSeamless(Canvas, X, BlackBorder + yOffset + Image.height, W,
    114111        ClientHeight - BlackBorder, -BlackBorder - xOffset,
    115112        -BlackBorder - yOffset, Paper);
    116113  end;
    117   DpiBitCanvas(Canvas, max(BlackBorder, BlackBorder + xOffset),
    118     max(BlackBorder, BlackBorder + yOffset),
    119     min(Image.width, min(Image.width + xOffset,
    120     min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset))
    121     ), min(Image.height, min(Image.height + yOffset,
    122     min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -
    123     yOffset))), Image.Canvas, max(0, -xOffset),
    124     max(0, -yOffset));
     114  DpiBitBltCanvas(Canvas, Max(BlackBorder, BlackBorder + xOffset),
     115    Max(BlackBorder, BlackBorder + yOffset),
     116    Min(Image.width, Min(Image.width + xOffset,
     117    Min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset))
     118    ), Min(Image.height, Min(Image.height + yOffset,
     119    Min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -
     120    yOffset))), Image.Canvas, Max(0, -xOffset),
     121    Max(0, -yOffset));
    125122end;
    126123
     
    128125var
    129126  X, Y, ad: Integer;
    130   s: string;
     127  S: string;
    131128  NewWidth: Integer;
    132129  NewHeight: Integer;
    133130begin
     131  Caption := Phrases2.Lookup('MENU_ADVTREE');
    134132  if Image = nil then begin
    135133    Image := TDpiBitmap.Create;
     
    139137
    140138    with Image.Canvas do begin
    141       // write advance names
     139      // Write advance names
    142140      Font.Assign(UniFont[ftSmall]);
    143       Font.color := clBlack;
    144       brush.Style := bsClear;
    145       for X := 0 to (Image.width - xStart) div xPitch do
    146         for Y := 0 to (Image.height - yStart) div yPitch do
     141      Font.Color := clBlack;
     142      Brush.Style := bsClear;
     143      for X := 0 to (Image.Width - xStart) div xPitch do
     144        for Y := 0 to (Image.Height - yStart) div yPitch do
    147145        begin
    148146          ad := Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1];
    149147          if ad and $FFFF00 = 0 then
    150148          begin
    151             s := Phrases.Lookup('ADVANCES', ad);
    152             while TextWidth(s) > 112 do
    153               Delete(s, Length(s), 1);
    154             TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, s);
     149            S := Phrases.Lookup('ADVANCES', ad);
     150            while TextWidth(S) > 112 do
     151              Delete(S, Length(S), 1);
     152            TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, S);
    155153            Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1]
    156154              := TransparentColor2;
    157           end
     155          end;
    158156        end;
    159157
    160       // write legend
     158      // Write legend
    161159      TextOut(xLegend, yLegend, Phrases2.Lookup('ADVTREE_UP0'));
    162160      TextOut(xLegend, yLegend + yLegendPitch, Phrases2.Lookup('ADVTREE_UP1'));
     
    172170  end;
    173171
    174   // fit window to image, center image in window, center window to screen
     172  // Fit window to image, center image in window, center window to screen
    175173  NewWidth := Min(DpiScreen.Width - 40, Image.Width + LeftBorder + RightBorder + 2 * BlackBorder);
    176174  NewHeight := Min(DpiScreen.Height - 40, Image.Height + TopBorder + BottomBorder + 2 * BlackBorder);
     
    190188  if Button = mbLeft then
    191189  begin
    192     dragging := true;
     190    Dragging := True;
    193191    xDown := X;
    194192    yDown := Y;
     
    199197  Shift: TShiftState; X, Y: Integer);
    200198begin
    201   dragging := false;
     199  Dragging := False;
    202200end;
    203201
     
    205203  X, Y: Integer);
    206204begin
    207   if dragging then
     205  if Dragging then
    208206  begin
    209207    xOffset := xOffset + X - xDown;
Note: See TracChangeset for help on using the changeset viewer.