-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsUnit.~pas
90 lines (77 loc) · 2.57 KB
/
SettingsUnit.~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
unit SettingsUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Spin, ExtCtrls, Inifiles;
type
TSettingsForm = class(TForm)
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
RadioGroup2: TRadioGroup;
RadioGroup1: TRadioGroup;
SpinEdit1: TSpinEdit;
Label3: TLabel;
ComboBox1: TComboBox;
Label1: TLabel;
CheckBoxWhiteOnTop: TCheckBox;
CheckBoxLines: TCheckBox;
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
SettingsForm: TSettingsForm;
implementation
{$R *.dfm}
procedure TSettingsForm.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TSettingsForm.FormClose(Sender: TObject;
var Action: TCloseAction);
var
Ini : TIniFile;
begin
Ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'TurboGChess.ini');
try
Ini.WriteBool('General', 'WhiteOnTop', CheckBoxWhiteOnTop.Checked );
Ini.WriteBool('General', 'ShowCoor', CheckBoxCoords.Checked );
Ini.WriteBool('General', 'ShowBoardLines', CheckBoxLines.Checked );
Ini.WriteString('General', 'ThinkDeep', InttoStr(SpinEdit1.Value) );
Ini.WriteString('General', 'Player1', InttoStr(RadioGroup1.ItemIndex) );
Ini.WriteString('General', 'Player2', InttoStr(RadioGroup2.ItemIndex) );
Ini.WriteString('General', 'PieceSet', InttoStr(ComboBox1.ItemIndex) );
finally
Ini.Free;
end;
end;
procedure TSettingsForm.FormShow(Sender: TObject);
var
Ini : TIniFile;
WhiteOnTop, ShowBoardLines : Boolean;
ThinkDeep, Player1, Player2, PieceSet : String;
begin
try
Ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'TurboGChess.ini');
WhiteOnTop := Ini.ReadBool('General','WhiteOnTop', False);
ShowBoardLines := Ini.ReadBool('General','ShowBoardLines', False);
ThinkDeep := Ini.ReadString('General','ThinkDeep', '3');
Player1 := Ini.ReadString('General','Player1', '0');
Player2 := Ini.ReadString('General','Player2', '1');
PieceSet := Ini.ReadString('General','PieceSet', '0');
CheckBoxWhiteOnTop.Checked:=WhiteOnTop;
CheckBoxLines.Checked:=ShowBoardLines;
SpinEdit1.Value:=StrtoInt(ThinkDeep);
RadioGroup1.ItemIndex:=StrtoInt(Player1);
RadioGroup2.ItemIndex:=StrtoInt(Player2);
ComboBox1.ItemIndex:=StrtoInt(PieceSet);
finally
Ini.Free;
end;
end;
end.