Exemple #1
0
        private static bool FindGoGInstallation(ModData modData, int appIdGog)
        {
            var prefixes = new[] { "HKEY_LOCAL_MACHINE\\Software\\", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\" };

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

                if (installDir == null)
                {
                    continue;
                }

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

                if (GameProvider.TryRegister(modData, installDir))
                {
                    return(true);
                }
            }

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

            return(false);
        }
Exemple #2
0
        private static bool FindCdInDrive(ModData modData)
        {
            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}");

                if (GameProvider.TryRegister(modData, installDir))
                {
                    return(true);
                }
            }

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

            return(false);
        }
Exemple #3
0
        private static bool FindSteamInstallation(ModData modData, int appIdSteam)
        {
            foreach (var steamDirectory in SteamDirectory())
            {
                var manifestPath = Path.Combine(steamDirectory, "steamapps", $"appmanifest_{appIdSteam}.acf");

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

                var data = 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}");

                if (GameProvider.TryRegister(modData, installDir))
                {
                    return(true);
                }
            }

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

            return(false);
        }