|
2 | 2 | using Foundation; |
3 | 3 | using HedgeModManager.Epic; |
4 | 4 | using HedgeModManager.Properties; |
| 5 | +using Microsoft.Win32; |
5 | 6 | using Steam; |
| 7 | +using System.IO; |
6 | 8 | using System.Linq; |
7 | 9 |
|
8 | 10 | public class ModdableGameLocator |
9 | 11 | { |
10 | 12 | public static readonly List<GameInfo> ModdableGameList = |
11 | 13 | [ |
| 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 | + }, |
12 | 25 | new() |
13 | 26 | { |
14 | 27 | ID = "SonicGenerations", |
@@ -202,6 +215,89 @@ public static List<IModdableGame> LocateGames() |
202 | 215 | games.Add(game); |
203 | 216 | } |
204 | 217 | } |
| 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 | + } |
205 | 301 | } |
206 | 302 |
|
207 | 303 | return games; |
|
0 commit comments