This repository was archived by the owner on Aug 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitFirstStart.pas
More file actions
294 lines (276 loc) · 7.46 KB
/
Copy pathUnitFirstStart.pas
File metadata and controls
294 lines (276 loc) · 7.46 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
unit UnitFirstStart;
{$WARNINGS OFF}
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Global, FileCtrl;
const
SetupStepCount = 3;
type
TfrmFirstStart = class(TForm)
lblFirstStartInfo: TLabel;
pnlStep1: TPanel;
bBack: TButton;
bNext: TButton;
bExit: TButton;
Bevel1: TBevel;
tGamePath: TEdit;
lblPathAutodetect: TLabel;
bBrowsePath: TButton;
lblStepInfo: TLabel;
pnlStep2: TPanel;
rbInternalSound: TRadioButton;
rbCustomSound: TRadioButton;
pnlStep3: TPanel;
cbSaveHistory: TCheckBox;
cbSaveChannels: TCheckBox;
cbPlayWhenPoEOpen: TCheckBox;
bSave: TButton;
cbStep: TComboBox;
cbAlertGuildChat: TCheckBox;
cbSaveOnlyAdded: TCheckBox;
tCustomSound: TEdit;
bBrowseCustom: TButton;
ood: TOpenDialog;
od: TFileOpenDialog;
procedure bNextClick(Sender: TObject);
procedure bExitClick(Sender: TObject);
procedure bBrowsePathClick(Sender: TObject);
procedure bBackClick(Sender: TObject);
procedure cbSaveHistoryClick(Sender: TObject);
procedure cbStepChange(Sender: TObject);
procedure bSaveClick(Sender: TObject);
procedure rbInternalSoundClick(Sender: TObject);
procedure bBrowseCustomClick(Sender: TObject);
private
SetupDone: boolean;
IsSetup: boolean;
StepId: integer;
procedure SetupStep(Index: integer);
procedure ModifySetupObject(var Settings: TSetupInfo);
public
function Setup(var Settings: TSetupInfo): boolean;
function Configure(var Settings: TSetupInfo): boolean;
end;
var
frmFirstStart: TfrmFirstStart;
implementation
{$R *.dfm}
procedure TfrmFirstStart.bBackClick(Sender: TObject);
begin
if StepId > 1 then
begin
Dec(StepId);
SetupStep(StepId);
end;
end;
procedure TfrmFirstStart.bBrowseCustomClick(Sender: TObject);
var
ft: TFileTypeItem;
begin
if adIsWinXP() then
begin
if ood.Execute() then
begin
tCustomSound.Text := ood.FileName;
end;
end else begin
ft := od.FileTypes.Add();
ft.FileMask := '*.wav';
ft.DisplayName := 'Wave files (*.wav)';
if od.Execute() then
begin
tCustomSound.Text := od.FileName;
end;
od.FileTypes.Clear();
end;
end;
procedure TfrmFirstStart.bBrowsePathClick(Sender: TObject);
var
sPath: string;
begin
sPath := tGamePath.Text;
if SelectDirectory('Select Path of Exile Install Directory', '', sPath, [sdNewUI, sdValidateDir]) then
begin
tGamePath.Text := sPath;
end;
end;
procedure TfrmFirstStart.bExitClick(Sender: TObject);
begin
SetupDone := false;
Close();
end;
procedure TfrmFirstStart.bNextClick(Sender: TObject);
function step1Validate(): boolean;
var
sPath: string;
begin
Result := false;
sPath := IncludeTrailingPathDelimiter(tGamePath.Text);
if not DirectoryExists(sPath) then
begin
adShowWinMsg(tGamePath.Handle, 'Directory doesn''t exists.', 'Error', TTI_ERROR);
exit;
end;
if not FileExists(sPath + POE_EXE_NAME) then
begin
adShowWinMsg(tGamePath.Handle, 'Directory doesn''t looking like Path of Exile directory.', 'Error', TTI_ERROR);
exit;
end;
Result := true;
end;
function step2Validate(): boolean;
begin
Result := true;
end;
function step3Validate(): boolean;
begin
Result := true;
end;
begin
case StepId of
1: begin
if step1Validate() then
begin
Inc(StepId);
SetupStep(StepId);
exit;
end;
end;
2: begin
if step2Validate() then
begin
Inc(StepId);
SetupStep(StepId);
exit;
end;
end;
3: begin
if step3Validate() then
begin
SetupDone := true;
Close();
end;
end;
end;
end;
procedure TfrmFirstStart.bSaveClick(Sender: TObject);
begin
SetupDone := true;
Close();
end;
procedure TfrmFirstStart.cbSaveHistoryClick(Sender: TObject);
begin
cbSaveChannels.Enabled := cbSaveHistory.Checked;
if cbSaveHistory.Checked then
begin
cbSaveChannels.Checked := cbSaveChannels.HelpContext = 1;
end else begin
cbSaveChannels.HelpContext := 0;
if cbSaveChannels.Checked then cbSaveChannels.HelpContext := 1;
cbSaveChannels.Checked := false;
end;
end;
procedure TfrmFirstStart.cbStepChange(Sender: TObject);
begin
SetupStep(cbStep.ItemIndex + 1);
end;
procedure TfrmFirstStart.ModifySetupObject(var Settings: TSetupInfo);
begin
Settings.Path := tGamePath.Text;
Settings.InternalSound := rbInternalSound.Checked;
Settings.PlayWhenGameOpen := cbPlayWhenPoEOpen.Checked;
Settings.LogPublic := cbSaveChannels.Checked;
Settings.LogHistory := cbSaveHistory.Checked;
Settings.AlertGuildChat := cbAlertGuildChat.Checked;
Settings.NoNewContacts := cbSaveOnlyAdded.Checked;
Settings.CustomSound := tCustomSound.Text; // TODO: Add option for that.
end;
procedure TfrmFirstStart.rbInternalSoundClick(Sender: TObject);
begin
bBrowseCustom.Enabled := rbCustomSound.Checked;
tCustomSound.Enabled := rbCustomSound.Checked;
end;
function TfrmFirstStart.Setup(var Settings: TSetupInfo): boolean;
begin
StepId := 1;
SetupStep(StepId);
SetupDone := false;
bExit.Caption := 'Exit';
IsSetup := true;
Caption := Format(HelpKeyword, ['first run']);
rbInternalSoundClick(nil);
ShowModal();
Result := SetupDone;
ModifySetupObject(Settings);
end;
function TfrmFirstStart.Configure(var Settings: TSetupInfo): boolean;
begin
StepId := 1;
tGamePath.HelpContext := 1;
SetupStep(StepId);
IsSetup := false;
SetupDone := false;
bExit.Caption := 'Close';
bSave.Visible := true;
bBack.Visible := false;
bNext.Visible := false;
cbStep.Items.Clear();
cbStep.Items.Add(pnlStep1.HelpKeyword);
cbStep.Items.Add(pnlStep2.HelpKeyword);
cbStep.Items.Add(pnlStep3.HelpKeyword);
cbStep.Visible := true;
cbStep.ItemIndex := 0;
Caption := Format(HelpKeyword, ['settings']);
lblStepInfo.Visible := false;
// Settings > Form
tGamePath.Text := Settings.Path;
cbSaveOnlyAdded.Checked := Settings.NoNewContacts;
tCustomSound.Text := Settings.CustomSound;
rbInternalSound.Checked := Settings.InternalSound;
cbPlayWhenPoEOpen.Checked := Settings.PlayWhenGameOpen;
cbSaveHistory.Checked := Settings.LogHistory;
cbSaveHistoryClick(nil);
rbInternalSoundClick(nil);
cbSaveChannels.Checked := Settings.LogPublic;
cbAlertGuildChat.Checked := Settings.AlertGuildChat;
ShowModal();
Result := SetupDone;
ModifySetupObject(Settings);
end;
procedure TfrmFirstStart.SetupStep(Index: integer);
var
Title: string;
begin
pnlStep1.Visible := false;
pnlStep2.Visible := false;
pnlStep3.Visible := false;
bBack.Enabled := Index > 1;
bNext.Enabled := Index < 4;
case Index of
1: begin
pnlStep1.Visible := true;
Title := pnlStep1.HelpKeyword;
if tGamePath.HelpContext = 0 then
begin
tGamePath.HelpContext := 1;
tGamePath.Text := poeLocateInstall();
if tGamePath.Text = '' then
begin
lblPathAutodetect.Caption := 'Can''t automatically detect Path of Exile install directory.';
end else begin
lblPathAutodetect.Caption := 'This is automatically detected install directory, verify it please.';
end;
lblPathAutodetect.Visible := true;
end;
end;
2: begin
pnlStep2.Visible := true;
Title := pnlStep2.HelpKeyword;
end;
3: begin
pnlStep3.Visible := true;
Title := pnlStep3.HelpKeyword;
end;
end;
lblFirstStartInfo.Caption := Format(lblFirstStartInfo.HelpKeyword, [Title]);
lblStepInfo.Caption := Format(lblStepInfo.HelpKeyword, [Index, SetupStepCount]);
end;
end.