Ignore:
Timestamp:
Mar 10, 2019, 4:48:41 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Allow to set nation in player settings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormPlayer.pas

    r279 r282  
    2020    ComboBoxMode: TComboBox;
    2121    ComboBoxAgressivity: TComboBox;
     22    ComboBoxNation: TComboBox;
    2223    EditName: TEdit;
    2324    Label1: TLabel;
     
    2627    Label4: TLabel;
    2728    Label5: TLabel;
     29    Label6: TLabel;
    2830    SpinEditStartUnits: TSpinEdit;
    2931    procedure ComboBoxModeChange(Sender: TObject);
     
    4850
    4951uses
    50   UCore;
     52  UCore, UNation;
    5153
    5254resourcestring
     
    111113
    112114procedure TFormPlayer.LoadData(Player: TPlayer);
     115var
     116  I: Integer;
    113117begin
     118  while ComboBoxNation.Items.Count > TGame(Player.Game).GameSystem.Nations.Count do
     119    ComboBoxNation.Items.Delete(ComboBoxNation.Items.Count - 1);
     120  while ComboBoxNation.Items.Count < TGame(Player.Game).GameSystem.Nations.Count do
     121    ComboBoxNation.Items.Add('');
     122  for I := 0 to TGame(Player.Game).GameSystem.Nations.Count - 1 do begin
     123    ComboBoxNation.Items[I] := TGame(Player.Game).GameSystem.Nations[I].Name;
     124    ComboBoxNation.Items.Objects[I] := TGame(Player.Game).GameSystem.Nations[I];
     125  end;
     126
     127  ComboBoxNation.ItemIndex := ComboBoxNation.Items.IndexOfObject(Player.Nation);
     128  if (ComboBoxNation.ItemIndex = -1) and (ComboBoxNation.Items.Count > 0) then
     129    ComboBoxNation.ItemIndex := 0;
     130
    114131  EditName.Text := Player.Name;
    115132  ComboBoxMode.ItemIndex := Integer(Player.Mode);
     
    123140procedure TFormPlayer.SaveData(Player: TPlayer);
    124141begin
     142  Player.Nation := TNation(ComboBoxNation.Items.Objects[ComboBoxNation.ItemIndex]);
    125143  Player.Name := EditName.Text;
    126144  Player.Mode := TPlayerMode(ComboBoxMode.ItemIndex);
Note: See TracChangeset for help on using the changeset viewer.