diff --git a/RecrownedAthenaeum/Data/SkinData.cs b/RecrownedAthenaeum/Data/SkinData.cs index a7ee0e5..17d1210 100644 --- a/RecrownedAthenaeum/Data/SkinData.cs +++ b/RecrownedAthenaeum/Data/SkinData.cs @@ -96,14 +96,14 @@ namespace RecrownedAthenaeum.Data /// /// The skin definition data. /// - public ISkinDefinitionData skin; + public SkinDefinitionData skin; /// /// Sets values for data. /// /// The name to be referenced by. /// The skin data. - public DefinitionData(string name, ISkinDefinitionData skinDefinitionData) + public DefinitionData(string name, SkinDefinitionData skinDefinitionData) { this.name = name; skin = skinDefinitionData; diff --git a/RecrownedAthenaeum/RecrownedAthenaeum.csproj b/RecrownedAthenaeum/RecrownedAthenaeum.csproj index eba74bc..187c5dc 100644 --- a/RecrownedAthenaeum/RecrownedAthenaeum.csproj +++ b/RecrownedAthenaeum/RecrownedAthenaeum.csproj @@ -86,9 +86,8 @@ - + - diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs b/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs index 416ab50..d029d42 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs +++ b/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs @@ -6,16 +6,13 @@ namespace RecrownedAthenaeum.UI.SkinSystem.Definitions /// /// Definition for a button. /// - public class ButtonSkinDefinition : ISkinDefinitionData + public class ButtonSkinDefinition : SkinDefinitionData { /// /// Names for the regions in the texture atlas respectively. /// public string upRegion, downRegion, disabledRegion, selectedRegion; - /// - public Type UIModuleType { get { return typeof(Button); } } - /// /// Constructs the definition with minimum requirements. /// @@ -23,8 +20,10 @@ namespace RecrownedAthenaeum.UI.SkinSystem.Definitions /// Name of region specifying the texture shown for when the button is not pressed. public ButtonSkinDefinition(string downRegion, string upRegion) { + UIModuleType = typeof(Button); this.downRegion = downRegion; this.upRegion = upRegion; } + } } diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ISkinDefinition.cs b/RecrownedAthenaeum/UI/SkinSystem/Definitions/ISkinDefinition.cs deleted file mode 100644 index 4c4b968..0000000 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ISkinDefinition.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace RecrownedAthenaeum.UI.SkinSystem.Definitions -{ - /// - /// A definition containing the data for the skin system. Should be in data transfer object model. - /// - public interface ISkinDefinitionData - { - /// - /// The module type this definition is definining. - /// - Type UIModuleType { get; } - } -} diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/SkinDefinition.cs b/RecrownedAthenaeum/UI/SkinSystem/Definitions/SkinDefinition.cs new file mode 100644 index 0000000..8fc115c --- /dev/null +++ b/RecrownedAthenaeum/UI/SkinSystem/Definitions/SkinDefinition.cs @@ -0,0 +1,20 @@ +using System; + +namespace RecrownedAthenaeum.UI.SkinSystem.Definitions +{ + /// + /// A definition containing the data for the skin system. Needs to follow data transfer object model. + /// + public class SkinDefinitionData + { + /// + /// The full name of the UI module this definition defines. + /// + public string uiModuleTypeFullName; + + /// + /// Sets the module type by setting . + /// + public Type UIModuleType { set { uiModuleTypeFullName = value.FullName; } } + } +} diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs b/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs index 02fc734..2144350 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs +++ b/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs @@ -13,11 +13,6 @@ namespace RecrownedAthenaeum.UI.SkinSystem.Definitions /// public string fontColor; - /// - /// The type of module that will be using this definition. - /// - public new Type UIModuleType => typeof(TextButton); - /// /// Creates this definition with the most minimal requirements. /// @@ -25,7 +20,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem.Definitions /// The texture region that represents when the button is not pressed. public TextButtonSkinDefinition(string downRegion, string upRegion) : base(downRegion, upRegion) { - + UIModuleType = typeof(TextButton); } } } diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextSkinDefinition.cs b/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextSkinDefinition.cs deleted file mode 100644 index 8d4f002..0000000 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextSkinDefinition.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using static System.Net.Mime.MediaTypeNames; - -namespace RecrownedAthenaeum.UI.SkinSystem.Definitions -{ - public class TextSkinDefinition : ISkinDefinitionData - { - public string color; - public Type UIModuleType { get { return typeof(Text); } } - - public TextSkinDefinition(string color) - { - this.color = color; - } - } -} diff --git a/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs b/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs index 6ca8d56..7237443 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs +++ b/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs @@ -47,6 +47,6 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// Convenience to cast to the needed definition type. /// The name of the definition. Default is null and will be replaced with "default" for name. /// The definition cast to T. - T ObtainDefinition(string definitionName = null) where T : ISkinDefinitionData; + T ObtainDefinition(string definitionName = null) where T : SkinDefinitionData; } } \ No newline at end of file diff --git a/RecrownedAthenaeum/UI/SkinSystem/MergedSkin.cs b/RecrownedAthenaeum/UI/SkinSystem/MergedSkin.cs index 36167a3..99cb2bc 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/MergedSkin.cs +++ b/RecrownedAthenaeum/UI/SkinSystem/MergedSkin.cs @@ -74,7 +74,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem } } - public T ObtainDefinition(string definitionName = null) where T : ISkinDefinitionData + public T ObtainDefinition(string definitionName = null) where T : SkinDefinitionData { try { diff --git a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs b/RecrownedAthenaeum/UI/SkinSystem/Skin.cs index 029e250..6e2a464 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs +++ b/RecrownedAthenaeum/UI/SkinSystem/Skin.cs @@ -21,8 +21,8 @@ namespace RecrownedAthenaeum.UI.SkinSystem private TextureAtlas textureAtlas; Dictionary colors; - readonly Dictionary moduleTypeOfDefinition; - readonly Dictionary> definitions; + readonly Dictionary moduleTypeOfDefinition; + readonly Dictionary> definitions; /// /// The texture for the cursor. @@ -39,8 +39,8 @@ namespace RecrownedAthenaeum.UI.SkinSystem this.textureAtlas = textureAtlas; this.CursorTexture = cursorTexture; colors = new Dictionary(); - moduleTypeOfDefinition = new Dictionary(); - definitions = new Dictionary>(); + moduleTypeOfDefinition = new Dictionary(); + definitions = new Dictionary>(); } /// @@ -79,14 +79,14 @@ namespace RecrownedAthenaeum.UI.SkinSystem textureAtlas.Draw(regionName, batch, destination, colors[color], rotation, origin); } - private ISkinDefinitionData ObtainDefinition(Type type, string definitionName) + private SkinDefinitionData ObtainDefinition(string typeFullName, string definitionName) { if (disposed) throw new ObjectDisposedException(GetType().Name); if (!Laminated) throw new InvalidOperationException("Skin has yet to be laminated yet."); if (definitionName == null) definitionName = "default"; - if (!definitions.ContainsKey(type)) throw new KeyNotFoundException("Could not find any skin definition defining type \"" + type.FullName + "\""); - if (!definitions[type].ContainsKey(definitionName)) throw new KeyNotFoundException("Could not find skin definition defining type \"" + type.Name + "\" with name \"" + definitionName + "\""); - return definitions[type][definitionName]; + if (!definitions.ContainsKey(typeFullName)) throw new KeyNotFoundException("Could not find any skin definition defining type \"" + typeFullName + "\""); + if (!definitions[typeFullName].ContainsKey(definitionName)) throw new KeyNotFoundException("Could not find skin definition defining type \"" + typeFullName + "\" with name \"" + definitionName + "\""); + return definitions[typeFullName][definitionName]; } /// @@ -95,7 +95,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 : ISkinDefinitionData + public virtual T ObtainDefinition(string definitionName = null) where T : SkinDefinitionData { return (T)ObtainDefinition(moduleTypeOfDefinition[typeof(T).FullName], definitionName); } @@ -105,18 +105,18 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// The name of the definition. Default (if left blank) name is "default". /// The definition itself. - public virtual void AddDefinition(ISkinDefinitionData skinDefinition, string definitionName = null) + public virtual 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."); if (definitionName == null) definitionName = "default"; - if (!definitions.ContainsKey(moduleTypeOfDefinition[skinDefinition.GetType().FullName])) + if (!definitions.ContainsKey(skinDefinition.uiModuleTypeFullName)) { - moduleTypeOfDefinition.Add(skinDefinition.GetType().FullName, skinDefinition.UIModuleType); - definitions.Add(skinDefinition.UIModuleType, new Dictionary()); - } else if (definitions[moduleTypeOfDefinition[skinDefinition.GetType().FullName]].ContainsKey(definitionName)) throw new ArgumentException("Type of definition with that name already exists!"); + moduleTypeOfDefinition.Add(skinDefinition.GetType().FullName, skinDefinition.uiModuleTypeFullName); + definitions.Add(skinDefinition.uiModuleTypeFullName, new Dictionary()); + } else if (definitions[skinDefinition.uiModuleTypeFullName].ContainsKey(definitionName)) throw new ArgumentException("Type of definition with that name already exists!"); - definitions[moduleTypeOfDefinition[skinDefinition.GetType().FullName]].Add(definitionName, skinDefinition); + definitions[skinDefinition.uiModuleTypeFullName].Add(definitionName, skinDefinition); } ///