close Warning: Can't synchronize with repository "(default)" (No changeset 184 in the repository). Look in the Trac log for more information.

Changeset 94 for trunk/UCore.pas


Ignore:
Timestamp:
Dec 21, 2014, 2:47:55 PM (9 years ago)
Author:
chronos
Message:
  • Added: Application now automatically open saved game file given as command line parameter after execution.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r91 r94  
    5656    procedure LoadConfig;
    5757    procedure SaveConfig;
     58    procedure CommandLineParams;
    5859  public
    5960    Game: TGame;
     
    175176end;
    176177
     178procedure TCore.CommandLineParams;
     179var
     180  FileName: string;
     181begin
     182  // Command line parameter handling
     183  if (ParamCount > 0) then begin
     184    FileName := UTF8Encode(ParamStr(1));
     185    if FileExistsUTF8(FileName) then begin
     186      Game.LoadFromFile(FileName);
     187      Player := Game.Players.GetFirstHuman;
     188      LastMapFileName := OpenDialog1.FileName;
     189      with Core.Game.CurrentPlayer do
     190        View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height);
     191      FormMain.AZoomAll.Execute;
     192      FormMain.Redraw;
     193    end;
     194  end;
     195end;
     196
    177197procedure TCore.UpdateActions;
    178198begin
     
    319339      FormMain.PaintBox1.Height);
    320340  Game.LoadConfig(XMLConfig1, 'Game');
    321   Game.New;
    322   Player := Game.Players.GetFirstHuman;
    323   Game.Running := True;
    324   FormMain.AZoomAll.Execute;
     341
     342  CommandLineParams;
     343
     344  if Game.FileName = '' then begin
     345    Game.New;
     346    Player := Game.Players.GetFirstHuman;
     347    Game.Running := True;
     348    FormMain.AZoomAll.Execute;
     349  end;
    325350  {with Core.ScaleDPI1 do begin
    326351    //ApplyToAll(DesignDPI);
Note: See TracChangeset for help on using the changeset viewer.