コード例 #1
0
        /// <summary>
        /// CleanupManager class constructor.
        /// </summary>
        /// <param name="FullAppPath">Path to SRC Repair installation directory.</param>
        /// <param name="SelectedGame">Instance of SourceGame class with selected in main window game.</param>
        /// <param name="AllowUnsafe">Allow or disallow to use unsafe cleanup methods.</param>
        public CleanupManager(string FullAppPath, SourceGame SelectedGame, bool AllowUnsafe = false)
        {
            // Filling some private fields...
            GamePath             = SelectedGame.GamePath;
            FullGamePath         = SelectedGame.FullGamePath;
            AppWorkshopDir       = SelectedGame.AppWorkshopDir;
            CloudScreenshotsPath = SelectedGame.CloudScreenshotsPath;

            // Initializing empty dictionary...
            CleanupTargets = new Dictionary <string, CleanupTarget>();

            // Fetching list of available cleanup targets from XML database file...
            using (FileStream XMLFS = new FileStream(Path.Combine(FullAppPath, StringsManager.CleanupDatabaseName), FileMode.Open, FileAccess.Read))
            {
                // Loading XML file from file stream...
                XmlDocument XMLD = new XmlDocument();
                XMLD.Load(XMLFS);

                // Parsing XML and filling our structures...
                foreach (XmlNode XmlItem in XMLD.SelectNodes("Targets/Target"))
                {
                    try
                    {
                        CleanupTargets.Add(XmlItem.SelectSingleNode("ID").InnerText, new CleanupTarget(XmlItem.SelectSingleNode("Name").InnerText, GetDirListFromNode(XmlItem, AllowUnsafe)));
                    }
                    catch (Exception Ex)
                    {
                        Logger.Warn(Ex, DebugStrings.AppDbgExCoreClnManConstructor);
                    }
                }
            }
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: leha-bot/srcrepair
        /// <summary>
        /// GameManager class constructor.
        /// </summary>
        /// <param name="App">CurrentApp class instance.</param>
        /// <param name="HideUnsupported">Enable or disable adding unsupported games to list.</param>
        public GameManager(CurrentApp App, bool HideUnsupported = true)
        {
            // Creating empty dictionary...
            SourceGames = new Dictionary <string, SourceGame>();

            // Fetching game libraries...
            List <String> GameDirs = App.SteamClient.FormatInstallDirs(App.Platform.SteamAppsFolderName);

            // Creating FileStream for XML database...
            using (FileStream XMLFS = new FileStream(Path.Combine(App.FullAppPath, Properties.Resources.GameListFile), FileMode.Open, FileAccess.Read))
            {
                // Loading XML file from file stream...
                XmlDocument XMLD = new XmlDocument();
                XMLD.Load(XMLFS);

                // Parsing XML and filling our structures...
                foreach (XmlNode XmlItem in XMLD.SelectNodes("Games/Game"))
                {
                    try
                    {
                        if (XmlItem.SelectSingleNode("Enabled").InnerText == "1" || !HideUnsupported)
                        {
                            SourceGame SG = new SourceGame(XmlItem.Attributes["Name"].Value, XmlItem.SelectSingleNode("DirName").InnerText, XmlItem.SelectSingleNode("SmallName").InnerText, XmlItem.SelectSingleNode("Executable").InnerText, XmlItem.SelectSingleNode("SID").InnerText, Convert.ToInt32(XmlItem.SelectSingleNode("SVer").InnerText), XmlItem.SelectSingleNode("VFDir").InnerText, XmlItem.SelectSingleNode("UserDir").InnerText == "1", XmlItem.SelectSingleNode("HUDsAvail").InnerText == "1", App.AppUserDir, App.SteamClient.FullSteamPath, App.Platform.SteamAppsFolderName, App.SteamClient.SteamID, GameDirs, App.Platform.OS);
                            if (SG.IsInstalled)
                            {
                                SourceGames.Add(XmlItem.Attributes["Name"].Value, SG);
                            }
                        }
                    }
                    catch (Exception Ex)
                    {
                        Logger.Warn(Ex, DebugStrings.AppDbgExCoreGameManConstructor);
                    }
                }
            }
        }