From 8387cbc60431ebdbc6dcb70af1735bdf2f39e7a1 Mon Sep 17 00:00:00 2001 From: Recrown Date: Tue, 29 Jan 2019 16:54:24 -0600 Subject: [PATCH] function for obtaining color will now work with nulls by setting the key to "default". --- RecrownedAthenaeum/UI/SkinSystem/ISkin.cs | 3 ++- RecrownedAthenaeum/UI/SkinSystem/Skin.cs | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs b/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs index 7237443..d6b1e19 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs +++ b/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs @@ -29,10 +29,11 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// Returns a with given name of defined color; + /// Should use value "default" if is null. /// /// Name of defined color. /// The defined color based on the name given. - Color GetColor(string name); + Color GetColor(string name = null); /// /// Returns a with given name of region. diff --git a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs b/RecrownedAthenaeum/UI/SkinSystem/Skin.cs index d42d8f0..5741d5b 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs +++ b/RecrownedAthenaeum/UI/SkinSystem/Skin.cs @@ -48,7 +48,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// Name of region. /// The region corresponding to the name or null if the requested region doesn't exist. - public virtual TextureAtlas.Region GetTextureAtlasRegion(string name) + public TextureAtlas.Region GetTextureAtlasRegion(string name) { if (name == null || !textureAtlas.ContainsRegion(name)) return null; return textureAtlas[name]; @@ -57,10 +57,11 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// Returns a with given name of defined color; /// - /// Name of defined color. + /// Name of defined color. Will use "default" if null. Default value is null. /// The defined color based on the name given. - public virtual Color GetColor(string name) + public Color GetColor(string name = null) { + if (name == null) name = "default"; return colors[name]; } @@ -73,7 +74,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// The destination to draw to. /// The rotation to use in radians. /// The origin for the rotation. - public virtual void Draw(string regionName, string color, SpriteBatch batch, Rectangle destination, float rotation = 0, Vector2 origin = default(Vector2)) + public void Draw(string regionName, string color, SpriteBatch batch, Rectangle destination, float rotation = 0, Vector2 origin = default(Vector2)) { if (disposed) throw new ObjectDisposedException(GetType().Name); textureAtlas.Draw(regionName, batch, destination, colors[color], rotation, origin); @@ -95,7 +96,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// Convenience to cast to the needed definition type. /// The name of the definition. /// The definition cast to T. - public virtual T ObtainDefinition(string definitionName = null) where T : SkinDefinitionData + public T ObtainDefinition(string definitionName = null) where T : SkinDefinitionData { return (T)ObtainDefinition(moduleTypeOfDefinition[typeof(T).FullName], definitionName); } @@ -105,7 +106,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// The name of the definition. Default (if left blank) name is "default". /// The definition itself. - public virtual void AddDefinition(SkinDefinitionData skinDefinition, string definitionName = null) + public void AddDefinition(SkinDefinitionData skinDefinition, string definitionName = null) { if (disposed) throw new ObjectDisposedException(GetType().Name); if (Laminated) throw new InvalidOperationException("This skin has been laminated and cannot be edited."); @@ -124,7 +125,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// /// - public virtual void AddColor(string name, Color color) + public void AddColor(string name, Color color) { if (Laminated) throw new InvalidOperationException("This skin has been laminated and cannot be edited."); colors.Add(name, color);