/
GuiJsonSerializer.cs
29 lines (28 loc) · 1.33 KB
/
GuiJsonSerializer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using Microsoft.Xna.Framework.Content;
using MonoGame.Extended.BitmapFonts;
using MonoGame.Extended.Serialization;
using Newtonsoft.Json;
namespace MonoGame.Extended.Gui.Serialization
{
public sealed class GuiJsonSerializer : JsonSerializer
{
public GuiJsonSerializer(ContentManager contentManager, params Type[] customControlTypes)
{
var textureRegionService = new GuiTextureRegionService();
Converters.Add(new Vector2JsonConverter());
Converters.Add(new SizeJsonConverter());
Converters.Add(new Size2JsonConverter());
Converters.Add(new ColorJsonConverter());
Converters.Add(new ThicknessJsonConverter());
Converters.Add(new ContentManagerJsonConverter<BitmapFont>(contentManager, font => font.Name));
Converters.Add(new ControlStyleJsonConverter(customControlTypes));
Converters.Add(new GuiTextureAtlasJsonConverter(contentManager, textureRegionService));
Converters.Add(new GuiNinePatchRegion2DJsonConverter(textureRegionService));
Converters.Add(new TextureRegion2DJsonConverter(textureRegionService));
Converters.Add(new AlignmentConverter());
ContractResolver = new ShortNameJsonContractResolver();
Formatting = Formatting.Indented;
}
}
}