Refactors and documentation.

This commit is contained in:
2019-01-15 17:03:17 -06:00
parent f5cbd9dbab
commit a62ec1bd38
8 changed files with 108 additions and 20 deletions

View File

@@ -24,7 +24,7 @@ namespace RecrownedAthenaeum.UI.Skin
/// Fonts stored in this skin.
/// </summary>
public readonly Dictionary<string, SpriteFont> fonts;
Dictionary<Type, Dictionary<string, ISkinDefinition>> definitions;
Dictionary<Type, Dictionary<string, ISkinDefinitionData>> definitions;
/// <summary>
/// Creates a basic unfilled skin.
@@ -35,7 +35,7 @@ namespace RecrownedAthenaeum.UI.Skin
this.textureAtlas = textureAtlas;
colors = new Dictionary<string, Color>();
fonts = new Dictionary<string, SpriteFont>();
definitions = new Dictionary<Type, Dictionary<string, ISkinDefinition>>();
definitions = new Dictionary<Type, Dictionary<string, ISkinDefinitionData>>();
}
/// <summary>
@@ -53,12 +53,12 @@ namespace RecrownedAthenaeum.UI.Skin
}
/// <summary>
/// Returns an <see cref="ISkinDefinition"/> of the given name and type.
/// Returns an <see cref="ISkinDefinitionData"/> of the given name and type.
/// </summary>
/// <param name="definitionName">Name of definition of the <paramref name="type"/></param>
/// <param name="type">The UIModule the definition defines.</param>
/// <returns>The interface for the definition.</returns>
public ISkinDefinition ObtainDefinition(string definitionName, Type type)
public ISkinDefinitionData ObtainDefinition(string definitionName, Type type)
{
if (definitionName == null) definitionName = "default";
if (!definitions.ContainsKey(type) || !definitions[type].ContainsKey(definitionName)) throw new ArgumentException("Could not find skin of type " + type.Name + " with name " + definitionName);
@@ -66,11 +66,11 @@ namespace RecrownedAthenaeum.UI.Skin
}
/// <summary>
/// Returns the default <see cref="ISkinDefinition"/> of the given parameters.
/// Returns the default <see cref="ISkinDefinitionData"/> of the given parameters.
/// </summary>
/// <param name="type">The type of definition the default should be coming from.</param>
/// <returns>The default definition for the given type.</returns>
public ISkinDefinition ObtainDefinition(Type type)
public ISkinDefinitionData ObtainDefinition(Type type)
{
return ObtainDefinition(null, type);
}
@@ -82,7 +82,7 @@ namespace RecrownedAthenaeum.UI.Skin
/// <param name="definitionName">The name of the definition.</param>
/// <param name="type">UIModule type the definition defines.</param>
/// <returns>The definition cast to T.</returns>
public T ObtainDefinition<T>(string definitionName, Type type) where T : ISkinDefinition
public T ObtainDefinition<T>(string definitionName, Type type) where T : ISkinDefinitionData
{
if (definitionName == null) definitionName = "default";
return (T)ObtainDefinition(definitionName, type);
@@ -94,7 +94,7 @@ namespace RecrownedAthenaeum.UI.Skin
/// <typeparam name="T">Convenience to cast to T.</typeparam>
/// <param name="type">The type of the UIModule to retrieve the default from.</param>
/// <returns>The default definition for the given type.</returns>
public T ObtainDefinition<T>(Type type) where T : ISkinDefinition
public T ObtainDefinition<T>(Type type) where T : ISkinDefinitionData
{
return ObtainDefinition<T>(null, type);
}
@@ -104,11 +104,11 @@ namespace RecrownedAthenaeum.UI.Skin
/// </summary>
/// <param name="definitionName">The name of the definition.</param>
/// <param name="skinDefinition">The definition itself.</param>
public void AddDefinition(string definitionName, ISkinDefinition skinDefinition)
public void AddDefinition(string definitionName, ISkinDefinitionData skinDefinition)
{
if (!definitions.ContainsKey(skinDefinition.UIModuleType))
{
definitions.Add(skinDefinition.UIModuleType, new Dictionary<string, ISkinDefinition>());
definitions.Add(skinDefinition.UIModuleType, new Dictionary<string, ISkinDefinitionData>());
} else if (definitions[skinDefinition.UIModuleType].ContainsKey(definitionName)) throw new ArgumentException("Type of definition with that name already exists!");
definitions[skinDefinition.UIModuleType].Add(definitionName, skinDefinition);