Changeset 132


Ignore:
Timestamp:
Jun 19, 2017, 10:06:50 AM (7 years ago)
Author:
chronos
Message:
  • Fixed: Some application states were not stored/restored correctly after application restart.
  • Fixed: Default maximized form state for PersistentForm.
  • Fixed: Do not scale up maximized forms according DPI settings.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r128 r132  
    11object FormMain: TFormMain
    2   Left = 784
     2  Left = 577
    33  Height = 621
    4   Top = 435
     4  Top = 309
    55  Width = 775
    66  Caption = 'xTactics'
    7   ClientHeight = 589
     7  ClientHeight = 596
    88  ClientWidth = 775
    99  Menu = MainMenu1
    10   OnActivate = FormActivate
    1110  OnClose = FormClose
    1211  OnCreate = FormCreate
     
    1413  OnKeyUp = FormKeyUp
    1514  OnShow = FormShow
    16   LCLVersion = '1.6.4.0'
     15  LCLVersion = '1.6.2.0'
    1716  WindowState = wsMaximized
    1817  object StatusBar1: TStatusBar
    1918    Left = 0
    2019    Height = 28
    21     Top = 561
     20    Top = 568
    2221    Width = 775
    2322    Panels = <   
     
    3534  object ToolBar1: TToolBar
    3635    Left = 0
    37     Height = 561
     36    Height = 568
    3837    Top = 0
    3938    Width = 80
     
    118117  object PaintBox1: TPaintBox
    119118    Left = 80
    120     Height = 561
     119    Height = 568
    121120    Top = 0
    122121    Width = 695
  • trunk/Forms/UFormMain.pas

    r128 r132  
    7575    procedure AZoomInExecute(Sender: TObject);
    7676    procedure AZoomOutExecute(Sender: TObject);
    77     procedure FormActivate(Sender: TObject);
    7877    procedure FormShow(Sender: TObject);
    7978    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    242241end;
    243242
    244 procedure TFormMain.FormActivate(Sender: TObject);
    245 begin
    246   if not Core.Initialized then begin
    247     Core.Init;
    248   end;
    249 end;
    250 
    251243procedure TFormMain.AZoomAllExecute(Sender: TObject);
    252244var
     
    313305begin
    314306  Core.Game.Running := False;
     307  Core.PersistentForm.Save(Self);
    315308  SaveConfig(Core.XMLConfig1, 'FormMain');
    316   Core.PersistentForm.Save(Self);
     309  Core.XMLConfig1.Flush;
    317310end;
    318311
     
    334327procedure TFormMain.FormShow(Sender: TObject);
    335328begin
    336   Core.XMLConfig1.Filename := 'Config.xml';
     329  Core.Init;
    337330  LoadConfig(Core.XMLConfig1, 'FormMain');
    338   Core.PersistentForm.Load(Self, True);
     331  Core.PersistentForm.Load(Self, wsMaximized);
    339332  ReloadView;
    340333  Redraw;
  • trunk/Packages/Common/UPersistentForm.pas

    r116 r132  
    2626    FormWindowState: TWindowState;
    2727    Form: TForm;
     28    DefaultFormWindowState: TWindowState;
    2829    procedure LoadFromRegistry(RegistryContext: TRegistryContext);
    2930    procedure SaveToRegistry(RegistryContext: TRegistryContext);
    3031    function CheckEntireVisible(Rect: TRect): TRect;
    3132    function CheckPartVisible(Rect: TRect; Part: Integer): TRect;
    32     procedure Load(Form: TForm; DefaultMaximized: Boolean = False);
     33    procedure Load(Form: TForm; DefaultFormWindowState: TWindowState = wsNormal);
    3334    procedure Save(Form: TForm);
    3435    constructor Create(AOwner: TComponent); override;
     
    5657  I: Integer;
    5758  WinControl: TWinControl;
    58   Count: Integer;
    5959begin
    6060  if Control is TListView then begin
     
    135135      + FormRestoredSize.Top;
    136136    // Other state
    137     FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(wsNormal)));
     137    FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(DefaultFormWindowState)));
    138138  finally
    139139    Free;
     
    216216end;
    217217
    218 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False);
    219 var
    220   LoadDefaults: Boolean;
     218procedure TPersistentForm.Load(Form: TForm; DefaultFormWindowState: TWindowState = wsNormal);
    221219begin
    222220  Self.Form := Form;
     221  Self.DefaultFormWindowState := DefaultFormWindowState;
     222
    223223  // Set default
    224224  FormNormalSize := Bounds((Screen.Width - Form.Width) div 2,
     
    230230
    231231  if not EqualRect(FormNormalSize, FormRestoredSize) or
    232     (LoadDefaults and DefaultMaximized) then begin
     232    (FormWindowState = wsMaximized) then begin
    233233    // Restore to maximized state
    234234    Form.WindowState := wsNormal;
  • trunk/UCore.pas

    r130 r132  
    224224      FormNew.Show;
    225225      FormNew.Hide;
    226       for I := 0 to Screen.FormCount - 1 do begin
     226      for I := 0 to Screen.FormCount - 1 do
     227      if (Screen.Forms[I].WindowState = wsNormal) or
     228        (Screen.Forms[I].WindowState = wsMinimized) then begin
    227229        StoreDimensions(Screen.Forms[I], StoredDimension);
    228230        ScaleDimensions(Screen.Forms[I], StoredDimension);
     
    436438procedure TCore.Init;
    437439begin
    438   {$IFDEF Linux}
    439   // If installed in Linux system then use installation directory for po files
    440   if Application.ExeName = '/usr/bin/xtactics' then
    441     CoolTranslator1.POFilesFolder := '/usr/share/xtactics/languages';
    442   {$ENDIF}
    443   FInitialized := True;
    444 
    445   LoadConfig;
    446   Game.LoadConfig(XMLConfig1, 'Game');
    447 
    448   // Update translated default player names
    449   TPlayer(Game.Players[0]).Name := SPlayer + ' 1';
    450   TPlayer(Game.Players[1]).Name := SPlayer + ' 2';
    451 
    452   CommandLineParams;
    453   ScaleDPI;
    454 
    455   if Game.FileName = '' then StartNewGame;
     440  if not Core.Initialized then begin
     441    {$IFDEF Linux}
     442    // If installed in Linux system then use installation directory for po files
     443    if Application.ExeName = '/usr/bin/xtactics' then
     444      CoolTranslator1.POFilesFolder := '/usr/share/xtactics/languages';
     445    {$ENDIF}
     446    FInitialized := True;
     447
     448    LoadConfig;
     449    Game.LoadConfig(XMLConfig1, 'Game');
     450
     451    // Update translated default player names
     452    TPlayer(Game.Players[0]).Name := SPlayer + ' 1';
     453    TPlayer(Game.Players[1]).Name := SPlayer + ' 2';
     454
     455    CommandLineParams;
     456    ScaleDPI;
     457
     458    if Game.FileName = '' then StartNewGame;
     459  end;
    456460end;
    457461
  • trunk/xtactics.lpi

    r128 r132  
    22<CONFIG>
    33  <ProjectOptions>
    4     <Version Value="10"/>
     4    <Version Value="9"/>
    55    <General>
    66      <SessionStorage Value="InProjectDir"/>
     
    279279        <StackChecks Value="True"/>
    280280      </Checks>
    281       <VerifyObjMethodCallValidity Value="True"/>
    282281    </CodeGeneration>
    283282    <Linking>
Note: See TracChangeset for help on using the changeset viewer.