private void SaveMapFile(string path) { Directory.CreateDirectory(Path.GetDirectoryName(path)); MapData.Name = NameInput.text; MapData.Description = DescriptionInput.text; MapData.Identifier = Guid.NewGuid().ToString(); LazyTileFix(MapData.Tiles); // Lazy fix, probably should investigate why it happens. Shouldn't really matter though. // These paths are so hardcoded, severely needs to be improved if we are to ever have variable save destinations. Texture2D mapPreview = SnapMapPreview(); string previewPath = Path.Combine(Content.CustomContentPath, MAP_FOLDER, PREVIEW_SUB_FOLDER, MapData.Name) + ".png"; SaveMapPreview(mapPreview, previewPath); MapData.Objects = DisassembleMapObjects(); var model = MapData.Disassemble(new Serialization.Assemblers.DisassemblyContext()); ValueModelSerializer serializer = new ValueModelSerializer(); File.WriteAllText(path, serializer.Serialize(model).ToString()); Alert.Open("Map succesfully saved."); }
private bool HasMetadata(JToken token) => ValueModelSerializer.HasMetadata(token, out JToken _);