Ignore:
Timestamp:
Nov 30, 2023, 10:16:14 PM (12 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/Direct.pas

    r405 r465  
    77  UDpiControls, Messg,
    88
    9   LCLIntf, LCLType, {$IFDEF Linux}LMessages, {$ENDIF}Messages, SysUtils, Classes,
     9  LCLIntf, LCLType, {$IFDEF UNIX}LMessages, {$ENDIF}Messages, SysUtils, Classes,
    1010  Graphics, Controls, Forms, DrawDlg, GameServer;
    1111
     
    2929    Gone: Boolean;
    3030    Quick: Boolean;
    31     procedure SetInfo(x: string);
    32     procedure SetState(x: integer);
     31    procedure SetInfo(X: string);
     32    procedure SetState(X: Integer);
    3333    procedure OnGo(var Msg: TMessage); message WM_GO;
    3434    procedure OnChangeClient(var Msg: TMessage); message WM_CHANGECLIENT;
     
    4040  DirectDlg: TDirectDlg;
    4141
     42
    4243implementation
    4344
    4445uses
    45   ScreenTools, Protocol, Start, LocalPlayer, NoTerm, Back, Global, UNetworkServer,
    46   UNetworkClient;
     46  ScreenTools, Protocol, Start, LocalPlayer, NoTerm, Back, Global, NetworkServer,
     47  NetworkClient;
    4748
    4849{$R *.lfm}
     
    5758//  hMem: Cardinal;
    5859//  p: pointer;
    59   s: string;
     60  S: string;
    6061Begin
    6162  case ID of
     
    7273      if visible then
    7374      begin
    74         s := Format(Phrases.Lookup('BUSY_MOD'), [Brains[Index].Name]);
    75         while BiColorTextWidth(Canvas, s) + 64 > ClientWidth do
    76           Delete(s, Length(s), 1);
    77         SetInfo(s);
     75        S := Format(Phrases.Lookup('BUSY_MOD'), [Brains[Index].Name]);
     76        while BiColorTextWidth(Canvas, S) + 64 > ClientWidth do
     77          Delete(S, Length(S), 1);
     78        SetInfo(S);
    7879      end;
    7980    ntCreateWorld:
     
    111112          hMem := GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE,
    112113            Length(NotifyMessage));
    113           p := GlobalLock(hMem);
    114           if p <> nil then
    115             move(NotifyMessage[1], p^, Length(NotifyMessage));
     114          P := GlobalLock(hMem);
     115          if P <> nil then
     116            Move(NotifyMessage[1], P^, Length(NotifyMessage));
    116117          GlobalUnlock(hMem);
    117118          SetClipboardData(CF_TEXT, hMem);
     
    153154        State := -1;
    154155        Show;
    155         {$IFDEF LINUX}
    156         // Force shown window repaint on Gtk2 widgetset
    157         Sleep(1);
    158         DpiApplication.ProcessMessages;
    159         {$ENDIF}
     156        Gtk2Fix;
    160157        Invalidate;
    161158        Update;
     
    183180  BrainTerm.Name := Phrases.Lookup('HUMAN');
    184181  if NetworkEnabled then begin
    185     BrainNetworkServer.Client := UNetworkServer.Client;
     182    BrainNetworkServer.Client := NetworkServer.Client;
    186183    BrainNetworkServer.Name := Phrases.Lookup('NETWORK_SERVER');
    187     BrainNetworkClient.Client := UNetworkClient.Client;
     184    BrainNetworkClient.Client := NetworkClient.Client;
    188185    BrainNetworkClient.Name := Phrases.Lookup('NETWORK_CLIENT');
    189186  end;
     
    198195  begin
    199196    PostMessage(Handle, WM_GO, 0, 0);
    200     Gone := true;
     197    Gone := True;
    201198  end;
    202199end;
     
    209206procedure TDirectDlg.OnGo(var Msg: TMessage);
    210207var
    211   i: integer;
    212   s: string;
     208  I: Integer;
     209  S: string;
    213210  FileName: string;
    214211begin
     
    220217    Exit;
    221218  end;
    222   Quick := false;
     219  Quick := False;
    223220  if ParamCount > 0 then
    224221  begin
    225     s := ParamStr(1);
    226     if (s[1] = '-') {$IFDEF WINDOWS}or (s[1] = '/'){$ENDIF} then
     222    S := ParamStr(1);
     223    if (S[1] = '-') {$IFDEF WINDOWS}or (S[1] = '/'){$ENDIF} then
    227224    begin // special mode
    228       Delete(s, 1, 1);
    229       for i := 1 to Length(s) do
    230         if s[i] in ['a' .. 'z'] then
    231           dec(s[i], 32);
    232       if s = 'MAN' then
     225      Delete(S, 1, 1);
     226      for I := 1 to Length(S) do
     227        if S[I] in ['a' .. 'z'] then
     228          Dec(S[I], 32);
     229      if S = 'MAN' then
    233230      begin
    234         Quick := true;
     231        Quick := True;
    235232        DirectHelp(cHelpOnly);
    236233        Close;
     
    242239        Quick := True;
    243240        if not LoadGame(ExtractFilePath(ParamStr(1)), ExtractFileName(ParamStr(1)
    244         ), -1, false) then begin
     241        ), -1, False) then begin
    245242          SimpleMessage(Phrases.Lookup('LOADERR'));
    246243          Close;
     
    280277procedure TDirectDlg.FormPaint(Sender: TObject);
    281278begin
    282   PaintBackground(self, 3, 3, ClientWidth - 6, ClientHeight - 6);
     279  PaintBackground(Self, 3, 3, ClientWidth - 6, ClientHeight - 6);
    283280  Frame(Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
    284281  Frame(Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
     
    297294end;
    298295
    299 procedure TDirectDlg.SetInfo(x: string);
    300 begin
    301   Info := x;
     296procedure TDirectDlg.SetInfo(X: string);
     297begin
     298  Info := X;
    302299  Invalidate;
    303300  Update;
    304   {$IFDEF LINUX}
     301  {$IFDEF UNIX}
    305302  DpiApplication.ProcessMessages;
    306303  {$ENDIF}
    307304end;
    308305
    309 procedure TDirectDlg.SetState(x: integer);
    310 begin
    311   if (x < 0) <> (State < 0) then begin
    312     State := x;
     306procedure TDirectDlg.SetState(X: Integer);
     307begin
     308  if (X < 0) <> (State < 0) then begin
     309    State := X;
    313310    Invalidate;
    314311    Update;
    315312  end
    316   else if x <> State then begin
    317     State := x;
     313  else if X <> State then begin
     314    State := X;
    318315    PaintProgressBar(Canvas, 6, ClientWidth div 2 - 64, 40, State, 128 - State,
    319316      128, MainTexture);
Note: See TracChangeset for help on using the changeset viewer.