1.1 --- a/installer/UnitfrmMain.pas Thu Jun 15 00:01:06 2006 +0000
1.2 +++ b/installer/UnitfrmMain.pas Tue Jun 27 22:39:42 2006 +0000
1.3 @@ -66,7 +66,7 @@
1.4 lblStep4: TLabel;
1.5 jspInstallProgress: TJvStandardPage;
1.6 pnlHeader5: TPanel;
1.7 - imgIcon5: TImage;
1.8 + imgIcon4: TImage;
1.9 lblTitle5: TLabel;
1.10 lblSubTitle5: TLabel;
1.11 ggeAll: TFlatGauge;
1.12 @@ -82,12 +82,11 @@
1.13 bvlSpacer5: TBevel;
1.14 jspSelectMod: TJvStandardPage;
1.15 pnlSelectMod: TPanel;
1.16 - imgIcon6: TImage;
1.17 + imgIcon5: TImage;
1.18 lblSelectMod: TLabel;
1.19 lblSelectModInfo: TLabel;
1.20 bvlSelectMod: TBevel;
1.21 lblInfo: TLabel;
1.22 - lstMods: TmxFlatListBox;
1.23 chkPassive: TFlatCheckBox;
1.24 lblStep3: TLabel;
1.25 pnlOS: TPanel;
1.26 @@ -99,6 +98,9 @@
1.27 frbStandaloneServer: TFlatRadioButton;
1.28 tmrSpeed: TTimer;
1.29 IdLogFile: TIdLogFile;
1.30 + shpMods: TShape;
1.31 + trvMods: TTreeView;
1.32 + FlatRadioButton1: TFlatRadioButton;
1.33 procedure jvwStepsCancelButtonClick(Sender: TObject);
1.34 procedure cmdCancelClick(Sender: TObject);
1.35 procedure cmdNextClick(Sender: TObject);
1.36 @@ -107,7 +109,6 @@
1.37 procedure cmdConnectClick(Sender: TObject);
1.38 procedure jplWizardChange(Sender: TObject);
1.39 procedure FormCreate(Sender: TObject);
1.40 - procedure lstModsClick(Sender: TObject);
1.41 procedure cmdProxySettingsClick(Sender: TObject);
1.42 procedure txtPortChange(Sender: TObject);
1.43 procedure trvDirectoriesExpanded(Sender: TObject; Node: TTreeNode);
1.44 @@ -120,6 +121,7 @@
1.45 var AllowExpansion: Boolean);
1.46 procedure trvDirectoriesCollapsing(Sender: TObject; Node: TTreeNode;
1.47 var AllowCollapse: Boolean);
1.48 + procedure trvModsClick(Sender: TObject);
1.49 private
1.50 OldProgress: Integer;
1.51 CurrProgress: Integer;
1.52 @@ -130,7 +132,7 @@
1.53 var
1.54 frmMain: TfrmMain;
1.55
1.56 -var VERSION: String = '1.2.3';
1.57 +var VERSION: String = '1.2.4';
1.58
1.59 implementation
1.60
1.61 @@ -154,6 +156,7 @@
1.62 eStr: TStringList;
1.63 CurNode: TTreeNode;
1.64 eOS: TOS;
1.65 + i: integer;
1.66 begin
1.67 { FTP }
1.68 if jplWizard.ActivePage = jspFTP then begin
1.69 @@ -198,55 +201,58 @@
1.70 else if jplWizard.ActivePage = jspSelectMod then begin
1.71 { Dedicated Server }
1.72 if (frbDedicatedServer.Checked) or (frbStandaloneServer.Checked) then begin
1.73 - jspInstallProgress.Show;
1.74 - ePath := lstMods.Items[lstMods.ItemIndex];
1.75 + ePath := trvMods.Selected.Text;
1.76 if ePath = 'Counter-Strike:Source' then
1.77 ePath := 'cstrike'
1.78 else if ePath = 'Day of Defeat:Source' then
1.79 ePath := 'dod'
1.80 else
1.81 ePath := 'hl2mp';
1.82 + ePath := 'SteamApps\' + trvMods.Selected.Parent.Text + '\source dedicated server\' + ePath;
1.83 // install it
1.84 if frbDedicatedServer.Checked then begin
1.85 - if DirectoryExists(SteamPath + ePath) then
1.86 - InstallDedicated(IncludeTrailingPathDelimiter(SteamPath + ePath), True)
1.87 + if DirectoryExists(SteamPath + ePath) then begin
1.88 + jspInstallProgress.Show;
1.89 + InstallDedicated(IncludeTrailingPathDelimiter(SteamPath + ePath), True);
1.90 + end
1.91 else begin
1.92 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);
1.93 - Application.Terminate;
1.94 + jspSelectMod.Show;
1.95 exit;
1.96 end;
1.97 end
1.98 else begin
1.99 - if DirectoryExists(StandaloneServer + ePath) then
1.100 + if DirectoryExists(StandaloneServer + ePath) then begin
1.101 + jspInstallProgress.Show;
1.102 InstallDedicated(IncludeTrailingPathDelimiter(StandaloneServer + ePath), False)
1.103 + end
1.104 else begin
1.105 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);
1.106 - Application.Terminate;
1.107 + jspSelectMod.Show;
1.108 exit;
1.109 end;
1.110 end;
1.111 end;
1.112 { Listen Server }
1.113 if frbListenServer.Checked then begin
1.114 - ePath := lstMods.Items[lstMods.ItemIndex];
1.115 + ePath := trvMods.Selected.Text;
1.116 if ePath = 'Counter-Strike:Source' then
1.117 - ePath := SteamPath + 'counter-strike source\cstrike'
1.118 + ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\counter-strike source\cstrike'
1.119 else if ePath = 'Half-Life 2 Deathmatch' then
1.120 - ePath := SteamPath + 'half-life 2 deathmatch\hl2mp'
1.121 + ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\half-life 2 deathmatch\hl2mp'
1.122 else
1.123 - ePath := SteamPath + 'Day Of Defeat source\dod';
1.124 + ePath := SteamPath + 'SteamApps\' + trvMods.Selected.Parent.Text + '\day of defeat source\dod';
1.125
1.126 if Pos(SteamPath, ePath) = 0 then
1.127 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)
1.128 else begin
1.129 - if not FileExists(ePath + '\gameinfo.txt') then begin
1.130 - MessageBox(Handle, 'You have to play this game once before installing Metamod:Source. Do this and try again.', PChar(Application.Title), MB_ICONWARNING);
1.131 + if not FileExists(ePath + '\gameinfo.txt') then begin
1.132 + MessageBox(Handle, 'You have to play this game once before installing Metamod:Source. Do that and try again.', PChar(Application.Title), MB_ICONWARNING);
1.133 exit;
1.134 end;
1.135
1.136 jspInstallProgress.Show;
1.137 - ePath := IncludeTrailingPathDelimiter(ePath);
1.138 - InstallListen(ePath);
1.139 + InstallListen(IncludeTrailingPathDelimiter(ePath));
1.140 end;
1.141 end;
1.142 { Custom mod below }
1.143 @@ -259,21 +265,33 @@
1.144 try
1.145 eRegistry.RootKey := HKEY_CURRENT_USER;
1.146 if eRegistry.OpenKey('Software\Valve\Steam', False) then begin
1.147 - ePath := eRegistry.ReadString('ModInstallPath');
1.148 - ePath := Copy(ePath, 1, Length(ePath) -10) + '\source dedicated server\';
1.149 + ePath := eRegistry.ReadString('SteamPath');
1.150 + ePath := IncludeTrailingPathDelimiter(StringReplace(ePath, '/', '\', [rfReplaceAll]));
1.151 + SteamPath := ePath;
1.152 +
1.153 + ePath := ePath + 'SteamApps\';
1.154 if DirectoryExists(ePath) then begin
1.155 - SteamPath := ePath;
1.156 - lstMods.Clear;
1.157 + trvMods.Items.Clear;
1.158 // Check Mods
1.159 - if DirectoryExists(SteamPath + 'cstrike') then
1.160 - lstMods.Items.Add('Counter-Strike:Source');
1.161 - if DirectoryExists(SteamPath + 'dod') then
1.162 - lstMods.Items.Add('Day of Defeat:Source');
1.163 - if DirectoryExists(SteamPath + 'hl2mp') then
1.164 - lstMods.Items.Add('Half-Life 2 Deatmatch');
1.165 + eStr := GetAllFiles(ePath + '*.*', faDirectory, False, True, False);
1.166 + for i := 0 to eStr.Count -1 do begin
1.167 + CurNode := trvMods.Items.Add(nil, eStr[i]);
1.168 +
1.169 + if DirectoryExists(ePath + eStr[i] + '\source dedicated server\cstrike') then
1.170 + trvMods.Items.AddChild(CurNode, 'Counter-Strike:Source');
1.171 + if DirectoryExists(ePath + eStr[i] + '\source dedicated server\dod') then
1.172 + trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source');
1.173 + if DirectoryExists(ePath + eStr[i] + '\source dedicated server\hl2mp') then
1.174 + trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch');
1.175 +
1.176 + if CurNode.Count = 0 then
1.177 + CurNode.Free
1.178 + else
1.179 + CurNode.Expand(False);
1.180 + end;
1.181 // Misc
1.182 jspSelectMod.Show;
1.183 - lstMods.ItemIndex := -1;
1.184 + trvMods.Selected := nil;
1.185 cmdNext.Enabled := False;
1.186 end
1.187 else
1.188 @@ -290,21 +308,33 @@
1.189 try
1.190 eRegistry.RootKey := HKEY_CURRENT_USER;
1.191 if eRegistry.OpenKey('Software\Valve\Steam', False) then begin
1.192 - ePath := eRegistry.ReadString('ModInstallPath') + '\';
1.193 - lstMods.Clear;
1.194 - ePath := Copy(ePath, 1, Length(ePath) -10);
1.195 + ePath := eRegistry.ReadString('SteamPath');
1.196 + ePath := IncludeTrailingPathDelimiter(StringReplace(ePath, '/', '\', [rfReplaceAll]));
1.197 + SteamPath := ePath;
1.198 +
1.199 + ePath := ePath + 'SteamApps\';
1.200 if DirectoryExists(ePath) then begin
1.201 - SteamPath := ePath;
1.202 + trvMods.Items.Clear;
1.203 // Check Mods
1.204 - if DirectoryExists(SteamPath + 'counter-strike source') then
1.205 - lstMods.Items.Add('Counter-Strike:Source');
1.206 - if DirectoryExists(SteamPath + 'half-life 2 deathmatch') then
1.207 - lstMods.Items.Add('Half-Life 2 Deathmatch');
1.208 - if DirectoryExists(SteamPath + 'Day Of Defeat source') then
1.209 - lstMods.Items.Add('Day of Defeat: Source');
1.210 + eStr := GetAllFiles(ePath + '*.*', faDirectory, False, True, False);
1.211 + for i := 0 to eStr.Count -1 do begin
1.212 + CurNode := trvMods.Items.Add(nil, eStr[i]);
1.213 +
1.214 + if DirectoryExists(ePath + eStr[i] + '\counter-strike source') then
1.215 + trvMods.Items.AddChild(CurNode, 'Counter-Strike:Source');
1.216 + if DirectoryExists(ePath + eStr[i] + '\day of defeat source') then
1.217 + trvMods.Items.AddChild(CurNode, 'Day of Defeat:Source');
1.218 + if DirectoryExists(ePath + eStr[i] + '\half-life 2 deathmatch') then
1.219 + trvMods.Items.AddChild(CurNode, 'Half-Life 2 Deatmatch');
1.220 +
1.221 + if CurNode.Count = 0 then
1.222 + CurNode.Free
1.223 + else
1.224 + CurNode.Expand(False);
1.225 + end;
1.226 // Misc
1.227 jspSelectMod.Show;
1.228 - lstMods.ItemIndex := -1;
1.229 + trvMods.Selected := nil;
1.230 cmdNext.Enabled := False;
1.231 end
1.232 else
1.233 @@ -323,12 +353,13 @@
1.234 if eRegistry.OpenKey('Software\Valve\HLServer', False) then begin
1.235 StandaloneServer := IncludeTrailingPathDelimiter(eRegistry.ReadString('InstallPath'));
1.236 if DirectoryExists(StandaloneServer + 'cstrike') then
1.237 - lstMods.Items.Add('Counter-Strike:Source');
1.238 + trvMods.Items.Add(nil, 'Counter-Strike:Source');
1.239 if DirectoryExists(StandaloneServer + 'dod') then
1.240 - lstMods.Items.Add('Day of Defeat:Source');
1.241 + trvMods.Items.Add(nil, 'Day of Defeat:Source');
1.242 if DirectoryExists(StandaloneServer + 'hl2mp') then
1.243 - lstMods.Items.Add('Half-Life 2 Deatmatch');
1.244 + trvMods.Items.Add(nil, 'Half-Life 2 Deatmatch');
1.245 jspSelectMod.Show;
1.246 + cmdNext.Enabled := False;
1.247 end
1.248 else
1.249 MessageBox(Handle, 'You haven''t installed Half-Life Dedicated Server yet!', 'Error', MB_ICONWARNING);
1.250 @@ -512,11 +543,6 @@
1.251 rtfDetails.Clear;
1.252 end;
1.253
1.254 -procedure TfrmMain.lstModsClick(Sender: TObject);
1.255 -begin
1.256 - cmdNext.Enabled := lstMods.ItemIndex <> -1;
1.257 -end;
1.258 -
1.259 procedure TfrmMain.cmdProxySettingsClick(Sender: TObject);
1.260 begin
1.261 frmProxy.ShowModal;
1.262 @@ -648,4 +674,12 @@
1.263 Node.SelectedIndex := 0;
1.264 end;
1.265
1.266 +procedure TfrmMain.trvModsClick(Sender: TObject);
1.267 +begin
1.268 + if Assigned(trvMods.Selected) then
1.269 + cmdNext.Enabled := Assigned(trvMods.Selected.Parent)
1.270 + else
1.271 + cmdNext.Enabled := False;
1.272 +end;
1.273 +
1.274 end.