コード例 #1
0
        TreeNode AddNodeToNode(string Name, VDFData parentVDFDataStructure, TreeNodeVDFTag treeNodeTag, TreeNode nodeSelected)
        {
            TreeNode newTreeNode;

            if (treeNodeTag.TagType == TreeNodeVDFTag.Type.Node) //If we have the node itself selected on our Treeview, we just need to call the AddNodeToNode method directly.
            {
                newTreeNode = AddNodeToNode(Name, nodeSelected, parentVDFDataStructure, treeNodeTag.Token as VDFNode);
            }
            else
            {
                //We will need to retrieve the parent of this key for this one if the key is the one that is selected.
                if (nodeSelected.Parent == null) //Make sure that the parent of the TreeNode is set to another TreeNode
                {
                    throw new NullReferenceException("TreeNode " + nodeSelected.Text + " parent property is not set!");
                }
                VDFKey selectedKey = treeNodeTag.Token as VDFKey; //Cast our token to key first.
                if (selectedKey.Parent == null)
                {
                    throw new NullReferenceException("Parent property of key " + selectedKey.Name + " is not set!");
                }
                VDFNode parentNode = selectedKey.Parent;
                newTreeNode = AddNodeToNode(Name, nodeSelected.Parent, vdfData, parentNode);
            }
            return(newTreeNode);
        }
コード例 #2
0
        /// <summary>
        /// Retrieves all the Steam Apps under the specified Library Folder.
        /// </summary>
        /// <param name="LibPath">The Library Directory to search on.</param>
        /// <returns></returns>
        public static List <SteamApp> RetrieveAppsUnderLibraryFolder(string LibPath)
        {
            List <SteamApp> steamapps = new List <SteamApp>();

            string steamAppsFolderPath = LibPath + "\\" + SteamAppsManager.STEAM_APPS_DIRNAME; //This is the folder that contains the application manifests.

            if (!Directory.Exists(steamAppsFolderPath))
            {
                return(steamapps);
            }
            string[] manifests = Directory.GetFiles(steamAppsFolderPath, APPMANIFEST_SEARCH_STRING); //Search for the application manifests under the SteamApps Folder of the library.

            if (manifests.Length == 0)
            {
                return(steamapps);
            }

            foreach (string manifest in manifests) //Parse all our manifest file in to a SteamApp instance.
            {
                VDFData parsedData;
                bool    parseResult = VDFData.TryParseFile(manifest, out parsedData); //Added this lines of code as there might be App manifests that are corrupted or empty.
                if (parseResult && parsedData.Nodes != null && parsedData.Nodes.Count != 0)
                {
                    steamapps.Add(new SteamApp(parsedData, LibPath));
                }
            }
            return(steamapps);
        }
コード例 #3
0
        const string APPMANIFEST_SEARCH_STRING = "appmanifest_*.acf";  //The search pattern to be used for searching steam apps manifest.


        /// <summary>
        /// Lists all the library folders of the steam installation.
        /// </summary>
        /// <param name="MainSteamInstallPath">The main directory of steam. (The installation folder.)</param>
        /// <returns></returns>
        public static List <string> RetrieveLibraryFolders(string MainSteamInstallPath)
        {
            List <string> libraryFolders = new List <string>(1); //Initialize our list of library folders with a count of 1 as we know that the InstallDir is a library folder.

            libraryFolders.Add(MainSteamInstallPath);

            //Let us now locate the file that contains the list of all the steam library folders in the machine.
            string LibFileFullPath = MainSteamInstallPath + "\\" + SteamAppsManager.STEAM_APPS_DIRNAME + "\\" + LIBRARY_FOLDERS_NAME; //The full path of the library folders file.

            if (!File.Exists(LibFileFullPath))
            {
                return(libraryFolders);
            }

            VDFData vdfReader = new VDFData(LibFileFullPath);

            VDFNode vNode = vdfReader.Nodes.FindNode(LIBFILE_NODE_NAME);      //Find the node that contains the list of steam libraries.

            if (vNode == null || vNode.Keys == null || vNode.Keys.Count == 0) //If it isn't found or the Nodes key is null or empty, there's nothing else to be done. Return the list of libraryfolders that we already have. (which is just MainSteamInstallPath)
            {
                return(libraryFolders);
            }

            foreach (VDFKey vKey in vNode.Keys) //List all the keys inside the vNode node.
            {
                if (vKey.Name.IsInteger())      //As per what I've seen from the Library Folders file, it seems that the key name for the location of the folders itself is a number so check if the key name is a number.
                {
                    libraryFolders.Add(vKey.Value);
                }
            }
            return(libraryFolders);
        }
コード例 #4
0
ファイル: SteamUser.cs プロジェクト: porohkun/SteamAppsTagger
        public void UpdateAppsFromSharedConfig()
        {
            _sharedConfig = new VDFData(File.ReadAllText(_sharedConfigPath), false);

            var apps = _sharedConfig.Nodes[0].Node("Software").Node("Valve").Node("Steam").Node("apps").Nodes;

            foreach (var app in apps)
            {
                var appId    = app.Name;
                var steamApp = Apps.FirstOrDefault(a => a.Id.ToString() == appId);
                if (steamApp == null)
                {
                    int id;
                    if (int.TryParse(app.Name, out id))
                    {
                        steamApp = new AppInfo(id);
                        Apps.Add(steamApp);
                    }
                }
                if (steamApp != null)
                {
                    if (app.ContainsNode("tags"))
                    {
                        foreach (var tag in app.Node("tags").Keys.Select(k => k.Value))
                        {
                            steamApp.SetTag(tag, true);
                        }
                    }
                }
            }
            UpdateTags();
        }
コード例 #5
0
        TreeNode CreateNewNode(string Name, VDFData parentVDFStructure, VDFNode parentNode, out VDFNode newNode)
        {
            newNode = new VDFNode(Name, parentVDFStructure, parentNode); //Create our new VDFNode first which will be referenced by our newNode argument (which will be passed back to the calling method.)
            TreeNode newTreeNode = new TreeNode(Name);

            newTreeNode.Tag = new TreeNodeVDFTag(TreeNodeVDFTag.Type.Node, newNode); //Set the tag to our newNode. Make sure to use VDFTag.
            return(newTreeNode);
        }
コード例 #6
0
        TreeNode AddRootNode(string Name, VDFData _vdfdata)
        {
            VDFNode  newNode;                                                        //Declare our newNode type VDFNode variable which we will be used by our CreateNewNode to pass back our newly created VDFNode.
            TreeNode newTreeNode = CreateNewNode(Name, _vdfdata, null, out newNode); //Call the method which will do the job of creating a TreeNode and VDFNode for us.

            if (_vdfdata.Nodes == null)
            {
                throw new NullReferenceException("Nodes list of VDFData class is set to null!");
            }
            _vdfdata.Nodes.Add(newNode);
            tViewData.Nodes.Add(newTreeNode);
            return(newTreeNode);
        }
コード例 #7
0
        TreeNode AddNodeToNode(string Name, TreeNode Parent, VDFData parentVDFDataStructure, VDFNode nodeParent)
        {
            VDFNode  newNode;                                                                            //Declare our newNode type VDFNode variable which we will be used by our CreateNewNode to pass back our newly created VDFNode.
            TreeNode newTreeNode = CreateNewNode(Name, parentVDFDataStructure, nodeParent, out newNode); //Call the method which will do the job of creating a TreeNode and VDFNode for us.

            if (nodeParent.Nodes == null)
            {
                throw new NullReferenceException("Nodes list of VDFData class is set to null!");
            }
            nodeParent.Nodes.Add(newNode);
            Parent.Nodes.Add(newTreeNode);
            return(newTreeNode);
        }
コード例 #8
0
 void LoadVDFDataToTreeView(VDFData _vdfdata)
 {
     tViewData.Nodes.Clear();
     if (_vdfdata.Nodes != null)
     {
         foreach (VDFNode vNode in _vdfdata.Nodes)
         {
             LoadVDFNodeToTreeView(vNode);
         }
     }
     if (tViewData.Nodes.Count > 0) //Make sure to expand our first node if it exists.
     {
         tViewData.Nodes[0].Expand();
     }
 }
コード例 #9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //check steam running
            //while (!CheckSteamProcess())
            //    MessageBox.Show("Steam app must be closed");

            //get steam users
            var userdatapath = Path.Combine(Settings.SteamInstallPath, "userdata");
            var users        = new Dictionary <string, string>();
            var localconfigs = new Dictionary <string, VDFNode>();

            foreach (var userdirpath in Directory.GetDirectories(userdatapath, "*", SearchOption.TopDirectoryOnly))
            {
                var userid      = Path.GetFileName(userdirpath);
                var localconfig = new VDFData(File.ReadAllText(Path.Combine(userdirpath, "config", "localconfig.vdf")), false).Nodes[0];
                localconfigs.Add(userid, localconfig);
                var username = "******";
                try { username = localconfig.Node("friends").Node(userid).Key("name"); } catch { }
                users.Add(userid, username);
            }
            switch (users.Count)
            {
            case 0: MessageBox.Show("Steam users not found"); Close(); break;

            case 1: _userId = users.Keys.First(); break;

            default:
                var suw = new SelectUserWindow(users);
                suw.ShowDialog();
                if (string.IsNullOrEmpty(suw.SelectedUser))
                {
                    Close();
                }
                _userId = suw.SelectedUser;
                break;
            }
            _localConfig = localconfigs[_userId];

            _steamUser = new SteamUser(_userId);
            _steamUser.UpdateAppsFromWeb();
            _steamUser.UpdateAppsFromSharedConfig();
            DataContext = _steamUser;
        }
コード例 #10
0
        /// <summary>
        /// Initializes the SteamApp class.
        /// </summary>
        /// <param name="vdfdata">The parsed VDF Data Structure.</param>
        /// <param name="LibPath">The path of the library containing the application.</param>
        void init(VDFData vdfdata, string LibPath)
        {
            if (vdfdata == null)
            {
                throw new ArgumentNullException("Argument VDF Data is set to null!");
            }

            if (vdfdata.Nodes == null || vdfdata.Nodes.Count == 0)
            {
                throw new NullReferenceException("Nodes of VDFData is either null or empty!");
            }

            _unparsedData = vdfdata;

            VDFNode vNode = vdfdata.Nodes.FindNode(MANIFEST_NODE); //Locate our root node. We can do nodes[0] as well and it'll be faster but just to be safe.

            if (vNode == null)
            {
                throw new NullReferenceException("Node " + MANIFEST_NODE + " is not found!");
            }

            if (vNode.Keys == null || vNode.Keys.Count == 0)
            {
                throw new NullReferenceException("Node " + MANIFEST_NODE + " list of keys is either null or empty!");
            }

            VDFKey vKey = vNode.Keys.FindKey(MANIFEST_KEY_NAME); //Locate our first key which will be the name of the app.

            if (vKey != null)
            {
                _Name = vKey.Value;
            }
            else
            {
                throw new NullReferenceException("Key pertaining to the name of the app is not found under " + MANIFEST_NODE + " node.");
            }

            vKey = vNode.Keys.FindKey(MANIFEST_KEY_APPID);

            if (vKey != null)
            {
                int tryresult;
                if (int.TryParse(vKey.Value, out tryresult))
                {
                    _AppID = tryresult;
                }
                else
                {
                    throw new NullReferenceException("Key pertaining to the Application ID of the app under " + MANIFEST_NODE + " node is invalid!");
                }
            }
            else
            {
                throw new NullReferenceException("Key pertaining to the Application ID of the app is not found under " + MANIFEST_NODE + " node.");
            }

            vKey = vNode.Keys.FindKey(MANIFEST_KEY_INSDIR);

            if (vKey != null)
            {
                _InstallDir     = LibPath + "\\" + SteamAppsManager.STEAM_APPS_DIRNAME + "\\" + SteamAppsManager.STEAM_APPS_COMMON_DIRNAME + "\\" + vKey.Value;
                _InstallDirName = vKey.Value;
            }
            else
            {
                throw new NullReferenceException("Key pertaining to the directory name containing the app under " + MANIFEST_NODE + " node is not found!");
            }
        }
コード例 #11
0
        /// <summary>
        /// Creates a SteamApp Class instance by parsing the VDF Data Structure in a Manifest file.
        /// </summary>
        /// <param name="ManifestPath">The path to the Application Manifest file.</param>
        /// <param name="LibPath">The path of the library containing the application.</param>
        public SteamApp(string ManifestPath, string LibPath)
        {
            VDFData vData = new VDFData(ManifestPath);

            init(vData, LibPath);
        }
コード例 #12
0
 /// <summary>
 /// Creates a SteamApp Class instance using an already parsed VDF Data Structure.
 /// </summary>
 /// <param name="parsedmanifest">The parsed VDF Data Structure.</param>
 /// <param name="LibPath">The path of the library containing the application.</param>
 public SteamApp(VDFData parsedmanifest, string LibPath)
 {
     init(parsedmanifest, LibPath);
 }