Changeset 181 for trunk/UCore.pas


Ignore:
Timestamp:
Feb 9, 2018, 9:41:25 AM (7 years ago)
Author:
chronos
Message:
  • Added: New window with players statistics.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r180 r181  
    1616  TCore = class(TDataModule)
    1717    AAbout: TAction;
     18    APlayersStats: TAction;
    1819    ANewSpectatorClient: TAction;
    1920    AShowUnitMoves: TAction;
     
    4950    procedure AHelpExecute(Sender: TObject);
    5051    procedure ANewSpectatorClientExecute(Sender: TObject);
     52    procedure APlayersStatsExecute(Sender: TObject);
    5153    procedure ASettingsExecute(Sender: TObject);
    5254    procedure AShowChartsExecute(Sender: TObject);
     
    7880    procedure LoadGame(FileName: string);
    7981    procedure RedrawClients;
     82    procedure UpdateOtherForms;
    8083  public
    8184    Game: TGame;
     
    103106uses
    104107  UFormMove, UFormMain, UFormNew, UFormSettings, UFormAbout, UFormPlayer,
    105   UFormHelp, UFormCharts, UFormUnitMoves;
     108  UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats;
    106109
    107110const
     
    366369end;
    367370
     371procedure TCore.APlayersStatsExecute(Sender: TObject);
     372begin
     373  if not Assigned(FormPlayersStats) then
     374    FormPlayersStats := TFormPlayersStats.Create(nil);
     375  FormPlayersStats.Show;
     376end;
     377
    368378procedure TCore.ASettingsExecute(Sender: TObject);
    369379begin
     
    383393procedure TCore.AShowChartsExecute(Sender: TObject);
    384394begin
     395  if not Assigned(FormCharts) then FormCharts := TFormCharts.Create(nil);
    385396  FormCharts.Show;
    386397end;
     
    388399procedure TCore.AShowUnitMovesExecute(Sender: TObject);
    389400begin
     401  if not Assigned(FormUnitMoves) then FormUnitMoves := TFormUnitMoves.Create(nil);
    390402  FormUnitMoves.Show;
    391403end;
     
    416428procedure TCore.DataModuleDestroy(Sender: TObject);
    417429begin
     430  if Assigned(FormPlayersStats) then FreeAndNil(FormPlayersStats);
     431  if Assigned(FormUnitMoves) then FreeAndNil(FormUnitMoves);
     432  if Assigned(FormCharts) then FreeAndNil(FormCharts);
    418433  FreeAndNil(FormClients);
    419434  FreeAndNil(StoredDimension);
     
    446461  FormClient.AZoomAll.Execute;
    447462  RedrawClients;
    448   if FormCharts.Visible then FormCharts.Redraw;
    449   if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     463  UpdateOtherForms;
    450464end;
    451465
     
    457471    Form.Redraw;
    458472  FormClient.Redraw;
     473end;
     474
     475procedure TCore.UpdateOtherForms;
     476begin
     477  if Assigned(FormCharts) and FormCharts.Visible then FormCharts.Redraw;
     478  if Assigned(FormUnitMoves) and FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     479  if Assigned(FormPlayersStats) and FormPlayersStats.Visible then FormPlayersStats.ReloadList;
    459480end;
    460481
     
    468489    else ShowMessage(Format(SPlayersNotInitialized, [Game.Players.Count, Game.Players.GetAliveCount]));
    469490  RedrawClients;
    470   if FormCharts.Visible then FormCharts.Redraw;
    471   if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     491  UpdateOtherForms;
    472492  ProcessComputerTurns;
    473493  UpdateActions;
     
    479499    FormClient.Client := Game.CurrentPlayer.Client;
    480500  end;
    481   if FormCharts.Visible then FormCharts.Redraw;
    482   if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     501  UpdateOtherForms;
    483502end;
    484503
    485504procedure TCore.DoMoveUpdated(UnitMove: TUnitMove);
    486505begin
    487   if FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     506  if Assigned(FormUnitMoves) and FormUnitMoves.Visible then
     507    FormUnitMoves.ReloadList;
    488508end;
    489509
Note: See TracChangeset for help on using the changeset viewer.