144 lines
4.2 KiB
C#
144 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using RecrownedAthenaeum.SpecialTypes;
|
|
using RecrownedAthenaeum.UI.Skin.Definitions;
|
|
|
|
namespace RecrownedAthenaeum.UI.Skin
|
|
{
|
|
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
|
|
{
|
|
try
|
|
{
|
|
return mainSkin.CursorTexture;
|
|
} catch (NullReferenceException)
|
|
{
|
|
return alternateSkin.CursorTexture;
|
|
}
|
|
}
|
|
}
|
|
|
|
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 (KeyNotFoundException)
|
|
{
|
|
return alternateSkin.GetTextureAtlasRegion(name);
|
|
}
|
|
catch (NullReferenceException)
|
|
{
|
|
return alternateSkin.GetTextureAtlasRegion(name);
|
|
}
|
|
}
|
|
|
|
public ISkinDefinitionData ObtainDefinition(string definitionName, Type type)
|
|
{
|
|
try
|
|
{
|
|
return mainSkin.ObtainDefinition(definitionName, type);
|
|
} catch (KeyNotFoundException)
|
|
{
|
|
return alternateSkin.ObtainDefinition(definitionName, type);
|
|
}
|
|
catch (NullReferenceException)
|
|
{
|
|
return alternateSkin.ObtainDefinition(definitionName, type);
|
|
}
|
|
}
|
|
|
|
public ISkinDefinitionData ObtainDefinition(Type type)
|
|
{
|
|
try
|
|
{
|
|
return mainSkin.ObtainDefinition(type);
|
|
}
|
|
catch (KeyNotFoundException)
|
|
{
|
|
return alternateSkin.ObtainDefinition(type);
|
|
}
|
|
catch (NullReferenceException)
|
|
{
|
|
return alternateSkin.ObtainDefinition(type);
|
|
}
|
|
}
|
|
|
|
public T ObtainDefinition<T>(string definitionName, Type type) where T : ISkinDefinitionData
|
|
{
|
|
try
|
|
{
|
|
return mainSkin.ObtainDefinition<T>(definitionName, type);
|
|
}
|
|
catch (KeyNotFoundException)
|
|
{
|
|
return alternateSkin.ObtainDefinition<T>(definitionName, type);
|
|
}
|
|
catch (NullReferenceException)
|
|
{
|
|
return alternateSkin.ObtainDefinition<T>(definitionName, type);
|
|
}
|
|
}
|
|
|
|
public T ObtainDefinition<T>(Type type) where T : ISkinDefinitionData
|
|
{
|
|
try
|
|
{
|
|
return mainSkin.ObtainDefinition<T>(type);
|
|
}
|
|
catch (KeyNotFoundException)
|
|
{
|
|
return alternateSkin.ObtainDefinition<T>(type);
|
|
}
|
|
catch (NullReferenceException)
|
|
{
|
|
return alternateSkin.ObtainDefinition<T>(type);
|
|
}
|
|
}
|
|
}
|
|
}
|