Exemple #1
0
        internal static SteamManifest GetSoulworkerSteamManifest()
        {
            const string SteamGameId = "1377580";
            string       steamInstallPath;

            if (!Environment.Is64BitOperatingSystem)
            {
                steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key32Path, Strings.Registry.Steam.InstallPath);
            }
            else
            {
                steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key64Path, Strings.Registry.Steam.InstallPath);

                if (steamInstallPath == String.Empty)
                {
                    steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key32Path, Strings.Registry.Steam.InstallPath);
                }
            }

            if (!String.IsNullOrEmpty(steamInstallPath))
            {
                string mainSteamLibrary   = Path.Combine(steamInstallPath, "steamapps");
                string libraryFoldersFile = Path.Combine(mainSteamLibrary, "libraryfolders.vdf");

                if (File.Exists(libraryFoldersFile))
                {
                    var    libraryManifest = SteamManifest.Load(libraryFoldersFile);
                    var    libraryPaths    = libraryManifest.EnumerateEntries().Select(entry => Path.Combine(entry.Value, "steamapps"));
                    string acfToFind       = $"appmanifest_{SteamGameId}.acf";

                    var acf = libraryPaths.Select(path => Path.Combine(path, acfToFind)).FirstOrDefault(path => File.Exists(path));
                    if (acf != null)
                    {
                        return(SteamManifest.Load(acf));
                    }
                }
            }

            return(null);
        }
        private static string GetGameforgeSwPath()
        {
            const string SteamGameId = "630100";
            string       steamInstallPath;
            string       swPath = String.Empty;

            if (!Environment.Is64BitOperatingSystem)
            {
                steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key32Path, Strings.Registry.Steam.InstallPath);
            }
            else
            {
                steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key64Path, Strings.Registry.Steam.InstallPath);

                if (steamInstallPath == String.Empty)
                {
                    steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key32Path, Strings.Registry.Steam.InstallPath);
                }
            }

            if (steamInstallPath != String.Empty)
            {
                List <string> libraryPaths     = new List <string>();
                string        mainSteamLibrary = Path.Combine(steamInstallPath, "steamapps");
                libraryPaths.Add(mainSteamLibrary);
                string libraryFoldersFile = Path.Combine(mainSteamLibrary, "libraryfolders.vdf");

                if (File.Exists(libraryFoldersFile))
                {
                    var libraryManifest = SteamManifest.Load(libraryFoldersFile);
                    int i = 1;
                    while (libraryManifest.Elements.TryGetValue((i++).ToString(), out SteamManifestElement sme))
                    {
                        libraryPaths.Add(Path.Combine(((SteamManifestEntry)sme).Value, "steamapps"));
                    }

                    foreach (string libraryPath in libraryPaths)
                    {
                        string acf = Path.Combine(libraryPath, $"appmanifest_{SteamGameId}.acf");
                        if (File.Exists(acf))
                        {
                            var smacf = SteamManifest.Load(acf);
                            if (smacf.Elements.TryGetValue("installdir", out SteamManifestElement sme))
                            {
                                string path = Path.Combine(libraryPath, "common", ((SteamManifestEntry)sme).Value);
                                if (Directory.Exists(path) &&
                                    Directory.GetFiles(path).Length > 0)
                                {
                                    swPath = path;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (swPath == String.Empty)
            {
                swPath = GetGameforgeLauncherSwPath();
            }

            return(swPath);
        }
Exemple #3
0
        private void CheckGFVersion()
        {
            const string SteamGameId = "630100";
            string       steamInstallPath;
            bool         success = false;

            if (!Environment.Is64BitOperatingSystem)
            {
                steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key32Path, Strings.Registry.Steam.InstallPath);
            }
            else
            {
                steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key64Path, Strings.Registry.Steam.InstallPath);

                if (steamInstallPath == String.Empty)
                {
                    steamInstallPath = Methods.GetRegistryValue(Strings.Registry.Steam.RegistryKey, Strings.Registry.Steam.Key32Path, Strings.Registry.Steam.InstallPath);
                }
            }

            if (steamInstallPath != String.Empty)
            {
                List <string> libraryPaths     = new List <string>();
                string        mainSteamLibrary = Path.Combine(steamInstallPath, "steamapps");
                libraryPaths.Add(mainSteamLibrary);
                string libraryFoldersFile = Path.Combine(mainSteamLibrary, "libraryfolders.vdf");

                if (File.Exists(libraryFoldersFile))
                {
                    var libraryManifest = SteamManifest.Load(libraryFoldersFile);
                    int i = 1;
                    while (libraryManifest.Elements.TryGetValue((i++).ToString(), out SteamManifestElement sme))
                    {
                        libraryPaths.Add(Path.Combine(((SteamManifestEntry)sme).Value, "steamapps"));
                    }

                    foreach (string libraryPath in libraryPaths)
                    {
                        string acf = Path.Combine(libraryPath, $"appmanifest_{SteamGameId}.acf");
                        if (File.Exists(acf))
                        {
                            var smacf = SteamManifest.Load(acf);
                            if (smacf.Elements.TryGetValue("StateFlags", out SteamManifestElement sme))
                            {
                                if (Int32.TryParse(((SteamManifestEntry)sme).Value, out int stateFlagInt))
                                {
                                    var appState = (AppState)stateFlagInt;
                                    if (appState == AppState.StateFullyInstalled)
                                    {
                                        success = true;
                                    }
                                    else
                                    {
                                        success = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (!success)
            {
                // if no valid soulworker found on steam, look on gameforge's launcher
                this.CheckGFLauncherVersion();
            }
        }