Skip to content

Commit f8dba98

Browse files
committed
- improved detection of Quake Live directory when it's installed outside the standard steam folder.
(Only works when extraQL is started from the workshop item folder.)
1 parent 144382a commit f8dba98

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ c:\program files (x86)\Steam\SteamApps\workshop\content\282440\539252269
1414
Changelog
1515
=========
1616

17+
Version 2.16
18+
---
19+
- improved detection of Quake Live directory when it's installed outside the standard steam folder.
20+
(Only works when extraQL is started from the workshop item folder.)
21+
1722
Version 2.15
1823
---
1924
- improved forwarding focus to an already running QL window when re-starting extraQL with enabled option to auto-start QL

source/MainForm.cs

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace ExtraQL
1212
{
1313
public partial class MainForm : Form
1414
{
15-
public const string Version = "2.15";
15+
public const string Version = "2.16";
1616

1717
private readonly Config config;
1818
private readonly HttpServer server;
@@ -781,36 +781,59 @@ private void InstallJavaScripts(string folder, bool install)
781781
#endregion
782782

783783
#region GetQuakeLivePath()
784+
785+
private delegate string StrFunc();
786+
784787
private string GetQuakeLivePath()
785788
{
786-
string path;
787-
if (this.txtSteamExe.Text != "")
789+
var methods = new StrFunc[] {GetQuakeLivePathFromTextField, GetQuakeLivePathFromExtraQlPath, GetQuakeLivePathFromRegisty };
790+
791+
foreach (var method in methods)
788792
{
789793
try
790794
{
791-
path = this.txtSteamExe.Text;
792-
if (Directory.Exists(path))
795+
var path = method();
796+
if (File.Exists(path))
793797
{
794-
if (!path.EndsWith("/") && !path.EndsWith("\\"))
795-
path += "quakelive_steam.exe";
798+
path = Path.GetDirectoryName(path);
799+
return path;
796800
}
797801
}
798802
catch
799803
{
800-
return null;
801804
}
802805
}
803-
else
806+
return null;
807+
}
808+
809+
private string GetQuakeLivePathFromTextField()
810+
{
811+
if (this.txtSteamExe.Text != "")
804812
{
805-
path = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath", null) as string;
806-
if (path != null)
807-
path = path.Replace("/", "\\") + @"\SteamApps\Common\Quake Live\quakelive_steam.exe";
813+
var path = this.txtSteamExe.Text;
814+
if (Directory.Exists(path))
815+
{
816+
if (!path.EndsWith("/") && !path.EndsWith("\\"))
817+
path += "quakelive_steam.exe";
818+
}
819+
return path;
808820
}
821+
return null;
822+
}
809823

810-
if (!File.Exists(path))
811-
return null;
812-
path = Path.GetDirectoryName(path);
813-
//Log("Quake Live folder: " + path);
824+
private string GetQuakeLivePathFromExtraQlPath()
825+
{
826+
var path = this.GetType().Assembly.Location;
827+
for (int i = 0; i < 5; i++)
828+
path = Path.GetDirectoryName(path) ?? "";
829+
return Path.Combine(path, @"common\Quake Live\quakelive_steam.exe");
830+
}
831+
832+
private string GetQuakeLivePathFromRegisty()
833+
{
834+
var path = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath", null) as string;
835+
if (path != null)
836+
path = path.Replace("/", "\\") + @"\SteamApps\Common\Quake Live\quakelive_steam.exe";
814837
return path;
815838
}
816839

@@ -829,7 +852,6 @@ private string GetConfigFolder()
829852
if (Regex.IsMatch(Path.GetFileName(dir) ?? "", "\\d{5,}"))
830853
{
831854
var path = Path.Combine(dir, "baseq3");
832-
//Log("Config folder: " + path);
833855
return path;
834856
}
835857
}
@@ -840,7 +862,10 @@ private string GetConfigFolder()
840862
#region GetSteamWorkshopPath()
841863
private string GetSteamWorkshopPath()
842864
{
843-
var path = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(this.GetQuakeLivePath())) ?? "", @"workshop\content\" + QuakeLiveAppId + "\\" + WorkshopExtraQL);
865+
var qlPath = this.GetQuakeLivePath();
866+
if (qlPath == null)
867+
return null;
868+
var path = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(qlPath)) ?? "", @"workshop\content\" + QuakeLiveAppId + "\\" + WorkshopExtraQL);
844869
return path;
845870
}
846871
#endregion
@@ -911,9 +936,9 @@ private void SetFormVisibility(bool visible)
911936
{
912937
if (visible)
913938
{
939+
this.Show();
914940
this.WindowState = FormWindowState.Normal;
915941
this.BringToFront();
916-
this.Show();
917942
this.Activate();
918943
}
919944
else

workshop/extraQL.vdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"previewfile" "d:\sources\extraQL\workshop\extraQL1.png"
77
"visibility" "0"
88
"title" "extraQL userscripts"
9-
"changenote" "https://github.com/PredatH0r/extraQL/releases/tag/v2.13"
9+
"changenote" "https://github.com/PredatH0r/extraQL/releases/tag/v2.16"
1010
}

0 commit comments

Comments
 (0)