forked from JBontes/Life32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBenchMark.pas
143 lines (125 loc) · 3.76 KB
/
BenchMark.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
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
unit BenchMark;
(* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. *)
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, Buttons, Menus;
type
TBenchMarkForm = class(TForm)
Button1: TButton;
Button2: TButton;
RichEdit1: TRichEdit;
GroupBox1: TGroupBox;
UpDown1: TUpDown;
Edit1: TEdit;
GroupBox2: TGroupBox;
cbShowDisplay: TCheckBox;
cbCheckEsc: TCheckBox;
cbShowProgress: TCheckBox;
Label1: TLabel;
Label2: TLabel;
RewindButton: TBitBtn;
Edit2: TEdit;
MainMenu1: TMainMenu;
Rewind1: TMenuItem;
Rewinddummy1: TMenuItem;
procedure Edit1Change(Sender: TObject);
procedure Edit1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure RewindButtonClick(Sender: TObject);
procedure Rewinddummy1Click(Sender: TObject);
private
procedure GetDlgSettings;
procedure SaveDlgSettings;
public
BenchmarkMillisecs: integer;
NumGens: integer;
ShowProgress, CheckEsc, ShowDisplay: boolean;
end;
var
BenchMarkForm: TBenchMarkForm;
implementation
{$R *.DFM}
uses
Prefs, LifeUtil, LifeConst, Unit1;
procedure TBenchMarkForm.Edit1Change(Sender: TObject);
begin
with Sender as TEdit do try
StrToInt(Text);
Font.Color:= clWindowText;
if (Length(Text)>0) and CharInSet(Text[1],['-']) then Abort;
except Font.Color:= clRed;
end; {try}
end;
procedure TBenchMarkForm.Edit1Click(Sender: TObject);
begin
try
with Sender as TEdit do SelectAll;
except {ignore}
end; {try}
end;
procedure TBenchMarkForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not CharInSet(Key,ValidNumbers) then key:= #0;
if Key = '-' then Key:= #0;
end;
procedure TBenchMarkForm.Button1Click(Sender: TObject);
begin
try
NumGens:= StrToInt(Edit1.Text);
except NumGens:= 0;
end;
ShowProgress:= cbShowProgress.Checked;
CheckEsc:= cbCheckEsc.Checked;
ShowDisplay:= cbShowDisplay.Checked;
SaveDlgSettings;
end;
procedure TBenchmarkForm.GetDlgSettings;
begin
with OpenReg do try
Left:= ReadInteger('Benchmark.pas','Left',Screen.Width);
Top:= ReadInteger('Benchmark.pas','Top',Screen.Height);
Edit1.Text:= IntToStr(ReadInteger('Benchmark.pas','Offset',1000));
cbShowDisplay.Checked:= ReadBool('Benchmark.pas','ShowDisplay',true);
cbShowProgress.Checked:= ReadBool('Benchmark.pas','ShowProgress',true);
cbCheckESC.Checked:= ReadBool('Benchmark.pas','CheckESC',true);
finally Free;
Left:= Min(Left,Screen.Width - Width);
Top:= Min(Top, Screen.Height - Height);
end; {with}
end;
procedure TBenchmarkForm.SaveDlgSettings;
begin
with OpenReg do try
WriteInteger('Benchmark.pas','Left',Left);
WriteInteger('Benchmark.pas','Top',Top);
try
WriteInteger('Benchmark.pas','Offset',StrToInt(Edit1.Text));
except {do nothing}
end; {try}
WriteBool('Benchmark.pas','ShowDisplay',cbShowDisplay.Checked);
WriteBool('Benchmark.pas','ShowProgress',cbShowProgress.Checked);
writeBool('Benchmark.pas','CheckESC',cbCheckESC.Checked);
finally Free;
end; {with}
end;
procedure TBenchMarkForm.FormActivate(Sender: TObject);
begin
GetDlgSettings;
Edit2.Text:= IntToStr(BenchmarkMillisecs);
RewindButton.Enabled:= Unit1.Form1.Generation <> 0;
end;
procedure TBenchMarkForm.RewindButtonClick(Sender: TObject);
begin
Unit1.Form1.Generation:= 0;
RewindButton.Enabled:= false;
end;
procedure TBenchMarkForm.Rewinddummy1Click(Sender: TObject);
begin
if RewindButton.Enabled then RewindButton.Click;
end;
end.