Exemple #1
0
        public KeyValue GetNewSpecials()
        {
            KeyValue newSpecials = new KeyValue("AbilitySpecial");

            for (int i = 0; i < s.Children.Count - 1; i++)                              //-1 Because "Add Behavior" button is a child
            {
                Grid     g = (Grid)s.Children[i];
                ComboBox t = (ComboBox)g.Children[0];
                TextBox  n = (TextBox)g.Children[1];
                TextBox  v = (TextBox)g.Children[2];

                if (t.SelectedItem.ToString() == "")
                {
                    t.SelectedItem = t.Items[0];
                }
                if (n.Text == "")
                {
                    n.Text = "var_" + (i + 1);
                }
                if (v.Text == "")
                {
                    v.Text = "0";
                }

                KeyValue abilitySpecial = new KeyValue((i + 1).ToString("D2"));
                KeyValue var_type       = new KeyValue("var_type", t.SelectedItem.ToString());
                KeyValue var            = new KeyValue(n.Text, v.Text);

                abilitySpecial.AddChild(var_type);
                abilitySpecial.AddChild(var);

                newSpecials.AddChild(abilitySpecial);
            }
            return(newSpecials);
        }
			public KeyValue getKV() {
				KeyValue root = new KeyValue("Return Value");
				KeyValue type = new KeyValue("Type");
				type.Set(this.type);
				KeyValue desc = new KeyValue("Description");
				desc.Set(description);
				root.AddChild(type);
				root.AddChild(desc);
				return root;
			}
Exemple #3
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            if (Directory.Exists(ApplicationSettings.instance.currentModPath))
            {
                filePath = ApplicationSettings.instance.currentModPath + "\\scripts\\npc\\" + file;
            }
            UpdateKVList();
            treeRootItem.Header = rootKey;
            treeRootItem.Items.Clear();
            parentKeys.Clear();
            valueKeys.Clear();
            docks.Clear();
            herolist_treeview.Items.Clear();
            parentKeys.Add(treeRootItem);
            herolist_treeview.Items.Add(treeRootItem);

            //parentKeysList.Add(kv_list[0].Parent);
            DoRootHierarchy(kv_list);
            if (kv_list.Count > 0)
            {
                root = kv_list[0].Parent;
            }
            else
            {
                root = new KeyValue(rootKey);
                root.AddChild(new KeyValue(""));                                        //Small hack to get a proper root if file is empty
                root.RemoveChild(root.children[0]);
            }
        }
Exemple #4
0
        public void serializeSettings()
        {
            KeyValue rootKV = new KeyValue("Addons");

            foreach (KeyValuePair <string, Addon> a in addons)
            {
                string   addonName = a.Key;
                Addon    addon     = a.Value;
                KeyValue addonKV   = new KeyValue(addonName);
                addon.serializeSettings(addonKV);
                rootKV.AddChild(addonKV);
            }

            Settings.Default.AddonsKV = rootKV.ToString();

            // serialize the customTiles
            string customTilesSerialized = "";

            for (int i = 0; i < customTiles.Length; i++)
            {
                customTilesSerialized += customTiles[i].serializedTileInfo + "|";
            }
            Settings.Default.CustomTileInfo = customTilesSerialized;
            Settings.Default.Save();
        }
		internal KeyValue getKV() {
			KeyValue root = new KeyValue(name);
			KeyValue funcClass = new KeyValue("Parent class");
			funcClass.Set(this.funcClass);
			KeyValue desc = new KeyValue("Description");
			desc.Set(description);
			KeyValue d2params = new KeyValue("Parameters");
			root.AddChild(funcClass);
			root.AddChild(desc);
			root.AddChild(d2params);
			root.AddChild(ret.getKV());
			foreach (var p in this.d2params) {
				KeyValue kv = p.getKV();
				d2params.AddChild(kv);
			}

			return root;
		}
		static void generateKV() {
			KeyValue root = new KeyValue("Dota2Functions");
			string currClass = "Global";
			foreach (var kv in funcs) {
				kv.Value.processStats();
				KeyValue func_kv = kv.Value.getKV();
				root.AddChild(func_kv);
			}
			File.WriteAllText("d2functions.txt", root.ToString());
		}
Exemple #7
0
        private void AddItem_Click(object sender, RoutedEventArgs e)
        {
            KeyValue k = new KeyValue("");

            k.AddChild(k);
            k.RemoveChild(k);
            kv_list.Add(k);
            root.AddChild(k);
            AddParentKey(parentKeys[0], k);
            OpenEditItemWindow(k.Key);
        }
        public static KeyValue GenerateGameConfig()
        {
            KeyValue kv = new KeyValue("Configs");

            KeyValue games = new KeyValue("Games");

            KeyValue currgame = new KeyValue("FIREFIGHT RELOADED");

            currgame.AddChild(KeyValueHelpers.addKey("GameDir", GlobalVars.moddir));

            KeyValue hammer = new KeyValue("Hammer");

            hammer.AddChild(KeyValueHelpers.addKey("GameData0", GlobalVars.fgd));
            hammer.AddChild(KeyValueHelpers.addKey("DefaultTextureScale", GlobalVars.DefaultTextureScale));
            hammer.AddChild(KeyValueHelpers.addKey("DefaultLightmapScale", GlobalVars.DefaultLightmapScale));
            hammer.AddChild(KeyValueHelpers.addKey("GameExe", GlobalVars.gameexe));
            hammer.AddChild(KeyValueHelpers.addKey("DefaultSolidEntity", GlobalVars.DefaultSolidEntity));
            hammer.AddChild(KeyValueHelpers.addKey("DefaultPointEntity", GlobalVars.DefaultPointEntity));
            hammer.AddChild(KeyValueHelpers.addKey("BSP", GlobalVars.vbsp));
            hammer.AddChild(KeyValueHelpers.addKey("Vis", GlobalVars.vvis));
            hammer.AddChild(KeyValueHelpers.addKey("Light", GlobalVars.vrad));
            hammer.AddChild(KeyValueHelpers.addKey("GameExeDir", GlobalVars.gamedir));
            hammer.AddChild(KeyValueHelpers.addKey("MapDir", GlobalVars.mapsrcdir));
            hammer.AddChild(KeyValueHelpers.addKey("BSPDir", GlobalVars.mapdir));
            hammer.AddChild(KeyValueHelpers.addKey("CordonTexture", GlobalVars.CordonTexture));
            hammer.AddChild(KeyValueHelpers.addKey("MaterialExcludeCount", GlobalVars.MaterialExcludeCount));

            currgame.AddChild(hammer);

            games.AddChild(currgame);

            kv.AddChild(games);

            kv.AddChild(KeyValueHelpers.addKey("SDKVersion", GlobalVars.SDKVersion));

            return(kv);
        }
		public void serializeSettings() {
			KeyValue rootKV = new KeyValue("Addons");
			foreach (KeyValuePair<string, Addon> a in addons) {
				string addonName = a.Key;
				Addon addon = a.Value;
				KeyValue addonKV = new KeyValue(addonName);
				addon.serializeSettings(addonKV);
				rootKV.AddChild(addonKV);
			}

			Settings.Default.AddonsKV = rootKV.ToString();

			// serialize the customTiles
			string customTilesSerialized = "";
			for (int i = 0; i < customTiles.Length; i++) {
				customTilesSerialized += customTiles[i].serializedTileInfo + "|";
			}
			Settings.Default.CustomTileInfo = customTilesSerialized;
			Settings.Default.Save();
		}
Exemple #10
0
 private void addPreference(KeyValue preferences, string key, string val)
 {
     KeyValue newKV = new KeyValue(key);
     newKV.AddChild(new KeyValue(val));
     preferences.AddChild(newKV);
 }
		internal void serializeSettings() {
			addonKV = new KeyValue(workshopID);
			if (WorkshopImgSizeOnWeb != 0) {
				addonKV.AddChild(new KeyValue("WorkshopImgSizeOnWeb").Set(WorkshopImgSizeOnWeb));
			}
		}
		private void generateSoundMapFile() {
			string[] files = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "*.txt", SearchOption.AllDirectories);
			vsndToName = new Dictionary<string, List<string>>();

			foreach (string file in files) {
				try {
					if (file.Contains("sounds") && !file.Contains("phonemes")) {
						KeyValue[] roots = KVParser.KV1.ParseAll(File.ReadAllText(file));
						if (roots == null || roots.Count() == 0) {
							continue;
						}

						foreach (KeyValue kv2 in roots) {
							string soundName = kv2.Key;


							if (kv2.HasChildren) {
								foreach (KeyValue kv3 in kv2.Children) {
									if (kv3.Key.Contains("wave")) {
										if (kv3.HasChildren) {
											foreach (KeyValue kv4 in kv3.Children) {
												string val4 = kv4.GetString();
												if (val4.EndsWith(".wav") || val4.EndsWith(".mp3")) {
													string vsnd = fixWave(val4);
													//Debug.WriteLine(val4 + " | " + soundName);
													string val = soundName + "|" + file.Replace(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "soundevents");
                                                    if (!vsndToName.ContainsKey(vsnd)) {
														List<string> soundNames = new List<string>();
														soundNames.Add(val);
														vsndToName[vsnd] = soundNames;
													} else {
														if (!vsndToName[vsnd].Contains(val)) {
															vsndToName[vsnd].Add(val);
														}
													}
												}

											}
										} else {
											string val3 = kv3.GetString();
											if (val3.EndsWith(".wav") || val3.EndsWith(".mp3")) {
												string vsnd = fixWave(val3);
												//Debug.WriteLine(val3 + " | " + soundName);
												string val = soundName + "|" + file.Replace(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "soundevents");
												if (!vsndToName.ContainsKey(vsnd)) {
													List<string> soundNames = new List<string>();
													soundNames.Add(val);
													vsndToName[vsnd] = soundNames;
												} else {
													if (!vsndToName[vsnd].Contains(val)) {
														vsndToName[vsnd].Add(val);
													}
												}
											}
										}
									}
								}
							}
						}
					}
				} catch (Exception ex) {
					Debug.WriteLine("Skipping " + file + ":");
					//Debug.WriteLine(ex.ToString());
					continue;
				}
			}

			KeyValue root = new KeyValue("Sounds");
			foreach (KeyValuePair<string, List<string>> m in vsndToName) {
				string soundVsnd = m.Key;
				List<string> soundInfos = m.Value;
				KeyValue soundKV = new KeyValue(soundVsnd);
				root.AddChild(soundKV);

				foreach (string soundInfo in soundInfos) {
					string[] parts = soundInfo.Split('|');
					string soundName = parts[0];
					string vsndevts = parts[1];

					vsndevts = vsndevts.Replace("\\", "/");
					vsndevts = vsndevts.Replace(".txt", ".vsndevts");

					KeyValue waveKV = new KeyValue(soundName + "|" + vsndevts);
					soundKV.AddChild(waveKV);
				}
			}

			File.WriteAllText(vsnd_to_soundname_Path, root.ToString());
		}
Exemple #13
0
 public void Add(T item)
 {
     KeyValue.AddChild(item.KeyValue);
 }
Exemple #14
0
 private void addKV(string addonName, string key, string val)
 {
     foreach (KeyValue kv in AddonDataMasterKV.Children)
     {
         string name = kv.Key;
         if (addonName.ToLower() == name.ToLower()) {
             KeyValue newKV = new KeyValue(key);
             newKV.AddChild(new KeyValue(val));
             kv.AddChild(newKV);
             break;
         }
     }
 }
		public void serializeSettings() {
			var root = new KeyValue("InstalledAddons");
			foreach (var kv in installedCustomGames) {
				var cg = kv.Value;
				cg.serializeSettings();
				root.AddChild(cg.addonKV);
			}
			Settings.Default.InstalledAddonsKV = root.ToString();

			Settings.Default.Save();
		}
Exemple #16
0
        internal void serializeSettings(KeyValue addonKV)
        {
            KeyValue workshopIDKV = new KeyValue("workshopID");

            workshopIDKV.AddChild(new KeyValue(this.workshopID.ToString()));
            addonKV.AddChild(workshopIDKV);

            KeyValue generateNote0KV = new KeyValue("generateNote0");

            generateNote0KV.AddChild(new KeyValue(this.generateNote0.ToString()));
            addonKV.AddChild(generateNote0KV);

            KeyValue generateLoreKV = new KeyValue("generateLore");

            generateLoreKV.AddChild(new KeyValue(this.generateLore.ToString()));
            addonKV.AddChild(generateLoreKV);

            KeyValue askToBreakUp = new KeyValue("askToBreakUp");

            askToBreakUp.AddChild(new KeyValue(this.askToBreakUp.ToString()));
            addonKV.AddChild(askToBreakUp);

            KeyValue autoDeleteBin = new KeyValue("autoDeleteBin");

            autoDeleteBin.AddChild(new KeyValue(this.autoDeleteBin.ToString()));
            addonKV.AddChild(autoDeleteBin);

            KeyValue barebonesLibUpdates = new KeyValue("barebonesLibUpdates");

            barebonesLibUpdates.AddChild(new KeyValue(this.barebonesLibUpdates.ToString()));
            addonKV.AddChild(barebonesLibUpdates);

            KeyValue generateUTF8 = new KeyValue("generateUTF8");

            generateUTF8.AddChild(new KeyValue(this.generateUTF8.ToString()));
            addonKV.AddChild(generateUTF8);

            KeyValue autoCompileCoffeeScript = new KeyValue("autoCompileCoffeeScript");

            autoCompileCoffeeScript.AddChild(new KeyValue(this.autoCompileCoffeeScript.ToString()));
            addonKV.AddChild(autoCompileCoffeeScript);

            KeyValue libraries = new KeyValue("libraries");

            addonKV.AddChild(libraries);
            foreach (KeyValuePair <string, Library> libraryKV in this.libraries)
            {
                Library  lib   = libraryKV.Value;
                KeyValue libKV = new KeyValue(lib.local);
                libraries.AddChild(libKV);
                // populate libKV
                if (lib.remote != null)
                {
                    KeyValue remoteKV = new KeyValue("Remote");
                    remoteKV.Set(lib.remote);
                    libKV.AddChild(remoteKV);
                }
                if (lib.defaultLibPath != null)
                {
                    KeyValue kv = new KeyValue("DefaultLibPath");
                    kv.Set(lib.defaultLibPath);
                    libKV.AddChild(kv);
                }
                var kv2 = new KeyValue("NeverCheckForUpdates");
                kv2.Set(lib.neverCheckForUpdates);
                libKV.AddChild(kv2);
            }
        }
Exemple #17
0
        /// <summary>
        /// Grab all of the keyvalues from a string.
        /// </summary>
        /// <param name="contents">The string containing keyvalues</param>
        /// <param name="allowunnamedkeys">Whether or not to allow unnamed blocks (used in bsp entity lump)</param>
        /// <returns>An array containing all root-level KeyValues in the string</returns>
        /// <exception cref="KVLib.KeyValues.KeyValueParsingException">Throws one of these if parsing fails</exception>
        public static KeyValue[] ParseAllKeyValues(string contents, bool allowunnamedkeys = false)
        {
            if (contents == null)
            {
                throw new KeyValueParsingException("Contents string was null!", new ArgumentNullException());
            }
            try
            {
                parseEnum parseState = parseEnum.lookingForKey;
                KeyValue  basekv     = new KeyValue("base"); // file contents are interpreted as children of this keyvalue
                KeyValue  curparent  = basekv;
                for (int i = 0; i < contents.Length; i++)
                {
                    // go until next symbol
                    if (contents[i] == ' ' || contents[i] == '\t' || contents[i] == '\n' || contents[i] == '\r')
                    {
                        continue;
                    }
                    switch (parseState)
                    {
                    case parseEnum.lookingForKey:
                        if (contents[i] == '{')
                        {
                            if (!allowunnamedkeys)
                            {
                                throw new KeyValueParsingException("Hit unnamed key while parsing without unnamed keys enabled.", null);
                            }
                            // This is a special case - some kv files, in particular bsp entity lumps, have unkeyed kvs
                            KeyValue cur = new KeyValue("UNNAMED");
                            curparent.AddChild(cur);
                            curparent  = cur;
                            parseState = parseEnum.lookingForValue;
                        }
                        else if (contents[i] == '"' || contents[i] == '\'')
                        {
                            //quoted key
                            int j = i + 1;
                            if (j >= contents.Length)
                            {
                                throw new KeyValueParsingException("Couldn't find terminating '" + contents[i].ToString() + "' for key started at position " + i.ToString(), null);
                            }
                            while (contents[j] != contents[i])
                            {
                                // handle escaped quotes
                                if (contents[j] == '\\')
                                {
                                    j++;
                                }
                                j++;
                                if (j >= contents.Length)
                                {
                                    throw new KeyValueParsingException("Couldn't find terminating '" + contents[i].ToString() + "' for key started at position " + i.ToString(), null);
                                }
                            }
                            //ok, now contents[i] and contents[j] are the same character, on either end of the key
                            KeyValue cur = new KeyValue(contents.Substring(i + 1, j - (i + 1)));
                            //Console.WriteLine("DEBUG: " + contents.Substring(i + 1, j - (i + 1)));
                            curparent.AddChild(cur);
                            curparent  = cur;
                            parseState = parseEnum.lookingForValue;
                            i          = j;
                        }
                        else if (Char.IsLetter(contents[i]))
                        {
                            //un-quoted key
                            int j = i;
                            while (contents[j] != ' ' && contents[j] != '\t' && contents[j] != '\n' && contents[j] != '\r')
                            {
                                j++;
                                if (j > contents.Length)
                                {
                                    throw new KeyValueParsingException("Couldn't find end of key started at position " + i.ToString(), null);
                                }
                            }
                            KeyValue cur = new KeyValue(contents.Substring(i, j - i));
                            curparent.AddChild(cur);
                            curparent  = cur;
                            parseState = parseEnum.lookingForValue;
                            i          = j;
                        }
                        else if (contents[i] == '}')
                        {
                            //drop one level
                            curparent = curparent.Parent;
                        }
                        else if (contents[i] == '/')
                        {
                            if (i + 1 < contents.Length && contents[i + 1] == '/')
                            {
                                // we're in a comment! throw stuff away until the next \n
                                while (i < contents.Length && contents[i] != '\n')
                                {
                                    i++;
                                }
                            }
                            else
                            {
                                if (BREAK_SPEC)
                                {
                                    // Valve (incorrectly?) matches / as a single-line comment
                                    while (i < contents.Length && contents[i] != '\n')
                                    {
                                        i++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            throw new KeyValueParsingException("Unexpected '" + contents[i].ToString() + "' at position " + i.ToString(), null);
                        }
                        break;

                    case parseEnum.lookingForValue:
                        if (contents[i] == '{')
                        {
                            // it's a list of children
                            // thankfully, we don't actually need to handle this!
                            parseState = parseEnum.lookingForKey;
                        }
                        else if (contents[i] == '"' || contents[i] == '\'')
                        {
                            //quoted value
                            int j = i + 1;
                            while (contents[j] != contents[i])
                            {
                                // handle escaped quotes
                                if (contents[j] == '\\')
                                {
                                    j++;
                                }
                                j++;
                                if (j > contents.Length)
                                {
                                    throw new KeyValueParsingException("Couldn't find terminating '" + contents[i].ToString() + "' for key started at position " + i.ToString(), null);
                                }
                            }
                            //ok, now contents[i] and contents[j] are the same character, on either end of the value
                            curparent.Set(contents.Substring(i + 1, j - (i + 1)));
                            curparent  = curparent.Parent;
                            parseState = parseEnum.lookingForKey;
                            i          = j;
                        }
                        else if (contents[i] == '/')
                        {
                            if (i + 1 < contents.Length && contents[i + 1] == '/')
                            {
                                // we're in a comment! throw stuff away until the next \n
                                while (i < contents.Length && contents[i] != '\n')
                                {
                                    i++;
                                }
                            }
                        }
                        else if (!Char.IsWhiteSpace(contents[i]))
                        {
                            int j = i;
                            while (contents[j] != ' ' && contents[j] != '\t' && contents[j] != '\n' && contents[j] != '\r')
                            {
                                j++;
                                if (j > contents.Length)
                                {
                                    // a value ending the file counts as ending the value
                                    break;
                                }
                            }
                            curparent.Set(contents.Substring(i, j - i));
                            curparent  = curparent.Parent;
                            parseState = parseEnum.lookingForKey;
                            i          = j;
                        }
                        else
                        {
                            throw new KeyValueParsingException("Unexpected '" + contents[i].ToString() + "' at position " + i.ToString(), null);
                        }
                        break;
                    }
                }
                // At the end of the file, we should be looking for another key
                if (parseState != parseEnum.lookingForKey)
                {
                    throw new KeyNotFoundException("File ended while looking for value", null);
                }
                // At the end of the file, all block values should be closed
                if (curparent != basekv)
                {
                    throw new KeyNotFoundException("Unterminated child blocks", null);
                }
                KeyValue[] ret = basekv.Children.ToArray <KeyValue>();
                basekv.ClearChildParents();
                return(ret);
            }
            catch (KeyValueParsingException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new KeyValueParsingException("Hit an exception while parsing kv data!", e);
            }
        }
Exemple #18
0
        private void generateSoundMapFile()
        {
            string[] files = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "*.txt", SearchOption.AllDirectories);
            vsndToName = new Dictionary <string, List <string> >();

            foreach (string file in files)
            {
                try {
                    if (file.Contains("sounds") && !file.Contains("phonemes"))
                    {
                        KeyValue[] roots = KVParser.KV1.ParseAll(File.ReadAllText(file));
                        if (roots == null || roots.Count() == 0)
                        {
                            continue;
                        }

                        foreach (KeyValue kv2 in roots)
                        {
                            string soundName = kv2.Key;


                            if (kv2.HasChildren)
                            {
                                foreach (KeyValue kv3 in kv2.Children)
                                {
                                    if (kv3.Key.Contains("wave"))
                                    {
                                        if (kv3.HasChildren)
                                        {
                                            foreach (KeyValue kv4 in kv3.Children)
                                            {
                                                string val4 = kv4.GetString();
                                                if (val4.EndsWith(".wav") || val4.EndsWith(".mp3"))
                                                {
                                                    string vsnd = fixWave(val4);
                                                    //Debug.WriteLine(val4 + " | " + soundName);
                                                    string val = soundName + "|" + file.Replace(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "soundevents");
                                                    if (!vsndToName.ContainsKey(vsnd))
                                                    {
                                                        List <string> soundNames = new List <string>();
                                                        soundNames.Add(val);
                                                        vsndToName[vsnd] = soundNames;
                                                    }
                                                    else
                                                    {
                                                        if (!vsndToName[vsnd].Contains(val))
                                                        {
                                                            vsndToName[vsnd].Add(val);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            string val3 = kv3.GetString();
                                            if (val3.EndsWith(".wav") || val3.EndsWith(".mp3"))
                                            {
                                                string vsnd = fixWave(val3);
                                                //Debug.WriteLine(val3 + " | " + soundName);
                                                string val = soundName + "|" + file.Replace(Path.Combine(Environment.CurrentDirectory, "possible_sscripts"), "soundevents");
                                                if (!vsndToName.ContainsKey(vsnd))
                                                {
                                                    List <string> soundNames = new List <string>();
                                                    soundNames.Add(val);
                                                    vsndToName[vsnd] = soundNames;
                                                }
                                                else
                                                {
                                                    if (!vsndToName[vsnd].Contains(val))
                                                    {
                                                        vsndToName[vsnd].Add(val);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                } catch (Exception ex) {
                    Debug.WriteLine("Skipping " + file + ":");
                    //Debug.WriteLine(ex.ToString());
                    continue;
                }
            }

            KeyValue root = new KeyValue("Sounds");

            foreach (KeyValuePair <string, List <string> > m in vsndToName)
            {
                string        soundVsnd  = m.Key;
                List <string> soundInfos = m.Value;
                KeyValue      soundKV    = new KeyValue(soundVsnd);
                root.AddChild(soundKV);

                foreach (string soundInfo in soundInfos)
                {
                    string[] parts     = soundInfo.Split('|');
                    string   soundName = parts[0];
                    string   vsndevts  = parts[1];

                    vsndevts = vsndevts.Replace("\\", "/");
                    vsndevts = vsndevts.Replace(".txt", ".vsndevts");

                    KeyValue waveKV = new KeyValue(soundName + "|" + vsndevts);
                    soundKV.AddChild(waveKV);
                }
            }

            File.WriteAllText(vsnd_to_soundname_Path, root.ToString());
        }
Exemple #19
0
        internal void serializeSettings(KeyValue addonKV)
        {
            KeyValue workshopIDKV = new KeyValue("workshopID");
            workshopIDKV.AddChild(new KeyValue(this.workshopID.ToString()));
            addonKV.AddChild(workshopIDKV);

            KeyValue generateNote0KV = new KeyValue("generateNote0");
            generateNote0KV.AddChild(new KeyValue(this.generateNote0.ToString()));
            addonKV.AddChild(generateNote0KV);

            KeyValue generateLoreKV = new KeyValue("generateLore");
            generateLoreKV.AddChild(new KeyValue(this.generateLore.ToString()));
            addonKV.AddChild(generateLoreKV);

            KeyValue askToBreakUp = new KeyValue("askToBreakUp");
            askToBreakUp.AddChild(new KeyValue(this.askToBreakUp.ToString()));
            addonKV.AddChild(askToBreakUp);

            KeyValue autoDeleteBin = new KeyValue("autoDeleteBin");
            autoDeleteBin.AddChild(new KeyValue(this.autoDeleteBin.ToString()));
            addonKV.AddChild(autoDeleteBin);

            KeyValue barebonesLibUpdates = new KeyValue("barebonesLibUpdates");
            barebonesLibUpdates.AddChild(new KeyValue(this.barebonesLibUpdates.ToString()));
            addonKV.AddChild(barebonesLibUpdates);

            KeyValue generateUTF8 = new KeyValue("generateUTF8");
            generateUTF8.AddChild(new KeyValue(this.generateUTF8.ToString()));
            addonKV.AddChild(generateUTF8);

            KeyValue libraries = new KeyValue("libraries");
            addonKV.AddChild(libraries);
            foreach (KeyValuePair<string, Library> libraryKV in this.libraries) {
                Library lib = libraryKV.Value;
                KeyValue libKV = new KeyValue(lib.local);
                libraries.AddChild(libKV);
                // populate libKV
                if (lib.remote != null) {
                    KeyValue remoteKV = new KeyValue("Remote");
                    remoteKV.Set(lib.remote);
                    libKV.AddChild(remoteKV);
                }
                if (lib.defaultLibPath != null) {
                    KeyValue kv = new KeyValue("DefaultLibPath");
                    kv.Set(lib.defaultLibPath);
                    libKV.AddChild(kv);
                }
                var kv2 = new KeyValue("NeverCheckForUpdates");
                kv2.Set(lib.neverCheckForUpdates);
                libKV.AddChild(kv2);
            }
        }
Exemple #20
0
        public void serializeSettings()
        {
            KeyValue rootKV = new KeyValue("Addons");
            foreach (KeyValuePair<string, Addon> a in addons) {
                string addonName = a.Key;
                Addon addon = a.Value;
                KeyValue addonKV = new KeyValue(addonName);
                addon.serializeSettings(addonKV);
                rootKV.AddChild(addonKV);
            }

            // compress string to take up less space.
            /*StringBuilder sb = new StringBuilder();
            string[] split = rootKV.ToString().Split('\n');
            for (int i = 0; i < split.Length; i++) {
                string l = split[i];
                l = l.Trim();
                sb.AppendLine(l);
            }*/

            Settings.Default.AddonsKV = rootKV.ToString();
            Settings.Default.Save();
        }
Exemple #21
0
        // init addon with basic Modkit preferences if it's never been done before.
        private void initPreferences(KeyValue addonKV, Addon a)
        {
            KeyValue pref = new KeyValue("preferences");
            addPreference(pref, "create_note0_lore", "0");
            KeyValue kv_files = new KeyValue("kv_files");
            string[] npcFiles = { "Heroes", "Units", "Items", "Abilities" };
            foreach (string s in npcFiles) {
                KeyValue name = new KeyValue(s);
                string path = Path.Combine(a.GamePath, "scripts", "npc", "npc_" + s.ToLower() + "_custom.txt");
                KeyValue pathKV = new KeyValue("path");
                pathKV.AddChild(new KeyValue(path));
                KeyValue activated = new KeyValue("activated");
                activated.AddChild(new KeyValue("1"));
                name.AddChild(pathKV);
                name.AddChild(activated);
                kv_files.AddChild(name);
            }

            pref.AddChild(kv_files);
            addonKV.AddChild(pref);
        }