Changeset 336 for trunk/Direct.pas
- Timestamp:
- Mar 31, 2021, 10:49:44 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Direct.pas
r190 r336 8 8 9 9 LCLIntf, LCLType, {$IFDEF Linux}LMessages, {$ENDIF}Messages, SysUtils, Classes, 10 Graphics, Controls, Forms, DrawDlg ;10 Graphics, Controls, Forms, DrawDlg, GameServer; 11 11 12 12 const … … 23 23 procedure FormClose(Sender: TObject; var Action: TCloseAction); 24 24 public 25 procedure DlgNotify(ID: integer);25 procedure DlgNotify(ID: TNotify; Index: Integer = 0); 26 26 private 27 27 Info: string; 28 State: integer; 29 Gone, Quick: boolean; 28 State: Integer; 29 Gone: Boolean; 30 Quick: Boolean; 30 31 procedure SetInfo(x: string); 31 32 procedure SetState(x: integer); … … 42 43 43 44 uses 44 ScreenTools, Protocol, GameServer,Start, LocalPlayer, NoTerm, Back;45 ScreenTools, Protocol, Start, LocalPlayer, NoTerm, Back; 45 46 46 47 {$R *.lfm} 47 48 48 procedure Notify(ID: integer);49 begin 50 DirectDlg.DlgNotify(ID );51 end; 52 53 procedure TDirectDlg.DlgNotify(ID: integer);49 procedure Notify(ID: TNotify; Index: Integer = 0); 50 begin 51 DirectDlg.DlgNotify(ID, Index); 52 end; 53 54 procedure TDirectDlg.DlgNotify(ID: TNotify; Index: Integer = 0); 54 55 var 55 56 // hMem: Cardinal; … … 58 59 begin 59 60 case ID of 60 ntInitLocalHuman: 61 begin62 SetMainTextureByAge(-1);63 State := -1;64 Info := Phrases.Lookup('BUSY_MODLH');65 Show;66 67 68 69 ntInitModule .. ntInitModule + maxBrain - 1:61 ntInitLocalHuman: begin 62 SetMainTextureByAge(-1); 63 State := -1; 64 Info := Phrases.Lookup('BUSY_MODLH'); 65 Show; 66 Application.ProcessMessages; // Repaint after show for Linux 67 Invalidate; 68 Update; 69 end; 70 ntInitModule: 70 71 if visible then 71 72 begin 72 s := Format(Phrases.Lookup('BUSY_MOD'), 73 [Brains[ID - ntInitModule].Name]); 73 s := Format(Phrases.Lookup('BUSY_MOD'), [Brains[Index].Name]); 74 74 while BiColorTextWidth(Canvas, s) + 64 > ClientWidth do 75 75 Delete(s, Length(s), 1); … … 82 82 if visible then 83 83 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])); 84 ntDeactivationMissing: 85 SimpleMessage(Format(Phrases.Lookup('MISSDEACT'), [Index])); 86 ntSetAIName: 87 LocalPlayer.SetAIName(Index, NotifyMessage); 88 ntException: 89 PostMessage(Handle, WM_AIEXCEPTION, Index, 0); 90 ntLoadBegin: begin 91 Info := Phrases.Lookup('BUSY_LOAD'); 92 SetState(0); 93 end; 94 ntLoadState: SetState(Index); 95 ntDLLError: 96 SimpleMessage(Format(Phrases.Lookup('DLLERROR'), [Brains[Index].FileName])); 101 97 ntAIError: 102 98 SimpleMessage(Format(Phrases.Lookup('AIERROR'), [NotifyMessage])); 103 ntClientError .. ntClientError + 128:99 ntClientError: 104 100 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 101 [Brains[Index].FileName])); 102 ntEndInfo: begin 103 Hide; 104 Background.Update; 105 end; 106 ntLoadError: begin 113 107 (* TODO if OpenClipboard(Handle) then 114 108 begin // copy file path to clipboard … … 134 128 end; 135 129 ntStartDone: 136 if not Quick then 137 begin 130 if not Quick then begin 138 131 StartDlg.Hide; 139 background.Update;132 Background.Update; 140 133 end; 141 134 ntStartGo, ntStartGoRefresh, ntStartGoRefreshMaps: 142 if Quick then 143 Close 144 else 145 begin 135 if Quick then Close 136 else begin 146 137 if ID = ntStartGoRefresh then 147 138 StartDlg.UpdateFormerGames … … 150 141 StartDlg.Show; 151 142 end; 152 ntChangeClient: 153 PostMessage(Handle, WM_CHANGECLIENT, 0, 0); 154 ntNextPlayer: 155 PostMessage(Handle, WM_NEXTPLAYER, 0, 0); 156 ntDeinitModule .. ntDeinitModule + maxBrain - 1: 143 ntChangeClient: PostMessage(Handle, WM_CHANGECLIENT, 0, 0); 144 ntNextPlayer: PostMessage(Handle, WM_NEXTPLAYER, 0, 0); 145 ntDeinitModule: 157 146 begin 158 147 Info := Format(Phrases2.Lookup('BUSY_DEINIT'), 159 [Brains[I D - ntDeinitModule].Name]);148 [Brains[Index].Name]); 160 149 while BiColorTextWidth(Canvas, Info) + 64 > ClientWidth do 161 150 Delete(Info, Length(Info), 1); … … 165 154 Invalidate; 166 155 Update; 167 end; 168 ntBackOn: 169 begin 170 background.Show; 171 background.Update; 172 sleep(50); // prevent flickering 173 end; 174 ntBackOff: 175 background.Close; 156 Application.ProcessMessages; 157 end; 158 ntBackOn: begin 159 Background.Show; 160 Background.Update; 161 Sleep(50); // prevent flickering 162 end; 163 ntBackOff: Background.Close; 176 164 end; 177 165 end; … … 179 167 procedure TDirectDlg.FormCreate(Sender: TObject); 180 168 begin 181 Gone := false;169 Gone := False; 182 170 State := -1; 183 171 Info := ''; … … 218 206 Application.MessageBox(PChar(Phrases.Lookup('NOAI')), 'C-evo', 0); 219 207 Close; 220 exit;208 Exit; 221 209 end; 222 210 Quick := false; … … 234 222 Quick := true; 235 223 DirectHelp(cHelpOnly); 236 Close 224 Close; 237 225 end; 238 226 end … … 249 237 end; 250 238 if not Quick then begin 251 background.Show;239 Background.Show; 252 240 StartDlg.Show; 253 241 end; … … 294 282 Invalidate; 295 283 Update; 284 Application.ProcessMessages; 296 285 end; 297 286 298 287 procedure TDirectDlg.SetState(x: integer); 299 288 begin 300 if (x < 0) <> (State < 0) then 301 begin 289 if (x < 0) <> (State < 0) then begin 302 290 State := x; 303 291 Invalidate; 304 Update 292 Update; 305 293 end 306 else if x <> State then 307 begin 294 else if x <> State then begin 308 295 State := x; 309 296 PaintProgressBar(Canvas, 6, ClientWidth div 2 - 64, 40, State, 128 - State,
Note:
See TracChangeset
for help on using the changeset viewer.