-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOPTIONS.pas
101 lines (87 loc) · 2.64 KB
/
OPTIONS.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
101
unit OPTIONS;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, TETRIS, IniFiles;
type
tForm2 = class(TForm)
lblHeight: TLabel;
scrlHeight: TScrollBar;
lblDensity: TLabel;
scrlDensity: TScrollBar;
chkNext: TCheckBox;
btnCancel: TButton;
btnOk: TButton;
lblHeightV: TLabel;
lblDensityV: TLabel;
lblLevelV: TLabel;
scrlSpeed: TScrollBar;
lblSpeed: TLabel;
scrlLvlChg: TScrollBar;
lblLvlChg: TLabel;
lblLvlChgV: TLabel;
lblSpeedV: TLabel;
procedure btnCancelClick(Sender: TObject);
procedure btnOkClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure scrlHeightChange(Sender: TObject);
procedure scrlDensityChange(Sender: TObject);
procedure scrlLvlChgChange(Sender: TObject);
procedure scrlSpeedChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: tForm2;
implementation
{$R *.dfm}
procedure tForm2.btnCancelClick(Sender: TObject);
begin
Close;
end;
procedure tForm2.btnOkClick(Sender: TObject);
var
myINI: TINIFile;
begin
Form1.OptHeight := scrlHeight.Position;
Form1.OptDensity := scrlDensity.Position;
Form1.OptLvlChg := scrlLvlChg.Position;
Form1.OptSpeed := scrlSpeed.Position;
Form1.OptNext := chkNext.Checked;
//SAve settings to INI file
myINI := TINIFile.Create(ExtractFilePath(Application.EXEName) + 'SliTris.ini');
myINI.WriteInteger('Settings', 'Starting_Height', Form1.OptHeight);
myINI.WriteInteger('Settings', 'Starting_Density', Form1.OptDensity);
myINI.WriteInteger('Settings', 'Level_Change', Form1.OptLvlChg);
myINI.WriteInteger('Settings', 'Speed', Form1.OptSpeed);
myINI.WriteBool('Settings', 'Show_Next', Form1.OptNext);
myINI.Free;
Close;
end;
procedure tForm2.FormCreate(Sender: TObject);
begin
scrlHeight.Position := Form1.OptHeight;
scrlDensity.Position := Form1.OptDensity;
scrlLvlChg.Position := Form1.OptLvlChg;
scrlSpeed.Position := Form1.OptSpeed;
chkNext.Checked := Form1.OptNext;
end;
procedure tForm2.scrlHeightChange(Sender: TObject);
begin
lblHeightV.Caption := IntToStr(scrlHeight.Position);
end;
procedure tForm2.scrlDensityChange(Sender: TObject);
begin
lblDensityV.Caption := IntToStr(scrlDensity.Position);
end;
procedure tForm2.scrlLvlChgChange(Sender: TObject);
begin
lblLvlChgV.Caption := IntToStr(scrlLvlChg.Position);
end;
procedure tForm2.scrlSpeedChange(Sender: TObject);
begin
lblSpeedV.Caption := IntToStr(scrlSpeed.Position);
end;
end.