Changeset 336
- Timestamp:
- Mar 31, 2021, 10:49:44 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 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, -
trunk/GameServer.pas
r328 r336 15 15 FirstBookCompatibleVersion = $010103; 16 16 17 // notifications18 ntCreateWorld = 0;19 ntInitModule = $100;20 ntInitLocalHuman = $1FF;21 ntDLLError = $200;22 ntAIError = $2FF;23 ntClientError = $300;24 ntInitPlayers = $400;25 ntDeactivationMissing = $410;26 ntSetAIName = $420;27 ntException = $500;28 ntLoadBegin = $600;29 ntLoadState = $601;30 ntEndInfo = $6FC;31 ntBackOn = $6FD;32 ntBackOff = $6FE;33 ntLoadError = $6FF;34 ntStartDone = $700;35 ntStartGo = $701;36 ntStartGoRefresh = $702;37 ntStartGoRefreshMaps = $703;38 ntChangeClient = $800;39 ntNextPlayer = $810;40 ntDeinitModule = $900;41 42 17 // module flags 43 18 fMultiple = $10000000; … … 48 23 49 24 type 50 TNotifyFunction = procedure(ID: integer); 25 // notifications 26 TNotify = ( 27 ntCreateWorld = 0, 28 ntInitModule = $100, 29 ntInitLocalHuman = $1FF, 30 ntDLLError = $200, 31 ntAIError = $2FF, 32 ntClientError = $300, 33 ntInitPlayers = $400, 34 ntDeactivationMissing = $410, 35 ntSetAIName = $420, 36 ntException = $500, 37 ntLoadBegin = $600, 38 ntLoadState = $601, 39 ntEndInfo = $6FC, 40 ntBackOn = $6FD, 41 ntBackOff = $6FE, 42 ntLoadError = $6FF, 43 ntStartDone = $700, 44 ntStartGo = $701, 45 ntStartGoRefresh = $702, 46 ntStartGoRefreshMaps = $703, 47 ntChangeClient = $800, 48 ntNextPlayer = $810, 49 ntDeinitModule = $900 50 ); 51 52 TNotifyFunction = procedure(ID: TNotify; Index: Integer = 0); 51 53 52 54 TBrainType = (btNoTerm, btSuperVirtual, btTerm, btRandom, btAI); … … 365 367 (CCPlayer < 0) then 366 368 begin 367 Notify(ntDeactivationMissing +p);369 Notify(ntDeactivationMissing, p); 368 370 ForceClientDeactivation; 369 371 end … … 513 515 if Kind = btAI then 514 516 begin { get client function } 515 Notify(ntInitModule +Brains.IndexOf(bix));517 Notify(ntInitModule, Brains.IndexOf(bix)); 516 518 if Flags and fDotNet > 0 then 517 519 Client := DotNetClient … … 522 524 begin 523 525 Client := nil; 524 Notify(ntDLLError +Brains.IndexOf(bix));526 Notify(ntDLLError, Brains.IndexOf(bix)); 525 527 end 526 528 else … … 528 530 Client := GetProcAddress(hm, 'client'); 529 531 if @Client = nil then 530 Notify(ntClientError +Brains.IndexOf(bix));531 end 532 end 532 Notify(ntClientError, Brains.IndexOf(bix)); 533 end; 534 end; 533 535 end; 534 536 if @Client <> nil then … … 545 547 DataSize := 0; 546 548 Flags := Flags or InitModuleData.Flags; 547 end 548 end 549 end; 550 end; 549 551 end; 550 552 … … 730 732 if bix[0].Kind <> btNoTerm then 731 733 Notify(ntInitLocalHuman); 734 732 735 BrainUsed := []; 733 736 for p := 0 to nPl - 1 do … … 955 958 else 956 959 NotifyMessage := ''; 957 Notify(ntSetAIName +p1);958 end 960 Notify(ntSetAIName, p1); 961 end; 959 962 end; 960 963 … … 1278 1281 end; 1279 1282 if not MovieMode then 1280 Notify(ntLoadState +CL.Progress * 128 div 1000);1283 Notify(ntLoadState, CL.Progress * 128 div 1000); 1281 1284 end; 1282 1285 … … 3250 3253 begin 3251 3254 if Brains[i].Kind = btAI then 3252 Notify(ntDeinitModule +i);3255 Notify(ntDeinitModule, i); 3253 3256 CallClient(i, cBreakGame, nil^); 3254 3257 end; -
trunk/LocalPlayer/NatStat.pas
r327 r336 114 114 (hMainTexture - ClientHeight) div 2); 115 115 ImageOp_B(Back, Template, 0, 0, 0, 0, ClientWidth, ClientHeight); 116 end 116 end; 117 117 end; 118 118 -
trunk/Packages/CevoComponents/DrawDlg.pas
r313 r336 86 86 procedure TDrawDlg.OnEraseBkgnd(var m: TMessage); 87 87 begin 88 // Full area should be covered by Paint method 88 89 end; 89 90
Note:
See TracChangeset
for help on using the changeset viewer.