public override MiniYaml Save() { return(new MiniYaml(FieldSaver.FormatValue(value))); }
public override MiniYaml Save() { return(FieldSaver.Save(this)); }
public List <MiniYamlNode> ToMiniYaml() { return(Players.Select(p => new MiniYamlNode("PlayerReference@{0}".F(p.Key), FieldSaver.SaveDifferences(p.Value, new PlayerReference()))).ToList()); }
public void Save(string toPath) { MapFormat = 5; var root = new List <MiniYamlNode>(); var fields = new [] { "Selectable", "MapFormat", "RequiresMod", "Title", "Description", "Author", "Tileset", "MapSize", "Bounds", "UseAsShellmap", "Type", }; foreach (var field in fields) { var f = this.GetType().GetField(field); if (f.GetValue(this) == null) { continue; } root.Add(new MiniYamlNode(field, FieldSaver.FormatValue(this, f))); } root.Add(new MiniYamlNode("Players", null, Players.Select(p => new MiniYamlNode( "PlayerReference@{0}".F(p.Key), FieldSaver.SaveDifferences(p.Value, new PlayerReference()))).ToList())); root.Add(new MiniYamlNode("Actors", null, Actors.Value.Select(x => new MiniYamlNode( x.Key, x.Value.Save())).ToList())); root.Add(new MiniYamlNode("Smudges", MiniYaml.FromList <SmudgeReference>(Smudges.Value))); root.Add(new MiniYamlNode("Rules", null, Rules)); root.Add(new MiniYamlNode("Sequences", null, Sequences)); root.Add(new MiniYamlNode("Weapons", null, Weapons)); root.Add(new MiniYamlNode("Voices", null, Voices)); var entries = new Dictionary <string, byte[]>(); entries.Add("map.bin", SaveBinaryData()); var s = root.WriteToString(); entries.Add("map.yaml", Encoding.UTF8.GetBytes(s)); // Saving the map to a new location if (toPath != Path) { Path = toPath; // Create a new map package // TODO: Add other files (custom assets) to the entries list Container = FileSystem.CreatePackage(Path, int.MaxValue, entries); } // Update existing package Container.Write(entries); }
public MiniYaml Save() { return(FieldSaver.SaveDifferences(this, Default)); }
public void Save(string toPath) { MapFormat = 7; var root = new List <MiniYamlNode>(); var fields = new[] { "MapFormat", "RequiresMod", "Title", "Description", "Author", "Tileset", "MapSize", "Bounds", "Visibility", "Type", }; foreach (var field in fields) { var f = this.GetType().GetField(field); if (f.GetValue(this) == null) { continue; } root.Add(new MiniYamlNode(field, FieldSaver.FormatValue(this, f))); } root.Add(new MiniYamlNode("Videos", FieldSaver.SaveDifferences(Videos, new MapVideos()))); root.Add(new MiniYamlNode("Options", FieldSaver.SaveDifferences(Options, new MapOptions()))); root.Add(new MiniYamlNode("Players", null, PlayerDefinitions)); root.Add(new MiniYamlNode("Actors", null, ActorDefinitions)); root.Add(new MiniYamlNode("Smudges", null, SmudgeDefinitions)); root.Add(new MiniYamlNode("Rules", null, RuleDefinitions)); root.Add(new MiniYamlNode("Sequences", null, SequenceDefinitions)); root.Add(new MiniYamlNode("VoxelSequences", null, VoxelSequenceDefinitions)); root.Add(new MiniYamlNode("Weapons", null, WeaponDefinitions)); root.Add(new MiniYamlNode("Voices", null, VoiceDefinitions)); root.Add(new MiniYamlNode("Notifications", null, NotificationDefinitions)); root.Add(new MiniYamlNode("Translations", null, TranslationDefinitions)); var entries = new Dictionary <string, byte[]>(); entries.Add("map.bin", SaveBinaryData()); var s = root.WriteToString(); entries.Add("map.yaml", Encoding.UTF8.GetBytes(s)); // Add any custom assets if (Container != null) { foreach (var file in Container.AllFileNames()) { if (file == "map.bin" || file == "map.yaml") { continue; } entries.Add(file, Container.GetContent(file).ReadAllBytes()); } } // Saving the map to a new location if (toPath != Path || Container == null) { Path = toPath; // Create a new map package Container = GlobalFileSystem.CreatePackage(Path, int.MaxValue, entries); } // Update existing package Container.Write(entries); }
public MiniYaml Save() { return(FieldSaver.Save(this)); }
public MiniYaml Save(Func <object, bool> initFilter = null) { var ret = new MiniYaml(Type); foreach (var init in InitDict) { if (init is ISuppressInitExport) { continue; } if (initFilter != null && !initFilter(init)) { continue; } var initName = init.GetType().Name; ret.Nodes.Add(new MiniYamlNode(initName.Substring(0, initName.Length - 4), FieldSaver.Save(init))); } return(ret); }
public MiniYaml Save() { var ret = new MiniYaml(Type); foreach (var init in InitDict) { var initName = init.GetType().Name; ret.Nodes.Add(new MiniYamlNode(initName.Substring(0, initName.Length - 4), FieldSaver.Save(init))); } return(ret); }