Changeset 349 for branches/highdpi/Direct.pas
- Timestamp:
- Apr 6, 2021, 8:11:02 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Direct.pas
r303 r349 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); 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; 35 36 procedure OnAIException(var Msg: TMessage); message WM_AIEXCEPTION; 36 37 end; … … 42 43 43 44 uses 44 ScreenTools, Protocol, GameServer, Start, LocalPlayer, NoTerm, Back;45 ScreenTools, Protocol, Start, LocalPlayer, NoTerm, Back, Global; 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 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: 70 73 if visible then 71 74 begin 72 s := Format(Phrases.Lookup('BUSY_MOD'), 73 [Brains[ID - ntInitModule].Name]); 75 s := Format(Phrases.Lookup('BUSY_MOD'), [Brains[Index].Name]); 74 76 while BiColorTextWidth(Canvas, s) + 64 > ClientWidth do 75 77 Delete(s, Length(s), 1); … … 82 84 if visible then 83 85 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])); 101 99 ntAIError: 102 100 SimpleMessage(Format(Phrases.Lookup('AIERROR'), [NotifyMessage])); 103 ntClientError .. ntClientError + 128:101 ntClientError: 104 102 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 113 109 (* TODO if OpenClipboard(Handle) then 114 110 begin // copy file path to clipboard … … 134 130 end; 135 131 ntStartDone: 136 if not Quick then 137 begin 132 if not Quick then begin 138 133 StartDlg.Hide; 139 background.Update;134 Background.Update; 140 135 end; 141 136 ntStartGo, ntStartGoRefresh, ntStartGoRefreshMaps: 142 if Quick then 143 Close 144 else 145 begin 137 if Quick then Close 138 else begin 146 139 if ID = ntStartGoRefresh then 147 140 StartDlg.UpdateFormerGames … … 150 143 StartDlg.Show; 151 144 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: 157 148 begin 158 149 Info := Format(Phrases2.Lookup('BUSY_DEINIT'), 159 [Brains[I D - ntDeinitModule].Name]);150 [Brains[Index].Name]); 160 151 while BiColorTextWidth(Canvas, Info) + 64 > ClientWidth do 161 152 Delete(Info, Length(Info), 1); … … 163 154 State := -1; 164 155 Show; 156 {$IFDEF LINUX} 157 DpiApplication.ProcessMessages; 158 {$ENDIF} 165 159 Invalidate; 166 160 Update; 167 161 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; 176 168 end; 177 169 end; … … 179 171 procedure TDirectDlg.FormCreate(Sender: TObject); 180 172 begin 181 Gone := false;173 Gone := False; 182 174 State := -1; 183 175 Info := ''; … … 208 200 end; 209 201 210 procedure TDirectDlg.OnGo(var m: TMessage);202 procedure TDirectDlg.OnGo(var Msg: TMessage); 211 203 var 212 204 i: integer; 213 205 s: string; 206 FileName: string; 214 207 begin 215 208 Hide; … … 218 211 DpiApplication.MessageBox(PChar(Phrases.Lookup('NOAI')), 'C-evo', 0); 219 212 Close; 220 exit;213 Exit; 221 214 end; 222 215 Quick := false; … … 224 217 begin 225 218 s := ParamStr(1); 226 if (s[1] = '-') or (s[1] = '/')then219 if (s[1] = '-') {$IFDEF WINDOWS}or (s[1] = '/'){$ENDIF} then 227 220 begin // special mode 228 221 Delete(s, 1, 1); … … 234 227 Quick := true; 235 228 DirectHelp(cHelpOnly); 236 Close 229 Close; 237 230 end; 238 231 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 245 246 SimpleMessage(Phrases.Lookup('LOADERR')); 246 247 Close; … … 249 250 end; 250 251 if not Quick then begin 251 background.Show;252 Background.Show; 252 253 StartDlg.Show; 253 254 end; 254 255 end; 255 256 256 procedure TDirectDlg.OnChangeClient(var m: TMessage);257 procedure TDirectDlg.OnChangeClient(var Msg: TMessage); 257 258 begin 258 259 ChangeClient; 259 260 end; 260 261 261 procedure TDirectDlg.OnNextPlayer(var m: TMessage);262 procedure TDirectDlg.OnNextPlayer(var Msg: TMessage); 262 263 begin 263 264 NextPlayer; … … 294 295 Invalidate; 295 296 Update; 297 {$IFDEF LINUX} 298 DpiApplication.ProcessMessages; 299 {$ENDIF} 296 300 end; 297 301 298 302 procedure TDirectDlg.SetState(x: integer); 299 303 begin 300 if (x < 0) <> (State < 0) then 301 begin 304 if (x < 0) <> (State < 0) then begin 302 305 State := x; 303 306 Invalidate; 304 Update 307 Update; 305 308 end 306 else if x <> State then 307 begin 309 else if x <> State then begin 308 310 State := x; 309 311 PaintProgressBar(Canvas, 6, ClientWidth div 2 - 64, 40, State, 128 - State,
Note:
See TracChangeset
for help on using the changeset viewer.