-
Notifications
You must be signed in to change notification settings - Fork 5
/
option.pas
100 lines (81 loc) · 2.44 KB
/
option.pas
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
unit option;
interface
uses
Windows, SysUtils, Classes, Controls, Forms, StdCtrls, ExtCtrls, Mask;
type
TFormOptions = class(TForm)
BevelPref: TBevel;
LabelPref: TLabel;
cbPassCard: TCheckBox;
cbIncFirst: TCheckBox;
LabelInitFirst: TLabel;
EditInitFirst: TMaskEdit;
BevelNames: TBevel;
LabelNames: TLabel;
LabelPlayer2: TLabel;
EditPlayer2: TEdit;
LabelPlayer3: TLabel;
EditPlayer3: TEdit;
LabelPlayer4: TLabel;
EditPlayer4: TEdit;
ButtonOK: TButton;
ButtonCancel: TButton;
procedure FormCreate(Sender: TObject);
procedure cbIncFirstClick(Sender: TObject);
procedure ButtonOKClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormOptions: TFormOptions;
implementation
uses
main;
{$R *.dfm}
procedure TFormOptions.FormCreate(Sender: TObject);
begin
cbPassCard.Checked := FormGaple.PassCardRequired;
cbIncFirst.Checked := FormGaple.IncFirstCardPair;
EditInitFirst.Text := IntToStr(FormGaple.FirstCardPair);
EditInitFirst.Enabled := not cbIncFirst.Checked;
EditPlayer2.Text := FormGaple.Players[2].Name;
EditPlayer3.Text := FormGaple.Players[3].Name;
EditPlayer4.Text := FormGaple.Players[4].Name;
end;
procedure TFormOptions.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = char(VK_ESCAPE) then
ModalResult := mrCancel
else
ModalResult := mrNone;
Key := #0;
end;
procedure TFormOptions.cbIncFirstClick(Sender: TObject);
begin
EditInitFirst.Enabled := not cbIncFirst.Checked;
end;
procedure TFormOptions.ButtonOKClick(Sender: TObject);
begin
with FormGaple do
if (EditPlayer2.Text <> EditPlayer3.Text) and
(EditPlayer2.Text <> EditPlayer4.Text) and
(EditPlayer3.Text <> EditPlayer4.Text) then
begin
ConfigFile.WriteBool('OPTIONS','PASSCARD',cbPassCard.Checked);
ConfigFile.WriteBool('OPTIONS','INCFIRSTCARD',cbIncFirst.Checked);
ConfigFile.WriteInteger('OPTIONS','FIRSTCARDPAIR',StrToInt(EditInitFirst.Text));
ConfigFile.WriteString('PLAYERS','2',EditPlayer2.Text);
ConfigFile.WriteString('PLAYERS','3',EditPlayer3.Text);
ConfigFile.WriteString('PLAYERS','4',EditPlayer4.Text);
end
else
begin
PlayerNameError;
EditPlayer2.SetFocus;
self.ModalResult := mrNone;
end;
end;
end.