Changeset 180 for trunk/UCore.pas
- Timestamp:
- Feb 8, 2018, 5:32:31 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r179 r180 8 8 Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms, 9 9 UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator, 10 URegistry, ULastOpenedList, Registry, Menus, UGeometry ;10 URegistry, ULastOpenedList, Registry, Menus, UGeometry, Contnrs, UFormClient; 11 11 12 12 type … … 16 16 TCore = class(TDataModule) 17 17 AAbout: TAction; 18 ANewSpectatorClient: TAction; 18 19 AShowUnitMoves: TAction; 19 20 AShowCharts: TAction; … … 47 48 procedure AGameSaveExecute(Sender: TObject); 48 49 procedure AHelpExecute(Sender: TObject); 50 procedure ANewSpectatorClientExecute(Sender: TObject); 49 51 procedure ASettingsExecute(Sender: TObject); 50 52 procedure AShowChartsExecute(Sender: TObject); … … 69 71 procedure GameNewTurnExecute(Sender: TObject); 70 72 procedure AutoSave; 71 function GetPlayer: TPlayer;72 73 procedure LoadConfig; 73 74 procedure SaveConfig; … … 76 77 procedure SelectClient; 77 78 procedure LoadGame(FileName: string); 79 procedure RedrawClients; 78 80 public 79 81 Game: TGame; … … 83 85 AnimationSpeed: Integer; 84 86 AutoSaveEnabled: Boolean; 85 CurrentClient: TClient; 87 FormClients: TObjectList; // TFormClient 88 //CurrentClient: TClient; 89 LocalClients: TObjectList; // TClient 86 90 procedure UpdateActions; 87 91 procedure Init; … … 147 151 procedure TCore.DoOnWin(Player: TPlayer); 148 152 begin 149 FormMain.Redraw;153 RedrawClients; 150 154 ShowMessage(Format(SPlayerWins, [Player.Name])); 151 155 end; … … 174 178 Game.SaveToFile(GetAppConfigDir(False) + 'AutoSave.xtg'); 175 179 Game.FileName := OldFileName; 176 end;177 178 function TCore.GetPlayer: TPlayer;179 begin180 Result := Game.CurrentPlayer;181 180 end; 182 181 … … 246 245 begin 247 246 FirstHuman := Game.Players.GetFirstHuman; 248 if Assigned(FirstHuman) then CurrentClient := FirstHuman.Client249 else CurrentClient := TClient(Server.Clients.First);247 if Assigned(FirstHuman) then FormClient.Client := FirstHuman.Client 248 else FormClient.Client := TClient(Server.Clients.First); 250 249 end; 251 250 … … 276 275 if MessageDlg(SEndGame, SEndGameQuestion, mtConfirmation, mbYesNo, 0) = mrYes then begin 277 276 Game.Running := False; 278 FormMain.Redraw;277 RedrawClients; 279 278 UpdateActions; 280 279 end; … … 286 285 if Game.CurrentPlayer.Mode = pmComputer then begin 287 286 Game.CurrentPlayer.Computer.Process; 288 FormMain.Redraw;287 RedrawClients; 289 288 Delay(Trunc((100 - AnimationSpeed) / 100 * 2000)); 290 289 end; 291 290 Game.NextTurn; 292 FormMain.Redraw;291 RedrawClients; 293 292 Application.ProcessMessages; 294 293 Sleep(1); … … 299 298 begin 300 299 Game.NextTurn; 301 FormMain.Redraw;300 RedrawClients; 302 301 ProcessComputerTurns; 303 302 UpdateActions; … … 354 353 FreeAndNil(FormHelp); 355 354 end; 355 end; 356 357 procedure TCore.ANewSpectatorClientExecute(Sender: TObject); 358 var 359 Form: TFormClient; 360 begin 361 Form := TFormClient.Create(nil); 362 Form.Client := Game.Server.Clients.New(SSpectator); 363 //Form.Client.Form := Form; 364 Form.AZoomAll.Execute; 365 Form.Show; 356 366 end; 357 367 … … 401 411 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml'; 402 412 ForceDirectories(GetAppConfigDir(False)); 413 FormClients := TObjectList.Create; 403 414 end; 404 415 405 416 procedure TCore.DataModuleDestroy(Sender: TObject); 406 417 begin 418 FreeAndNil(FormClients); 407 419 FreeAndNil(StoredDimension); 408 420 Game.SaveConfig(XMLConfig1, 'Game'); … … 429 441 SelectClient; 430 442 LastOpenedList1.AddItem(FileName); 431 with Core.CurrentClient do443 with FormClient.Client do 432 444 View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0), 433 TPoint.Create(Form Main.PaintBox1.Width, FormMain.PaintBox1.Height));434 Form Main.AZoomAll.Execute;435 FormMain.Redraw;445 TPoint.Create(FormClient.PaintBox1.Width, FormClient.PaintBox1.Height)); 446 FormClient.AZoomAll.Execute; 447 RedrawClients; 436 448 if FormCharts.Visible then FormCharts.Redraw; 437 449 if FormUnitMoves.Visible then FormUnitMoves.ReloadList; 450 end; 451 452 procedure TCore.RedrawClients; 453 var 454 Form: TFormClient; 455 begin 456 for Form in FormClients do 457 Form.Redraw; 458 FormClient.Redraw; 438 459 end; 439 460 … … 446 467 if Game.Players.GetAliveCount = Game.Players.Count then Game.Running := True 447 468 else ShowMessage(Format(SPlayersNotInitialized, [Game.Players.Count, Game.Players.GetAliveCount])); 448 FormMain.Redraw;469 RedrawClients; 449 470 if FormCharts.Visible then FormCharts.Redraw; 450 471 if FormUnitMoves.Visible then FormUnitMoves.ReloadList; … … 455 476 procedure TCore.DoPlayerChange(Sender: TObject); 456 477 begin 457 if Assigned(Game.CurrentPlayer) and Assigned(Game.CurrentPlayer.Client) then 458 CurrentClient := Game.CurrentPlayer.Client; 478 if Assigned(Game.CurrentPlayer) and Assigned(Game.CurrentPlayer.Client) then begin 479 FormClient.Client := Game.CurrentPlayer.Client; 480 end; 459 481 if FormCharts.Visible then FormCharts.Redraw; 460 482 if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
Note:
See TracChangeset
for help on using the changeset viewer.