|
bmasterc@126
|
1 |
unit UnitfrmMain; |
|
bmasterc@126
|
2 |
|
|
bmasterc@126
|
3 |
interface |
|
bmasterc@126
|
4 |
|
|
bmasterc@126
|
5 |
uses |
|
bmasterc@126
|
6 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
|
bmasterc@126
|
7 |
Dialogs, TFlatRadioButtonUnit, StdCtrls, ComCtrls, mxFlatControls, JvPageList, |
|
bmasterc@126
|
8 |
ExtCtrls, JvExControls, JvComponent, TFlatButtonUnit, jpeg, TFlatEditUnit, |
|
bmasterc@126
|
9 |
TFlatGaugeUnit, ImgList, FileCtrl, Registry, CheckLst, TFlatComboBoxUnit, |
|
bmasterc@126
|
10 |
TFlatCheckBoxUnit, IdBaseComponent, IdComponent, IdTCPConnection, |
|
bmasterc@126
|
11 |
IdTCPClient, IdFTP, IdException, IdAntiFreezeBase, IdAntiFreeze, |
|
bmasterc@273
|
12 |
IdIntercept, IdLogBase, IdLogFile, pngimage; |
|
bmasterc@126
|
13 |
|
|
bmasterc@126
|
14 |
type |
|
bmasterc@126
|
15 |
TfrmMain = class(TForm) |
|
bmasterc@126
|
16 |
jplWizard: TJvPageList; |
|
bmasterc@126
|
17 |
jspWelcome: TJvStandardPage; |
|
bmasterc@126
|
18 |
pnlButtons: TPanel; |
|
bmasterc@126
|
19 |
bvlSpace: TBevel; |
|
bmasterc@126
|
20 |
cmdNext: TFlatButton; |
|
bmasterc@126
|
21 |
cmdCancel: TFlatButton; |
|
bmasterc@126
|
22 |
imgInstall: TImage; |
|
bmasterc@126
|
23 |
lblWelcome: TLabel; |
|
bmasterc@126
|
24 |
lblInfo1: TLabel; |
|
bmasterc@126
|
25 |
lblInfo2: TLabel; |
|
bmasterc@126
|
26 |
lblInfo3: TLabel; |
|
bmasterc@126
|
27 |
jspLicense: TJvStandardPage; |
|
bmasterc@126
|
28 |
pnlLicense: TPanel; |
|
bmasterc@126
|
29 |
imgIcon1: TImage; |
|
bmasterc@126
|
30 |
lblTitle1: TLabel; |
|
bmasterc@126
|
31 |
lblSubTitle1: TLabel; |
|
bmasterc@126
|
32 |
freLicense: TmxFlatRichEdit; |
|
bmasterc@126
|
33 |
frbAgree: TFlatRadioButton; |
|
bmasterc@126
|
34 |
ftbDontAgree: TFlatRadioButton; |
|
bmasterc@126
|
35 |
jspInstallMethod: TJvStandardPage; |
|
bmasterc@126
|
36 |
pnlHeader2: TPanel; |
|
bmasterc@126
|
37 |
imgIcon2: TImage; |
|
bmasterc@126
|
38 |
lblTitle2: TLabel; |
|
bmasterc@126
|
39 |
lblSubTitle2: TLabel; |
|
bmasterc@126
|
40 |
lblInstallMethod: TLabel; |
|
bmasterc@126
|
41 |
pnlInstallMethod: TPanel; |
|
bmasterc@126
|
42 |
frbDedicatedServer: TFlatRadioButton; |
|
bmasterc@126
|
43 |
frbListenServer: TFlatRadioButton; |
|
bmasterc@126
|
44 |
frbSelectMod: TFlatRadioButton; |
|
bmasterc@126
|
45 |
frbFTP: TFlatRadioButton; |
|
bmasterc@126
|
46 |
cmdBack: TFlatButton; |
|
bmasterc@126
|
47 |
jspFTP: TJvStandardPage; |
|
bmasterc@126
|
48 |
pnlHeader3: TPanel; |
|
bmasterc@126
|
49 |
imgIcon3: TImage; |
|
bmasterc@126
|
50 |
lblTitle3: TLabel; |
|
bmasterc@126
|
51 |
lblSubTitle3: TLabel; |
|
bmasterc@126
|
52 |
lblStep1: TLabel; |
|
bmasterc@126
|
53 |
pnlFTPData: TPanel; |
|
bmasterc@126
|
54 |
lblHost: TLabel; |
|
bmasterc@126
|
55 |
txtHost: TFlatEdit; |
|
bmasterc@126
|
56 |
lblUserName: TLabel; |
|
bmasterc@126
|
57 |
txtUserName: TFlatEdit; |
|
bmasterc@126
|
58 |
txtPassword: TFlatEdit; |
|
bmasterc@126
|
59 |
lblPassword: TLabel; |
|
bmasterc@126
|
60 |
txtPort: TFlatEdit; |
|
bmasterc@126
|
61 |
lblPort: TLabel; |
|
bmasterc@126
|
62 |
lblStep2: TLabel; |
|
bmasterc@126
|
63 |
cmdConnect: TFlatButton; |
|
bmasterc@126
|
64 |
pnlDirectory: TPanel; |
|
bmasterc@126
|
65 |
trvDirectories: TTreeView; |
|
bmasterc@126
|
66 |
lblStep4: TLabel; |
|
bmasterc@126
|
67 |
jspInstallProgress: TJvStandardPage; |
|
bmasterc@126
|
68 |
pnlHeader5: TPanel; |
|
bmasterc@214
|
69 |
imgIcon4: TImage; |
|
bmasterc@126
|
70 |
lblTitle5: TLabel; |
|
bmasterc@126
|
71 |
lblSubTitle5: TLabel; |
|
bmasterc@126
|
72 |
ggeAll: TFlatGauge; |
|
bmasterc@126
|
73 |
lblProgress: TLabel; |
|
bmasterc@126
|
74 |
ggeItem: TFlatGauge; |
|
bmasterc@126
|
75 |
rtfDetails: TmxFlatRichEdit; |
|
bmasterc@126
|
76 |
lblDetails: TLabel; |
|
bmasterc@126
|
77 |
bvlSpace2: TBevel; |
|
bmasterc@126
|
78 |
ilImages: TImageList; |
|
bmasterc@126
|
79 |
bvlSpacer1: TBevel; |
|
bmasterc@126
|
80 |
bvlSpacer2: TBevel; |
|
bmasterc@126
|
81 |
bvlSpacer3: TBevel; |
|
bmasterc@126
|
82 |
bvlSpacer5: TBevel; |
|
bmasterc@126
|
83 |
jspSelectMod: TJvStandardPage; |
|
bmasterc@126
|
84 |
pnlSelectMod: TPanel; |
|
bmasterc@214
|
85 |
imgIcon5: TImage; |
|
bmasterc@126
|
86 |
lblSelectMod: TLabel; |
|
bmasterc@126
|
87 |
lblSelectModInfo: TLabel; |
|
bmasterc@126
|
88 |
bvlSelectMod: TBevel; |
|
bmasterc@126
|
89 |
lblInfo: TLabel; |
|
bmasterc@126
|
90 |
chkPassive: TFlatCheckBox; |
|
bmasterc@126
|
91 |
lblStep3: TLabel; |
|
bmasterc@126
|
92 |
pnlOS: TPanel; |
|
bmasterc@126
|
93 |
optWindows: TFlatRadioButton; |
|
bmasterc@126
|
94 |
optLinux: TFlatRadioButton; |
|
bmasterc@126
|
95 |
IdFTP: TIdFTP; |
|
bmasterc@126
|
96 |
cmdProxySettings: TFlatButton; |
|
bmasterc@126
|
97 |
IdAntiFreeze: TIdAntiFreeze; |
|
bmasterc@126
|
98 |
frbStandaloneServer: TFlatRadioButton; |
|
bmasterc@126
|
99 |
tmrSpeed: TTimer; |
|
bmasterc@126
|
100 |
IdLogFile: TIdLogFile; |
|
bmasterc@214
|
101 |
shpMods: TShape; |
|
bmasterc@214
|
102 |
trvMods: TTreeView; |
|
bmasterc@214
|
103 |
FlatRadioButton1: TFlatRadioButton; |
|
bmasterc@126
|
104 |
procedure jvwStepsCancelButtonClick(Sender: TObject); |
|
bmasterc@126
|
105 |
procedure cmdCancelClick(Sender: TObject); |
|
bmasterc@126
|
106 |
procedure cmdNextClick(Sender: TObject); |
|
bmasterc@126
|
107 |
procedure CheckNext(Sender: TObject); |
|
bmasterc@126
|
108 |
procedure cmdBackClick(Sender: TObject); |
|
bmasterc@126
|
109 |
procedure cmdConnectClick(Sender: TObject); |
|
bmasterc@126
|
110 |
procedure jplWizardChange(Sender: TObject); |
|
bmasterc@126
|
111 |
procedure FormCreate(Sender: TObject); |
|
bmasterc@126
|
112 |
procedure cmdProxySettingsClick(Sender: TObject); |
|
bmasterc@126
|
113 |
procedure txtPortChange(Sender: TObject); |
|
bmasterc@126
|
114 |
procedure trvDirectoriesExpanded(Sender: TObject; Node: TTreeNode); |
|
bmasterc@126
|
115 |
procedure trvDirectoriesChange(Sender: TObject; Node: TTreeNode); |
|
bmasterc@126
|
116 |
procedure IdFTPWork(Sender: TObject; AWorkMode: TWorkMode; |
|
bmasterc@126
|
117 |
const AWorkCount: Integer); |
|
bmasterc@126
|
118 |
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
|
bmasterc@126
|
119 |
procedure tmrSpeedTimer(Sender: TObject); |
|
bmasterc@126
|
120 |
procedure trvDirectoriesExpanding(Sender: TObject; Node: TTreeNode; |
|
bmasterc@126
|
121 |
var AllowExpansion: Boolean); |
|
bmasterc@126
|
122 |
procedure trvDirectoriesCollapsing(Sender: TObject; Node: TTreeNode; |
|
bmasterc@126
|
123 |
var AllowCollapse: Boolean); |
|
bmasterc@214
|
124 |
procedure trvModsClick(Sender: TObject); |
|
bmasterc@277
|
125 |
procedure trvDirectoriesMouseDown(Sender: TObject; |
|
bmasterc@277
|
126 |
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
|
bmasterc@126
|
127 |
private |
|
bmasterc@126
|
128 |
OldProgress: Integer; |
|
bmasterc@126
|
129 |
CurrProgress: Integer; |
|
bmasterc@126
|
130 |
public |
|
bmasterc@126
|
131 |
procedure ExceptionHandler(Sender: TObject; E: Exception); |
|
bmasterc@126
|
132 |
end; |
|
bmasterc@126
|
133 |
|
|
bmasterc@126
|
134 |
var |
|
bmasterc@126
|
135 |
frmMain: TfrmMain; |
|
bmasterc@126
|
136 |
|
|
bmasterc@268
|
137 |
var VERSION: String = '<none>'; |
|
bmasterc@126
|
138 |
|
|
bmasterc@126
|
139 |
implementation |
|
bmasterc@126
|
140 |
|
|
bmasterc@126
|
141 |
uses UnitFunctions, UnitfrmProxy, UnitInstall, UnitSelectModPath; |
|
bmasterc@126
|
142 |
|
|
bmasterc@126
|
143 |
{$R *.dfm} |
|
bmasterc@126
|
144 |
|
|
bmasterc@126
|
145 |
procedure TfrmMain.jvwStepsCancelButtonClick(Sender: TObject); |
|
bmasterc@126
|
146 |
begin |
|
bmasterc@126
|
147 |
Close; |
|
bmasterc@126
|
148 |
end; |
|
bmasterc@126
|
149 |
|
|
bmasterc@126
|
150 |
procedure TfrmMain.cmdCancelClick(Sender: TObject); |
|
bmasterc@126
|
151 |
begin |
|
bmasterc@126
|
152 |
Close; |
|
bmasterc@126
|
153 |
end; |
|
bmasterc@126
|
154 |
|
|
bmasterc@126
|
155 |
procedure TfrmMain.cmdNextClick(Sender: TObject); |
|
bmasterc@126
|
156 |
var ePath: String; |
|
bmasterc@126
|
157 |
eRegistry: TRegistry; |
|
bmasterc@126
|
158 |
eStr: TStringList; |
|
bmasterc@126
|
159 |
CurNode: TTreeNode; |
|
bmasterc@126
|
160 |
eOS: TOS; |
|
bmasterc@214
|
161 |
i: integer; |
|
bmasterc@411
|
162 |
Source: Boolean; |
|
bmasterc@126
|
163 |
begin |
|
bmasterc@126
|
164 |
{ FTP } |
|
bmasterc@126
|
165 |
if jplWizard.ActivePage = jspFTP then begin |
|
bmasterc@126
|
166 |
if not IdFTP.Connected then |
|
bmasterc@126
|
167 |
IdFTP.Connect; |
|
bmasterc@126
|
168 |
eStr := TStringList.Create; |
|
bmasterc@126
|
169 |
ePath := '/'; |
|
bmasterc@126
|
170 |
CurNode := trvDirectories.Selected; |
|
bmasterc@274
|
171 |
if (Assigned(CurNode)) then begin |
|
bmasterc@274
|
172 |
repeat |
|
bmasterc@274
|
173 |
ePath := '/' + CurNode.Text + ePath; |
|
bmasterc@274
|
174 |
CurNode := CurNode.Parent; |
|
bmasterc@274
|
175 |
until (not Assigned(CurNode)); |
|
bmasterc@274
|
176 |
end; |
|
bmasterc@274
|
177 |
IdFTP.ChangeDir(ePath); |
|
bmasterc@126
|
178 |
IdFTP.List(eStr, '', False); |
|
bmasterc@411
|
179 |
eStr.CaseSensitive := False; |
|
bmasterc@411
|
180 |
// check if gameinfo.txt is in the directory -> valid installation |
|
bmasterc@411
|
181 |
if (eStr.IndexOf('gameinfo.txt') = -1) then begin |
|
bmasterc@126
|
182 |
MessageBox(Handle, 'Invalid directory. Please select your mod directory and try again.', PChar(Application.Title), MB_ICONWARNING); |
|
bmasterc@126
|
183 |
eStr.Free; |
|
bmasterc@126
|
184 |
exit; |
|
bmasterc@126
|
185 |
end |
|
bmasterc@126
|
186 |
else |
|
bmasterc@126
|
187 |
eStr.Free; |
|
bmasterc@411
|
188 |
// check for orangebox directory |
|
bmasterc@411
|
189 |
Source := True; |
|
bmasterc@417
|
190 |
if (AnsiSameText(ExtractFileName(trvDirectories.Selected.Text), 'tf')) then begin |
|
bmasterc@411
|
191 |
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of |
|
bmasterc@411
|
192 |
mrYes: Source := False; |
|
bmasterc@411
|
193 |
mrNo: Source := True; |
|
bmasterc@411
|
194 |
mrCancel: begin |
|
bmasterc@411
|
195 |
eStr.Free; |
|
bmasterc@411
|
196 |
exit; |
|
bmasterc@411
|
197 |
end; |
|
bmasterc@411
|
198 |
end; |
|
bmasterc@411
|
199 |
end; |
|
bmasterc@126
|
200 |
// design stuff |
|
bmasterc@126
|
201 |
trvDirectories.Enabled := False; |
|
bmasterc@126
|
202 |
cmdConnect.Enabled := False; |
|
bmasterc@126
|
203 |
optWindows.Enabled := False; |
|
bmasterc@126
|
204 |
optLinux.Enabled := False; |
|
bmasterc@126
|
205 |
Screen.Cursor := crHourGlass; |
|
bmasterc@126
|
206 |
|
|
bmasterc@126
|
207 |
if optWindows.Checked then |
|
bmasterc@126
|
208 |
eOS := osWindows |
|
bmasterc@209
|
209 |
else |
|
bmasterc@126
|
210 |
eOS := osLinux; |
|
bmasterc@126
|
211 |
|
|
bmasterc@126
|
212 |
jspInstallProgress.Show; |
|
bmasterc@126
|
213 |
// installation |
|
bmasterc@126
|
214 |
Screen.Cursor := crAppStart; |
|
bmasterc@411
|
215 |
InstallFTP(eOS, Source); |
|
bmasterc@126
|
216 |
end |
|
bmasterc@126
|
217 |
else if jplWizard.ActivePage = jspInstallProgress then |
|
bmasterc@126
|
218 |
Close |
|
bmasterc@126
|
219 |
else if jplWizard.ActivePage = jspSelectMod then begin |
|
bmasterc@126
|
220 |
{ Dedicated Server } |
|
bmasterc@416
|
221 |
if frbDedicatedServer.Checked then begin |
|
bmasterc@416
|
222 |
Source := True; |
|
bmasterc@416
|
223 |
ePath := trvMods.Selected.Text; |
|
bmasterc@416
|
224 |
if ePath = 'Counter-Strike:Source' then |
|
bmasterc@416
|
225 |
ePath := trvMods.Selected.Parent.Text + '\source dedicated server\cstrike' |
|
bmasterc@416
|
226 |
else if ePath = 'Day of Defeat:Source' then |
|
bmasterc@416
|
227 |
ePath := trvMods.Selected.Parent.Text + '\source dedicated server\dod' |
|
bmasterc@416
|
228 |
else if ePath = 'Half-Life 2 Deathmatch' then |
|
bmasterc@416
|
229 |
ePath := trvMods.Selected.Parent.Text + '\source dedicated server\hl2mp' |
|
bmasterc@416
|
230 |
else begin |
|
bmasterc@416
|
231 |
{ get games } |
|
bmasterc@416
|
232 |
if ePath = 'Team Fortress 2' then |
|
bmasterc@416
|
233 |
ePath := trvMods.Selected.Parent.Text + '\source 2007 dedicated server\tf'; |
|
bmasterc@416
|
234 |
{ ask user, just in case } |
|
bmasterc@416
|
235 |
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of |
|
bmasterc@416
|
236 |
mrYes: Source := False; |
|
bmasterc@416
|
237 |
mrNo: Source := True; |
|
bmasterc@416
|
238 |
mrCancel: exit; |
|
bmasterc@416
|
239 |
end; |
|
bmasterc@416
|
240 |
end; |
|
bmasterc@416
|
241 |
SteamPath := IncludeTrailingPathDelimiter(SteamPath) + 'steamapps\'; |
|
bmasterc@416
|
242 |
// install it |
|
bmasterc@416
|
243 |
if DirectoryExists(SteamPath + ePath) then begin |
|
bmasterc@416
|
244 |
jspInstallProgress.Show; |
|
bmasterc@416
|
245 |
InstallDedicated(IncludeTrailingPathDelimiter(SteamPath + ePath), True, Source); |
|
bmasterc@416
|
246 |
end |
|
bmasterc@416
|
247 |
else begin |
|
bmasterc@416
|
248 |
MessageBox(Handle, 'Error: The directory of the mod you selected doesn''t exist any more. Run Dedicated Server with the chosen mod and try again.', PChar(Application.Title), MB_ICONERROR); |
|
bmasterc@416
|
249 |
jspSelectMod.Show; |
|
bmasterc@416
|
250 |
exit; |
|
bmasterc@416
|
251 |
end; |
|
bmasterc@416
|
252 |
end; |
|
bmasterc@416
|
253 |
{ Standalone Server } |
|
bmasterc@416
|
254 |
if frbStandaloneServer.Checked then begin |
|
bmasterc@411
|
255 |
Source := True; |
|
bmasterc@214
|
256 |
ePath := trvMods.Selected.Text; |
|
bmasterc@126
|
257 |
if ePath = 'Counter-Strike:Source' then |
|
bmasterc@126
|
258 |
ePath := 'cstrike' |
|
bmasterc@126
|
259 |
else if ePath = 'Day of Defeat:Source' then |
|
bmasterc@126
|
260 |
ePath := 'dod' |
|
bmasterc@411
|
261 |
else if ePath = 'Half-Life 2 Deathmatch' then |
|
bmasterc@411
|
262 |
ePath := 'hl2mp' |
|
bmasterc@411
|
263 |
else begin |
|
bmasterc@411
|
264 |
{ get games } |
|
bmasterc@411
|
265 |
if ePath = 'Team Fortress 2' then |
|
bmasterc@416
|
266 |
ePath := 'orangebox\tf'; |
|
bmasterc@411
|
267 |
{ ask user, just in case } |
|
bmasterc@411
|
268 |
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of |
|
bmasterc@411
|
269 |
mrYes: Source := False; |
|
bmasterc@411
|
270 |
mrNo: Source := True; |
|
bmasterc@411
|
271 |
mrCancel: exit; |
|
bmasterc@411
|
272 |
end; |
|
bmasterc@411
|
273 |
end; |
|
bmasterc@126
|
274 |
// install it |
|
bmasterc@416
|
275 |
if DirectoryExists(StandaloneServer + ePath) then begin |
|
bmasterc@416
|
276 |
jspInstallProgress.Show; |
|
bmasterc@416
|
277 |
InstallDedicated(IncludeTrailingPathDelimiter(StandaloneServer + ePath), False, Source) |
|
bmasterc@126
|
278 |
end |
|
bmasterc@126
|
279 |
else begin |
|
bmasterc@416
|
280 |
MessageBox(Handle, 'Error: The directory of the mod you selected doesn''t exist (any more). Run Half-Life Dedicated Server with the chosen mod again and restart.', PChar(Application.Title), MB_ICONERROR); |
|
bmasterc@416
|
281 |
jspSelectMod.Show; |
|
bmasterc@416
|
282 |
exit; |
|
bmasterc@126
|
283 |
end; |
|
bmasterc@126
|
284 |
end; |
|
bmasterc@126
|
285 |
{ Listen Server } |
|
bmasterc@126
|
286 |
if frbListenServer.Checked then begin |
|
bmasterc@411
|
287 |
Source := True; |
|
bmasterc@214
|
288 |
ePath := trvMods.Selected.Text; |
|
bmasterc@126
|
289 |
if ePath = 'Counter-Strike:Source' then |
|
bmasterc@214
|
290 |
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\counter-strike source\cstrike' |
|
bmasterc@126
|
291 |
else if ePath = 'Half-Life 2 Deathmatch' then |
|
bmasterc@214
|
292 |
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\half-life 2 deathmatch\hl2mp' |
|
bmasterc@411
|
293 |
else if ePath = 'Day of Defeat:Source' then |
|
bmasterc@411
|
294 |
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\day of defeat source\dod' |
|
bmasterc@411
|
295 |
else begin |
|
bmasterc@411
|
296 |
{ get games } |
|
bmasterc@411
|
297 |
if ePath = 'Team Fortress 2' then |
|
bmasterc@411
|
298 |
ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\team fortress 2\tf'; |
|
bmasterc@411
|
299 |
{ ask user, just in case } |
|
bmasterc@411
|
300 |
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of |
|
bmasterc@411
|
301 |
mrYes: Source := False; |
|
bmasterc@411
|
302 |
mrNo: Source := True; |
|
bmasterc@411
|
303 |
mrCancel: exit; |
|
bmasterc@411
|
304 |
end; |
|
bmasterc@411
|
305 |
end; |
|
bmasterc@126
|
306 |
|
|
bmasterc@126
|
307 |
if Pos(SteamPath, ePath) = 0 then |
|
bmasterc@126
|
308 |
MessageBox(Handle, 'An error occured. Please report this bug to the Metamod:Source team and post a new thread on the forums of www.amxmodx.org.', PChar(Application.Title), MB_ICONSTOP) |
|
bmasterc@126
|
309 |
else begin |
|
bmasterc@214
|
310 |
if not FileExists(ePath + '\gameinfo.txt') then begin |
|
bmasterc@214
|
311 |
MessageBox(Handle, 'You have to play this game once before installing Metamod:Source. Do that and try again.', PChar(Application.Title), MB_ICONWARNING); |
|
bmasterc@126
|
312 |
exit; |
|
bmasterc@126
|
313 |
end; |
|
bmasterc@126
|
314 |
|
|
bmasterc@126
|
315 |
jspInstallProgress.Show; |
|
bmasterc@411
|
316 |
InstallListen(IncludeTrailingPathDelimiter(ePath), Source); |
|
bmasterc@126
|
317 |
end; |
|
bmasterc@126
|
318 |
end; |
|
bmasterc@126
|
319 |
{ Custom mod below } |
|
bmasterc@126
|
320 |
end |
|
bmasterc@126
|
321 |
else if jplWizard.ActivePage <> jspInstallMethod then |
|
bmasterc@126
|
322 |
jplWizard.NextPage |
|
bmasterc@126
|
323 |
else begin |
|
bmasterc@126
|
324 |
if frbDedicatedServer.Checked then begin // Dedicated Server |
|
bmasterc@126
|
325 |
eRegistry := TRegistry.Create(KEY_READ); |
|
bmasterc@126
|
326 |
try |
|
bmasterc@126
|
327 |
eRegistry.RootKey := HKEY_CURRENT_USER; |
|
bmasterc@126
|
328 |
if eRegistry.OpenKey('Software\Valve\Steam', False) then begin |
|
bmasterc@214
|
329 |
ePath := eRegistry.ReadString('SteamPath'); |
|
bmasterc@214
|
330 |
ePath := IncludeTrailingPathDelimiter(StringReplace(ePath, '/', '\', [rfReplaceAll])); |
|
bmasterc@214
|
331 |
SteamPath := ePath; |
|
bmasterc@214
|
332 |
|
|
bmasterc@214
|
333 |
ePath := ePath + 'SteamApps\'; |
|
bmasterc@126
|
334 |
if DirectoryExists(ePath) then begin |
|
bmasterc@214
|
335 |
trvMods.Items.Clear; |
|
bmasterc@126
|
336 |
// Check Mods |
|
bmasterc@214
|
337 |
eStr := GetAllFiles(ePath + '*.*', faDirectory, False, True, False); |
|
bmasterc@214
|
338 |
for i := 0 to eStr.Count -1 do begin |
|
bmasterc@214
|
339 |
CurNode := trvMods.Items.Add(nil, eStr[i]); |
|
bmasterc@214
|
340 |
|
|
bmasterc@214
|
341 |
if DirectoryExists(ePath + eStr[i] + '\source dedicated server\cstrike') then |
|
bmasterc@214
|
342 |
trvMods.Items.AddChild(CurNode, 'Counter-Strike:Source'); |
|
bmasterc@214
|
343 |
if DirectoryExists(ePath + eStr[i] + '\source dedicated server\dod') then |
|
bmasterc@214
|
344 |
trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source'); |
|
bmasterc@214
|
345 |
if DirectoryExists(ePath + eStr[i] + '\source dedicated server\hl2mp') then |
|
bmasterc@214
|
346 |
trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch'); |
|
bmasterc@416
|
347 |
if DirectoryExists(ePath + eStr[i] + '\source 2007 dedicated server\tf') then |
|
bmasterc@416
|
348 |
trvMods.Items.AddChild(CurNode, 'Team Fortress 2'); |
|
bmasterc@214
|
349 |
|
|
bmasterc@214
|
350 |
if CurNode.Count = 0 then |
|
bmasterc@214
|
351 |
CurNode.Free |
|
bmasterc@214
|
352 |
else |
|
bmasterc@214
|
353 |
CurNode.Expand(False); |
|
bmasterc@214
|
354 |
end; |
|
bmasterc@126
|
355 |
// Misc |
|
bmasterc@126
|
356 |
jspSelectMod.Show; |
|
bmasterc@214
|
357 |
trvMods.Selected := nil; |
|
bmasterc@126
|
358 |
cmdNext.Enabled := False; |
|
bmasterc@126
|
359 |
end |
|
bmasterc@126
|
360 |
else |
|
bmasterc@126
|
361 |
MessageBox(Handle, 'You have to run Dedicated Server once before installing Metamod:Source!', 'Error', MB_ICONWARNING); |
|
bmasterc@126
|
362 |
end |
|
bmasterc@126
|
363 |
else |
|
bmasterc@126
|
364 |
MessageBox(Handle, 'You haven''t installed Steam yet! Download it at www.steampowered.com, install Dedicated Server and try again.', 'Error', MB_ICONWARNING); |
|
bmasterc@126
|
365 |
finally |
|
bmasterc@126
|
366 |
eRegistry.Free; |
|
bmasterc@126
|
367 |
end; |
|
bmasterc@126
|
368 |
end |
|
bmasterc@126
|
369 |
else if frbListenServer.Checked then begin // Listen Server |
|
bmasterc@126
|
370 |
eRegistry := TRegistry.Create(KEY_READ); |
|
bmasterc@126
|
371 |
try |
|
bmasterc@126
|
372 |
eRegistry.RootKey := HKEY_CURRENT_USER; |
|
bmasterc@126
|
373 |
if eRegistry.OpenKey('Software\Valve\Steam', False) then begin |
|
bmasterc@214
|
374 |
ePath := eRegistry.ReadString('SteamPath'); |
|
bmasterc@214
|
375 |
ePath := IncludeTrailingPathDelimiter(StringReplace(ePath, '/', '\', [rfReplaceAll])); |
|
bmasterc@214
|
376 |
SteamPath := ePath; |
|
bmasterc@214
|
377 |
|
|
bmasterc@214
|
378 |
ePath := ePath + 'SteamApps\'; |
|
bmasterc@126
|
379 |
if DirectoryExists(ePath) then begin |
|
bmasterc@214
|
380 |
trvMods.Items.Clear; |
|
bmasterc@126
|
381 |
// Check Mods |
|
bmasterc@214
|
382 |
eStr := GetAllFiles(ePath + '*.*', faDirectory, False, True, False); |
|
bmasterc@214
|
383 |
for i := 0 to eStr.Count -1 do begin |
|
bmasterc@214
|
384 |
CurNode := trvMods.Items.Add(nil, eStr[i]); |
|
bmasterc@214
|
385 |
|
|
bmasterc@214
|
386 |
if DirectoryExists(ePath + eStr[i] + '\counter-strike source') then |
|
bmasterc@214
|
387 |
trvMods.Items.AddChild(CurNode, 'Counter-Strike:Source'); |
|
bmasterc@214
|
388 |
if DirectoryExists(ePath + eStr[i] + '\day of defeat source') then |
|
bmasterc@214
|
389 |
trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source'); |
|
bmasterc@214
|
390 |
if DirectoryExists(ePath + eStr[i] + '\half-life 2 deathmatch') then |
|
bmasterc@214
|
391 |
trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch'); |
|
bmasterc@411
|
392 |
if DirectoryExists(ePath + eStr[i] + '\team fortress 2') then |
|
bmasterc@411
|
393 |
trvMods.Items.AddChild(CurNode, 'Team Fortress 2'); |
|
bmasterc@214
|
394 |
|
|
bmasterc@214
|
395 |
if CurNode.Count = 0 then |
|
bmasterc@214
|
396 |
CurNode.Free |
|
bmasterc@214
|
397 |
else |
|
bmasterc@214
|
398 |
CurNode.Expand(False); |
|
bmasterc@214
|
399 |
end; |
|
bmasterc@126
|
400 |
// Misc |
|
bmasterc@126
|
401 |
jspSelectMod.Show; |
|
bmasterc@214
|
402 |
trvMods.Selected := nil; |
|
bmasterc@126
|
403 |
cmdNext.Enabled := False; |
|
bmasterc@126
|
404 |
end |
|
bmasterc@126
|
405 |
else |
|
bmasterc@126
|
406 |
MessageBox(Handle, 'You haven''t installed Steam yet! Download it at www.steampowered.com, install Dedicated Server and try again.', 'Error', MB_ICONWARNING); |
|
bmasterc@126
|
407 |
end |
|
bmasterc@126
|
408 |
else |
|
bmasterc@126
|
409 |
MessageBox(Handle, 'You haven''t installed Steam yet! Download it at www.steampowered.com, install Dedicated Server and try again.', 'Error', MB_ICONWARNING); |
|
bmasterc@126
|
410 |
finally |
|
bmasterc@126
|
411 |
eRegistry.Free; |
|
bmasterc@126
|
412 |
end; |
|
bmasterc@126
|
413 |
end |
|
bmasterc@126
|
414 |
else if frbStandaloneServer.Checked then begin // Standalone Server |
|
bmasterc@126
|
415 |
eRegistry := TRegistry.Create; |
|
bmasterc@126
|
416 |
try |
|
bmasterc@126
|
417 |
eRegistry.RootKey := HKEY_CURRENT_USER; |
|
bmasterc@126
|
418 |
if eRegistry.OpenKey('Software\Valve\HLServer', False) then begin |
|
bmasterc@126
|
419 |
StandaloneServer := IncludeTrailingPathDelimiter(eRegistry.ReadString('InstallPath')); |
|
bmasterc@126
|
420 |
if DirectoryExists(StandaloneServer + 'cstrike') then |
|
bmasterc@214
|
421 |
trvMods.Items.Add(nil, 'Counter-Strike:Source'); |
|
bmasterc@126
|
422 |
if DirectoryExists(StandaloneServer + 'dod') then |
|
bmasterc@214
|
423 |
trvMods.Items.Add(nil, 'Day of Defeat:Source'); |
|
bmasterc@126
|
424 |
if DirectoryExists(StandaloneServer + 'hl2mp') then |
|
bmasterc@214
|
425 |
trvMods.Items.Add(nil, 'Half-Life 2 Deatmatch'); |
|
bmasterc@411
|
426 |
if DirectoryExists(StandaloneServer + 'orangebox\tf') then |
|
bmasterc@411
|
427 |
trvMods.Items.Add(nil, 'Team Fortress 2'); |
|
bmasterc@126
|
428 |
jspSelectMod.Show; |
|
bmasterc@214
|
429 |
cmdNext.Enabled := False; |
|
bmasterc@126
|
430 |
end |
|
bmasterc@126
|
431 |
else |
|
bmasterc@126
|
432 |
MessageBox(Handle, 'You haven''t installed Half-Life Dedicated Server yet!', 'Error', MB_ICONWARNING); |
|
bmasterc@126
|
433 |
finally |
|
bmasterc@126
|
434 |
eRegistry.Free; |
|
bmasterc@126
|
435 |
end; |
|
bmasterc@126
|
436 |
end |
|
bmasterc@126
|
437 |
else if frbSelectMod.Checked then begin |
|
bmasterc@126
|
438 |
{ Custom mod } |
|
bmasterc@126
|
439 |
if frmSelectModPath.ShowModal = mrOk then begin |
|
bmasterc@416
|
440 |
ePath := frmSelectModPath.trvDirectory.SelectedFolder.PathName; |
|
bmasterc@411
|
441 |
{ check if this is an orangebox game } |
|
bmasterc@411
|
442 |
Source := True; |
|
bmasterc@416
|
443 |
if (AnsiSameText(ExtractFileName(ePath), 'tf')) then begin |
|
bmasterc@411
|
444 |
case MessageBox(Handle, 'It looks like your server is using the OrangeBox engine. Would you like to install the appropriate binaries for it?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNOCANCEL) of |
|
bmasterc@411
|
445 |
mrYes: Source := False; |
|
bmasterc@411
|
446 |
mrNo: Source := True; |
|
bmasterc@411
|
447 |
mrCancel: exit; |
|
bmasterc@411
|
448 |
end; |
|
bmasterc@411
|
449 |
end; |
|
bmasterc@411
|
450 |
{ install now } |
|
bmasterc@126
|
451 |
jspInstallProgress.Show; |
|
bmasterc@416
|
452 |
InstallCustom(IncludeTrailingPathDelimiter(ePath), osWindows, Source); |
|
bmasterc@126
|
453 |
end; |
|
bmasterc@126
|
454 |
end |
|
bmasterc@126
|
455 |
else if frbFTP.Checked then // FTP |
|
bmasterc@126
|
456 |
jspFTP.Show; |
|
bmasterc@126
|
457 |
end; |
|
bmasterc@126
|
458 |
end; |
|
bmasterc@126
|
459 |
|
|
bmasterc@126
|
460 |
procedure TfrmMain.CheckNext(Sender: TObject); |
|
bmasterc@126
|
461 |
begin |
|
bmasterc@126
|
462 |
cmdNext.Enabled := frbAgree.Checked; |
|
bmasterc@126
|
463 |
end; |
|
bmasterc@126
|
464 |
|
|
bmasterc@126
|
465 |
procedure TfrmMain.cmdBackClick(Sender: TObject); |
|
bmasterc@126
|
466 |
begin |
|
bmasterc@126
|
467 |
if jplWizard.ActivePage = jspFTP then |
|
bmasterc@126
|
468 |
jspInstallMethod.Show |
|
bmasterc@126
|
469 |
else begin |
|
bmasterc@126
|
470 |
jplWizard.PrevPage; |
|
bmasterc@126
|
471 |
cmdBack.Visible := jplWizard.ActivePageIndex <> 0; |
|
bmasterc@126
|
472 |
end; |
|
bmasterc@126
|
473 |
end; |
|
bmasterc@126
|
474 |
|
|
bmasterc@126
|
475 |
procedure TfrmMain.cmdConnectClick(Sender: TObject); |
|
bmasterc@126
|
476 |
var i: integer; |
|
bmasterc@126
|
477 |
eStr: TStringList; |
|
bmasterc@126
|
478 |
CurNode: TTreeNode; |
|
bmasterc@285
|
479 |
Path: String; |
|
bmasterc@126
|
480 |
begin |
|
bmasterc@126
|
481 |
if (Trim(txtHost.Text) = '') or (Trim(txtUsername.Text) = '') then |
|
bmasterc@126
|
482 |
MessageBox(Handle, 'Please fill in each field!', PChar(Application.Title), MB_ICONWARNING) |
|
bmasterc@126
|
483 |
else if cmdConnect.Caption = 'Connect' then begin |
|
bmasterc@126
|
484 |
// ... design stuff ... |
|
bmasterc@126
|
485 |
Screen.Cursor := crHourGlass; |
|
bmasterc@126
|
486 |
cmdConnect.Enabled := False; |
|
bmasterc@126
|
487 |
cmdProxySettings.Enabled := False; |
|
bmasterc@126
|
488 |
txtHost.Enabled := False; |
|
bmasterc@126
|
489 |
txtPort.Enabled := False; |
|
bmasterc@126
|
490 |
txtUsername.Enabled := False; |
|
bmasterc@126
|
491 |
txtPassword.Enabled := False; |
|
bmasterc@126
|
492 |
chkPassive.Enabled := False; |
|
bmasterc@126
|
493 |
cmdConnect.Caption := 'Connecting...'; |
|
bmasterc@126
|
494 |
// ... set values ... |
|
bmasterc@126
|
495 |
IdFTP.Host := txtHost.Text; |
|
bmasterc@126
|
496 |
IdFTP.Port := StrToInt(txtPort.Text); |
|
bmasterc@126
|
497 |
IdFTP.Username := txtUsername.Text; |
|
bmasterc@126
|
498 |
IdFTP.Passive := chkPassive.Checked; |
|
bmasterc@126
|
499 |
IdFTP.Password := txtPassword.Text; |
|
bmasterc@126
|
500 |
// ... connect and check values etc ... |
|
bmasterc@126
|
501 |
try |
|
bmasterc@126
|
502 |
IdFTP.Connect(True, 15000); |
|
bmasterc@285
|
503 |
// ... get initial directory ... |
|
bmasterc@285
|
504 |
Path := IdFTP.RetrieveCurrentDir; |
|
bmasterc@285
|
505 |
// ... "fix" path ... |
|
bmasterc@126
|
506 |
eStr := TStringList.Create; |
|
bmasterc@285
|
507 |
eStr.Text := StringReplace(Path, '/', #13, [rfReplaceAll]); |
|
bmasterc@126
|
508 |
for i := eStr.Count -1 downto 0 do begin |
|
bmasterc@126
|
509 |
if eStr[i] = '' then |
|
bmasterc@126
|
510 |
eStr.Delete(i); |
|
bmasterc@126
|
511 |
end; |
|
bmasterc@285
|
512 |
if (Copy(Path, Length(Path) -1, 1) <> '/') then |
|
bmasterc@285
|
513 |
Path := Path + '/'; |
|
bmasterc@126
|
514 |
// ... connect successful, change captions ... |
|
bmasterc@126
|
515 |
trvDirectories.Enabled := True; |
|
bmasterc@126
|
516 |
cmdConnect.Enabled := True; |
|
bmasterc@126
|
517 |
cmdConnect.Caption := 'Disconnect'; |
|
bmasterc@285
|
518 |
// ... change to / and create all the directories ... |
|
bmasterc@126
|
519 |
CurNode := nil; |
|
bmasterc@285
|
520 |
if (Path <> '/') then begin |
|
bmasterc@285
|
521 |
try |
|
bmasterc@285
|
522 |
IdFTP.ChangeDir('/'); |
|
bmasterc@285
|
523 |
with GetAllDirs do begin |
|
bmasterc@285
|
524 |
for i := 0 to Count -1 do begin |
|
bmasterc@285
|
525 |
if (Assigned(CurNode)) then |
|
bmasterc@285
|
526 |
trvDirectories.Items.AddChild(trvDirectories.Items.Add(nil, Strings[i]), 'Scanning...') |
|
bmasterc@285
|
527 |
else begin |
|
bmasterc@285
|
528 |
CurNode := trvDirectories.Items.Add(nil, Strings[i]); |
|
bmasterc@285
|
529 |
trvDirectories.Items.AddChild(CurNode, 'Scanning...'); |
|
bmasterc@285
|
530 |
if (Pos('/' + CurNode.Text + '/', Path) = 0) then |
|
bmasterc@285
|
531 |
CurNode := nil; |
|
bmasterc@285
|
532 |
end |
|
bmasterc@285
|
533 |
end; |
|
bmasterc@285
|
534 |
Free; |
|
bmasterc@285
|
535 |
end; |
|
bmasterc@285
|
536 |
IdFTP.ChangeDir(Path); |
|
bmasterc@285
|
537 |
except |
|
bmasterc@285
|
538 |
if (IdFTP.Connected) then |
|
bmasterc@285
|
539 |
IdFTP.ChangeDir(Path) |
|
bmasterc@285
|
540 |
else |
|
bmasterc@285
|
541 |
IdFTP.Connect; |
|
bmasterc@285
|
542 |
end; |
|
bmasterc@285
|
543 |
end; |
|
bmasterc@285
|
544 |
// ... find directories in start path ... |
|
bmasterc@126
|
545 |
if eStr.Count <> 0 then begin |
|
bmasterc@285
|
546 |
for i := 0 to eStr.Count -1 do begin |
|
bmasterc@285
|
547 |
if (not ((i = 0) and (Assigned(CurNode)))) then |
|
bmasterc@285
|
548 |
CurNode := trvDirectories.Items.AddChild(CurNode, eStr[i]); |
|
bmasterc@285
|
549 |
end; |
|
bmasterc@126
|
550 |
end; |
|
bmasterc@285
|
551 |
trvDirectories.Selected := CurNode; |
|
bmasterc@126
|
552 |
eStr.Free; |
|
bmasterc@126
|
553 |
// ... scan for directories ... |
|
bmasterc@126
|
554 |
with GetAllDirs do begin |
|
bmasterc@126
|
555 |
for i := 0 to Count -1 do |
|
bmasterc@126
|
556 |
trvDirectories.Items.AddChild(trvDirectories.Items.AddChild(CurNode, Strings[i]), 'Scanning...'); |
|
bmasterc@126
|
557 |
Free; |
|
bmasterc@126
|
558 |
end; |
|
bmasterc@126
|
559 |
|
|
bmasterc@126
|
560 |
if Assigned(CurNode) then |
|
bmasterc@126
|
561 |
CurNode.Expand(False); |
|
bmasterc@126
|
562 |
except |
|
bmasterc@126
|
563 |
on E: Exception do begin |
|
bmasterc@126
|
564 |
// reset button properties |
|
bmasterc@126
|
565 |
cmdConnect.Enabled := True; |
|
bmasterc@126
|
566 |
txtHost.Enabled := True; |
|
bmasterc@126
|
567 |
txtPort.Enabled := True; |
|
bmasterc@126
|
568 |
txtUsername.Enabled := True; |
|
bmasterc@126
|
569 |
txtPassword.Enabled := True; |
|
bmasterc@126
|
570 |
chkPassive.Enabled := True; |
|
bmasterc@126
|
571 |
cmdProxySettings.Enabled := True; |
|
bmasterc@126
|
572 |
cmdNext.Enabled := False; |
|
bmasterc@126
|
573 |
cmdConnect.Caption := 'Connect'; |
|
bmasterc@126
|
574 |
// analyze messages |
|
bmasterc@126
|
575 |
if Pos('Login incorrect.', E.Message) <> 0 then begin // login failed |
|
bmasterc@126
|
576 |
MessageBox(Handle, 'Login incorrect. Check your FTP settings and try again.', PChar(Application.Title), MB_ICONWARNING); |
|
bmasterc@126
|
577 |
txtUsername.SetFocus; |
|
bmasterc@126
|
578 |
txtUsername.SelectAll; |
|
bmasterc@126
|
579 |
end |
|
bmasterc@126
|
580 |
else if Pos('Host not found.', E.Message) <> 0 then begin // host not found |
|
bmasterc@126
|
581 |
MessageBox(Handle, 'The entered host couldn''t be found. Check your settings and try again.', PChar(Application.Title), MB_ICONWARNING); |
|
bmasterc@126
|
582 |
txtHost.SetFocus; |
|
bmasterc@126
|
583 |
txtHost.SelectAll; |
|
bmasterc@126
|
584 |
end |
|
bmasterc@126
|
585 |
else if Pos('Connection refused.', E.Message) <> 0 then begin // wrong port (?) |
|
bmasterc@126
|
586 |
MessageBox(Handle, 'The host refused the connection. Check your port and try again.', PChar(Application.Title), MB_ICONWARNING); |
|
bmasterc@126
|
587 |
txtPort.SetFocus; |
|
bmasterc@126
|
588 |
txtPort.SelectAll; |
|
bmasterc@126
|
589 |
end |
|
bmasterc@126
|
590 |
else if E is EIdProtocolReplyError then begin // wrong port |
|
bmasterc@126
|
591 |
MessageBox(Handle, 'The port you entered is definitely wrong. Check it and try again.', PChar(Application.Title), MB_ICONWARNING); |
|
bmasterc@126
|
592 |
txtPort.SetFocus; |
|
bmasterc@126
|
593 |
txtPort.SelectAll; |
|
bmasterc@126
|
594 |
end |
|
bmasterc@126
|
595 |
else |
|
bmasterc@126
|
596 |
MessageBox(Handle, PChar(E.Message), PChar(Application.Title), MB_ICONWARNING); // unknown error |
|
bmasterc@126
|
597 |
// ... connect failed, leave procedure ... |
|
bmasterc@126
|
598 |
Screen.Cursor := crDefault; |
|
bmasterc@126
|
599 |
exit; |
|
bmasterc@126
|
600 |
end; |
|
bmasterc@126
|
601 |
end; |
|
bmasterc@126
|
602 |
|
|
bmasterc@126
|
603 |
Screen.Cursor := crDefault; |
|
bmasterc@126
|
604 |
end |
|
bmasterc@126
|
605 |
else begin |
|
bmasterc@126
|
606 |
Screen.Cursor := crHourGlass; |
|
bmasterc@126
|
607 |
IdFTP.Quit; |
|
bmasterc@126
|
608 |
trvDirectories.Items.Clear; |
|
bmasterc@126
|
609 |
trvDirectories.Enabled := False; |
|
bmasterc@126
|
610 |
cmdConnect.Enabled := True; |
|
bmasterc@126
|
611 |
cmdProxySettings.Enabled := True; |
|
bmasterc@126
|
612 |
txtHost.Enabled := True; |
|
bmasterc@126
|
613 |
txtPort.Enabled := True; |
|
bmasterc@126
|
614 |
txtUsername.Enabled := True; |
|
bmasterc@126
|
615 |
txtPassword.Enabled := True; |
|
bmasterc@126
|
616 |
chkPassive.Enabled := True; |
|
bmasterc@126
|
617 |
cmdConnect.Caption := 'Connect'; |
|
bmasterc@126
|
618 |
cmdNext.Enabled := False; |
|
bmasterc@126
|
619 |
Screen.Cursor := crDefault; |
|
bmasterc@126
|
620 |
end; |
|
bmasterc@126
|
621 |
end; |
|
bmasterc@126
|
622 |
|
|
bmasterc@126
|
623 |
procedure TfrmMain.jplWizardChange(Sender: TObject); |
|
bmasterc@126
|
624 |
begin |
|
bmasterc@126
|
625 |
if (jplWizard.ActivePage = jspInstallProgress) then begin |
|
bmasterc@126
|
626 |
cmdNext.Caption := '&Finish'; |
|
bmasterc@126
|
627 |
cmdNext.Enabled := False; |
|
bmasterc@126
|
628 |
cmdBack.Visible := False; |
|
bmasterc@126
|
629 |
end |
|
bmasterc@126
|
630 |
else begin |
|
bmasterc@126
|
631 |
cmdNext.Caption := '&Next >'; |
|
bmasterc@126
|
632 |
cmdNext.Enabled := True; |
|
bmasterc@126
|
633 |
cmdBack.Visible := jplWizard.ActivePageIndex <> 0; |
|
bmasterc@126
|
634 |
end; |
|
bmasterc@126
|
635 |
|
|
bmasterc@126
|
636 |
if (jplWizard.ActivePage = jspLicense) then |
|
bmasterc@126
|
637 |
cmdNext.Enabled := frbAgree.Checked; |
|
bmasterc@126
|
638 |
|
|
bmasterc@126
|
639 |
if (jplWizard.ActivePage = jspFTP) then |
|
bmasterc@126
|
640 |
cmdNext.Enabled := False; |
|
bmasterc@126
|
641 |
end; |
|
bmasterc@126
|
642 |
|
|
bmasterc@126
|
643 |
procedure TfrmMain.FormCreate(Sender: TObject); |
|
bmasterc@126
|
644 |
begin |
|
bmasterc@126
|
645 |
if LowerCase(ParamStr(1)) = '-logftp' then begin |
|
bmasterc@126
|
646 |
MessageBox(Handle, 'FTP installation will be logged to FTP.log!', PChar(Application.Title), MB_ICONINFORMATION); |
|
bmasterc@126
|
647 |
IdLogFile.Filename := ExtractFilePath(ParamStr(0)) + 'FTP.log'; |
|
bmasterc@126
|
648 |
IdLogFile.Active := True; |
|
bmasterc@126
|
649 |
end; |
|
bmasterc@126
|
650 |
|
|
bmasterc@126
|
651 |
rtfDetails.Clear; |
|
bmasterc@126
|
652 |
end; |
|
bmasterc@126
|
653 |
|
|
bmasterc@126
|
654 |
procedure TfrmMain.cmdProxySettingsClick(Sender: TObject); |
|
bmasterc@126
|
655 |
begin |
|
bmasterc@126
|
656 |
frmProxy.ShowModal; |
|
bmasterc@126
|
657 |
// Apply Proxy Settings |
|
bmasterc@126
|
658 |
case frmProxy.cboProxy.ItemIndex of |
|
bmasterc@126
|
659 |
0: IdFTP.ProxySettings.ProxyType := fpcmNone; // none |
|
bmasterc@126
|
660 |
1: IdFTP.ProxySettings.ProxyType := fpcmHttpProxyWithFtp; // HTTP Proxy with FTP |
|
bmasterc@126
|
661 |
2: IdFTP.ProxySettings.ProxyType := fpcmOpen; // Open |
|
bmasterc@126
|
662 |
3: IdFTP.ProxySettings.ProxyType := fpcmSite; // Site |
|
bmasterc@126
|
663 |
4: IdFTP.ProxySettings.ProxyType := fpcmTransparent; // Transparent |
|
bmasterc@126
|
664 |
5: IdFTP.ProxySettings.ProxyType := fpcmUserPass; // User (Password) |
|
bmasterc@126
|
665 |
6: IdFTP.ProxySettings.ProxyType := fpcmUserSite; // User (Site) |
|
bmasterc@126
|
666 |
end; |
|
bmasterc@126
|
667 |
|
|
bmasterc@126
|
668 |
IdFTP.ProxySettings.Host := frmProxy.txtHost.Text; |
|
bmasterc@126
|
669 |
IdFTP.ProxySettings.UserName := frmProxy.txtPort.Text; |
|
bmasterc@126
|
670 |
IdFTP.ProxySettings.Password := frmProxy.txtPassword.Text; |
|
bmasterc@126
|
671 |
IdFTP.ProxySettings.Port := StrToInt(frmProxy.txtPort.Text); |
|
bmasterc@126
|
672 |
end; |
|
bmasterc@126
|
673 |
|
|
bmasterc@126
|
674 |
procedure TfrmMain.txtPortChange(Sender: TObject); |
|
bmasterc@126
|
675 |
var i: integer; |
|
bmasterc@126
|
676 |
begin |
|
bmasterc@126
|
677 |
if txtPort.Text = '' then |
|
bmasterc@126
|
678 |
txtPort.Text := '21' |
|
bmasterc@126
|
679 |
else begin |
|
bmasterc@126
|
680 |
// check if value is numeric... |
|
bmasterc@126
|
681 |
for i := Length(txtPort.Text) downto 1 do begin |
|
bmasterc@126
|
682 |
if Pos(txtPort.Text[i], '0123456789') = 0 then begin |
|
bmasterc@126
|
683 |
txtPort.Text := '21'; |
|
bmasterc@126
|
684 |
txtPort.SelStart := 4; |
|
bmasterc@126
|
685 |
exit; |
|
bmasterc@126
|
686 |
end; |
|
bmasterc@126
|
687 |
end; |
|
bmasterc@126
|
688 |
end; |
|
bmasterc@126
|
689 |
end; |
|
bmasterc@126
|
690 |
|
|
bmasterc@126
|
691 |
procedure TfrmMain.trvDirectoriesExpanded(Sender: TObject; |
|
bmasterc@126
|
692 |
Node: TTreeNode); |
|
bmasterc@126
|
693 |
var ePath: String; |
|
bmasterc@126
|
694 |
CurNode: TTreeNode; |
|
bmasterc@126
|
695 |
i: integer; |
|
bmasterc@126
|
696 |
begin |
|
bmasterc@126
|
697 |
if Node.Item[0].Text = 'Scanning...' then begin // no directories added yet |
|
bmasterc@126
|
698 |
Screen.Cursor := crHourGlass; |
|
bmasterc@126
|
699 |
// get complete path |
|
bmasterc@126
|
700 |
ePath := '/'; |
|
bmasterc@126
|
701 |
CurNode := Node; |
|
bmasterc@126
|
702 |
repeat |
|
bmasterc@126
|
703 |
ePath := '/' + CurNode.Text + ePath; |
|
bmasterc@126
|
704 |
CurNode := CurNode.Parent; |
|
bmasterc@126
|
705 |
until (not Assigned(CurNode)); |
|
bmasterc@126
|
706 |
// change dir and add directories in it |
|
bmasterc@126
|
707 |
try |
|
bmasterc@126
|
708 |
Repaint; |
|
bmasterc@126
|
709 |
IdFTP.ChangeDir(ePath); |
|
bmasterc@126
|
710 |
with GetAllDirs do begin |
|
bmasterc@126
|
711 |
Node.Item[0].Free; |
|
bmasterc@126
|
712 |
for i := 0 to Count -1 do begin |
|
bmasterc@126
|
713 |
trvDirectories.Items.AddChild(trvDirectories.Items.AddChild(Node, Strings[i]), 'Scanning...'); |
|
bmasterc@126
|
714 |
end; |
|
bmasterc@126
|
715 |
Free; |
|
bmasterc@126
|
716 |
end; |
|
bmasterc@126
|
717 |
finally |
|
bmasterc@126
|
718 |
Application.ProcessMessages; |
|
bmasterc@126
|
719 |
end; |
|
bmasterc@126
|
720 |
Screen.Cursor := crDefault; |
|
bmasterc@126
|
721 |
end; |
|
bmasterc@126
|
722 |
end; |
|
bmasterc@126
|
723 |
|
|
bmasterc@126
|
724 |
procedure TfrmMain.trvDirectoriesChange(Sender: TObject; Node: TTreeNode); |
|
bmasterc@126
|
725 |
begin |
|
bmasterc@126
|
726 |
cmdNext.Enabled := Assigned(trvDirectories.Selected); |
|
bmasterc@126
|
727 |
end; |
|
bmasterc@126
|
728 |
|
|
bmasterc@126
|
729 |
procedure TfrmMain.IdFTPWork(Sender: TObject; AWorkMode: TWorkMode; |
|
bmasterc@126
|
730 |
const AWorkCount: Integer); |
|
bmasterc@126
|
731 |
begin |
|
bmasterc@126
|
732 |
if AWorkCount > 15 then begin |
|
bmasterc@126
|
733 |
ggeItem.Progress := AWorkCount; |
|
bmasterc@126
|
734 |
CurrProgress := AWorkCount; |
|
bmasterc@126
|
735 |
end; |
|
bmasterc@126
|
736 |
|
|
bmasterc@126
|
737 |
if Cancel then |
|
bmasterc@126
|
738 |
IdFTP.Abort; |
|
bmasterc@126
|
739 |
|
|
bmasterc@126
|
740 |
Application.ProcessMessages; |
|
bmasterc@126
|
741 |
end; |
|
bmasterc@126
|
742 |
|
|
bmasterc@126
|
743 |
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction); |
|
bmasterc@126
|
744 |
begin |
|
bmasterc@126
|
745 |
if (jplWizard.ActivePage = jspFTP) and (IdFTP.Connected) then |
|
bmasterc@126
|
746 |
IdFTP.Quit; |
|
bmasterc@126
|
747 |
if (jplWizard.ActivePage = jspInstallProgress) and (ggeAll.Progress <> ggeAll.MaxValue) and (not Cancel) then begin |
|
bmasterc@126
|
748 |
if MessageBox(Handle, 'Do you really want to cancel the installation?', PChar(Application.Title), MB_ICONQUESTION + MB_YESNO) = mrYes then begin |
|
bmasterc@126
|
749 |
Screen.Cursor := crDefault; |
|
bmasterc@126
|
750 |
Application.OnException := ExceptionHandler; |
|
bmasterc@126
|
751 |
Cancel := True; |
|
bmasterc@126
|
752 |
if IdFTP.Connected then |
|
bmasterc@126
|
753 |
IdFTP.Quit; |
|
bmasterc@126
|
754 |
end |
|
bmasterc@126
|
755 |
else |
|
bmasterc@126
|
756 |
Action := caNone; |
|
bmasterc@126
|
757 |
end; |
|
bmasterc@126
|
758 |
end; |
|
bmasterc@126
|
759 |
|
|
bmasterc@126
|
760 |
procedure TfrmMain.ExceptionHandler(Sender: TObject; E: Exception); |
|
bmasterc@126
|
761 |
begin |
|
bmasterc@126
|
762 |
// IF any exceptions were raised after close, nobody would want them so leave this empty |
|
bmasterc@126
|
763 |
end; |
|
bmasterc@126
|
764 |
|
|
bmasterc@126
|
765 |
procedure TfrmMain.tmrSpeedTimer(Sender: TObject); |
|
bmasterc@126
|
766 |
begin |
|
bmasterc@126
|
767 |
Caption := CalcSpeed(OldProgress, CurrProgress); |
|
bmasterc@126
|
768 |
OldProgress := CurrProgress; |
|
bmasterc@126
|
769 |
end; |
|
bmasterc@126
|
770 |
|
|
bmasterc@126
|
771 |
procedure TfrmMain.trvDirectoriesExpanding(Sender: TObject; |
|
bmasterc@126
|
772 |
Node: TTreeNode; var AllowExpansion: Boolean); |
|
bmasterc@126
|
773 |
begin |
|
bmasterc@126
|
774 |
Node.ImageIndex := 1; |
|
bmasterc@126
|
775 |
Node.SelectedIndex := 1; |
|
bmasterc@126
|
776 |
end; |
|
bmasterc@126
|
777 |
|
|
bmasterc@126
|
778 |
procedure TfrmMain.trvDirectoriesCollapsing(Sender: TObject; |
|
bmasterc@126
|
779 |
Node: TTreeNode; var AllowCollapse: Boolean); |
|
bmasterc@126
|
780 |
begin |
|
bmasterc@126
|
781 |
Node.ImageIndex := 0; |
|
bmasterc@126
|
782 |
Node.SelectedIndex := 0; |
|
bmasterc@126
|
783 |
end; |
|
bmasterc@126
|
784 |
|
|
bmasterc@214
|
785 |
procedure TfrmMain.trvModsClick(Sender: TObject); |
|
bmasterc@214
|
786 |
begin |
|
bmasterc@214
|
787 |
if Assigned(trvMods.Selected) then |
|
bmasterc@214
|
788 |
cmdNext.Enabled := Assigned(trvMods.Selected.Parent) |
|
bmasterc@214
|
789 |
else |
|
bmasterc@214
|
790 |
cmdNext.Enabled := False; |
|
bmasterc@214
|
791 |
end; |
|
bmasterc@214
|
792 |
|
|
bmasterc@277
|
793 |
procedure TfrmMain.trvDirectoriesMouseDown(Sender: TObject; |
|
bmasterc@277
|
794 |
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); |
|
bmasterc@277
|
795 |
var Node: TTreeNode; |
|
bmasterc@277
|
796 |
begin |
|
bmasterc@277
|
797 |
Node := trvDirectories.GetNodeAt(X, Y); |
|
bmasterc@277
|
798 |
if (Assigned(Node)) then begin |
|
bmasterc@277
|
799 |
if (Node.DisplayRect(True).Right < X) then |
|
bmasterc@277
|
800 |
trvDirectories.Selected := nil; |
|
bmasterc@277
|
801 |
end; |
|
bmasterc@277
|
802 |
end; |
|
bmasterc@277
|
803 |
|
|
bmasterc@126
|
804 |
end. |