Beispiel #1
0
        public static List <SteamAppManifest> GetInstalledApps()
        {
            var result = new List <SteamAppManifest>();

            string        installPath    = GetInstallPathInternal();
            List <string> libraryFolders = GetLibraryFolders();

            foreach (string libraryFolder in libraryFolders)
            {
                string steamAppsFolder = Path.Combine(libraryFolder, "steamapps");
                string commonFolder    = Path.Combine(steamAppsFolder, "common");
                IEnumerable <string> appManifestFilePaths = Directory.EnumerateFiles(steamAppsFolder, "appmanifest_*.acf");
                foreach (string appManifestFilePath in appManifestFilePaths)
                {
                    using (TextReader reader = new StreamReader(File.OpenRead(appManifestFilePath), DefaultFileEncoding))
                    {
                        var appManifest = SteamAppManifest.Load(reader);
                        if (appManifest == null)
                        {
                            continue;
                        }

                        string fullInstallPath = Path.Combine(commonFolder, appManifest.InstallDir);
                        if (!Directory.Exists(fullInstallPath))
                        {
                            continue;
                        }

                        appManifest.InstallDir = fullInstallPath;
                        result.Add(appManifest);
                    }
                }
            }

            return(result.OrderBy(x => x.Name).ToList());
        }
Beispiel #2
0
        private static int Execute(string[] args)
        {
            SteamAppManifest eu4AppManifest    = GetEu4AppManifest();
            string           steamInstallPath  = Steam.InstallPath;
            uint             activeUserId      = Steam.ActiveUserId;
            string           steamUserDataPath = Path.Combine(steamInstallPath, "userdata", activeUserId.ToString());
            string           eu4UserDataPath   = Path.Combine(steamUserDataPath, _eu4AppId.ToString());

            string _eu4InstallPath = Path.GetFullPath(eu4AppManifest.InstallDir);
            string _localSavesPath = Path.GetFullPath(Path.Combine(GetMyDocumentsPath(), "Paradox Interactive", eu4AppManifest.Name, "save games"));
            string _cloudSavesPath = Path.GetFullPath(Path.Combine(eu4UserDataPath, "remote", "save games"));

            Out("EU4 Install Path: " + _eu4InstallPath);
            Out("Local Saves: " + _localSavesPath);
            Out("Cloud Saves: " + _cloudSavesPath);
            Out(string.Empty);

            if (args.Length > 0)
            {
                Load(args[0]);
            }

            Out("Type 'help' or '?' for help.");

Loop:
            bool isLoaded = !string.IsNullOrWhiteSpace(_loadedFilePath) &&
                            File.Exists(_loadedFilePath);
            string prompt = isLoaded ? Path.GetFileNameWithoutExtension(_loadedFilePath) : "--not loaded--";

            string input = ReadInput($"{prompt}> ");

            if (string.IsNullOrWhiteSpace(input))
            {
                goto Loop;
            }

            string[] cmdArgs = ParseInput(input);
            if (cmdArgs.Length < 1)
            {
                goto Loop;
            }

            string cmd = cmdArgs.First();

            string[] cmdParams = cmdArgs.Skip(1).ToArray();

            if ("help".Equals(cmd, _ignoreCaseCmp) ||
                "?".Equals(cmd, _ignoreCaseCmp))
            {
                ShowHelp();
            }
            else if ("backup".Equals(cmd, _ignoreCaseCmp))
            {
                Backup();
            }
            else if ("clean".Equals(cmd, _ignoreCaseCmp) &&
                     cmdParams.Length >= 1)
            {
                Clean(cmdParams);
            }
            else if ("delete".Equals(cmd, _ignoreCaseCmp) &&
                     cmdParams.Length >= 1)
            {
                Delete(cmdParams);
            }
            else if ("load".Equals(cmd, _ignoreCaseCmp) &&
                     cmdParams.Length >= 1)
            {
                string filePath = cmdParams[0];
                Load(filePath);
            }
            else if ("print".Equals(cmd, _ignoreCaseCmp))
            {
                Print();
            }
            else if ("restore".Equals(cmd, _ignoreCaseCmp) &&
                     cmdParams.Length >= 1 &&
                     !string.IsNullOrEmpty(cmdParams[0]))
            {
                string hash = cmdParams[0];
                Restore(hash);
            }
            else if ("show".Equals(cmd, _ignoreCaseCmp) &&
                     cmdParams.Length >= 1)
            {
                string action = cmdParams[0];
                Show(action);
            }
            else if ("tag".Equals(cmd, _ignoreCaseCmp) &&
                     cmdParams.Length >= 1 &&
                     cmdParams[0].Length == 3)
            {
                ChangeTag(cmdParams);
            }
            else if ("q".Equals(cmd, _ignoreCaseCmp) ||
                     "quit".Equals(cmd, _ignoreCaseCmp) ||
                     "exit".Equals(cmd, _ignoreCaseCmp))
            {
                goto Done;
            }
            else
            {
                Error("Unrecognized input.");
            }

            goto Loop;

Done:
            if (_watcher != null)
            {
                _watcher.Dispose();
            }

            return(0);
        }