Ignore:
Timestamp:
Feb 3, 2019, 11:28:03 PM (6 years ago)
Author:
chronos
Message:
  • Added: New forms for game systems management.
  • Added: Allow to load/save game system from/to file system as .xts file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.pas

    r274 r275  
    2525    Button2: TButton;
    2626    Button3: TButton;
     27    ButtonGameSystems: TButton;
    2728    ButtonRandomize: TButton;
    2829    ButtonCancel: TButton;
     
    4142    CheckBoxUnitsMoveImmediately: TCheckBox;
    4243    CheckBoxVoid: TCheckBox;
     44    ComboBoxGameSystem: TComboBox;
    4345    ComboBoxGridType: TComboBox;
    4446    ComboBoxMapShape: TComboBox;
     
    5456    Label14: TLabel;
    5557    Label15: TLabel;
     58    Label16: TLabel;
    5659    Label2: TLabel;
    5760    Label3: TLabel;
     
    117120    procedure AServerModifyExecute(Sender: TObject);
    118121    procedure AServerRemoveExecute(Sender: TObject);
     122    procedure ButtonGameSystemsClick(Sender: TObject);
    119123    procedure ButtonImageBrowseClick(Sender: TObject);
    120124    procedure ButtonRandomizeClick(Sender: TObject);
     
    169173    procedure MapPreviewPaint;
    170174    procedure MapPreviewRedraw;
     175    procedure ReloadGameSystemsMenu;
    171176  public
    172177    procedure Translate;
     
    186191
    187192uses
    188   UFormPlayer, UFormChat, UCore, UFormServer, UClientGUI, UFormClient;
     193  UFormPlayer, UFormChat, UCore, UFormServer, UClientGUI, UFormClient,
     194  UFormGameSystems;
    189195
    190196resourcestring
     
    403409end;
    404410
     411procedure TFormNew.ReloadGameSystemsMenu;
     412var
     413  I: Integer;
     414  LastSystem: Pointer;
     415begin
     416  if ComboBoxGameSystem.ItemIndex <> -1 then
     417    LastSystem := ComboBoxGameSystem.Items.Objects[ComboBoxGameSystem.ItemIndex]
     418    else LastSystem := nil;
     419  ComboBoxGameSystem.Items.BeginUpdate;
     420  try
     421    while ComboBoxGameSystem.Items.Count > Core.GameSystems.Count do
     422      ComboBoxGameSystem.Items.Delete(ComboBoxGameSystem.Items.Count - 1);
     423    while ComboBoxGameSystem.Items.Count < Core.GameSystems.Count do
     424      ComboBoxGameSystem.Items.Add('');
     425    for I := 0 to Core.GameSystems.Count - 1 do begin
     426      ComboBoxGameSystem.Items[I] := Core.GameSystems[I].Name;
     427      ComboBoxGameSystem.Items.Objects[I] := Core.GameSystems[I];
     428    end;
     429    if Assigned(LastSystem) then
     430      ComboBoxGameSystem.ItemIndex := ComboBoxGameSystem.Items.IndexOfObject(LastSystem);
     431    if (ComboBoxGameSystem.ItemIndex = -1) and (ComboBoxGameSystem.Items.Count > 0) then
     432      ComboBoxGameSystem.ItemIndex := 0;
     433  finally
     434    ComboBoxGameSystem.Items.EndUpdate;
     435  end;
     436end;
     437
    405438procedure TFormNew.MapPreviewPaint;
    406439var
     
    525558  Core.PersistentForm.Load(Self);
    526559  Core.ThemeManager1.UseTheme(Self);
     560  ReloadGameSystemsMenu;
    527561  ReloadView;
    528562  //Height := Trunc(1.5 * Height);
     
    678712      ServerList.Items.Delete(I);
    679713    ReloadView;
     714  end;
     715end;
     716
     717procedure TFormNew.ButtonGameSystemsClick(Sender: TObject);
     718begin
     719  FormGameSystems := TFormGameSystems.Create(nil);
     720  try
     721    FormGameSystems.GameSystems := Core.GameSystems;
     722    FormGameSystems.ShowModal;
     723    ReloadGameSystemsMenu;
     724  finally
     725    FreeAndNil(FormGameSystems);
    680726  end;
    681727end;
Note: See TracChangeset for help on using the changeset viewer.