public static bool Save(this FeatureContainer f, Boolean overwrite) { FileInfo file = SourceManager.GetFileName(f.Name, f.Source, f.category); if (file.Exists && (f.FileName == null || !f.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) FeatureContainer.Serializer.Serialize(writer, f); f.FileName = file.FullName; return(true); }
public static bool Save(this SubRace r, Boolean overwrite) { r.Name = r.Name.Replace(ConfigManager.SourceSeperator, '-'); FileInfo file = SourceManager.GetFileName(r.Name, r.Source, Program.Context.Config.SubRaces_Directory); if (file.Exists && (r.FileName == null || !r.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) SubRace.Serializer.Serialize(writer, r); r.FileName = file.FullName; return(true); }
public static bool Save(this Condition cond, Boolean overwrite) { cond.Name = cond.Name.Replace(ConfigManager.SourceSeperator, '-'); FileInfo file = SourceManager.GetFileName(cond.Name, cond.Source, Program.Context.Config.Conditions_Directory); if (file.Exists && (cond.FileName == null || !cond.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) Condition.Serializer.Serialize(writer, cond); cond.FileName = file.FullName; return(true); }
public static bool Save(this Background background, Boolean overwrite) { background.Name = background.Name.Replace(ConfigManager.SourceSeperator, '-'); FileInfo file = SourceManager.GetFileName(background.Name, background.Source, Program.Context.Config.Backgrounds_Directory); if (file.Exists && (background.FileName == null || !background.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) Background.Serializer.Serialize(writer, background); background.FileName = file.FullName; return(true); }
public static bool Save(this Monster m, Boolean overwrite) { m.Name = m.Name.Replace(ConfigManager.SourceSeperator, '-'); FileInfo file = SourceManager.GetFileName(m.Name, m.Source, Program.Context.Config.Monster_Directory); if (file.Exists && (m.FileName == null || !m.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) Monster.Serializer.Serialize(writer, m); m.FileName = file.FullName; return(true); }
public static bool Save(this Language l, Boolean overwrite) { l.Name = l.Name.Replace(ConfigManager.SourceSeperator, '-'); FileInfo file = SourceManager.GetFileName(l.Name, l.Source, Program.Context.Config.Languages_Directory); if (file.Exists && (l.FileName == null || !l.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) Language.Serializer.Serialize(writer, l); l.FileName = file.FullName; return(true); }
public static bool Save(this Spell s, Boolean overwrite) { s.Name = s.Name.Replace(ConfigManager.SourceSeperator, '-'); FileInfo file = SourceManager.GetFileName(s.Name, s.Source, Program.Context.Config.Spells_Directory); if (file.Exists && (s.Filename == null || !s.Filename.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) Spell.Serializer.Serialize(writer, s); s.Filename = file.FullName; return(true); }
public static bool Save(this Item i, Boolean overwrite) { Item o = null; i.Name = i.Name.Replace(ConfigManager.SourceSeperator, '-'); if (Program.Context.Items.ContainsKey(i.Name + " " + ConfigManager.SourceSeperator + " " + i.Source)) { o = Program.Context.Items[i.Name + " " + ConfigManager.SourceSeperator + " " + i.Source]; } if (o != null && !o.autogenerated && o.Category.Path != i.Category.Path) { throw new Exception("Item needs a unique name"); } FileInfo file = SourceManager.GetFileName(i.Name, i.Source, Path.Combine(Program.Context.Config.Items_Directory, Path.Combine(i.Category.MakePath().ToArray()))); if (file.Exists && (i.FileName == null || !i.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) Item.Serializer.Serialize(writer, i); i.FileName = file.FullName; return(true); }
public static bool Save(this MagicProperty mp, Boolean overwrite) { mp.Name = mp.Name.Replace(ConfigManager.SourceSeperator, '-'); MagicProperty o = null; if (Program.Context.Magic.ContainsKey(mp.Name + " " + ConfigManager.SourceSeperator + " " + mp.Source)) { o = Program.Context.Magic[mp.Name + " " + ConfigManager.SourceSeperator + " " + mp.Source]; } if (o != null && o.Category != mp.Category) { throw new Exception("Magic Property needs a unique name"); } FileInfo file = SourceManager.GetFileName(mp.Name, mp.Source, ImportExtensions.MagicPropertyCleanname(Program.Context, mp.Category)); if (file.Exists && (mp.FileName == null || !mp.FileName.Equals(file.FullName)) && !overwrite) { return(false); } using (TextWriter writer = new StreamWriter(file.FullName)) MagicProperty.Serializer.Serialize(writer, mp); mp.FileName = file.FullName; return(true); }