diff --git a/readme.md b/readme.md index 2dbb654..c59aa5d 100644 --- a/readme.md +++ b/readme.md @@ -14,6 +14,11 @@ c:\program files (x86)\Steam\SteamApps\workshop\content\282440\539252269 Changelog ========= +Version 2.16 +--- +- 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.) + Version 2.15 --- - improved forwarding focus to an already running QL window when re-starting extraQL with enabled option to auto-start QL diff --git a/source/MainForm.cs b/source/MainForm.cs index 79cf47e..ff5b163 100644 --- a/source/MainForm.cs +++ b/source/MainForm.cs @@ -12,7 +12,7 @@ namespace ExtraQL { public partial class MainForm : Form { - public const string Version = "2.15"; + public const string Version = "2.16"; private readonly Config config; private readonly HttpServer server; @@ -781,36 +781,59 @@ private void InstallJavaScripts(string folder, bool install) #endregion #region GetQuakeLivePath() + + private delegate string StrFunc(); + private string GetQuakeLivePath() { - string path; - if (this.txtSteamExe.Text != "") + var methods = new StrFunc[] {GetQuakeLivePathFromTextField, GetQuakeLivePathFromExtraQlPath, GetQuakeLivePathFromRegisty }; + + foreach (var method in methods) { try { - path = this.txtSteamExe.Text; - if (Directory.Exists(path)) + var path = method(); + if (File.Exists(path)) { - if (!path.EndsWith("/") && !path.EndsWith("\\")) - path += "quakelive_steam.exe"; + path = Path.GetDirectoryName(path); + return path; } } catch { - return null; } } - else + return null; + } + + private string GetQuakeLivePathFromTextField() + { + if (this.txtSteamExe.Text != "") { - path = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath", null) as string; - if (path != null) - path = path.Replace("/", "\\") + @"\SteamApps\Common\Quake Live\quakelive_steam.exe"; + var path = this.txtSteamExe.Text; + if (Directory.Exists(path)) + { + if (!path.EndsWith("/") && !path.EndsWith("\\")) + path += "quakelive_steam.exe"; + } + return path; } + return null; + } - if (!File.Exists(path)) - return null; - path = Path.GetDirectoryName(path); - //Log("Quake Live folder: " + path); + private string GetQuakeLivePathFromExtraQlPath() + { + var path = this.GetType().Assembly.Location; + for (int i = 0; i < 5; i++) + path = Path.GetDirectoryName(path) ?? ""; + return Path.Combine(path, @"common\Quake Live\quakelive_steam.exe"); + } + + private string GetQuakeLivePathFromRegisty() + { + var path = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath", null) as string; + if (path != null) + path = path.Replace("/", "\\") + @"\SteamApps\Common\Quake Live\quakelive_steam.exe"; return path; } @@ -829,7 +852,6 @@ private string GetConfigFolder() if (Regex.IsMatch(Path.GetFileName(dir) ?? "", "\\d{5,}")) { var path = Path.Combine(dir, "baseq3"); - //Log("Config folder: " + path); return path; } } @@ -840,7 +862,10 @@ private string GetConfigFolder() #region GetSteamWorkshopPath() private string GetSteamWorkshopPath() { - var path = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(this.GetQuakeLivePath())) ?? "", @"workshop\content\" + QuakeLiveAppId + "\\" + WorkshopExtraQL); + var qlPath = this.GetQuakeLivePath(); + if (qlPath == null) + return null; + var path = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(qlPath)) ?? "", @"workshop\content\" + QuakeLiveAppId + "\\" + WorkshopExtraQL); return path; } #endregion @@ -911,9 +936,9 @@ private void SetFormVisibility(bool visible) { if (visible) { + this.Show(); this.WindowState = FormWindowState.Normal; this.BringToFront(); - this.Show(); this.Activate(); } else diff --git a/workshop/extraQL.vdf b/workshop/extraQL.vdf index 735723e..f26cedf 100644 --- a/workshop/extraQL.vdf +++ b/workshop/extraQL.vdf @@ -6,5 +6,5 @@ "previewfile" "d:\sources\extraQL\workshop\extraQL1.png" "visibility" "0" "title" "extraQL userscripts" - "changenote" "https://github.com/PredatH0r/extraQL/releases/tag/v2.13" + "changenote" "https://github.com/PredatH0r/extraQL/releases/tag/v2.16" }