Skip to content

Commit

Permalink
finding gamepath from epic launcher (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingalek authored Jan 8, 2020
1 parent e1bd5b1 commit b35af6f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion OWML.Launcher/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace OWML.Launcher
{
public class App
{
private const string Version = "0.3.18";
private const string Version = "0.3.19";

private readonly IOwmlConfig _owmlConfig;
private readonly IModConsole _writer;
Expand Down
32 changes: 29 additions & 3 deletions OWML.Launcher/PathFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using Microsoft.Win32;
using Newtonsoft.Json;
using OWML.Common;

namespace OWML.Launcher
Expand Down Expand Up @@ -61,9 +62,28 @@ private string FindInDefaultFolders()

private string FindInRegistry()
{
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Outer Wilds_is1");
var value = (string)key?.GetValue("InstallLocation");
return IsValidGamePath(value) ? value : null;
var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Epic Games\EpicGamesLauncher");
var appDataPath = (string)key?.GetValue("AppDataPath");
if (string.IsNullOrEmpty(appDataPath))
{
return null;
}
var manifestsPath = appDataPath + "Manifests";
if (!Directory.Exists(manifestsPath))
{
return null;
}
var manifestPaths = Directory.GetFiles(manifestsPath, "*.item", SearchOption.TopDirectoryOnly);
foreach (var manifestPath in manifestPaths)
{
var json = File.ReadAllText(manifestPath);
var epicManifest = JsonConvert.DeserializeObject<EpicManifest>(json);
if (epicManifest.InstallLocation.Contains("OuterWilds") && IsValidGamePath(epicManifest.InstallLocation))
{
return epicManifest.InstallLocation;
}
}
return null;
}

private string PromptGamePath()
Expand All @@ -87,5 +107,11 @@ private bool IsValidGamePath(string gamePath)
File.Exists($"{gamePath}/OuterWilds.exe");
}

public class EpicManifest
{
[JsonProperty("InstallLocation")]
public string InstallLocation { get; set; }
}

}
}
2 changes: 1 addition & 1 deletion OWML.SampleMods/OWML.EnableDebugMode/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"name": "EnableDebugMode",
"uniqueName": "Alek.EnableDebugMode",
"version": "0.2",
"owmlVersion": "0.3.18",
"owmlVersion": "0.3.19",
"enabled": false
}
2 changes: 1 addition & 1 deletion OWML.SampleMods/OWML.LoadCustomAssets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"name": "LoadCustomAssets",
"uniqueName": "Alek.LoadCustomAssets",
"version": "0.4",
"owmlVersion": "0.3.18",
"owmlVersion": "0.3.19",
"enabled": false
}

0 comments on commit b35af6f

Please sign in to comment.