2019-01-20 07:08:38 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-12-28 20:35:01 +00:00
|
|
|
|
using RecrownedAthenaeum.Graphics.Render;
|
2019-11-24 20:49:53 +00:00
|
|
|
|
using RecrownedAthenaeum.Types;
|
2019-12-28 21:41:06 +00:00
|
|
|
|
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using OpenTK;
|
2019-01-20 07:08:38 +00:00
|
|
|
|
|
2019-12-28 21:41:06 +00:00
|
|
|
|
namespace RecrownedAthenaeum.Graphics.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-11-24 02:47:21 +00:00
|
|
|
|
if (mainSkin.CursorTexture != null) {
|
2019-01-27 20:57:35 +00:00
|
|
|
|
return mainSkin.CursorTexture;
|
2019-11-24 02:47:21 +00:00
|
|
|
|
} else {
|
2019-01-27 20:57:35 +00:00
|
|
|
|
return alternateSkin.CursorTexture;
|
|
|
|
|
}
|
2019-01-20 07:08:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-24 00:04:43 +00:00
|
|
|
|
public void Draw(string regionName, string color, ConsistentSpriteBatch batch, Rectangle destination, float rotation = 0, Vector2 origin = default(Vector2))
|
2019-01-20 07:08:38 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-28 21:41:06 +00:00
|
|
|
|
public Color4 GetColor(string name)
|
2019-01-20 07:08:38 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return mainSkin.GetColor(name);
|
|
|
|
|
} catch (KeyNotFoundException)
|
|
|
|
|
{
|
|
|
|
|
return alternateSkin.GetColor(name);
|
|
|
|
|
}
|
|
|
|
|
catch (NullReferenceException)
|
|
|
|
|
{
|
|
|
|
|
return alternateSkin.GetColor(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-08 05:43:25 +00:00
|
|
|
|
public TextureAtlas.Region GetTextureAtlasRegion(string name, bool required = false)
|
2019-01-20 07:08:38 +00:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return mainSkin.GetTextureAtlasRegion(name);
|
|
|
|
|
}
|
|
|
|
|
catch (NullReferenceException)
|
|
|
|
|
{
|
2019-03-08 05:43:25 +00:00
|
|
|
|
return alternateSkin.GetTextureAtlasRegion(name, required);
|
2019-01-20 07:08:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|