Beispiel #1
0
        private static Installation?FindGoGInstallation(ModData modData, IGeneration generation)
        {
            if (Platform.CurrentPlatform == PlatformType.Windows)
            {
                var prefixes = new[] { "HKEY_LOCAL_MACHINE\\Software\\", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\" };

                foreach (var prefix in prefixes)
                {
                    var installDir = Registry.GetValue($"{prefix}GOG.com\\Games\\{generation.GogAppId}", "path", null) as string;

                    if (installDir == null)
                    {
                        continue;
                    }

                    Log.Write("debug", $"GoG version candidate: {installDir}");

                    var game = InstallationUtils.TryRegister(modData, installDir, generation);

                    if (game != null)
                    {
                        return(game);
                    }
                }

                Log.Write("debug", "GoG version not found");
            }
            else
            {
                Log.Write("debug", "GoG version not supported on this platform");
            }

            return(null);
        }
Beispiel #2
0
        private static Installation?FindCdVersion(ModData modData, IGeneration generation)
        {
            foreach (var driveInfo in DriveInfo.GetDrives())
            {
                if (driveInfo.DriveType != DriveType.CDRom || !driveInfo.IsReady)
                {
                    continue;
                }

                var installDir = driveInfo.RootDirectory.FullName;

                Log.Write("debug", $"CD version candidate: {installDir}");

                var game = InstallationUtils.TryRegister(modData, installDir, generation);

                if (game != null)
                {
                    return(game);
                }
            }

            Log.Write("debug", "CD version not found");

            return(null);
        }
Beispiel #3
0
        private static Installation?FindSteamInstallation(ModData modData, IGeneration generation)
        {
            foreach (var steamDirectory in InstallationFinder.SteamDirectory())
            {
                var manifestPath = Path.Combine(steamDirectory, "steamapps", $"appmanifest_{generation.SteamAppId}.acf");

                if (!File.Exists(manifestPath))
                {
                    continue;
                }

                var data = InstallationFinder.ParseKeyValuesManifest(manifestPath);

                if (!data.TryGetValue("StateFlags", out var stateFlags) || stateFlags != "4")
                {
                    continue;
                }

                if (!data.TryGetValue("installdir", out var installDir))
                {
                    continue;
                }

                installDir = Path.Combine(steamDirectory, "steamapps", "common", installDir);

                Log.Write("debug", $"Steam version candidate: {installDir}");

                var game = InstallationUtils.TryRegister(modData, installDir, generation);

                if (game != null)
                {
                    return(game);
                }
            }

            Log.Write("debug", "Steam version not found");

            return(null);
        }