public static void SaveDatabaseToFile(InterrupterDatabase database, string path) { StreamWriter file = new StreamWriter(path); file.WriteLine("// "); file.WriteLine("// Interrupter Ultimate - Spells and Tag Groups - Database file"); file.WriteLine("// How to read:"); file.WriteLine("// \"fields\" are separated by Tab Stop character (the one appearing after pressing Tab key on left edge of the keyboard), "); file.WriteLine("// all other characters (except commas for TagIDs and Aliases) including whitespace are parts of those fields."); file.WriteLine("// "); file.WriteLine("// Tag group:<tab>tagGroupID<tab>Interrupt<tab>RemoveFromInterrupts<tab>Aliases separated by \",\" (comma)"); file.WriteLine("// Spell:<tab>spellName<tab>tspellID<tab>Interrupt<tab>TagIDs separated by commas"); file.WriteLine("// Unit:<tab>unitID<tab>included"); file.WriteLine("// Lines starting with \"//\" are ignored."); file.WriteLine("// "); file.WriteLine("// Do not manually edit unless you are 100% sure of what you are doing, this file is NOT verified when loading"); file.WriteLine("// "); file.WriteLine("// "); foreach (KeyValuePair<string, SpellTagGroup> entry in database.Tags) { file.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", "Tag group:", entry.Key.ToString().Normalize(), entry.Value.Include.ToString().Normalize(), entry.Value.EntirelyExclude.ToString().Normalize(), entry.Value.Aliases.ToRealString().Normalize()); } foreach (KeyValuePair<int, InterrupterSpell> entry in database.Spells) { file.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", "Spell:", entry.Value.Name.Normalize(), entry.Key.ToString().Normalize(), entry.Value.Include.ToString().Normalize(), entry.Value.TagGroupIDs.ToRealString().Normalize()); } foreach (KeyValuePair<string, bool> unit in database.Units) { file.WriteLine("{0}\t{1}\t{2}", "Unit:", unit.Key, unit.Value); } file.Close(); }
static public void SaveDatabaseToFile(InterrupterDatabase database, string path) { StreamWriter file = new StreamWriter(path); file.WriteLine("// "); file.WriteLine("// Interrupter Ultimate - Spells and Tag Groups - Database file"); file.WriteLine("// How to read:"); file.WriteLine("// \"fields\" are separated by Tab Stop character (the one appearing after pressing Tab key on left edge of the keyboard), "); file.WriteLine("// all other characters (except commas for TagIDs and Aliases) including whitespace are parts of those fields."); file.WriteLine("// "); file.WriteLine("// Tag group:<tab>tagGroupID<tab>Interrupt<tab>RemoveFromInterrupts<tab>Aliases separated by \",\" (comma)"); file.WriteLine("// Spell:<tab>spellName<tab>tspellID<tab>Interrupt<tab>TagIDs separated by commas"); file.WriteLine("// Unit:<tab>unitID<tab>included"); file.WriteLine("// Lines starting with \"//\" are ignored."); file.WriteLine("// "); file.WriteLine("// Do not manually edit unless you are 100% sure of what you are doing, this file is NOT verified when loading"); file.WriteLine("// "); file.WriteLine("// "); foreach (KeyValuePair <string, SpellTagGroup> entry in database.Tags) { file.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", "Tag group:", entry.Key.ToString().Normalize(), entry.Value.Include.ToString().Normalize(), entry.Value.EntirelyExclude.ToString().Normalize(), entry.Value.Aliases.ToRealString().Normalize()); } foreach (KeyValuePair <int, InterrupterSpell> entry in database.Spells) { file.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", "Spell:", entry.Value.Name.Normalize(), entry.Key.ToString().Normalize(), entry.Value.Include.ToString().Normalize(), entry.Value.TagGroupIDs.ToRealString().Normalize()); } foreach (KeyValuePair <string, bool> unit in database.Units) { file.WriteLine("{0}\t{1}\t{2}", "Unit:", unit.Key, unit.Value); } file.Close(); }
public override void Initialize() { base.Initialize(); if (!IsInitialized) { slog("Initializing..."); if (File.Exists(DatabasePath)) { blog(DatabasePath + " found, extracting database..."); InterrupterContainer = ReadDatabaseFromFile(DatabasePath); dlogTags(InterrupterContainer); dlogSpells(InterrupterContainer); dlog("Sorting database..."); var sortedspells = (from entry in InterrupterContainer.Spells orderby entry.Value.Name ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); var sortedtags = (from entry in InterrupterContainer.Tags orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); var sortedunits = (from entry in InterrupterContainer.Units orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); InterrupterContainer.Spells = sortedspells; InterrupterContainer.Tags = sortedtags; InterrupterContainer.Units = sortedunits; foreach (KeyValuePair<string, bool> unit in InterrupterContainer.Units) { SpellTracker.VerifyTargetToTrack(unit.Key, unit.Value); } dlog("Database sorted."); blog("Database is ready."); } else { blog(DatabasePath + " not found, building default database..."); CreateDefaultInterrupterDatabase(); dlog("Sorting database..."); var sortedspells = (from entry in InterrupterContainer.Spells orderby entry.Value.Name ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); var sortedtags = (from entry in InterrupterContainer.Tags orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); var sortedunits = (from entry in InterrupterContainer.Units orderby entry.Key ascending select entry).ToDictionary(pair => pair.Key, pair => pair.Value); InterrupterContainer.Spells = sortedspells; InterrupterContainer.Tags = sortedtags; InterrupterContainer.Units = sortedunits; dlog("Database sorted."); blog("Default database is ready."); } IsInitialized = true; slog("Initialization completed."); } }
static public InterrupterDatabase ReadDatabaseFromFile(string path) { string line; InterrupterDatabase output = new InterrupterDatabase(); using (StreamReader file = new StreamReader(path)) { while ((line = file.ReadLine()) != null) { string[] parts = line.Split('\t'); if (parts[0] == "Tag group:") { SpellTagGroup tag = new SpellTagGroup(parts[2].ToBoolean(), parts[3].ToBoolean(), parts[1], parts[4].Split(',')); output.Tags.Add(tag.GroupID, tag); } else if (parts[0] == "Spell:") { InterrupterSpell spell = new InterrupterSpell(parts[2].ToInt32(), parts[3].ToBoolean(), output.Tags, parts[4].Split(',')); output.Spells.Add(spell.ID, spell); } else if (parts[0] == "Unit:") { output.Units.Add(parts[1].ToString(), parts[2].ToBoolean()); } else if (parts[0].StartsWith("//")) { continue; } else { Logging.WriteDebug("<Interrupter Ultimate> Invalid database line: " + line); } } } return(output); }
public static InterrupterDatabase ReadDatabaseFromFile(string path) { string line; InterrupterDatabase output = new InterrupterDatabase(); using (StreamReader file = new StreamReader(path)) { while ((line = file.ReadLine()) != null) { string[] parts = line.Split('\t'); if (parts[0] == "Tag group:") { SpellTagGroup tag = new SpellTagGroup(parts[2].ToBoolean(), parts[3].ToBoolean(), parts[1], parts[4].Split(',')); output.Tags.Add(tag.GroupID, tag); } else if (parts[0] == "Spell:") { InterrupterSpell spell = new InterrupterSpell(parts[2].ToInt32(), parts[3].ToBoolean(), output.Tags, parts[4].Split(',')); output.Spells.Add(spell.ID, spell); } else if (parts[0] == "Unit:") { output.Units.Add(parts[1].ToString(), parts[2].ToBoolean()); } else if (parts[0].StartsWith("//")) { continue; } else { Logging.WriteDebug("<Interrupter Ultimate> Invalid database line: " + line); } } } return output; }
private void dlogSpells(InterrupterDatabase database) { database.dlogSpells(); }
private void dlogTags(InterrupterDatabase database) { database.dlogTags(); }