Changeset 227


Ignore:
Timestamp:
Sep 9, 2018, 11:45:45 AM (6 years ago)
Author:
chronos
Message:
  • Fixed: Load and start new game after main form is shown so cells can be correctly zoomed to be visible all.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormClient.pas

    r223 r227  
    302302  ToolBar1.Visible := AToolBarVisible.Checked;
    303303  StatusBar1.Visible := AStatusBarVisible.Checked;
    304   AGameEndTurn.Enabled := Assigned(Client.ControlPlayer) and
     304  AGameEndTurn.Enabled := Assigned(Client) and Assigned(Client.ControlPlayer) and
    305305    Client.ControlPlayer.IsAlive and TurnActive;
    306   ASurrender.Enabled := Assigned(Client.ControlPlayer) and
     306  ASurrender.Enabled := Assigned(Client) and Assigned(Client.ControlPlayer) and
    307307    Client.ControlPlayer.IsAlive;
    308308end;
  • trunk/Forms/UFormMain.lfm

    r222 r227  
    99  DesignTimePPI = 144
    1010  Menu = MainMenu1
     11  OnActivate = FormActivate
    1112  OnClose = FormClose
    1213  OnCreate = FormCreate
  • trunk/Forms/UFormMain.pas

    r221 r227  
    6969    procedure AToolBarBigIconsExecute(Sender: TObject);
    7070    procedure AToolBarVisibleExecute(Sender: TObject);
     71    procedure FormActivate(Sender: TObject);
    7172    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    7273    procedure FormShow(Sender: TObject);
     
    7778    procedure Timer1Timer(Sender: TObject);
    7879  private
     80    FormActivated: Boolean;
     81    procedure ApplicationStart(Ptr: IntPtr);
    7982  public
    8083    procedure LoadConfig(Config: TXmlConfig; Path: string);
     
    173176end;
    174177
     178procedure TFormMain.FormActivate(Sender: TObject);
     179begin
     180  if not FormActivated then begin
     181    FormActivated := True;
     182  end;
     183end;
     184
    175185procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
    176186  );
     
    191201begin
    192202  FormClient.Free;
     203end;
     204
     205procedure TFormMain.ApplicationStart(Ptr: IntPtr);
     206begin
     207  Core.ReopenGameOnInit;
    193208end;
    194209
     
    202217  ReloadView;
    203218  FormClient.Show;
     219  Application.QueueAsyncCall(ApplicationStart, 0);
    204220end;
    205221
  • trunk/UCore.pas

    r226 r227  
    9494    LocalClients: TClients;
    9595    ServerList: TServerList;
     96    procedure ReopenGameOnInit;
    9697    procedure LoadConfig;
    9798    procedure SaveConfig;
     
    490491  SelectClient;
    491492  LastOpenedList1.AddItem(FileName);
    492   FormClient.AZoomAll.Execute;
    493493  UpdateOtherForms;
    494494  UpdateInterface;
     
    496496  if Assigned(ServerClient) then ServerClient.TurnStart
    497497    else raise Exception.Create(SMissingServerClientForPlayer);
     498  FormClient.AZoomAll.Execute;
    498499end;
    499500
     
    515516    Action.Assign(TAction(FormClient.ActionList1.Actions[I]));
    516517    Action.ActionList := FormMain.ActionList1;
     518  end;
     519end;
     520
     521procedure TCore.ReopenGameOnInit;
     522begin
     523  CommandLineParams;
     524  if not GameLoaded and ReopenLastFile and (LastOpenedList1.Items.Count > 0) and
     525    FileExists(LastOpenedList1.Items[0]) then
     526    LoadGame(LastOpenedList1.Items[0]);
     527
     528  if Game.FileName = '' then begin
     529    Game.Assign(GameSettings);
     530    StartNewGame;
    517531  end;
    518532end;
     
    626640    ServerList.LoadConfig(XmlConfig1, 'ServerList');
    627641
    628     CommandLineParams;
    629     if not GameLoaded and ReopenLastFile and (LastOpenedList1.Items.Count > 0) and
    630       FileExists(LastOpenedList1.Items[0]) then
    631       LoadGame(LastOpenedList1.Items[0]);
    632642    FormClientActions;
    633 
    634     if Game.FileName = '' then begin
    635       Game.Assign(GameSettings);
    636       StartNewGame;
    637     end;
    638643  end;
    639644end;
Note: See TracChangeset for help on using the changeset viewer.