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."); }
protected override JToken SerializeWithoutMetadata(ValueModel value) { ObjectModel model = value as ObjectModel; IEnumerable <JProperty> properties = model.GetProperties().Select(x => new JProperty(x.Name, _internalSerializer.Serialize(x.Model))); return(new JObject(properties)); }
protected override JToken SerializeWithoutMetadata(ValueModel model) { ArrayModel arrayModel = model as ArrayModel; return(new JArray(arrayModel.Elements.Select(x => _internalSerializer.Serialize(x)))); }