using System;
using System.Collections.Generic;
using RecrownedAthenaeum.Render;
using RecrownedAthenaeum.Types;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
namespace RecrownedAthenaeum.UI.SkinSystem
{
internal class MergedSkin : ISkin
{
///
/// The skin to try to use first.
///
public ISkin mainSkin;
///
/// The fallback skin.
///
public ISkin alternateSkin;
public Texture2D CursorTexture
{
get
{
if (mainSkin.CursorTexture != null) {
return mainSkin.CursorTexture;
} else {
return alternateSkin.CursorTexture;
}
}
}
public void Draw(string regionName, string color, ConsistentSpriteBatch 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, bool required = false)
{
try
{
return mainSkin.GetTextureAtlasRegion(name);
}
catch (NullReferenceException)
{
return alternateSkin.GetTextureAtlasRegion(name, required);
}
}
public T ObtainDefinition(string definitionName = null) where T : SkinDefinitionData
{
try
{
return mainSkin.ObtainDefinition(definitionName);
}
catch (NullReferenceException)
{
return alternateSkin.ObtainDefinition(definitionName);
}
}
}
}