Skip to content

Commit f80d217

Browse files
committed
Add Epic Games Store finder
1 parent 0cc44a6 commit f80d217

4 files changed

Lines changed: 75 additions & 2 deletions

File tree

Everest.Installer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<Compile Include="src\CustomControls\CustomTextBox.cs">
8585
<SubType>Component</SubType>
8686
</Compile>
87+
<Compile Include="src\Finders\EpicFinder.cs" />
8788
<Compile Include="src\Finders\LocalFinder.cs" />
8889
<Compile Include="src\Infos\EverestInfo.Installer.cs" />
8990
<Compile Include="src\ProgressShapes.cs" />

Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@
3434
// You can specify all the values or you can default the Build and Revision Numbers
3535
// by using the '*' as shown below:
3636
// [assembly: AssemblyVersion("1.0.*")]
37-
[assembly: AssemblyVersion("19.03.0.*")]
37+
[assembly: AssemblyVersion("19.08.0.*")]
3838
[assembly: AssemblyFileVersion("1.0.0.0")]

src/Finders/EpicFinder.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using Microsoft.Win32;
2+
using MonoMod.Utils;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Text.RegularExpressions;
9+
10+
namespace MonoMod.Installer {
11+
public class EpicFinder : GameFinder {
12+
13+
// "" -> "
14+
public readonly static Regex DisplayNameRegex = new Regex(@"\s*""DisplayName"": ""(.*)"",", RegexOptions.Compiled);
15+
public readonly static Regex InstallLocationRegex = new Regex(@"\s*""InstallLocation"": ""(.*)"",", RegexOptions.Compiled);
16+
17+
public override string ID => "epic";
18+
19+
public override string FindGameDir(string gameid) {
20+
if ((PlatformHelper.Current & Platform.Windows) != Platform.Windows)
21+
return null;
22+
23+
string regKey =
24+
(PlatformHelper.Current & Platform.X64) == Platform.X64 ?
25+
@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Epic Games\EpicGamesLauncher" :
26+
@"HKEY_LOCAL_MACHINE\SOFTWARE\Epic Games\EpicGamesLauncher";
27+
// Win32 is case-insensitive.
28+
string appdata = (string) Registry.GetValue(regKey, "AppDataPath", null);
29+
if (!Directory.Exists(appdata))
30+
return null;
31+
32+
// path ends up pointing to f.e. C:\ProgramData\Epic\EpicGamesLauncher\Data\
33+
// Manifest .item (pretty much .json) files are stored in the Manifests subdir.
34+
// The filenames sadly aren't consistent across machines / accounts,
35+
// meaning that we'll need to crawl through them to find the right one.
36+
37+
string manifests = Path.Combine(appdata, "Manifests");
38+
if (!Directory.Exists(manifests))
39+
return null;
40+
41+
foreach (string manifest in Directory.GetFiles(manifests)) {
42+
if (!manifest.EndsWith(".item", StringComparison.InvariantCultureIgnoreCase))
43+
continue;
44+
45+
string displayName = null;
46+
string installLocation = null;
47+
48+
using (StreamReader reader = new StreamReader(manifest))
49+
while (!reader.EndOfStream) {
50+
string line = reader.ReadLine().Trim();
51+
Match match;
52+
53+
match = DisplayNameRegex.Match(line);
54+
if (match.Success)
55+
displayName = Regex.Unescape(match.Groups[1].Value);
56+
57+
match = InstallLocationRegex.Match(line);
58+
if (match.Success)
59+
installLocation = Regex.Unescape(match.Groups[1].Value);
60+
}
61+
62+
if (!string.IsNullOrEmpty(displayName) && gameid.Equals(displayName, StringComparison.InvariantCultureIgnoreCase) &&
63+
!string.IsNullOrEmpty(installLocation) && Directory.Exists(installLocation))
64+
return installLocation;
65+
}
66+
67+
return null;
68+
}
69+
70+
}
71+
}

src/Infos/EverestInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public override Dictionary<string, string> GameIDs {
7777
get {
7878
return new Dictionary<string, string>() {
7979
{ "local", "Celeste.exe" },
80-
{ "steam", "Celeste" }
80+
{ "steam", "Celeste" },
81+
{ "epic", "Celeste" }
8182
};
8283
}
8384
}

0 commit comments

Comments
 (0)