-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlgAutoBuild_Heats.pas
135 lines (119 loc) · 4.28 KB
/
dlgAutoBuild_Heats.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
unit dlgAutoBuild_Heats;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Samples.Spin,
Vcl.ExtCtrls, Vcl.Imaging.jpeg;
type
TAutoBuild_Heats = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Image1: TImage;
Panel2: TPanel;
btnCancel: TButton;
btnOk: TButton;
Panel3: TPanel;
Label7: TLabel;
Label8: TLabel;
lblSeedDepth1: TLabel;
prefHeatAlgorithm: TRadioGroup;
prefUseDefRaceTime: TCheckBox;
prefRaceTimeTopPercent: TSpinEdit;
prefExcludeOutsideLanes: TCheckBox;
prefSeperateGender: TCheckBox;
prefGroupBy: TRadioGroup;
rgpSeedMethod: TRadioGroup;
spnSeedDepth: TSpinEdit;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
procedure ReadPreferences(IniFileName: string);
procedure WritePreferences(IniFileName: string);
public
{ Public declarations }
end;
var
AutoBuild_Heats: TAutoBuild_Heats;
implementation
{$R *.dfm}
uses SCMUtility, IniFiles;
{
With the exception of 'closed' and 'raced' heats, all heats held in the current event
will be deleted prior to running auto-build.
Only members nominated for the current event are considered. Nominees held
in 'closed' or 'raced' heats are excluded from the 'Entrant Pool'.
Entrants are given lane placements based on 'TimeToBeat'. This algorithm is
calculated each time an auto-build is executed.
The fastest heat is always the last heat. Fastest lanes are the two center
lanes. Slowest, the two outer lanes.
}
procedure TAutoBuild_Heats.FormCreate(Sender: TObject);
var
iniFileName: string;
begin
iniFileName := GetSCMPreferenceFileName();
if FileExists(iniFileName) then
ReadPreferences(iniFileName);
end;
procedure TAutoBuild_Heats.FormDestroy(Sender: TObject);
var
iniFileName: string;
begin
iniFileName := GetSCMPreferenceFileName();
if FileExists(iniFileName) then
WritePreferences(iniFileName);
end;
procedure TAutoBuild_Heats.FormShow(Sender: TObject);
begin
btnOk.SetFocus;
end;
procedure TAutoBuild_Heats.ReadPreferences(IniFileName: string);
var
iFile: TIniFile;
begin
iFile := TIniFile.Create(IniFileName);
// TTB defaults to (1) .. the entrant's average of top 3 race-times
prefHeatAlgorithm.ItemIndex :=
(iFile.ReadInteger('Preferences', 'HeatAlgorithm', 1));
// default to - get an average race-time of other swimmers
prefUseDefRaceTime.State := TCheckBoxState(iFile.ReadInteger('Preferences',
'UseDefRaceTime', integer(cbChecked)));
// The bottom percent to select from ... default is 50%
prefRaceTimeTopPercent.Value :=
(iFile.ReadInteger('Preferences', 'RaceTimeTopPercent', 50));
// auto-create heats - this option will omit gutter lanes
prefExcludeOutsideLanes.State :=
TCheckBoxState(iFile.ReadInteger('Preferences', 'ExcludeOutsideLanes',
integer(cbUnchecked)));
prefSeperateGender.State := TCheckBoxState(iFile.ReadInteger('Preferences',
'SeperateGender', integer(cbUnchecked)));
prefGroupBy.ItemIndex := iFile.ReadInteger('Preferences', 'GroupBy', 0);
rgpSeedMethod.ItemIndex := iFile.ReadInteger('Preferences', 'SeedMethod', 0);
// 2020-11-01 auto-build v2 seed depth for Circle Seed */
spnSeedDepth.Value := (iFile.ReadInteger('Preferences', 'SeedDepth', 3));
iFile.Free;
end;
procedure TAutoBuild_Heats.WritePreferences(IniFileName: string);
var
iFile: TIniFile;
begin
iFile := TIniFile.Create(IniFileName);
iFile.WriteInteger('Preferences', 'HeatAlgorithm',
prefHeatAlgorithm.ItemIndex);
iFile.WriteInteger('Preferences', 'UseDefRaceTime',
integer(prefUseDefRaceTime.State));
iFile.WriteInteger('Preferences', 'RaceTimeTopPercent',
prefRaceTimeTopPercent.Value);
iFile.WriteInteger('Preferences', 'ExcludeOutsideLanes',
integer(prefExcludeOutsideLanes.State));
iFile.WriteInteger('Preferences', 'SeperateGender',
integer(prefSeperateGender.State));
iFile.WriteInteger('Preferences', 'GroupBy', prefGroupBy.ItemIndex);
iFile.WriteInteger('Preferences', 'SeedMethod', rgpSeedMethod.ItemIndex);
// 2020-11-01 auto-build v2 seed depth for Circle Seed */
iFile.WriteInteger('Preferences', 'SeedDepth', (spnSeedDepth.Value));
iFile.Free;
end;
end.