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/Start.pas

    r170 r178  
    77  GameServer, Messg, ButtonBase, ButtonA, ButtonC, ButtonB, Area, Math,
    88  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls,
    9   Menus, Registry, DrawDlg, fgl, Protocol;
     9  Menus, Registry, DrawDlg, fgl, Protocol, UDpiControls;
    1010
    1111const
     
    5656    Down1Btn: TButtonC;
    5757    Up1Btn: TButtonC;
    58     List: TListBox;
     58    List: TDpiListBox;
    5959    RenameBtn: TButtonB;
    6060    DeleteBtn: TButtonB;
     
    7272    procedure FormShow(Sender: TObject);
    7373    procedure FormHide(Sender: TObject);
    74     procedure FormClose(Sender: TObject; var Action: TCloseAction);
    7574    procedure FormCreate(Sender: TObject);
    7675    procedure FormDestroy(Sender: TObject);
    7776    procedure BrainClick(Sender: TObject);
    78     procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    7977    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
    8078      Shift: TShiftState; x, y: integer);
    81     procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
    82       Shift: TShiftState; x, y: integer);
    83     procedure FormMouseMove(Sender: TObject; Shift: TShiftState; x, y: integer);
    8479    procedure Up1BtnClick(Sender: TObject);
    8580    procedure Down1BtnClick(Sender: TObject);
     81    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    8682    procedure ListClick(Sender: TObject);
    8783    procedure RenameBtnClick(Sender: TObject);
     
    9288    procedure Down2BtnClick(Sender: TObject);
    9389    procedure QuitBtnClick(Sender: TObject);
     90    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    9491    procedure CustomizeBtnClick(Sender: TObject);
    9592    procedure AutoDiffUpBtnClick(Sender: TObject);
    9693    procedure AutoDiffDownBtnClick(Sender: TObject);
     94    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
     95      Shift: TShiftState; x, y: integer);
     96    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; x, y: integer);
    9797    procedure AutoEnemyUpBtnClick(Sender: TObject);
    9898    procedure AutoEnemyDownBtnClick(Sender: TObject);
    9999    procedure ReplayBtnClick(Sender: TObject);
    100100  public
    101     EmptyPicture: TBitmap;
     101    EmptyPicture: TDpiBitmap;
    102102    procedure UpdateFormerGames;
    103103    procedure UpdateMaps;
     
    127127    MapFileName: string;
    128128    FormerGames, Maps: TStringList;
    129     LogoBuffer, Mini: TBitmap; { game world sample preview }
     129    LogoBuffer, Mini: TDpiBitmap; { game world sample preview }
    130130    MiniColors: array [0 .. 11, 0 .. 1] of TColor;
    131131    // BookDate: string;
     
    155155
    156156uses
    157   Directories, Direct, ScreenTools, Inp, Back, Locale, PixelPointer;
     157  Directories, Direct, ScreenTools, Inp, Back, Locale;
    158158
    159159{$R *.lfm}
     
    290290  PlayerSlots.Count := nPlOffered;
    291291  for i := 0 to PlayerSlots.Count - 1 do
    292   with PlayerSlots[i] do begin
     292  with TPlayerSlot(PlayerSlots[i]) do begin
    293293    DiffUpBtn := TButtonC.Create(self);
    294294    DiffUpBtn.Graphic := GrExt[HGrSystem].Data;
     
    324324    CustomizeBtn.ButtonIndex := 2;
    325325
    326   Brains[0].Picture := TBitmap.Create;
     326  Brains[0].Picture := TDpiBitmap.Create;
    327327  Brains[0].Picture.SetSize(64, 64);
    328328  BitBlt(Brains[0].Picture.Canvas.Handle, 0, 0, 64, 64,
    329329    GrExt[HGrSystem2].Data.Canvas.Handle, 1, 111, SRCCOPY);
    330   Brains[1].Picture := TBitmap.Create;
     330  Brains[1].Picture := TDpiBitmap.Create;
    331331  Brains[1].Picture.SetSize(64, 64);
    332332  BitBlt(Brains[1].Picture.Canvas.Handle, 0, 0, 64, 64,
    333333    GrExt[HGrSystem2].Data.Canvas.Handle, 66, 111, SRCCOPY);
    334   Brains[2].Picture := TBitmap.Create;
     334  Brains[2].Picture := TDpiBitmap.Create;
    335335  Brains[2].Picture.SetSize(64, 64);
    336336  BitBlt(Brains[2].Picture.Canvas.Handle, 0, 0, 64, 64,
    337337    GrExt[HGrSystem2].Data.Canvas.Handle, 131, 111, SRCCOPY);
    338   Brains[3].Picture := TBitmap.Create;
     338  Brains[3].Picture := TDpiBitmap.Create;
    339339  Brains[3].Picture.SetSize(64, 64);
    340340  BitBlt(Brains[3].Picture.Canvas.Handle, 0, 0, 64, 64,
     
    346346  with AIBrains[I] do
    347347  begin
    348     AIBrains[i].Picture := TBitmap.Create;
     348    AIBrains[i].Picture := TDpiBitmap.Create;
    349349    if not LoadGraphicFile(AIBrains[i].Picture, HomeDir + 'AI' + DirectorySeparator +
    350350      FileName + DirectorySeparator + FileName + '.png', gfNoError) then begin
     
    363363  AIBrains.Free;
    364364
    365   EmptyPicture := TBitmap.Create;
     365  EmptyPicture := TDpiBitmap.Create;
    366366  EmptyPicture.PixelFormat := pf24bit;
    367367  EmptyPicture.SetSize(64, 64);
    368368  EmptyPicture.Canvas.FillRect(0, 0, EmptyPicture.Width, EmptyPicture.Height);
    369   LogoBuffer := TBitmap.Create;
     369  LogoBuffer := TDpiBitmap.Create;
    370370  LogoBuffer.PixelFormat := pf24bit;
    371371  LogoBuffer.SetSize(wBuffer, 56);
    372372  LogoBuffer.Canvas.FillRect(0, 0, LogoBuffer.Width, LogoBuffer.Height);
    373373
    374   Mini := TBitmap.Create;
     374  Mini := TDpiBitmap.Create;
    375375  for x := 0 to 11 do
    376376    for y := 0 to 1 do
     
    926926      begin // load
    927927        FileName := List.Items[List.ItemIndex];
    928         if LoadGame(GetSavedDir + DirectorySeparator, FileName + CevoExt, LoadTurn, false)
     928        if LoadGame(DataDir + 'Saved' + DirectorySeparator, FileName + CevoExt, LoadTurn, false)
    929929        then
    930930          UnlistBackupFile(FileName)
     
    10101010        end;
    10111011
    1012         StartNewGame(GetSavedDir + DirectorySeparator, FileName + CevoExt, MapFileName,
     1012        StartNewGame(DataDir + 'Saved' + DirectorySeparator, FileName + CevoExt, MapFileName,
    10131013          lxpre[WorldSize], lypre[WorldSize], StartLandMass, MaxTurn);
    10141014        UnlistBackupFile(FileName);
     
    11451145    pgLoad:
    11461146      begin
    1147         AssignFile(LogFile, GetSavedDir + DirectorySeparator + List.Items[List.ItemIndex]
     1147        AssignFile(LogFile, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex]
    11481148          + CevoExt);
    11491149        try
     
    11981198        if Page = pgEditMap then
    11991199          MapFileName := List.Items[List.ItemIndex] + CevoMapExt;
    1200         if LoadGraphicFile(Mini, GetMapsDir + DirectorySeparator + Copy(MapFileName, 1,
     1200        if LoadGraphicFile(Mini, DataDir + 'Maps' + DirectorySeparator + Copy(MapFileName, 1,
    12011201          Length(MapFileName) - 9) + '.png', gfNoError) then
    12021202        begin
     
    12151215        end;
    12161216
    1217         AssignFile(MapFile, GetMapsDir + DirectorySeparator + MapFileName);
     1217        AssignFile(MapFile, DataDir + 'Maps' + DirectorySeparator + MapFileName);
    12181218        try
    12191219          Reset(MapFile, 4);
     
    13951395begin
    13961396  FormerGames.Clear;
    1397   if FindFirst(GetSavedDir + DirectorySeparator + '*' + CevoExt, $21, F) = 0 then
     1397  if FindFirst(DataDir + 'Saved' + DirectorySeparator + '*' + CevoExt, $21, F) = 0 then
    13981398    repeat
    13991399      I := FormerGames.Count;
     
    14151415begin
    14161416  Maps.Clear;
    1417   if FindFirst(GetMapsDir + DirectorySeparator + '*' + CevoMapExt, $21, f) = 0 then
     1417  if FindFirst(DataDir + 'Maps' + DirectorySeparator + '*' + CevoMapExt, $21, f) = 0 then
    14181418    repeat
    14191419      Maps.Add(Copy(f.Name, 1, Length(f.Name) - 9));
     
    17901790        end;
    17911791      if Page = pgLoad then
    1792         AssignFile(f, GetSavedDir + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt)
     1792        AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt)
    17931793      else
    1794         AssignFile(f, GetMapsDir + DirectorySeparator + List.Items[List.ItemIndex] +
     1794        AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex] +
    17951795          CevoMapExt);
    17961796      ok := true;
    17971797      try
    17981798        if Page = pgLoad then
    1799           Rename(f, GetSavedDir + DirectorySeparator + NewName + CevoExt)
     1799          Rename(f, DataDir + 'Saved'+ DirectorySeparator + NewName + CevoExt)
    18001800        else
    1801           Rename(f, GetMapsDir + DirectorySeparator + NewName + CevoMapExt);
     1801          Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + CevoMapExt);
    18021802      except
    18031803        // Play('INVALID');
     
    18061806      if Page <> pgLoad then
    18071807        try // rename map picture
    1808           AssignFile(f, GetMapsDir + DirectorySeparator + List.Items[List.ItemIndex]
     1808          AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex]
    18091809            + '.png');
    1810           Rename(f, GetMapsDir + DirectorySeparator + NewName + '.png');
     1810          Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + '.png');
    18111811        except
    18121812        end;
     
    18421842    begin
    18431843      if Page = pgLoad then
    1844         AssignFile(f, GetSavedDir + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt)
     1844        AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt)
    18451845      else
    1846         AssignFile(f, GetMapsDir + DirectorySeparator + List.Items[List.ItemIndex] +
     1846        AssignFile(f, DataDir + 'Maps' + DirectorySeparator + List.Items[List.ItemIndex] +
    18471847          CevoMapExt);
    18481848      Erase(f);
     
    20362036procedure TStartDlg.ReplayBtnClick(Sender: TObject);
    20372037begin
    2038   LoadGame(GetSavedDir + DirectorySeparator, List.Items[List.ItemIndex] + CevoExt,
     2038  LoadGame(DataDir + 'Saved' + DirectorySeparator, List.Items[List.ItemIndex] + CevoExt,
    20392039    LastTurn, True);
    20402040  SlotAvailable := -1;
Note: See TracChangeset for help on using the changeset viewer.