1 | unit UFormPlayer;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | ColorBox, UGame;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormPlayer }
|
---|
14 |
|
---|
15 | TFormPlayer = class(TForm)
|
---|
16 | ButtonCancel: TButton;
|
---|
17 | ButtonOk: TButton;
|
---|
18 | CheckBoxDefensive: TCheckBox;
|
---|
19 | ColorBox1: TColorBox;
|
---|
20 | ComboBox1: TComboBox;
|
---|
21 | ComboBoxAgressivity: TComboBox;
|
---|
22 | EditName: TEdit;
|
---|
23 | Label1: TLabel;
|
---|
24 | Label2: TLabel;
|
---|
25 | Label3: TLabel;
|
---|
26 | Label4: TLabel;
|
---|
27 | private
|
---|
28 | { private declarations }
|
---|
29 | public
|
---|
30 | procedure Translate;
|
---|
31 | procedure Load(Player: TPlayer);
|
---|
32 | procedure Save(Player: TPlayer);
|
---|
33 | end;
|
---|
34 |
|
---|
35 | var
|
---|
36 | FormPlayer: TFormPlayer;
|
---|
37 |
|
---|
38 | implementation
|
---|
39 |
|
---|
40 | {$R *.lfm}
|
---|
41 |
|
---|
42 | resourcestring
|
---|
43 | SHuman = 'Human';
|
---|
44 | SComputer = 'Computer';
|
---|
45 | SAgroNotAttacking = 'Not attacking';
|
---|
46 | SAgroLow = 'Low';
|
---|
47 | SAgroMedium = 'Medium';
|
---|
48 | SAgroHigh = 'High';
|
---|
49 |
|
---|
50 | { TFormPlayer }
|
---|
51 |
|
---|
52 | procedure TFormPlayer.Translate;
|
---|
53 | var
|
---|
54 | LastIndex: Integer;
|
---|
55 | begin
|
---|
56 | with ComboBox1 do begin
|
---|
57 | LastIndex := ItemIndex;
|
---|
58 | Clear;
|
---|
59 | Items.Add(SHuman);
|
---|
60 | Items.Add(SComputer);
|
---|
61 | ItemIndex := LastIndex;
|
---|
62 | end;
|
---|
63 | with ComboBoxAgressivity do begin
|
---|
64 | LastIndex := ItemIndex;
|
---|
65 | Clear;
|
---|
66 | Items.Add(SAgroLow);
|
---|
67 | Items.Add(SAgroMedium);
|
---|
68 | Items.Add(SAgroHigh);
|
---|
69 | ItemIndex := LastIndex;
|
---|
70 | end;
|
---|
71 | end;
|
---|
72 |
|
---|
73 | procedure TFormPlayer.Load(Player: TPlayer);
|
---|
74 | begin
|
---|
75 | EditName.Text := Player.Name;
|
---|
76 | ComboBox1.ItemIndex := Integer(Player.Mode);
|
---|
77 | ColorBox1.Selected := Player.Color;
|
---|
78 | Label4.Visible := Player.Mode = pmComputer;
|
---|
79 | ComboBoxAgressivity.Visible := Player.Mode = pmComputer;
|
---|
80 | ComboBoxAgressivity.ItemIndex := Integer(Player.Agressivity);
|
---|
81 | CheckBoxDefensive.Visible := Player.Mode = pmComputer;
|
---|
82 | CheckBoxDefensive.Checked := Player.Defensive;
|
---|
83 | end;
|
---|
84 |
|
---|
85 | procedure TFormPlayer.Save(Player: TPlayer);
|
---|
86 | begin
|
---|
87 | Player.Name := EditName.Text;
|
---|
88 | Player.Mode := TPlayerMode(ComboBox1.ItemIndex);
|
---|
89 | Player.Color := ColorBox1.Selected;
|
---|
90 | Player.Agressivity := TComputerAgressivity(ComboBoxAgressivity.ItemIndex);
|
---|
91 | Player.Defensive := CheckBoxDefensive.Checked;
|
---|
92 | end;
|
---|
93 |
|
---|
94 | end.
|
---|
95 |
|
---|