Ignore:
Timestamp:
Jun 21, 2024, 12:44:53 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
  • Modified: Use TFormEx for all forms for code simplification.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormMain.pas

    r316 r317  
    1 unit UFormMain;
     1unit FormMain;
    22
    33interface
     
    55uses
    66  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    7   UGame, LCLType, Menus, ActnList, ComCtrls, dateutils, XMLConf, DOM;
     7  Game, LCLType, Menus, ActnList, ComCtrls, DateUtils, XMLConf, DOM, FormClient,
     8  FormKeyShortcuts, FormPlayersStats, FormUnitMoves, FormCharts, FormEx;
    89
    910const
     
    1516  { TFormMain }
    1617
    17   TFormMain = class(TForm)
     18  TFormMain = class(TFormEx)
    1819    AUnitShapeVisible: TAction;
    1920    AMapGridVisible: TAction;
     
    9394    procedure UpdateClientForms;
    9495  public
     96    FormClient: TFormClient;
     97    FormKeyShortcuts: TFormKeyShortcuts;
     98    FormPlayersStats: TFormPlayersStats;
     99    FormUnitMoves: TFormUnitMoves;
     100    FormCharts: TFormCharts;
    95101    procedure LoadConfig(Config: TXmlConfig; Path: string);
    96102    procedure SaveConfig(Config: TXmlConfig; Path: string);
     
    98104  end;
    99105
    100 var
    101   FormMain: TFormMain;
    102 
    103106
    104107implementation
    105108
    106109uses
    107   UCore, UFormClient;
     110  Core;
    108111
    109112resourcestring
     
    124127begin
    125128  NewCaption := 'xTactics';
    126   if Assigned(Core.Game.CurrentPlayer) then
    127     NewCaption := Core.Game.CurrentPlayer.Name + ' - ' + STurn + ' ' + IntToStr(Core.Game.TurnCounter) + ' - ' + NewCaption;
     129  if Assigned(Core.Core.Game.CurrentPlayer) then
     130    NewCaption := Core.Core.Game.CurrentPlayer.Name + ' - ' + STurn + ' ' +
     131    IntToStr(Core.Core.Game.TurnCounter) + ' - ' + NewCaption;
    128132  Caption := NewCaption;
    129133end;
     
    150154begin
    151155  if AToolBarBigIcons.Checked then begin
    152     ToolBar1.Images := Core.ImageListLarge;
    153     ToolBar1.ButtonWidth := Core.ImageListLarge.Width + 7;
    154     ToolBar1.ButtonHeight := Core.ImageListLarge.Height + 6;
    155     ToolBar1.Width := Core.ImageListLarge.Width + 10;
    156     ToolBar1.Height := Core.ImageListLarge.Height + 10;
     156    ToolBar1.Images := Core.Core.ImageListLarge;
     157    ToolBar1.ButtonWidth := Core.Core.ImageListLarge.Width + 7;
     158    ToolBar1.ButtonHeight := Core.Core.ImageListLarge.Height + 6;
     159    ToolBar1.Width := Core.Core.ImageListLarge.Width + 10;
     160    ToolBar1.Height := Core.Core.ImageListLarge.Height + 10;
    157161  end else begin
    158     ToolBar1.Images := Core.ImageListSmall;
    159     ToolBar1.ButtonWidth := Core.ImageListSmall.Width + 7;
    160     ToolBar1.ButtonHeight := Core.ImageListSmall.Height + 6;
    161     ToolBar1.Width := Core.ImageListSmall.Width + 10;
    162     ToolBar1.Height := Core.ImageListSmall.Height + 10;
     162    ToolBar1.Images := Core.Core.ImageListSmall;
     163    ToolBar1.ButtonWidth := Core.Core.ImageListSmall.Width + 7;
     164    ToolBar1.ButtonHeight := Core.Core.ImageListSmall.Height + 6;
     165    ToolBar1.Width := Core.Core.ImageListSmall.Width + 10;
     166    ToolBar1.Height := Core.Core.ImageListSmall.Height + 10;
    163167  end;
    164168  ToolBar1.Visible := AToolBarVisible.Checked;
     
    227231procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    228232begin
    229   Core.Game.Running := False;
    230   Core.PersistentForm.Save(Self);
    231   SaveConfig(Core.XMLConfig1, 'FormMain');
    232   Core.CellGridVisible := AMapGridVisible.Checked;
    233   Core.UnitShapeVisible := AUnitShapeVisible.Checked;
    234   Core.Done;
     233  Core.Core.Game.Running := False;
     234  SaveConfig(Core.Core.XMLConfig1, 'FormMain');
     235  Core.Core.CellGridVisible := AMapGridVisible.Checked;
     236  Core.Core.UnitShapeVisible := AUnitShapeVisible.Checked;
     237  Core.Core.Done;
    235238end;
    236239
    237240procedure TFormMain.FormDestroy(Sender: TObject);
    238241begin
    239   FormClient.Free;
     242  FreeAndNil(FormClient);
    240243end;
    241244
    242245procedure TFormMain.ApplicationStart(Ptr: IntPtr);
    243246begin
    244   Core.ReopenGameOnInit;
     247  Core.Core.ReopenGameOnInit;
    245248end;
    246249
     
    255258  FormClient.AStatusBarVisible.Checked := AStatusBarVisible.Checked;
    256259  FormClient.AStatusBarVisible.Update;
    257   Core.CellGridVisible := AMapGridVisible.Checked;
    258   Core.UnitShapeVisible := AUnitShapeVisible.Checked;
     260  Core.Core.CellGridVisible := AMapGridVisible.Checked;
     261  Core.Core.UnitShapeVisible := AUnitShapeVisible.Checked;
    259262  if Assigned(FormClient.Client) then begin
    260     FormClient.Client.CellGridVisible := Core.CellGridVisible;
    261     FormClient.Client.UnitShapeVisible := Core.UnitShapeVisible;
     263    FormClient.Client.CellGridVisible := Core.Core.CellGridVisible;
     264    FormClient.Client.UnitShapeVisible := Core.Core.UnitShapeVisible;
    262265  end;
    263266  FormClient.Redraw;
    264   for I := 0 to Core.FormClients.Count - 1 do begin
    265     Core.FormClients[I].AToolBarBigIcons.Checked := AToolBarBigIcons.Checked;
    266     Core.FormClients[I].AToolBarBigIcons.Update;
    267     Core.FormClients[I].AToolBarVisible.Checked := AToolBarVisible.Checked;
    268     Core.FormClients[I].AToolBarVisible.Update;
    269     Core.FormClients[I].AStatusBarVisible.Checked := AStatusBarVisible.Checked;
    270     Core.FormClients[I].AStatusBarVisible.Update;
    271     if Assigned(Core.FormClients[I].Client) then begin
    272       Core.FormClients[I].Client.CellGridVisible := Core.CellGridVisible;
    273       Core.FormClients[I].Client.UnitShapeVisible := Core.UnitShapeVisible;
     267  for I := 0 to Core.Core.FormClients.Count - 1 do begin
     268    Core.Core.FormClients[I].AToolBarBigIcons.Checked := AToolBarBigIcons.Checked;
     269    Core.Core.FormClients[I].AToolBarBigIcons.Update;
     270    Core.Core.FormClients[I].AToolBarVisible.Checked := AToolBarVisible.Checked;
     271    Core.Core.FormClients[I].AToolBarVisible.Update;
     272    Core.Core.FormClients[I].AStatusBarVisible.Checked := AStatusBarVisible.Checked;
     273    Core.Core.FormClients[I].AStatusBarVisible.Update;
     274    if Assigned(Core.Core.FormClients[I].Client) then begin
     275      Core.Core.FormClients[I].Client.CellGridVisible := Core.Core.CellGridVisible;
     276      Core.Core.FormClients[I].Client.UnitShapeVisible := Core.Core.UnitShapeVisible;
    274277    end;
    275     Core.FormClients[I].Redraw;
     278    Core.Core.FormClients[I].Redraw;
    276279  end;
    277280end;
     
    280283begin
    281284  if not FormShown then begin
    282     Core.LoadConfig;
    283     AMapGridVisible.Checked := Core.CellGridVisible;
    284     AUnitShapeVisible.Checked := Core.UnitShapeVisible;
    285     Core.ScaleDPI;
    286     Core.PersistentForm.Load(Self);
    287     FullScreen := Core.PersistentForm.FormFullScreen;
    288     Core.ThemeManager1.UseTheme(Self);
    289     Core.Init;
    290     LoadConfig(Core.XMLConfig1, 'FormMain');
     285    AMapGridVisible.Checked := Core.Core.CellGridVisible;
     286    AUnitShapeVisible.Checked := Core.Core.UnitShapeVisible;
     287    Core.Core.ScaleDPI;
     288    FullScreen := Core.Core.PersistentForm1.FormFullScreen;
     289    Core.Core.Init;
     290    LoadConfig(Core.Core.XMLConfig1, 'FormMain');
    291291    ReloadView;
    292292    FormClient.Show;
Note: See TracChangeset for help on using the changeset viewer.