Skip to content

Commit

Permalink
- improved detection of Quake Live directory when it's installed outs…
Browse files Browse the repository at this point in the history
…ide the standard steam folder.

  (Only works when extraQL is started from the workshop item folder.)
  • Loading branch information
PredatH0r committed Nov 27, 2015
1 parent 144382a commit f8dba98
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 44 additions & 19 deletions source/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand All @@ -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
Expand Down Expand Up @@ -911,9 +936,9 @@ private void SetFormVisibility(bool visible)
{
if (visible)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.BringToFront();
this.Show();
this.Activate();
}
else
Expand Down
2 changes: 1 addition & 1 deletion workshop/extraQL.vdf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit f8dba98

Please sign in to comment.