Changeset 276 for trunk/Forms


Ignore:
Timestamp:
Feb 3, 2019, 11:55:30 PM (6 years ago)
Author:
chronos
Message:
  • Fixed: Load/save game syste name correctly from/to file.
Location:
trunk/Forms
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormGameSystem.lfm

    r275 r276  
    88  ClientWidth = 781
    99  DesignTimePPI = 144
     10  OnClose = FormClose
     11  OnCreate = FormCreate
     12  OnShow = FormShow
    1013  LCLVersion = '1.8.4.0'
    1114  object ButtonSave: TButton
     
    1417    Top = 528
    1518    Width = 113
    16     Anchors = [akTop, akLeft, akBottom]
     19    Anchors = [akLeft, akBottom]
    1720    Caption = 'Save'
    1821    OnClick = ButtonSaveClick
     
    3033  end
    3134  object ButtonCancel: TButton
    32     Left = 472
     35    Left = 504
    3336    Height = 38
    3437    Top = 528
    3538    Width = 113
    36     Anchors = [akLeft]
     39    Anchors = [akRight]
    3740    Caption = 'Cancel'
    3841    ModalResult = 2
     
    4043  end
    4144  object ButtonOk: TButton
    42     Left = 616
     45    Left = 647
    4346    Height = 38
    44     Top = 529
     47    Top = 528
    4548    Width = 113
    46     Anchors = [akLeft, akBottom]
     49    Anchors = [akRight, akBottom]
    4750    Caption = 'OK'
    4851    ModalResult = 1
    4952    TabOrder = 3
     53  end
     54  object PageControl1: TPageControl
     55    Left = 16
     56    Height = 496
     57    Top = 16
     58    Width = 744
     59    ActivePage = TabSheetGeneral
     60    Anchors = [akTop, akLeft, akRight, akBottom]
     61    TabIndex = 0
     62    TabOrder = 4
     63    object TabSheetGeneral: TTabSheet
     64      Caption = 'General'
     65      ClientHeight = 456
     66      ClientWidth = 734
     67      object CheckBoxEmptyCellsNeutral: TCheckBox
     68        Left = 16
     69        Height = 30
     70        Top = 16
     71        Width = 362
     72        Caption = 'Set cells without player units as neutral'
     73        TabOrder = 0
     74      end
     75      object CheckBoxUnitsSplitMerge: TCheckBox
     76        Left = 16
     77        Height = 30
     78        Top = 55
     79        Width = 231
     80        Caption = 'Units can split or merge'
     81        TabOrder = 1
     82      end
     83      object CheckBoxUnitsMoveImmediately: TCheckBox
     84        Left = 16
     85        Height = 30
     86        Top = 95
     87        Width = 234
     88        Caption = 'Units move immediately'
     89        TabOrder = 2
     90      end
     91    end
     92    object TabSheetUnits: TTabSheet
     93      Caption = 'Units'
     94    end
    5095  end
    5196  object OpenDialog1: TOpenDialog
  • trunk/Forms/UFormGameSystem.pas

    r275 r276  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   UGameSystem;
     9  ComCtrls, UGameSystem;
    1010
    1111type
     
    1818    ButtonSave: TButton;
    1919    ButtonLoad: TButton;
     20    CheckBoxEmptyCellsNeutral: TCheckBox;
     21    CheckBoxUnitsMoveImmediately: TCheckBox;
     22    CheckBoxUnitsSplitMerge: TCheckBox;
    2023    OpenDialog1: TOpenDialog;
     24    PageControl1: TPageControl;
    2125    SaveDialog1: TSaveDialog;
     26    TabSheetGeneral: TTabSheet;
     27    TabSheetUnits: TTabSheet;
    2228    procedure ButtonLoadClick(Sender: TObject);
    2329    procedure ButtonSaveClick(Sender: TObject);
     30    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     31    procedure FormCreate(Sender: TObject);
     32    procedure FormShow(Sender: TObject);
    2433  private
    2534    FGameSystem: TGameSystem;
     
    3847implementation
    3948
     49{$R *.lfm}
     50
     51uses
     52  UCore;
     53
    4054resourcestring
    4155  SFileDialogFilter = 'xTactics game system (.xts)|*.xts|All files|*.*';
    42 
    43 
    44 {$R *.lfm}
    4556
    4657{ TFormGameSystem }
     
    6273  SaveDialog1.InitialDir := ExtractFileDir(GameSystem.FileName);
    6374  SaveDialog1.FileName := ExtractFileName(GameSystem.FileName);
     75  SaveDialog1.DefaultExt := GameSystemExt;
    6476  if SaveDialog1.Execute then begin
    6577    GameSystem.SaveToFile(SaveDialog1.FileName);
    6678  end;
     79end;
     80
     81procedure TFormGameSystem.FormClose(Sender: TObject;
     82  var CloseAction: TCloseAction);
     83begin
     84  Core.PersistentForm.Save(Self);
     85end;
     86
     87procedure TFormGameSystem.FormCreate(Sender: TObject);
     88begin
     89  Core.ThemeManager1.UseTheme(Self);
     90  Core.CoolTranslator1.TranslateComponentRecursive(Self);
     91end;
     92
     93procedure TFormGameSystem.FormShow(Sender: TObject);
     94begin
     95  Core.PersistentForm.Load(Self);
    6796end;
    6897
     
    75104procedure TFormGameSystem.LoadData(GameSystem: TGameSystem);
    76105begin
    77 
     106  Self.GameSystem := GameSystem;
     107  CheckBoxEmptyCellsNeutral.Checked := GameSystem.EmptyCellsNeutral;
     108  CheckBoxUnitsSplitMerge.Checked := GameSystem.UnitsSplitMerge;
     109  CheckBoxUnitsMoveImmediately.Checked := GameSystem.UnitsMoveImmediately;
    78110end;
    79111
    80112procedure TFormGameSystem.SaveData(GameSystem: TGameSystem);
    81113begin
    82 
     114  GameSystem.EmptyCellsNeutral := CheckBoxEmptyCellsNeutral.Checked;
     115  GameSystem.UnitsSplitMerge := CheckBoxUnitsSplitMerge.Checked;
     116  GameSystem.UnitsMoveImmediately := CheckBoxUnitsMoveImmediately.Checked;
    83117end;
    84118
  • trunk/Forms/UFormGameSystems.pas

    r275 r276  
    6767  SRemoveItems = 'Remove items';
    6868  SRemoveItemsQuery = 'Do you want to remove selected items?';
    69 
     69  SNewGameSystem = 'New game system';
    7070
    7171{ TFormGameSystems }
     
    9696  with TGameSystem(ListView1.Selected.Data) do begin
    9797    TempEntry := TGameSystem.Create;
     98    TempEntry.Assign(TGameSystem(ListView1.Selected.Data));
    9899    FormGameSystem := TFormGameSystem.Create(Self);
    99100    try
     
    101102      if FormGameSystem.ShowModal = mrOk then begin
    102103        FormGameSystem.SaveData(TempEntry);
     104        TGameSystem(ListView1.Selected.Data).Assign(TempEntry);
    103105        UpdateList;
    104106        UpdateInterface;
     
    118120  FormGameSystem := TFormGameSystem.Create(Self);
    119121  try
     122    TempEntry.FileName := SNewGameSystem + GameSystemExt;
    120123    FormGameSystem.LoadData(TempEntry);
    121124    if FormGameSystem.ShowModal = mrOk then begin
    122125      FormGameSystem.SaveData(TempEntry);
     126      TGameSystem(ListView1.Selected.Data).Assign(TempEntry);
    123127      UpdateList;
    124128      UpdateInterface;
     
    165169  if Item.Index < ListView1.Items.Count then
    166170  with TGameSystem(GameSystems[Item.Index]) do begin
    167     Item.Caption := Name;
     171    Item.Caption := GetName;
    168172    Item.Data := GameSystems[Item.Index];
    169173  end;
  • trunk/Forms/UFormNew.lfm

    r275 r276  
    2121    Top = 60
    2222    Width = 806
    23     ActivePage = TabSheetMode
     23    ActivePage = TabSheetRules
    2424    Align = alClient
    2525    BorderSpacing.Around = 4
    26     TabIndex = 0
     26    TabIndex = 3
    2727    TabOrder = 0
    2828    OnChange = PageControl1Change
     
    546546      object Panel4: TPanel
    547547        Left = 0
    548         Height = 652
     548        Height = 596
    549549        Top = 0
    550550        Width = 796
    551551        Align = alClient
    552552        BevelOuter = bvNone
    553         ClientHeight = 652
     553        ClientHeight = 596
    554554        ClientWidth = 796
    555555        TabOrder = 0
     
    694694          end
    695695        end
    696         object CheckBoxEmptyCellsNeutral: TCheckBox
    697           Left = 336
    698           Height = 30
    699           Top = 62
    700           Width = 362
    701           Caption = 'Set cells without player units as neutral'
    702           TabOrder = 5
    703         end
    704         object CheckBoxUnitsSplitMerge: TCheckBox
    705           Left = 336
    706           Height = 30
    707           Top = 101
    708           Width = 231
    709           Caption = 'Units can split or merge'
    710           TabOrder = 6
    711         end
    712         object CheckBoxUnitsMoveImmediately: TCheckBox
    713           Left = 336
    714           Height = 30
    715           Top = 141
    716           Width = 234
    717           Caption = 'Units move immediately'
    718           TabOrder = 7
    719         end
    720696      end
    721697    end
  • trunk/Forms/UFormNew.pas

    r275 r276  
    3333    ButtonPlayerModify: TButton;
    3434    ButtonPlayerRemove: TButton;
    35     CheckBoxUnitsSplitMerge: TCheckBox;
    36     CheckBoxEmptyCellsNeutral: TCheckBox;
    3735    CheckBoxBridges: TCheckBox;
    3836    CheckBoxCity: TCheckBox;
     
    4038    CheckBoxFogOfWar: TCheckBox;
    4139    CheckBoxSymetricMap: TCheckBox;
    42     CheckBoxUnitsMoveImmediately: TCheckBox;
    4340    CheckBoxVoid: TCheckBox;
    4441    ComboBoxGameSystem: TComboBox;
     
    192189uses
    193190  UFormPlayer, UFormChat, UCore, UFormServer, UClientGUI, UFormClient,
    194   UFormGameSystems;
     191  UFormGameSystems, UGameSystem;
    195192
    196193resourcestring
     
    367364    SpinEditTurns.Value := StayAliveForDefinedTurns;
    368365    SpinEditSpecialCells.Value := SpecialCaptureCellCount;
    369     CheckBoxEmptyCellsNeutral.Checked := GameSystem.EmptyCellsNeutral;
    370     CheckBoxUnitsSplitMerge.Checked := GameSystem.UnitsSplitMerge;
    371     CheckBoxUnitsMoveImmediately.Checked := GameSystem.UnitsMoveImmediately;
     366    ComboBoxGameSystem.ItemIndex := ComboBoxGameSystem.Items.IndexOf(GameSystemName);
    372367  end;
    373368end;
     
    398393    StayAliveForDefinedTurns := SpinEditTurns.Value;
    399394    SpecialCaptureCellCount := SpinEditSpecialCells.Value;
    400     GameSystem.EmptyCellsNeutral := CheckBoxEmptyCellsNeutral.Checked;
    401     GameSystem.UnitsSplitMerge := CheckBoxUnitsSplitMerge.Checked;
    402     GameSystem.UnitsMoveImmediately := CheckBoxUnitsMoveImmediately.Checked;
     395    GameSystem := TGameSystem(ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]);
     396    GameSystemName := GameSystem.GetName;
    403397  end;
    404398end;
     
    424418      ComboBoxGameSystem.Items.Add('');
    425419    for I := 0 to Core.GameSystems.Count - 1 do begin
    426       ComboBoxGameSystem.Items[I] := Core.GameSystems[I].Name;
     420      ComboBoxGameSystem.Items[I] := Core.GameSystems[I].GetName;
    427421      ComboBoxGameSystem.Items.Objects[I] := Core.GameSystems[I];
    428422    end;
     
    558552  Core.PersistentForm.Load(Self);
    559553  Core.ThemeManager1.UseTheme(Self);
    560   ReloadGameSystemsMenu;
    561554  ReloadView;
    562555  //Height := Trunc(1.5 * Height);
     
    773766procedure TFormNew.Load(Server: TServer);
    774767begin
     768  ReloadGameSystemsMenu;
    775769  with Server do begin
    776770    RadioButtonModeLocal.Checked := Mode = smLocal;
Note: See TracChangeset for help on using the changeset viewer.