summaryrefslogtreecommitdiff
path: root/plugins/Chess4Net/GameOptionsUnit.pas
blob: 0c8fd6cdeb7f48377e50105386a74495b0c2ab74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
////////////////////////////////////////////////////////////////////////////////
// All code below is exclusively owned by author of Chess4Net - Pavel Perminov
// (packpaul@mail.ru, packpaul1@gmail.com).
// Any changes, modifications, borrowing and adaptation are a subject for
// explicit permition from the owner.

unit GameOptionsUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,
  Dialogs, StdCtrls, TntStdCtrls, ExtCtrls, ComCtrls,
  ModalForm;

type
  TGameOptionsForm = class(TModalForm)
    OkButton: TTntButton;
    CancelButton: TTntButton;
    TimeControlGroupBox: TTntGroupBox;
    EqualTimeCheckBox: TTntCheckBox;
    YouGroupBox: TTntGroupBox;
    YouMinLabel: TTntLabel;
    YouIncLabel: TTntLabel;
    YouMinEdit: TEdit;
    YouIncEdit: TEdit;
    YouUnlimitedCheckBox: TTntCheckBox;
    OpponentGroupBox: TTntGroupBox;
    OpponentMinLabel: TTntLabel;
    OpponentIncLabel: TTntLabel;
    OpponentIncEdit: TEdit;
    OpponentMinEdit: TEdit;
    OpponentUnlimitedCheckBox: TTntCheckBox;
    Panel1: TPanel;
    AutoFlagCheckBox: TTntCheckBox;
    TakeBackCheckBox: TTntCheckBox;
    TrainingModeGroupBox: TTntGroupBox;
    TrainingEnabledCheckBox: TTntCheckBox;
    ExtBaseComboBox: TTntComboBox;
    UsrBaseCheckBox: TTntCheckBox;
    ExtBaseLabel: TTntLabel;
    GamePauseCheckBox: TTntCheckBox;
    YouMinUpDown: TUpDown;
    YouIncUpDown: TUpDown;
    OpponentMinUpDown: TUpDown;
    OpponentIncUpDown: TUpDown;
    GameAdjournCheckBox: TTntCheckBox;
    procedure YouEditChange(Sender: TObject);
    procedure OpponentEditChange(Sender: TObject);
    procedure EqualTimeCheckBoxClick(Sender: TObject);
    procedure UnlimitedCheckBoxClick(Sender: TObject);
    procedure TrainingEnabledCheckBoxClick(Sender: TObject);
    procedure ExtBaseComboBoxChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    procedure FLocalize;
  protected
    function GetModalID: TModalFormID; override;
  end;

implementation

{$R *.dfm}

uses
  LocalizerUnit;

procedure TGameOptionsForm.YouEditChange(Sender: TObject);
begin
  YouMinEdit.Text := IntToStr(YouMinUpDown.Position);
  YouIncEdit.Text := IntToStr(YouIncUpDown.Position);
  if EqualTimeCheckBox.Checked then
    begin
      OpponentMinEdit.Text := YouMinEdit.Text;
      OpponentIncEdit.Text := YouIncEdit.Text;
    end;
end;


procedure TGameOptionsForm.OpponentEditChange(Sender: TObject);
begin
  OpponentMinEdit.Text := IntToStr(OpponentMinUpDown.Position);
  OpponentIncEdit.Text := IntToStr(OpponentIncUpDown.Position);
  if EqualTimeCheckBox.Checked then
    begin
      YouMinEdit.Text := OpponentMinEdit.Text;
      YouIncEdit.Text := OpponentIncEdit.Text;
    end;
end;


procedure TGameOptionsForm.EqualTimeCheckBoxClick(Sender: TObject);
begin
  if EqualTimeCheckBox.Checked then
    begin
      OpponentMinEdit.Text := YouMinEdit.Text;
      OpponentIncEdit.Text := YouIncEdit.Text;
      OpponentUnlimitedCheckBox.Checked := YouUnlimitedCheckBox.Checked;
    end;
end;


procedure TGameOptionsForm.UnlimitedCheckBoxClick(Sender: TObject);
begin
  if EqualTimeCheckBox.Checked then
    begin
      YouUnlimitedCheckBox.Checked := TCheckBox(Sender).Checked;
      OpponentUnlimitedCheckBox.Checked := TCheckBox(Sender).Checked;
    end;

  YouMinEdit.Enabled := (not YouUnlimitedCheckBox.Checked);
  YouMinUpDown.Enabled := (not YouUnlimitedCheckBox.Checked);
  YouIncEdit.Enabled := (not YouUnlimitedCheckBox.Checked);
  YouIncUpDown.Enabled := (not YouUnlimitedCheckBox.Checked);

  OpponentMinEdit.Enabled := (not OpponentUnlimitedCheckBox.Checked);
  OpponentMinUpDown.Enabled := (not OpponentUnlimitedCheckBox.Checked);
  OpponentIncEdit.Enabled := (not OpponentUnlimitedCheckBox.Checked);
  OpponentIncUpDown.Enabled := (not OpponentUnlimitedCheckBox.Checked);
end;


procedure TGameOptionsForm.TrainingEnabledCheckBoxClick(Sender: TObject);
begin
  ExtBaseComboBox.Enabled := TrainingEnabledCheckBox.Checked;
  UsrBaseCheckBox.Enabled := TrainingEnabledCheckBox.Checked and (ExtBaseComboBox.ItemIndex <> 0);
  TakeBackCheckBox.Enabled := not TrainingEnabledCheckBox.Checked;
end;


procedure TGameOptionsForm.ExtBaseComboBoxChange(Sender: TObject);
begin
  UsrBaseCheckBox.Enabled := (ExtBaseComboBox.ItemIndex <> 0);
  if ExtBaseComboBox.ItemIndex = 0 then
    UsrBaseCheckBox.Checked := TRUE;
end;


procedure TGameOptionsForm.FormShow(Sender: TObject);
begin
  ExtBaseComboBoxChange(Sender);
end;


function TGameOptionsForm.GetModalID: TModalFormID;
begin
  Result := mfGameOptions;
end;


procedure TGameOptionsForm.FormCreate(Sender: TObject);
begin
  FLocalize;
end;


procedure TGameOptionsForm.FLocalize;
begin
  with TLocalizer.Instance do
  begin
    Caption := GetLabel(24);

    TimeControlGroupBox.Caption := GetLabel(25);
    EqualTimeCheckBox.Caption := GetLabel(26);
    YouGroupBox.Caption := GetLabel(27);
    OpponentGroupBox.Caption := GetLabel(28);
    YouUnlimitedCheckBox.Caption := GetLabel(29);
    OpponentUnlimitedCheckBox.Caption := GetLabel(29);
    YouMinLabel.Caption := GetLabel(30);
    OpponentMinLabel.Caption := GetLabel(30);
    YouIncLabel.Caption := GetLabel(31);
    OpponentIncLabel.Caption := GetLabel(31);

    TrainingModeGroupBox.Caption := GetLabel(32);
    TrainingEnabledCheckBox.Caption := GetLabel(33);
    ExtBaseLabel.Caption := GetLabel(34);
    UsrBaseCheckBox.Caption := GetLabel(35);

    GamePauseCheckBox.Caption := GetLabel(36);
    GameAdjournCheckBox.Caption := GetLabel(37);
    TakeBackCheckBox.Caption := GetLabel(38);
    AutoFlagCheckBox.Caption := GetLabel(39);

    OkButton.Caption := GetLabel(11);
    CancelButton.Caption := GetLabel(12);
  end;
end;


end.