Ignore:
Timestamp:
Apr 6, 2021, 8:11:02 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Merged trunk branch version r348 into highdpi branch.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Direct.pas

    r303 r349  
    88
    99  LCLIntf, LCLType, {$IFDEF Linux}LMessages, {$ENDIF}Messages, SysUtils, Classes,
    10   Graphics, Controls, Forms, DrawDlg;
     10  Graphics, Controls, Forms, DrawDlg, GameServer;
    1111
    1212const
     
    2323    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    2424  public
    25     procedure DlgNotify(ID: integer);
     25    procedure DlgNotify(ID: TNotify; Index: Integer = 0);
    2626  private
    2727    Info: string;
    28     State: integer;
    29     Gone, Quick: boolean;
     28    State: Integer;
     29    Gone: Boolean;
     30    Quick: Boolean;
    3031    procedure SetInfo(x: string);
    3132    procedure SetState(x: integer);
    32     procedure OnGo(var m: TMessage); message WM_GO;
    33     procedure OnChangeClient(var m: TMessage); message WM_CHANGECLIENT;
    34     procedure OnNextPlayer(var m: TMessage); message WM_NEXTPLAYER;
     33    procedure OnGo(var Msg: TMessage); message WM_GO;
     34    procedure OnChangeClient(var Msg: TMessage); message WM_CHANGECLIENT;
     35    procedure OnNextPlayer(var Msg: TMessage); message WM_NEXTPLAYER;
    3536    procedure OnAIException(var Msg: TMessage); message WM_AIEXCEPTION;
    3637  end;
     
    4243
    4344uses
    44   ScreenTools, Protocol, GameServer, Start, LocalPlayer, NoTerm, Back;
     45  ScreenTools, Protocol, Start, LocalPlayer, NoTerm, Back, Global;
    4546
    4647{$R *.lfm}
    4748
    48 procedure Notify(ID: integer);
    49 begin
    50   DirectDlg.DlgNotify(ID);
    51 end;
    52 
    53 procedure TDirectDlg.DlgNotify(ID: integer);
     49procedure Notify(ID: TNotify; Index: Integer = 0);
     50begin
     51  DirectDlg.DlgNotify(ID, Index);
     52end;
     53
     54procedure TDirectDlg.DlgNotify(ID: TNotify; Index: Integer = 0);
    5455var
    5556//  hMem: Cardinal;
     
    5859begin
    5960  case ID of
    60     ntInitLocalHuman:
    61       begin
    62         SetMainTextureByAge(-1);
    63         State := -1;
    64         Info := Phrases.Lookup('BUSY_MODLH');
    65         Show;
    66         Invalidate;
    67         Update;
    68       end;
    69     ntInitModule .. ntInitModule + maxBrain - 1:
     61    ntInitLocalHuman: begin
     62      SetMainTextureByAge(-1);
     63      State := -1;
     64      Info := Phrases.Lookup('BUSY_MODLH');
     65      Show;
     66      {$IFDEF LINUX}
     67      DpiApplication.ProcessMessages;
     68      {$ENDIF}
     69      Invalidate;
     70      Update;
     71    end;
     72    ntInitModule:
    7073      if visible then
    7174      begin
    72         s := Format(Phrases.Lookup('BUSY_MOD'),
    73           [Brains[ID - ntInitModule].Name]);
     75        s := Format(Phrases.Lookup('BUSY_MOD'), [Brains[Index].Name]);
    7476        while BiColorTextWidth(Canvas, s) + 64 > ClientWidth do
    7577          Delete(s, Length(s), 1);
     
    8284      if visible then
    8385        SetInfo(Phrases.Lookup('BUSY_INIT'));
    84     ntDeactivationMissing .. ntDeactivationMissing + nPl - 1:
    85       SimpleMessage(Format(Phrases.Lookup('MISSDEACT'),
    86         [ID - ntDeactivationMissing]));
    87     ntSetAIName .. ntSetAIName + nPl - 1:
    88       LocalPlayer.SetAIName(ID - ntSetAIName, NotifyMessage);
    89     ntException .. ntException + maxBrain - 1:
    90       PostMessage(Handle, WM_AIEXCEPTION, ID - ntException, 0);
    91     ntLoadBegin:
    92       begin
    93         Info := Phrases.Lookup('BUSY_LOAD');
    94         SetState(0);
    95       end;
    96     ntLoadState .. ntLoadState + 128:
    97       SetState(ID - ntLoadState);
    98     ntDLLError .. ntDLLError + 128:
    99       SimpleMessage(Format(Phrases.Lookup('DLLERROR'),
    100         [Brains[ID - ntDLLError].FileName]));
     86    ntDeactivationMissing:
     87      SimpleMessage(Format(Phrases.Lookup('MISSDEACT'), [Index]));
     88    ntSetAIName:
     89      LocalPlayer.SetAIName(Index, NotifyMessage);
     90    ntException:
     91      PostMessage(Handle, WM_AIEXCEPTION, Index, 0);
     92    ntLoadBegin: begin
     93      Info := Phrases.Lookup('BUSY_LOAD');
     94      SetState(0);
     95    end;
     96    ntLoadState: SetState(Index);
     97    ntDLLError:
     98      SimpleMessage(Format(Phrases.Lookup('DLLERROR'), [Brains[Index].FileName]));
    10199    ntAIError:
    102100      SimpleMessage(Format(Phrases.Lookup('AIERROR'), [NotifyMessage]));
    103     ntClientError .. ntClientError + 128:
     101    ntClientError:
    104102      SimpleMessage(Format(Phrases.Lookup('CLIENTERROR'),
    105         [Brains[ID - ntClientError].FileName]));
    106     ntEndInfo:
    107       begin
    108         Hide;
    109         background.Update;
    110       end;
    111     ntLoadError:
    112       begin
     103        [Brains[Index].FileName]));
     104    ntEndInfo: begin
     105      Hide;
     106      Background.Update;
     107    end;
     108    ntLoadError: begin
    113109(* TODO        if OpenClipboard(Handle) then
    114110        begin // copy file path to clipboard
     
    134130      end;
    135131    ntStartDone:
    136       if not Quick then
    137       begin
     132      if not Quick then begin
    138133        StartDlg.Hide;
    139         background.Update;
     134        Background.Update;
    140135      end;
    141136    ntStartGo, ntStartGoRefresh, ntStartGoRefreshMaps:
    142       if Quick then
    143         Close
    144       else
    145       begin
     137      if Quick then Close
     138      else begin
    146139        if ID = ntStartGoRefresh then
    147140          StartDlg.UpdateFormerGames
     
    150143        StartDlg.Show;
    151144      end;
    152     ntChangeClient:
    153       PostMessage(Handle, WM_CHANGECLIENT, 0, 0);
    154     ntNextPlayer:
    155       PostMessage(Handle, WM_NEXTPLAYER, 0, 0);
    156     ntDeinitModule .. ntDeinitModule + maxBrain - 1:
     145    ntChangeClient: PostMessage(Handle, WM_CHANGECLIENT, 0, 0);
     146    ntNextPlayer: PostMessage(Handle, WM_NEXTPLAYER, 0, 0);
     147    ntDeinitModule:
    157148      begin
    158149        Info := Format(Phrases2.Lookup('BUSY_DEINIT'),
    159           [Brains[ID - ntDeinitModule].Name]);
     150          [Brains[Index].Name]);
    160151        while BiColorTextWidth(Canvas, Info) + 64 > ClientWidth do
    161152          Delete(Info, Length(Info), 1);
     
    163154        State := -1;
    164155        Show;
     156        {$IFDEF LINUX}
     157        DpiApplication.ProcessMessages;
     158        {$ENDIF}
    165159        Invalidate;
    166160        Update;
    167161      end;
    168     ntBackOn:
    169       begin
    170         background.Show;
    171         background.Update;
    172         sleep(50); // prevent flickering
    173       end;
    174     ntBackOff:
    175       background.Close;
     162    ntBackOn: begin
     163      Background.Show;
     164      Background.Update;
     165      Sleep(50); // prevent flickering
     166    end;
     167    ntBackOff: Background.Close;
    176168  end;
    177169end;
     
    179171procedure TDirectDlg.FormCreate(Sender: TObject);
    180172begin
    181   Gone := false;
     173  Gone := False;
    182174  State := -1;
    183175  Info := '';
     
    208200end;
    209201
    210 procedure TDirectDlg.OnGo(var m: TMessage);
     202procedure TDirectDlg.OnGo(var Msg: TMessage);
    211203var
    212204  i: integer;
    213205  s: string;
     206  FileName: string;
    214207begin
    215208  Hide;
     
    218211    DpiApplication.MessageBox(PChar(Phrases.Lookup('NOAI')), 'C-evo', 0);
    219212    Close;
    220     exit;
     213    Exit;
    221214  end;
    222215  Quick := false;
     
    224217  begin
    225218    s := ParamStr(1);
    226     if (s[1] = '-') or (s[1] = '/') then
     219    if (s[1] = '-') {$IFDEF WINDOWS}or (s[1] = '/'){$ENDIF} then
    227220    begin // special mode
    228221      Delete(s, 1, 1);
     
    234227        Quick := true;
    235228        DirectHelp(cHelpOnly);
    236         Close
     229        Close;
    237230      end;
    238231    end
    239     else if (FileExists(ParamStr(1))) then
    240     begin
    241       Quick := true;
    242       if not LoadGame(ExtractFilePath(ParamStr(1)), ExtractFileName(ParamStr(1)
    243         ), -1, false) then
    244       begin
     232    else if (FileExists(ParamStr(1))) then begin
     233      FileName := ParamStr(1);
     234      if ExtractFileExt(FileName) = CevoExt then begin
     235        Quick := True;
     236        if not LoadGame(ExtractFilePath(ParamStr(1)), ExtractFileName(ParamStr(1)
     237        ), -1, false) then begin
     238          SimpleMessage(Phrases.Lookup('LOADERR'));
     239          Close;
     240        end;
     241      end else
     242      if ExtractFileExt(FileName) = CevoMapExt then begin
     243        Quick := True;
     244        EditMap(FileName, lxmax, lymax, 30);
     245      end else begin
    245246        SimpleMessage(Phrases.Lookup('LOADERR'));
    246247        Close;
     
    249250  end;
    250251  if not Quick then begin
    251     background.Show;
     252    Background.Show;
    252253    StartDlg.Show;
    253254  end;
    254255end;
    255256
    256 procedure TDirectDlg.OnChangeClient(var m: TMessage);
     257procedure TDirectDlg.OnChangeClient(var Msg: TMessage);
    257258begin
    258259  ChangeClient;
    259260end;
    260261
    261 procedure TDirectDlg.OnNextPlayer(var m: TMessage);
     262procedure TDirectDlg.OnNextPlayer(var Msg: TMessage);
    262263begin
    263264  NextPlayer;
     
    294295  Invalidate;
    295296  Update;
     297  {$IFDEF LINUX}
     298  DpiApplication.ProcessMessages;
     299  {$ENDIF}
    296300end;
    297301
    298302procedure TDirectDlg.SetState(x: integer);
    299303begin
    300   if (x < 0) <> (State < 0) then
    301   begin
     304  if (x < 0) <> (State < 0) then begin
    302305    State := x;
    303306    Invalidate;
    304     Update
     307    Update;
    305308  end
    306   else if x <> State then
    307   begin
     309  else if x <> State then begin
    308310    State := x;
    309311    PaintProgressBar(Canvas, 6, ClientWidth div 2 - 64, 40, State, 128 - State,
Note: See TracChangeset for help on using the changeset viewer.