public XElement Save(string MapSetSaveFileName, bool moveToMapSetDirectory = false) { if (String.IsNullOrWhiteSpace(Path)) { Path = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), "font.fnt"); } else if (moveToMapSetDirectory) { Path = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), System.IO.Path.GetFileName(Path)); } File.WriteAllBytes(Path, Data); XElement result = new XElement("font"); result.Add(new XAttribute("uid", UID.ToString())); result.Add(new XAttribute("path", PathHelper.Delta(MapSetSaveFileName, Path))); if (KeepEvenUseless) { result.Add(new XAttribute("keep", "keep")); } return(result); }
public static XElement Save(Map map, String MapSetSaveFileName, bool moveToMapSetDirectory = false) { if (String.IsNullOrWhiteSpace(map.Path)) { map.Path = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), $"{map.Name}.lz4"); } else if (moveToMapSetDirectory) { map.Path = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), System.IO.Path.GetFileName(map.Path)); } XElement result = new XElement("map"); result.Add(new XAttribute("name", map.Name)); result.Add(new XAttribute("font", map.FontID)); result.Add(new XAttribute("path", PathHelper.Delta(MapSetSaveFileName, map.Path))); result.Add(new XAttribute("uid", map.UID.ToString())); // DLI XElement dlis = new XElement("dlis"); if (map.DLIS != null) { foreach (DLI dli in map.DLIS) { dlis.Add(dli.Save()); } } result.Add(dlis); // Init Routine if (!String.IsNullOrWhiteSpace(map.InitRoutine)) { if (String.IsNullOrWhiteSpace(map.InitRoutinePath)) { map.InitRoutinePath = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), $"Init {map.Name}.asm"); } else if (moveToMapSetDirectory) { map.InitRoutinePath = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), System.IO.Path.GetFileName(map.InitRoutinePath)); } File.WriteAllText(map.InitRoutinePath, map.InitRoutine); } result.Add(new XElement("InitRoutinePath", PathHelper.Delta(MapSetSaveFileName, map.InitRoutinePath))); // Exec Routine if (!String.IsNullOrWhiteSpace(map.ExecRoutine)) { if (String.IsNullOrWhiteSpace(map.ExecRoutinePath)) { map.ExecRoutinePath = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), $"Exec {map.Name}.asm"); } else if (moveToMapSetDirectory) { map.ExecRoutinePath = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), System.IO.Path.GetFileName(map.ExecRoutinePath)); } File.WriteAllText(map.ExecRoutinePath, map.ExecRoutine); } result.Add(new XElement("ExecRoutinePath", PathHelper.Delta(MapSetSaveFileName, map.ExecRoutinePath))); // TileCollision Routine if (!String.IsNullOrWhiteSpace(map.TileCollisionRoutine)) { if (String.IsNullOrWhiteSpace(map.TileCollisionRoutinePath)) { map.TileCollisionRoutinePath = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), $"TileCollision {map.Name}.asm"); } else if (moveToMapSetDirectory) { map.TileCollisionRoutinePath = PathHelper.CreateFileWithUniqueName(System.IO.Path.GetDirectoryName(MapSetSaveFileName), System.IO.Path.GetFileName(map.TileCollisionRoutinePath)); } File.WriteAllText(map.TileCollisionRoutinePath, map.TileCollisionRoutine); } result.Add(new XElement("TileCollisionRoutinePath", PathHelper.Delta(MapSetSaveFileName, map.TileCollisionRoutinePath))); result.Add(ExportColorDetection("Colpf0Dectection", map.Colpf0Detection, map.Colpf0DetectionRects, map.Colpf0DetectionFlags)); result.Add(ExportColorDetection("Colpf2Dectection", map.Colpf2Detection, map.Colpf2DetectionRects, map.Colpf2DetectionFlags)); result.Add(ExportColorDetection("Colpf3Dectection", map.Colpf3Detection, map.Colpf3DetectionRects, map.Colpf3DetectionFlags)); result.Add(new XElement("foe", map.Foe)); result.Add(new XElement("brucestart", new XElement("x1", map.BruceStartX1), new XElement("x2", map.BruceStartX2), new XElement("y1", map.BruceStartY1), new XElement("y2", map.BruceStartY2))); result.Add(new XElement("exit1", new XElement("map", map.Exit1MapID), new XElement("x", map.Exit1X), new XElement("y", map.Exit1Y))); result.Add(new XElement("exit2", new XElement("map", map.Exit2MapID), new XElement("x", map.Exit2X), new XElement("y", map.Exit2Y))); result.Add(new XElement("exit3", new XElement("map", map.Exit3MapID), new XElement("x", map.Exit3X), new XElement("y", map.Exit3Y))); result.Add(new XElement("exit4", new XElement("map", map.Exit4MapID), new XElement("x", map.Exit4X), new XElement("y", map.Exit4Y))); result.Add(new XElement("YamoSpawnPosition", map.YamoSpawnPosition)); result.Add(new XElement("NinjaSpawnPosition", map.NinjaSpawnPosition)); result.Add(new XElement("NinjaEnterCount1", map.NinjaEnterCount1)); result.Add(new XElement("NinjaEnterCount2", map.NinjaEnterCount2)); result.Add(new XElement("YamoEnterCount1", map.YamoEnterCount1)); result.Add(new XElement("YamoEnterCount2", map.YamoEnterCount2)); EncodeAndSaveTiles(map); return(result); }