private void writeTooltips() { foreach (string path in getAddonLangPaths()) { alreadyHasKeys.Clear(); string thisLang = path.Substring(path.LastIndexOf('\\') + 1); string thisLangCopy = thisLang; thisLang = thisLang.Substring(thisLang.LastIndexOf('_') + 1); string outputPath = Path.Combine(contentPath, "tooltips_" + thisLang); KeyValue kv = KVParser.KV1.ParseAll(File.ReadAllText(path, Encoding.Unicode))[0]; foreach (KeyValue kv2 in kv.Children) { if (kv2.Key == "Tokens") { foreach (KeyValue kv3 in kv2.Children) { alreadyHasKeys.Add(kv3.Key.ToLowerInvariant()); } } } StringBuilder content = new StringBuilder(); string head0 = "\t\t// DOTA 2 MODKIT GENERATED TOOLTIPS FOR: " + this.name + "\n" + "\t\t// Keys already defined in " + thisLangCopy + " are not listed, nor are Modifiers with the property \"IsHidden\" \"1\".\n"; content.Append(head0); string head1 = "\n\t\t// ******************** HEROES ********************\n"; content.Append(head1); foreach (HeroEntry he in heroEntries) { if (!alreadyHasKeys.Contains(he.name.key.ToLowerInvariant())) { content.Append(he); } } string head2 = "\n\t\t// ******************** UNITS ********************\n"; content.Append(head2); foreach (UnitEntry ue in unitEntries) { if (!alreadyHasKeys.Contains(ue.name.key.ToLowerInvariant())) { content.Append(ue); } } string head3 = "\n\t\t// ******************** ABILITY MODIFIERS ********************\n"; content.Append(head3); foreach (string amn in abilityModifierNames) { ModifierEntry me = new ModifierEntry(this, amn); if (!alreadyHasKeys.Contains(me.name.key.ToLowerInvariant())) { content.Append(me + "\n"); } } string head4 = "\n\t\t// ******************** ITEM MODIFIERS ********************\n"; content.Append(head4); foreach (string imn in itemModifierNames) { ModifierEntry me = new ModifierEntry(this, imn); if (!alreadyHasKeys.Contains(me.name.key.ToLowerInvariant())) { content.Append(me + "\n"); } } string head5 = "\n\t\t// ******************** ABILITIES ********************\n"; content.Append(head5); foreach (AbilityEntry ae in abilityEntries) { if (!alreadyHasKeys.Contains(ae.name.key.ToLowerInvariant())) { content.Append(ae + "\n"); } else { // the addon_language already has this ability. but let's check // if there are any new AbilitySpecials. bool missingAbilSpecials = false; foreach (Pair p in ae.abilitySpecials) { if (!alreadyHasKeys.Contains(p.key.ToLowerInvariant())) { // the addon_language doesn't contain this abil special. content.Append(p.ToString()); missingAbilSpecials = true; } } if (missingAbilSpecials) { content.Append("\n"); } } } string head6 = "\n\t\t// ******************** ITEMS ********************\n"; content.Append(head6); foreach (AbilityEntry ae in itemEntries) { if (!alreadyHasKeys.Contains(ae.name.key.ToLowerInvariant())) { content.Append(ae + "\n"); } else { // the addon_language already has this ability. but let's check // if there are any new AbilitySpecials. bool missingAbilSpecials = false; foreach (Pair p in ae.abilitySpecials) { if (!alreadyHasKeys.Contains(p.key.ToLowerInvariant())) { // the addon_language doesn't contain this abil special. content.Append(p.ToString()); missingAbilSpecials = true; } } if (missingAbilSpecials) { content.Append("\n"); } } } File.WriteAllText(outputPath, content.ToString(), Encoding.Unicode); Process.Start(outputPath); } }
private void writeTooltips() { foreach (string path in getAddonLangPaths()) { alreadyHasKeys.Clear(); string thisLang = path.Substring(path.LastIndexOf('\\') + 1); string thisLangCopy = thisLang; thisLang = thisLang.Substring(thisLang.LastIndexOf('_') + 1); string outputPath = Path.Combine(contentPath, "tooltips_" + thisLang); KeyValue kv = KVParser.KV1.ParseAll(File.ReadAllText(path, Encoding.Unicode))[0]; foreach (KeyValue kv2 in kv.Children) { if (kv2.Key == "Tokens") { foreach (KeyValue kv3 in kv2.Children) { alreadyHasKeys.Add(kv3.Key.ToLowerInvariant()); } } } StringBuilder content = new StringBuilder(); string head0 = "\t\t// DOTA 2 MODKIT GENERATED TOOLTIPS FOR: " + this.name + "\n" + "\t\t// Keys already defined in " + thisLangCopy + " are not listed, nor are Modifiers with the property \"IsHidden\" \"1\".\n"; content.Append(head0); string head1 = "\n\t\t// ******************** HEROES ********************\n"; content.Append(head1); foreach (HeroEntry he in heroEntries) { if (!alreadyHasKeys.Contains(he.name.key.ToLowerInvariant())) { content.Append(he); } } string head2 = "\n\t\t// ******************** UNITS ********************\n"; content.Append(head2); foreach (UnitEntry ue in unitEntries) { if (!alreadyHasKeys.Contains(ue.name.key.ToLowerInvariant())) { content.Append(ue); } } string head3 = "\n\t\t// ******************** ABILITY MODIFIERS ********************\n"; content.Append(head3); foreach (string amn in abilityModifierNames) { ModifierEntry me = new ModifierEntry(this, amn); if (!alreadyHasKeys.Contains(me.name.key.ToLowerInvariant())) { content.Append(me + "\n"); } } string head4 = "\n\t\t// ******************** ITEM MODIFIERS ********************\n"; content.Append(head4); foreach (string imn in itemModifierNames) { ModifierEntry me = new ModifierEntry(this, imn); if (!alreadyHasKeys.Contains(me.name.key.ToLowerInvariant())) { content.Append(me + "\n"); } } string head5 = "\n\t\t// ******************** ABILITIES ********************\n"; content.Append(head5); foreach (AbilityEntry ae in abilityEntries) { if (!alreadyHasKeys.Contains(ae.name.key.ToLowerInvariant())) { content.Append(ae + "\n"); } else { // the addon_language already has this ability. but let's check // if there are any new AbilitySpecials. bool missingAbilSpecials = false; foreach (Pair p in ae.abilitySpecials) { if (!alreadyHasKeys.Contains(p.key.ToLowerInvariant())) { // the addon_language doesn't contain this abil special. content.Append(p.ToString()); missingAbilSpecials = true; } } if (missingAbilSpecials) { content.Append("\n"); } } } string head6 = "\n\t\t// ******************** ITEMS ********************\n"; content.Append(head6); foreach (AbilityEntry ae in itemEntries) { if (!alreadyHasKeys.Contains(ae.name.key.ToLowerInvariant())) { content.Append(ae + "\n"); } else { // the addon_language already has this ability. but let's check // if there are any new AbilitySpecials. bool missingAbilSpecials = false; foreach (Pair p in ae.abilitySpecials) { if (!alreadyHasKeys.Contains(p.key.ToLowerInvariant())) { // the addon_language doesn't contain this abil special. content.Append(p.ToString()); missingAbilSpecials = true; } } if (missingAbilSpecials) { content.Append("\n"); } } } File.WriteAllText(outputPath, content.ToString(), Encoding.Unicode); Process.Start(outputPath); } }