Ignore:
Timestamp:
Jul 5, 2017, 6:24:55 PM (7 years ago)
Author:
chronos
Message:
  • Added: Player starts units can be configured in player dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormPlayer.pas

    r90 r134  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ColorBox, UGame;
     9  ColorBox, Menus, Spin, UGame;
    1010
    1111type
     
    1818    CheckBoxDefensive: TCheckBox;
    1919    ColorBox1: TColorBox;
    20     ComboBox1: TComboBox;
     20    ComboBoxMode: TComboBox;
    2121    ComboBoxAgressivity: TComboBox;
    2222    EditName: TEdit;
     
    2525    Label3: TLabel;
    2626    Label4: TLabel;
     27    Label5: TLabel;
     28    SpinEditStartUnits: TSpinEdit;
     29    procedure ComboBoxModeChange(Sender: TObject);
     30    procedure FormShow(Sender: TObject);
    2731  private
    2832    { private declarations }
    2933  public
    3034    procedure Translate;
     35    procedure UpdateInterface;
    3136    procedure Load(Player: TPlayer);
    3237    procedure Save(Player: TPlayer);
     
    4348  SHuman = 'Human';
    4449  SComputer = 'Computer';
    45   SAgroNotAttacking = 'Not attacking';
    4650  SAgroLow = 'Low';
    4751  SAgroMedium = 'Medium';
     
    5054{ TFormPlayer }
    5155
     56procedure TFormPlayer.ComboBoxModeChange(Sender: TObject);
     57begin
     58  UpdateInterface;
     59end;
     60
     61procedure TFormPlayer.FormShow(Sender: TObject);
     62begin
     63  UpdateInterface;
     64end;
     65
    5266procedure TFormPlayer.Translate;
    5367var
    5468  LastIndex: Integer;
    5569begin
    56   with ComboBox1 do begin
     70  with ComboBoxMode do begin
    5771    LastIndex := ItemIndex;
    5872    Clear;
     
    7185end;
    7286
     87procedure TFormPlayer.UpdateInterface;
     88begin
     89  ComboBoxAgressivity.Visible := ComboBoxMode.ItemIndex = 1;
     90  CheckBoxDefensive.Visible := ComboBoxMode.ItemIndex = 1;
     91  Label4.Visible := ComboBoxMode.ItemIndex = 1;
     92end;
     93
    7394procedure TFormPlayer.Load(Player: TPlayer);
    7495begin
    7596  EditName.Text := Player.Name;
    76   ComboBox1.ItemIndex := Integer(Player.Mode);
     97  ComboBoxMode.ItemIndex := Integer(Player.Mode);
    7798  ColorBox1.Selected := Player.Color;
    78   Label4.Visible := Player.Mode = pmComputer;
    79   ComboBoxAgressivity.Visible := Player.Mode = pmComputer;
    8099  ComboBoxAgressivity.ItemIndex := Integer(Player.Agressivity);
    81   CheckBoxDefensive.Visible := Player.Mode = pmComputer;
    82100  CheckBoxDefensive.Checked := Player.Defensive;
     101  SpinEditStartUnits.Value := Player.StartUnits;
     102  UpdateInterface;
    83103end;
    84104
     
    86106begin
    87107  Player.Name := EditName.Text;
    88   Player.Mode := TPlayerMode(ComboBox1.ItemIndex);
     108  Player.Mode := TPlayerMode(ComboBoxMode.ItemIndex);
    89109  Player.Color := ColorBox1.Selected;
    90110  Player.Agressivity := TComputerAgressivity(ComboBoxAgressivity.ItemIndex);
    91111  Player.Defensive := CheckBoxDefensive.Checked;
     112  Player.StartUnits := SpinEditStartUnits.Value;
    92113end;
    93114
Note: See TracChangeset for help on using the changeset viewer.