示例#1
0
        protected override void resetSteamPath()
        {
            string          reg_path = null, set_path = null;
            RegistryHandler steam = new RegistryHandler("local_machine", "SOFTWARE\\Valve\\Steam", false);

            reg_path = isSteamPath(steam.getValue("InstallPath"));
            set_path = isSteamPath(Core.settings.steam_override);

            if (set_path != null)
            {
                path = set_path;
            }
            else if (reg_path != null)
            {
                path = reg_path;
            }
            else
            {
                path = null;
            }

            if (path != null)
            {
                DirectoryInfo read_me = new DirectoryInfo(Path.Combine(path, "steamapps"));
                // Loads the steam isntall path folders
                loadSteamPaths(read_me);

                // Loads the alt steam library folders
                if (File.Exists(Path.Combine(path, "config", "config.vdf")))
                {
                    config_file = new SteamConfigFile(Path.Combine(path, "config", "config.vdf"));
                    foreach (string folder in config_file.BaseInstallFolders)
                    {
                        read_me = new DirectoryInfo(Path.Combine(folder, "SteamApps"));
                        loadSteamPaths(read_me);
                    }
                }



                // Loads the steam cloud folders
                read_me = new DirectoryInfo(Path.Combine(path, "userdata"));
                if (read_me.Exists)
                {
                    DirectoryInfo[] read_us;
                    read_us = read_me.GetDirectories();
                    foreach (DirectoryInfo subDir in read_us)
                    {
                        setUserEv(subDir.Name, EnvironmentVariable.SteamUserData, subDir.FullName);
                    }
                    userdata_path = read_me.FullName;
                }
            }
            else
            {
                userdata_path   = null;
                steam_apps_path = null;
            }
        }
示例#2
0
        public void Update(bool force = false)
        {
            if (_updating && !force)
            {
                return;
            }

            _updating = true;

            var old = new App[_list.Count];

            _list.CopyTo(old, 0);

            _list.Clear();

            var steamConfig = new SteamConfigFile(_steam.SteamConfigPath);

            if (!steamConfig.SteamElement.Children.ContainsKey("apps"))
            {
                _log.Info("No apps in the Steam config, aborting update");
                _updating = false;
                return;
            }

            var apps = steamConfig.SteamElement.Children["apps"];

            foreach (var app in apps.Children)
            {
                uint id;
                var  valid = uint.TryParse(app.Key, out id);
                if (!valid)
                {
                    continue;
                }
                var oldApp = old.FirstOrDefault(a => a.Id == id);
                if (oldApp != null)
                {
                    Add(oldApp);
                    continue;
                }
                var data = app.Value;
                var hasAllLocalContent   = data.Children.ContainsKey("HasAllLocalContent") && data.Children["HasAllLocalContent"].Value == "1";
                var upToDate             = data.Children.ContainsKey("UpToDate") && data.Children["UpToDate"].Value == "1";
                var addGameExplorerEntry = data.Children.ContainsKey("AddGameExplorerEntry") &&
                                           data.Children["AddGameExplorerEntry"].Value == "1";
                var state = ((hasAllLocalContent && upToDate) || addGameExplorerEntry)
                                ? EAppState.k_EAppStateFullyInstalled
                                : EAppState.k_EAppStateUninstalled;
                Add(id, state);
            }

            _updating = false;
        }