Changeset 207


Ignore:
Timestamp:
May 22, 2018, 9:43:29 AM (6 years ago)
Author:
chronos
Message:
  • Fixed: Keep correctly main form dimensions in non-maximized state. Scaling DPI was affecting its size and position.
  • Added: Remember last opened tab in New game form.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormClient.pas

    r206 r207  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    99  UGame, LCLType, Menus, ActnList, ComCtrls, dateutils, XMLConf, DOM, UCommPin,
    10   UGeometry, UGameClient, UGameProtocol;
     10  UGeometry, UGameClient, UGameProtocol, UThreading;
    1111
    1212const
     
    231231    FClient.OnTurnStart := DoTurnStart;
    232232    FClient.OnDestroy := DoClientDestroy;
     233    FClient.View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0), TPoint.Create(PaintBox1.Width, PaintBox1.Height));
    233234  end;
    234235  Redraw;
     
    243244begin
    244245  TurnActive := True;
    245   UpdateInterface;
     246  Synchronize(UpdateInterface);
    246247end;
    247248
  • trunk/Forms/UFormMain.pas

    r206 r207  
    149149  FormClient.ManualDock(PanelMain, nil, alClient);
    150150  FormClient.Align := alClient;
    151   FormClient.Show;
    152151end;
    153152
     
    179178procedure TFormMain.FormShow(Sender: TObject);
    180179begin
     180  Core.LoadConfig;
     181  Core.ScaleDPI;
     182  Core.PersistentForm.Load(Self, True);
    181183  Core.Init;
    182184  LoadConfig(Core.XMLConfig1, 'FormMain');
    183   Core.PersistentForm.Load(Self, True);
    184185  ReloadView;
     186  FormClient.Show;
    185187end;
    186188
  • trunk/Forms/UFormNew.pas

    r199 r207  
    342342  ReloadView;
    343343  //Height := Trunc(1.5 * Height);
    344   PageControl1.TabIndex := 0;
     344  //PageControl1.TabIndex := 0;
    345345end;
    346346
  • trunk/Languages/xtactics.cs.po

    r206 r207  
    740740msgid "xTactics games (.xtg)|*.xtg|All files|*.*"
    741741msgstr "xTactics hry (.xtg)|*.xtg|Všechny soubory|*.*"
     742
     743#: ucore.smissingserverclientforplayer
     744msgid "Server client for current player not found."
     745msgstr "Chybí klient serveru pro aktuálního hráče"
    742746
    743747#: ucore.splayersnotinitialized
  • trunk/Languages/xtactics.po

    r206 r207  
    724724#: ucore.sfiledialogfilter
    725725msgid "xTactics games (.xtg)|*.xtg|All files|*.*"
     726msgstr ""
     727
     728#: ucore.smissingserverclientforplayer
     729msgid "Server client for current player not found."
    726730msgstr ""
    727731
  • trunk/Packages/Common/UPersistentForm.pas

    r192 r207  
    1919    FMinVisiblePart: Integer;
    2020    FRegistryContext: TRegistryContext;
     21    FirstLoad: Boolean;
    2122    procedure LoadControl(Control: TControl);
    2223    procedure SaveControl(Control: TControl);
     
    119120    RootKey := RegistryContext.RootKey;
    120121    OpenKey(RegistryContext.Key + '\Forms\' + Form.Name, True);
     122    FirstLoad := not ValueExists('WindowState');
    121123    // Normal size
    122124    FormNormalSize.Left := ReadIntegerWithDefault('NormalLeft', FormNormalSize.Left);
     
    227229
    228230  if not EqualRect(FormNormalSize, FormRestoredSize) or
    229     DefaultMaximized then begin
     231    (DefaultMaximized and FirstLoad) then begin
    230232    // Restore to maximized state
    231233    Form.WindowState := wsNormal;
     
    263265  FMinVisiblePart := 50;
    264266  FRegistryContext.RootKey := HKEY_CURRENT_USER;
     267  FirstLoad := False;
    265268end;
    266269
  • trunk/UCore.lfm

    r206 r207  
    44  OldCreateOrder = False
    55  Height = 676
    6   HorizontalOffset = 275
    7   VerticalOffset = 190
     6  HorizontalOffset = 262
     7  VerticalOffset = 203
    88  Width = 1048
    99  PPI = 120
  • trunk/UCore.pas

    r206 r207  
    6767    RegistryContext: TRegistryContext;
    6868    GameLoaded: Boolean;
     69    FormNewTabIndex: Integer;
    6970    procedure LoadRecentExecute(Sender: TObject);
    7071    procedure StartNewGame;
     
    7576    procedure GameNewTurnExecute(Sender: TObject);
    7677    procedure AutoSave;
    77     procedure LoadConfig;
    78     procedure SaveConfig;
    7978    procedure CommandLineParams;
    80     procedure ScaleDPI;
    8179    procedure SelectClient;
    8280    procedure LoadGame(FileName: string);
     
    9694    LocalClients: TClients;
    9795    ServerList: TServerList;
     96    procedure LoadConfig;
     97    procedure SaveConfig;
    9898    procedure Spectate(Player: TPlayer);
    9999    procedure UpdateActions;
     100    procedure ScaleDPI;
    100101    procedure Init;
    101102    procedure Done;
     
    127128  SPlayersNotInitialized = 'Not all players were initialized with start cell. Needed %d, initialized %d. Change map parameters to have more terrain cells.';
    128129  SFileDialogFilter = 'xTactics games (.xtg)|*.xtg|All files|*.*';
     130  SMissingServerClientForPlayer = 'Server client for current player not found.';
    129131
    130132
     
    190192  ScaleDPI1.DPI := Point(XMLConfig1.GetValue('DPIX', 96), XMLConfig1.GetValue('DPIY', 96));
    191193  ScaleDPI1.AutoDetect := XMLConfig1.GetValue('DPIAuto', True);
     194  FormNewTabIndex := XMLConfig1.GetValue('FormNewTabIndex', 0);
    192195end;
    193196
     
    203206  XMLConfig1.SetValue('DPIY', ScaleDPI1.DPI.Y);
    204207  XMLConfig1.SetValue('DPIAuto', ScaleDPI1.AutoDetect);
     208  XMLConfig1.SetValue('FormNewTabIndex', FormNewTabIndex);
    205209end;
    206210
     
    297301  try
    298302    FormNew.Load(Server);
     303    FormNew.PageControl1.TabIndex := FormNewTabIndex;
    299304    if FormNew.ShowModal = mrOk then begin
    300305      FormNew.Save(Server);
     
    303308      GameLoaded := False;
    304309    end;
     310    FormNewTabIndex := FormNew.PageControl1.TabIndex;
    305311  finally
    306312    FormNew.Free;
     
    488494  ServerClient := Server.Clients.SearchByPlayer(Game.CurrentPlayer);
    489495  if Assigned(ServerClient) then ServerClient.TurnStart
    490     else raise Exception.Create('Server client for current player not found.');
     496    else raise Exception.Create(SMissingServerClientForPlayer);
    491497end;
    492498
     
    573579  if Game.Players.GetAliveCount = Game.Players.Count then Game.Running := True
    574580    else ShowMessage(Format(SPlayersNotInitialized, [Game.Players.Count, Game.Players.GetAliveCount]));
     581  FormClient.AZoomAll.Execute;
    575582  RedrawClients;
    576583  UpdateOtherForms;
     
    578585  ServerClient := Server.Clients.SearchByPlayer(Game.CurrentPlayer);
    579586  if Assigned(ServerClient) then ServerClient.TurnStart
    580     else raise Exception.Create('Server client for current player not found.');
     587    else raise Exception.Create(SMissingServerClientForPlayer);
    581588end;
    582589
     
    616623    GameSettings.Players[1].Name := SPlayer + ' 2';
    617624
    618     LoadConfig;
    619625    GameSettings.LoadConfig(XMLConfig1, 'Game');
    620626    Server.LoadConfig(XMLConfig1, 'Server');
     
    624630    if not GameLoaded and ReopenLastFile and (LastOpenedList1.Items.Count > 0) then
    625631      LoadGame(LastOpenedList1.Items[0]);
    626     ScaleDPI;
    627632    FormClientActions;
    628633
Note: See TracChangeset for help on using the changeset viewer.