Skip to content

Commit 72115c3

Browse files
Add Unleashed Recomp support
1 parent 546176b commit 72115c3

9 files changed

Lines changed: 151 additions & 2 deletions

File tree

26 KB
Loading

Source/HedgeModManager.UI/GameBanana.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public static class GameBanana
88
{
99
public static readonly Dictionary<string, string[]> GameIDMappings = new()
1010
{
11+
{ "hedgemmswa", [ "UnleashedRecompiled" ] },
1112
{ "hedgemmgens", [ "SonicGenerations" ] },
1213
{ "hedgemmlw", [ "SonicLostWorld" ] },
1314
{ "hedgemmforces", [ "SonicForces" ] },

Source/HedgeModManager.UI/Languages/en-AU.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<system:String x:Key="Common.Program.Sub">A program designed to assist with loading Hedgehog Engine mods.</system:String>
88

99
<!-- Common Game -->
10+
<system:String x:Key="Common.Game.UnleashedRecompiled" >Unleashed Recompiled</system:String>
1011
<system:String x:Key="Common.Game.SonicGenerations" >Sonic Generations (2011)</system:String>
1112
<system:String x:Key="Common.Game.SonicLostWorld" >Sonic Lost World</system:String>
1213
<system:String x:Key="Common.Game.SonicForces" >Sonic Forces</system:String>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using HedgeModManager.Foundation;
2+
using System.Diagnostics;
3+
4+
namespace HedgeModManager;
5+
6+
public class GameSimple(string platform, string id, string name, string root, string? executable, string nativeOS, string launchCommand, string launchCommandArgs) : IGame
7+
{
8+
public string Platform { get; set; } = platform;
9+
public string ID { get; set; } = id;
10+
public string Name { get; set; } = name;
11+
public string Root { get; set; } = root;
12+
public string? Executable { get; set; } = executable;
13+
public string NativeOS { get; set; } = nativeOS;
14+
public string? PrefixRoot { get; set; } = null;
15+
public string LaunchCommand { get; set; } = launchCommand;
16+
public string LaunchCommandArgs { get; set; } = launchCommandArgs;
17+
public bool SupportsDirectLaunch { get; set; }
18+
public bool SupportsLauncher { get; set; }
19+
20+
public Task Run(string? launchArgs, bool useLauncher)
21+
{
22+
launchArgs ??= LaunchCommandArgs;
23+
24+
Process.Start(new ProcessStartInfo
25+
{
26+
FileName = LaunchCommand,
27+
Arguments = launchArgs ?? string.Empty,
28+
WorkingDirectory = Root,
29+
UseShellExecute = true
30+
});
31+
32+
return Task.CompletedTask;
33+
}
34+
}

Source/HedgeModManager/ModGeneric.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,18 @@ public ModGeneric(string root)
3939

4040
public void Parse(Ini file)
4141
{
42-
if (file.TryGetValue("Desc", out var descSection))
42+
IniGroup? descSection = null;
43+
if (file.Groups.TryGetValue("Desc", out IniGroup? desc))
44+
{
45+
descSection = desc;
46+
}
47+
else if (file.Groups.TryGetValue("Details", out IniGroup? details))
48+
{
49+
descSection = details;
50+
IsReadOnly = true;
51+
}
52+
53+
if (descSection != null)
4354
{
4455
Title = descSection.Get("Title", string.Empty);
4556
Version = descSection.Get("Version", string.Empty);

Source/HedgeModManager/ModdableGameLocator.cs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22
using Foundation;
33
using HedgeModManager.Epic;
44
using HedgeModManager.Properties;
5+
using Microsoft.Win32;
56
using Steam;
7+
using System.IO;
68
using System.Linq;
79

810
public class ModdableGameLocator
911
{
1012
public static readonly List<GameInfo> ModdableGameList =
1113
[
14+
new()
15+
{
16+
ID = "UnleashedRecompiled",
17+
SupportsCodes = false,
18+
PlatformInfos = new()
19+
{
20+
{ "Windows", new (string.Empty, "SOFTWARE\\UnleashedRecomp") },
21+
{ "Flatpak", new ("io.github.hedge_dev.unleashedrecomp", "unleashedrecomp")},
22+
{ "Desktop", new ("UnleashedRecomp", "unleashedrecomp")}
23+
}
24+
},
1225
new()
1326
{
1427
ID = "SonicGenerations",
@@ -202,6 +215,89 @@ public static List<IModdableGame> LocateGames()
202215
games.Add(game);
203216
}
204217
}
218+
if (gameInfo.PlatformInfos.TryGetValue("Windows", out var windowsInfo) &&
219+
OperatingSystem.IsWindows())
220+
{
221+
string root = string.Empty;
222+
string exe = string.Empty;
223+
try
224+
{
225+
// "Executable" is used to hold the registry key
226+
var key = Registry.CurrentUser.OpenSubKey(windowsInfo.Executable);
227+
if (key != null)
228+
{
229+
exe = key.GetValue("ExecutableFilePath") as string ?? string.Empty;
230+
root = key.GetValue("RootDirectoryPath") as string ?? string.Empty;
231+
if (string.IsNullOrEmpty(root))
232+
root = Path.GetDirectoryName(exe)!;
233+
}
234+
key?.Close();
235+
}
236+
catch { }
237+
238+
if (Directory.Exists(root) && File.Exists(exe))
239+
{
240+
var gameSimple = new GameSimple(
241+
"Windows", string.Empty, gameInfo.ID,
242+
root, Path.GetFileName(exe), "Windows", exe, string.Empty);
243+
244+
var game = new ModdableGameGeneric(gameSimple)
245+
{
246+
SupportsDirectLaunch = true,
247+
SupportsLauncher = false,
248+
Is64Bit = gameInfo.Is64Bit
249+
};
250+
game.ModDatabase.SupportsCodeCompilation = gameInfo.SupportsCodes;
251+
games.Add(game);
252+
}
253+
}
254+
if (gameInfo.PlatformInfos.TryGetValue("Flatpak", out var flatpakInfo))
255+
{
256+
string root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
257+
".var/app", flatpakInfo.ID);
258+
259+
if (Directory.Exists(root))
260+
{
261+
// Use custom path for SWA
262+
if (gameInfo.ID == "UnleashedRecompiled")
263+
root = Path.Combine(Paths.GetActualUserConfigPath(), "UnleashedRecomp");
264+
265+
var gameSimple = new GameSimple(
266+
"Flatpak", flatpakInfo.ID, gameInfo.ID,
267+
root, Path.GetFileName(flatpakInfo.Executable), "Linux",
268+
"xdg-open", $"{flatpakInfo.Executable}:");
269+
270+
var game = new ModdableGameGeneric(gameSimple)
271+
{
272+
SupportsDirectLaunch = true,
273+
SupportsLauncher = false,
274+
Is64Bit = gameInfo.Is64Bit
275+
};
276+
game.ModDatabase.SupportsCodeCompilation = gameInfo.SupportsCodes;
277+
games.Add(game);
278+
}
279+
}
280+
if (OperatingSystem.IsLinux() && gameInfo.PlatformInfos.TryGetValue("Desktop", out var desktopInfo))
281+
{
282+
string root = Path.Combine(Paths.GetActualUserConfigPath(), desktopInfo.ID);
283+
284+
if (Directory.Exists(root))
285+
{
286+
var gameSimple = new GameSimple(
287+
"Desktop", desktopInfo.ID, gameInfo.ID,
288+
root, Path.GetFileName(desktopInfo.Executable), "Linux",
289+
"xdg-open", $"{desktopInfo.Executable}:");
290+
291+
var game = new ModdableGameGeneric(gameSimple)
292+
{
293+
SupportsDirectLaunch = true,
294+
SupportsLauncher = false,
295+
Is64Bit = gameInfo.Is64Bit
296+
};
297+
game.ModDatabase.SupportsCodeCompilation = gameInfo.SupportsCodes;
298+
games.Add(game);
299+
}
300+
}
205301
}
206302

207303
return games;

flatpak/hedgemodmanager.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Icon=io.github.hedge_dev.hedgemodmanager
66
Categories=Game;
77
Comment=Configure mods for various Hedgehog Engine games
88
Keywords=hedgehog;mod;loader;manager;sonic
9-
MimeType=x-scheme-handler/hedgemm;x-scheme-handler/hedgemmgens;x-scheme-handler/hedgemmlw;x-scheme-handler/hedgemmforces;x-scheme-handler/hedgemmtenpex;x-scheme-handler/hedgemmmusashi;x-scheme-handler/hedgemmrainbow;x-scheme-handler/hedgemmhite;x-scheme-handler/hedgemmrangers;x-scheme-handler/hedgemmmillersonic;x-scheme-handler/hedgemmmillershadow
9+
MimeType=x-scheme-handler/hedgemm;x-scheme-handler/hedgemmswa;x-scheme-handler/hedgemmgens;x-scheme-handler/hedgemmlw;x-scheme-handler/hedgemmforces;x-scheme-handler/hedgemmtenpex;x-scheme-handler/hedgemmmusashi;x-scheme-handler/hedgemmrainbow;x-scheme-handler/hedgemmhite;x-scheme-handler/hedgemmrangers;x-scheme-handler/hedgemmmillersonic;x-scheme-handler/hedgemmmillershadow

flatpak/io.github.hedge_dev.hedgemodmanager-autobuild.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ command: /app/bin/HedgeModManager.UI
1313

1414
finish-args:
1515
- --socket=x11
16+
# UnleashedRecomp permissions
17+
- --filesystem=xdg-config/UnleashedRecomp:create
18+
- --filesystem=xdg-data/applications/UnleashedRecomp.desktop:ro
1619
# Create permissions are required for accessing the mod loader, game and for patching game prefixes
1720
# Steam permissions
1821
- --filesystem=~/.steam/steam/steamapps:create

flatpak/io.github.hedge_dev.hedgemodmanager.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ command: /app/bin/HedgeModManager.UI
1313

1414
finish-args:
1515
- --socket=x11
16+
# UnleashedRecomp permissions
17+
- --filesystem=xdg-config/UnleashedRecomp:create
18+
- --filesystem=xdg-data/applications/UnleashedRecomp.desktop:ro
1619
# Create permissions are required for accessing the mod loader, game and for patching game prefixes
1720
# Steam permissions
1821
- --filesystem=~/.steam/steam/steamapps:create

0 commit comments

Comments
 (0)