mirror of
https://github.com/psforever/GameLauncher.git
synced 2026-01-19 18:24:45 +00:00
Fix path ordering bug
EXE discovery is now ordered from newest to oldest.
This commit is contained in:
parent
d67413195c
commit
fce71df0f3
|
|
@ -46,15 +46,16 @@ namespace PSLauncher
|
||||||
Dictionary<LaunchDomain, string> domains = new Dictionary<LaunchDomain, string>()
|
Dictionary<LaunchDomain, string> domains = new Dictionary<LaunchDomain, string>()
|
||||||
{
|
{
|
||||||
{ LaunchDomain.Live, "https://lpj.daybreakgames.com/ps/live" },
|
{ LaunchDomain.Live, "https://lpj.daybreakgames.com/ps/live" },
|
||||||
{ LaunchDomain.PSForever, "https://login.psforever.net/" }
|
{ LaunchDomain.PSForever, "https://login.psforever.net/psf/live/login" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public LauncherForm()
|
public LauncherForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
#if DEBUG
|
||||||
//if (Debugger.IsAttached)
|
Settings.Default.Reset();
|
||||||
// Settings.Default.Reset();
|
Console.SetOut(new Util.ControlWriter(this.ps_consoleOutput));
|
||||||
|
#endif
|
||||||
|
|
||||||
string psDefault = Util.getDefaultPlanetSideDirectory();
|
string psDefault = Util.getDefaultPlanetSideDirectory();
|
||||||
|
|
||||||
|
|
@ -163,7 +164,7 @@ namespace PSLauncher
|
||||||
|
|
||||||
if (!Util.checkDirForPlanetSide(path))
|
if (!Util.checkDirForPlanetSide(path))
|
||||||
{
|
{
|
||||||
setErrorMessage("Invalid planetside exe");
|
setErrorMessage("Invalid " + SettingsForm.PS_EXE_NAME);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -477,7 +478,7 @@ namespace PSLauncher
|
||||||
JObject obj = JObject.Parse(text);
|
JObject obj = JObject.Parse(text);
|
||||||
result = (string)obj["result"];
|
result = (string)obj["result"];
|
||||||
token = (string)obj["launchArgs"];
|
token = (string)obj["launchArgs"];
|
||||||
addLine(text);
|
//addLine(text);
|
||||||
}
|
}
|
||||||
catch (Newtonsoft.Json.JsonException x2)
|
catch (Newtonsoft.Json.JsonException x2)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace PSLauncher
|
namespace PSLauncher
|
||||||
{
|
{
|
||||||
|
|
@ -57,43 +58,67 @@ namespace PSLauncher
|
||||||
{
|
{
|
||||||
public static string getDefaultPlanetSideDirectory()
|
public static string getDefaultPlanetSideDirectory()
|
||||||
{
|
{
|
||||||
|
// paths are in order of newest (most likely to have the right planetside) to oldest
|
||||||
Microsoft.Win32.RegistryKey key = null;
|
Microsoft.Win32.RegistryKey key = null;
|
||||||
string psFolder = "";
|
string psFolder = "";
|
||||||
|
List<string> pathsToCheck = new List<String>();
|
||||||
|
|
||||||
// non-steam install
|
// non-steam install
|
||||||
|
// Known to be: C:\Users\Public\Daybreak Game Company\Installed Games\PlanetSide 2 Test\LaunchPad.exe
|
||||||
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\LaunchPad.exe");
|
key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\LaunchPad.exe");
|
||||||
|
|
||||||
if (key != null && key.GetValue("") != null)
|
if (key != null && key.GetValue("") != null)
|
||||||
{
|
{
|
||||||
String defaultDirectory;
|
String defaultDirectory;
|
||||||
defaultDirectory = key.GetValue("").ToString();
|
defaultDirectory = key.GetValue("").ToString();
|
||||||
|
|
||||||
|
Console.WriteLine("LaunchPad.exe key found {0}", defaultDirectory);
|
||||||
|
|
||||||
defaultDirectory = Path.GetDirectoryName(defaultDirectory);
|
defaultDirectory = Path.GetDirectoryName(defaultDirectory);
|
||||||
|
|
||||||
// verify that we aren't mistakingly returning a PlanetSide 2 directory...
|
// verify that we aren't mistakingly returning a PlanetSide 2 directory...
|
||||||
if (Directory.Exists(defaultDirectory) && checkDirForPlanetSide(defaultDirectory))
|
pathsToCheck.Add(defaultDirectory);
|
||||||
return defaultDirectory;
|
|
||||||
|
|
||||||
// try to go up a directory and find the PlanetSide folder
|
// try to go up a directory and find the PlanetSide folder
|
||||||
string upOne = Directory.GetParent(defaultDirectory).FullName;
|
string upOne = Directory.GetParent(defaultDirectory).FullName;
|
||||||
psFolder = Path.Combine(upOne, "Planetside");
|
psFolder = Path.Combine(upOne, "Planetside");
|
||||||
|
|
||||||
if (Directory.Exists(psFolder) && checkDirForPlanetSide(psFolder))
|
pathsToCheck.Add(psFolder);
|
||||||
return psFolder;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("No LaunchPad.exe key found");
|
||||||
}
|
}
|
||||||
|
|
||||||
// worth a shot!
|
// HACK: Should work on Win7 and above
|
||||||
psFolder = Path.Combine(ProgramFilesx86(), "Sony\\PlanetSide");
|
psFolder = "C:\\Users\\Public\\Daybreak Game Company\\Installed Games\\Planetside";
|
||||||
|
pathsToCheck.Add(psFolder);
|
||||||
if (Directory.Exists(psFolder) && checkDirForPlanetSide(psFolder))
|
|
||||||
return psFolder;
|
// HACK 2: our last attempt
|
||||||
|
|
||||||
// HACK: our last attempt. Should work on Win7 and above with and updated launcher
|
|
||||||
psFolder = "C:\\Users\\Public\\Sony Online Entertainment\\Installed Games\\Planetside";
|
psFolder = "C:\\Users\\Public\\Sony Online Entertainment\\Installed Games\\Planetside";
|
||||||
|
pathsToCheck.Add(psFolder);
|
||||||
|
|
||||||
if (Directory.Exists(psFolder) && checkDirForPlanetSide(psFolder))
|
// worth a shot! (for windows XP or old installs)
|
||||||
return psFolder;
|
psFolder = Path.Combine(ProgramFilesx86(), "Sony\\PlanetSide");
|
||||||
|
pathsToCheck.Add(psFolder);
|
||||||
|
|
||||||
// give up
|
int i = 1;
|
||||||
|
foreach(var path in pathsToCheck)
|
||||||
|
{
|
||||||
|
Console.WriteLine("M{0} - {1}", i, path);
|
||||||
|
|
||||||
|
if (Directory.Exists(path) && checkDirForPlanetSide(path))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Path found using M{0}", i);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("No default planetside.exe path found");
|
||||||
|
|
||||||
|
// give up :'(
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,5 +137,30 @@ namespace PSLauncher
|
||||||
|
|
||||||
return Environment.GetEnvironmentVariable("ProgramFiles");
|
return Environment.GetEnvironmentVariable("ProgramFiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from https://stackoverflow.com/questions/18726852/redirecting-console-writeline-to-textbox
|
||||||
|
public class ControlWriter : TextWriter
|
||||||
|
{
|
||||||
|
private Control textbox;
|
||||||
|
public ControlWriter(Control textbox)
|
||||||
|
{
|
||||||
|
this.textbox = textbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(char value)
|
||||||
|
{
|
||||||
|
textbox.Text += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(string value)
|
||||||
|
{
|
||||||
|
textbox.Text += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Encoding Encoding
|
||||||
|
{
|
||||||
|
get { return Encoding.ASCII; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue