示例#1
0
        internal static Skin FromJsonSkin(IGameContext ctx, JsonSkinData data, string root = null)
        {
            GameUtils.Log($"About to load skin: {data.Metadata.Name} by {data.Metadata.Author}");

            var skin = new Skin();

            skin.Metadata = SkinMetadata.FromJson(data.Metadata);

            if (data.ColorSchemes == null)
            {
                data.ColorSchemes = new Dictionary <string, JsonColorScheme>();
            }

            if (!data.ColorSchemes.ContainsKey("light"))
            {
                data.ColorSchemes.Add("light", JsonColorScheme.DefaultLight);
            }

            if (!data.ColorSchemes.ContainsKey("dark"))
            {
                data.ColorSchemes.Add("dark", JsonColorScheme.DefaultDark);
            }

            skin.LightColorScheme = ColorScheme.FromJsonColors(data.ColorSchemes["light"], JsonColorScheme.DefaultLight);
            skin.DarkColorScheme  = ColorScheme.FromJsonColors(data.ColorSchemes["dark"], JsonColorScheme.DefaultDark);

            skin.LoadFontsFromJson(ctx, data.Fonts ?? new JsonFontList(), root);

            skin.Textures   = SkinTextureList.FromJsonTextures(ctx, data.Textures, root);
            skin.LayoutInfo = SkinLayoutInfo.FromJsonData(data.LayoutInfo);

            GameUtils.Log("Skin loaded.");

            return(skin);
        }
        internal static SkinMetadata FromJson(JsonSkinMetadata data)
        {
            var meta = new SkinMetadata();

            meta.Name        = data.Name;
            meta.Author      = data.Author;
            meta.Description = data.Description;

            return(meta);
        }