2019-01-20 07:08:38 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
using RecrownedAthenaeum.SpecialTypes;
|
2019-01-27 23:39:18 +00:00
|
|
|
|
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
2019-01-20 07:08:38 +00:00
|
|
|
|
|
2019-01-27 23:39:18 +00:00
|
|
|
|
namespace RecrownedAthenaeum.UI.SkinSystem
|
2019-01-20 07:08:38 +00:00
|
|
|
|
{
|
|
|
|
|
internal class MergedSkin : ISkin
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The skin to try to use first.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ISkin mainSkin;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The fallback skin.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ISkin alternateSkin;
|
|
|
|
|
|
|
|
|
|
public Texture2D CursorTexture
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-01-27 20:57:35 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return mainSkin.CursorTexture;
|
|
|
|
|
} catch (NullReferenceException)
|
|
|
|
|
{
|
|
|
|
|
return alternateSkin.CursorTexture;
|
|
|
|
|
}
|
2019-01-20 07:08:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Draw(string regionName, string color, SpriteBatch batch, Rectangle destination, float rotation = 0, Vector2 origin = default(Vector2))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
mainSkin.Draw(regionName, color, batch, destination, rotation, origin);
|
|
|
|
|
} catch (KeyNotFoundException)
|
|
|
|
|
{
|
|
|
|
|
alternateSkin.Draw(regionName, color, batch, destination, rotation, origin);
|
|
|
|
|
} catch (NullReferenceException)
|
|
|
|
|
{
|
|
|
|
|
alternateSkin.Draw(regionName, color, batch, destination, rotation, origin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color GetColor(string name)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return mainSkin.GetColor(name);
|
|
|
|
|
} catch (KeyNotFoundException)
|
|
|
|
|
{
|
|
|
|
|
return alternateSkin.GetColor(name);
|
|
|
|
|
}
|
|
|
|
|
catch (NullReferenceException)
|
|
|
|
|
{
|
|
|
|
|
return alternateSkin.GetColor(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TextureAtlas.Region GetTextureAtlasRegion(string name)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return mainSkin.GetTextureAtlasRegion(name);
|
|
|
|
|
}
|
|
|
|
|
catch (NullReferenceException)
|
|
|
|
|
{
|
|
|
|
|
return alternateSkin.GetTextureAtlasRegion(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-29 22:22:14 +00:00
|
|
|
|
public T ObtainDefinition<T>(string definitionName = null) where T : SkinDefinitionData
|
2019-01-20 07:08:38 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2019-01-29 01:43:41 +00:00
|
|
|
|
return mainSkin.ObtainDefinition<T>(definitionName);
|
2019-01-20 07:08:38 +00:00
|
|
|
|
}
|
|
|
|
|
catch (NullReferenceException)
|
|
|
|
|
{
|
2019-01-29 01:43:41 +00:00
|
|
|
|
return alternateSkin.ObtainDefinition<T>(definitionName);
|
2019-01-20 07:08:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|