Beispiel #1
0
        private void LoadKeyValuesFromFile(string path, bool InVpk)
        {
            string text = "";

            if (InVpk)
            {
                text = DotaVPKService.Instance.ReadTextFromVPK(path);
            }
            else
            {
                text = File.ReadAllText(path);
            }

            KeyValue kv = KVParser.ParseKeyValueText(text);

            KeyValueNode = kv;
        }
Beispiel #2
0
        public ObservableCollection <KeyValue> ReadKeyValuesFromFile(string path, string rootKey)
        {
            a = "";
            if (!File.Exists(path))
            {
                File.Create(path).Close();
                emptyFile = true;
            }
            a = File.ReadAllText(path);
            KeyValue kv = KVParser.ParseKeyValueText(a);

            Console.WriteLine(kv.Key);
            if (kv.Key != rootKey)
            {
                Utils.CreateNewFile(path, rootKey);
            }
            foreach (KeyValue data in GetChildren(kv))
            {
                tempList.Add((KeyValue)data);
            }
            return(tempList);
        }
Beispiel #3
0
        /// <summary>
        /// Try to find the route where Steam and Dota 2 are installed.
        /// </summary>
        /// <returns></returns>
        static void FindGameDirectory()
        {
            // Look for the Steam installation path in the registry.
            string steamDirectory = (string)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Valve\\Steam", "SteamPath", null);

            // So... you dont have it in the registry huh.
            if (steamDirectory == null || !Directory.Exists(steamDirectory))
            {
                Console.WriteLine("The Steam installation path could not be found from the registry. Do you have Steam installed?");
                goto unableToObtain;
            }

            string configFile = steamDirectory + "/config/config.vdf";

            // So... you dont have Steam Configuration file...
            if (!File.Exists(configFile))
            {
                Console.WriteLine("The Steam installation path has been found, but the configuration file dont exist!");
                goto unableToObtain;
            }

            try {
                // Read and Parse the Steam configuration file.
                String   configData = File.ReadAllText(configFile);
                KeyValue values     = KVParser.ParseKeyValueText(configData);

                KeyValue software = FindChildren(values, "Software");
                KeyValue valve    = FindChildren(software, "Valve");
                KeyValue steam    = FindChildren(valve, "Steam");

                KeyValue installFolder1 = FindChildren(steam, "BaseInstallFolder_1");
                KeyValue installFolder2 = FindChildren(steam, "BaseInstallFolder_2");

                // Try with 2 routes
                string baseInstallFolder  = null;
                string baseInstallFolder2 = null;

                if (installFolder1 != null)
                {
                    baseInstallFolder = installFolder1.GetString();
                }

                if (installFolder2 != null)
                {
                    baseInstallFolder2 = installFolder2.GetString();
                }

                String gamePathExt = "\\steamapps\\common\\dota 2 beta\\game";

                if (baseInstallFolder != null && Directory.Exists(baseInstallFolder + gamePathExt))
                {
                    gameDirectory = baseInstallFolder + gamePathExt;
                }
                else if (baseInstallFolder2 != null && Directory.Exists(baseInstallFolder2 + gamePathExt))
                {
                    gameDirectory = baseInstallFolder2 + gamePathExt;
                }
                else if (Directory.Exists(steamDirectory + gamePathExt))
                {
                    gameDirectory = steamDirectory + gamePathExt;
                }
                else
                {
                    goto unableToObtain;
                }

                goto setupPaths;
            }
            catch (Exception why) {
                Console.WriteLine("There was a problem reading the Steam configuration file, please report the following message: " + why.Message);
                goto unableToObtain;
            }

unableToObtain:
            Console.WriteLine("Unable to obtain the location of the Dota 2 folder. Checking if we are already in the /game/ folder...");

setupPaths:
            // ?
            if (!Directory.Exists(gameDirectory + "\\dota\\"))
            {
                Console.WriteLine();
                Console.WriteLine(gameDirectory);
                Abort("We are sorry but the Dota 2 installation folder could not be found. Try placing the Updater files in the /game/ folder of Dota 2.");
            }

            installDirectory = gameDirectory + "\\dota_divine_ui";
            versionFilePath  = installDirectory + "\\version.txt";
        }