Ignore:
Timestamp:
Jun 23, 2019, 3:15:29 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Use DpiControls package for High DPI support.
File:
1 edited

Legend:

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

    r173 r178  
    1313  Protocol, Tribes, PVSB, ClientTools, ScreenTools, BaseWin, Messg, ButtonBase,
    1414  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, DrawDlg, Types,
    15   Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area;
     15  Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area,
     16  UDpiControls;
    1617
    1718const
     
    228229    BrushType: Cardinal;
    229230    trix: array [0 .. 63] of integer;
    230     AILogo: array [0 .. nPl - 1] of TBitmap;
    231     Mini, Panel, TopBar: TBitmap;
     231    AILogo: array [0 .. nPl - 1] of TDpiBitmap;
     232    Mini, Panel, TopBar: TDpiBitmap;
    232233    sb: TPVScrollbar;
    233234    Closable, RepaintOnResize, Tracking, TurnComplete, Edited, GoOnPhase,
     
    276277  public
    277278    UsedOffscreenWidth, UsedOffscreenHeight: integer;
    278     Offscreen: TBitmap;
    279     OffscreenUser: TForm;
     279    Offscreen: TDpiBitmap;
     280    OffscreenUser: TDpiForm;
    280281    procedure CreateParams(var p: TCreateParams); override;
    281282    procedure Client(Command, NewPlayer: integer; var Data);
     
    428429  CityRepMask: Cardinal;
    429430  ReceivedOffer: TOffer;
    430   Buffer: TBitmap;
    431   SmallImp: TBitmap;
     431  Buffer: TDpiBitmap;
     432  SmallImp: TDpiBitmap;
    432433  BlinkON: Boolean;
    433434  DestinationMarkON: Boolean;
     
    455456procedure InitMyModel(mix: integer; final: boolean);
    456457
    457 procedure ImpImage(ca: TCanvas; x, y, iix: integer; Government: integer = -1;
     458procedure ImpImage(ca: TDpiCanvas; x, y, iix: integer; Government: integer = -1;
    458459  IsControl: boolean = false);
    459460procedure HelpOnTerrain(Loc, NewMode: integer);
    460461
    461 
    462462implementation
    463463
    464464uses
    465465  Directories, IsoEngine, CityScreen, Draft, MessgEx, Select, CityType, Help,
    466   UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego, PixelPointer, Sound,
     466  UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego,
    467467  Battle, Rates, TechTree, Registry;
    468468
     
    620620end;
    621621
    622 procedure ImpImage(ca: TCanvas; x, y, iix: integer; Government: integer;
     622procedure ImpImage(ca: TDpiCanvas; x, y, iix: integer; Government: integer;
    623623  IsControl: boolean);
    624624begin
     
    859859end;
    860860
    861 procedure PaintZoomedTile(dst: TBitmap; x, y, Loc: integer);
     861procedure PaintZoomedTile(dst: TDpiBitmap; x, y, Loc: integer);
    862862
    863863  procedure TSprite(xDst, yDst, xSrc, ySrc: integer);
     
    10881088    if G.RO[DipMem[me].pContact] <> nil then
    10891089    begin // close windows for next player
    1090       for i := 0 to Screen.FormCount - 1 do
    1091         if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg)
     1090      for i := 0 to DpiScreen.FormCount - 1 do
     1091        if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg)
    10921092        then
    1093           Screen.Forms[i].Close;
     1093          DpiScreen.Forms[i].Close;
    10941094    end
    10951095    else
     
    11161116    if G.RO[DipMem[me].pContact] <> nil then
    11171117    begin // close windows for next player
    1118       for i := 0 to Screen.FormCount - 1 do
    1119         if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg)
     1118      for i := 0 to DpiScreen.FormCount - 1 do
     1119        if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg)
    11201120        then
    1121           Screen.Forms[i].Close;
     1121          DpiScreen.Forms[i].Close;
    11221122    end
    11231123    else
     
    12311231  begin
    12321232    if AILogo[p] = nil then
    1233       AILogo[p] := TBitmap.Create;
     1233      AILogo[p] := TDpiBitmap.Create;
    12341234    if not LoadGraphicFile(AILogo[p], HomeDir + Name + '.png', gfNoError) then
    12351235    begin
     
    14971497
    14981498    HGrStdUnits := LoadGraphicSet('StdUnits.png');
    1499     SmallImp := TBitmap.Create;
     1499    SmallImp := TDpiBitmap.Create;
    15001500    SmallImp.PixelFormat := pf24bit;
    15011501    InitSmallImp;
     
    18111811    end;
    18121812
    1813     for i := 0 to Screen.FormCount - 1 do
    1814       if Screen.Forms[i] is TBufferedDrawDlg then
    1815         Screen.Forms[i].Enabled := true;
     1813    for i := 0 to DpiScreen.FormCount - 1 do
     1814      if DpiScreen.Forms[i] is TBufferedDrawDlg then
     1815        DpiScreen.Forms[i].Enabled := true;
    18161816
    18171817    if ClientMode <> cResume then
     
    18241824      // first turn after anarchy -- don't show despotism palace!
    18251825      Update;
    1826       for i := 0 to Screen.FormCount - 1 do
    1827         if (Screen.Forms[i].Visible) and (Screen.Forms[i] is TBufferedDrawDlg)
     1826      for i := 0 to DpiScreen.FormCount - 1 do
     1827        if (DpiScreen.Forms[i].Visible) and (DpiScreen.Forms[i] is TBufferedDrawDlg)
    18281828        then
    18291829        begin
    1830           if @Screen.Forms[i].OnShow <> nil then
    1831             Screen.Forms[i].OnShow(nil);
    1832           Screen.Forms[i].Invalidate;
    1833           Screen.Forms[i].Update;
     1830          if @DpiScreen.Forms[i].OnShow <> nil then
     1831            DpiScreen.Forms[i].OnShow(nil);
     1832          DpiScreen.Forms[i].Invalidate;
     1833          DpiScreen.Forms[i].Update;
    18341834        end;
    18351835
     
    26652665        SaveSettings;
    26662666        CityDlg.CloseAction := None;
    2667         for i := 0 to Screen.FormCount - 1 do
    2668           if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg)
     2667        for i := 0 to DpiScreen.FormCount - 1 do
     2668          if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg)
    26692669          then
    2670             Screen.Forms[i].Close;
     2670            DpiScreen.Forms[i].Close;
    26712671        if LogDlg.Visible then
    26722672          LogDlg.Close;
     
    34093409  i, j: integer;
    34103410begin
    3411   MainFormKeyDown := FormKeyDown;
    34123411  BaseWin.CreateOffscreen(Offscreen);
    34133412
     
    35083507  end;
    35093508
    3510   Mini := TBitmap.Create;
     3509  Mini := TDpiBitmap.Create;
    35113510  Mini.PixelFormat := pf24bit;
    3512   Panel := TBitmap.Create;
     3511  Panel := TDpiBitmap.Create;
    35133512  Panel.PixelFormat := pf24bit;
    35143513  Panel.Canvas.Font.Assign(UniFont[ftSmall]);
    35153514  Panel.Canvas.Brush.Style := bsClear;
    3516   TopBar := TBitmap.Create;
     3515  TopBar := TDpiBitmap.Create;
    35173516  TopBar.PixelFormat := pf24bit;
    35183517  TopBar.Canvas.Font.Assign(UniFont[ftNormal]);
    35193518  TopBar.Canvas.Brush.Style := bsClear;
    3520   Buffer := TBitmap.Create;
     3519  Buffer := TDpiBitmap.Create;
    35213520  Buffer.PixelFormat := pf24bit;
    35223521  if 2 * lxmax > 3 * xSizeBig then
     
    35383537procedure TMainScreen.FormDestroy(Sender: TObject);
    35393538var
    3540   I: Integer;
    3541 begin
    3542   MainFormKeyDown := nil;
     3539  i: integer;
     3540begin
    35433541  FreeAndNil(sb);
    35443542  FreeAndNil(TopBar);
     
    35463544  FreeAndNil(Buffer);
    35473545  FreeAndNil(Panel);
    3548   for I := 0 to nPl - 1 do
     3546  for i := 0 to nPl - 1 do
    35493547    if AILogo[i] <> nil then
    3550       FreeAndNil(AILogo[I]);
     3548      FreeAndNil(AILogo[i]);
    35513549  FreeAndNil(Offscreen);
    35523550end;
     
    37533751  if supervising and (me <> 0) then
    37543752  begin
    3755     for i := 0 to Screen.FormCount - 1 do
    3756       if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    3757         Screen.Forms[i].Close; // close windows
     3753    for i := 0 to DpiScreen.FormCount - 1 do
     3754      if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then
     3755        DpiScreen.Forms[i].Close; // close windows
    37583756    ItsMeAgain(0);
    37593757  end;
     
    38993897  if IsMultiPlayerGame then
    39003898  begin // close windows for next player
    3901     for i := 0 to Screen.FormCount - 1 do
    3902       if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    3903         Screen.Forms[i].Close;
     3899    for i := 0 to DpiScreen.FormCount - 1 do
     3900      if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then
     3901        DpiScreen.Forms[i].Close;
    39043902  end
    39053903  else
     
    39113909  end;
    39123910  for i := 0 to Screen.FormCount - 1 do
    3913     if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    3914       Screen.Forms[i].Enabled := false;
     3911    if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then
     3912      DpiScreen.Forms[i].Enabled := false;
    39153913
    39163914  if Server(sTurn, pTurn, 0, nil^) >= rExecuted then
     
    41794177{$IFDEF LINUX}
    41804178// Can't do scrolling of DC under Linux, then fallback into BitBlt.
    4181 function ScrollDC(Canvas: TCanvas; dx: longint; dy: longint; const lprcScroll:TRect; const lprcClip:TRect; hrgnUpdate:HRGN; lprcUpdate: PRect):Boolean;
     4179function ScrollDC(Canvas: TDpiCanvas; dx: longint; dy: longint; const lprcScroll:TRect; const lprcClip:TRect; hrgnUpdate:HRGN; lprcUpdate: PRect):Boolean;
    41824180begin
    41834181  BitBltCanvas(Canvas, lprcScroll.Left + dx, lprcScroll.Top + dy, lprcScroll.Right - lprcScroll.Left, lprcScroll.Bottom - lprcScroll.Top,
     
    50805078begin
    50815079  if idle and (me >= 0) and (GameMode <> cMovie) then
    5082     if (fsModal in Screen.ActiveForm.FormState) or
    5083       (Screen.ActiveForm is TBufferedDrawDlg) and
    5084       (TBufferedDrawDlg(Screen.ActiveForm).WindowMode <> wmPersistent) then
     5080    if (fsModal in DpiScreen.ActiveForm.FormState) or
     5081      (DpiScreen.ActiveForm is TBufferedDrawDlg) and
     5082      (TBufferedDrawDlg(DpiScreen.ActiveForm).WindowMode <> wmPersistent) then
    50855083    begin
    50865084      BlinkTime := BlinkOnTime + BlinkOffTime - 1;
     
    51175115        if (dx <> 0) or (dy <> 0) then
    51185116        begin
    5119           if (Screen.ActiveForm <> MainScreen) and
    5120             (@Screen.ActiveForm.OnDeactivate <> nil) then
    5121             Screen.ActiveForm.OnDeactivate(nil);
     5117          if (DpiScreen.ActiveForm <> MainScreen) and
     5118            (@DpiScreen.ActiveForm.OnDeactivate <> nil) then
     5119            DpiScreen.ActiveForm.OnDeactivate(nil);
    51225120          Scroll(dx, dy);
    51235121        end
     
    64586456    ((p = 0) or (1 shl p and G.RO[0].Alive <> 0)) then
    64596457  begin
    6460     for i := 0 to Screen.FormCount - 1 do
    6461       if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    6462         Screen.Forms[i].Close; // close windows
     6458    for i := 0 to DpiScreen.FormCount - 1 do
     6459      if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then
     6460        DpiScreen.Forms[i].Close; // close windows
    64636461    ItsMeAgain(p);
    64646462    SumCities(TaxSum, ScienceSum);
     
    80038001  Centre(CenterLoc);
    80048002  PaintAllMaps;
    8005   for i := 0 to Screen.FormCount - 1 do
    8006     if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    8007       TBufferedDrawDlg(Screen.Forms[i]).SmartUpdateContent(false);
     8003  for i := 0 to DpiScreen.FormCount - 1 do
     8004    if DpiScreen.Forms[i].Visible and (DpiScreen.Forms[i] is TBufferedDrawDlg) then
     8005      TBufferedDrawDlg(DpiScreen.Forms[i]).SmartUpdateContent(false);
    80088006end;
    80098007
Note: See TracChangeset for help on using the changeset viewer.