Refactors and documentation.
This commit is contained in:
parent
f5cbd9dbab
commit
a62ec1bd38
@ -21,6 +21,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\RecrownedAthenaeum.Pipeline.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@ -3,35 +3,78 @@ using RecrownedAthenaeum.Pipeline.NinePatch;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
/// <summary>
|
||||
/// Data transfer object for a texture atlas.
|
||||
/// </summary>
|
||||
public class TextureAtlasData
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains the regions of the texture atlas.
|
||||
/// </summary>
|
||||
public AtlasRegionData[] regions;
|
||||
/// <summary>
|
||||
/// The name of the file.
|
||||
/// </summary>
|
||||
public string textureName;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the atlas given the regions and the file name of the texture file to be used.
|
||||
/// </summary>
|
||||
/// <param name="textureName"></param>
|
||||
/// <param name="regions"></param>
|
||||
public TextureAtlasData(string textureName, AtlasRegionData[] regions)
|
||||
{
|
||||
this.regions = regions;
|
||||
this.textureName = textureName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data object that contains information about the region ninepatch situation of a given region in an atlas.
|
||||
/// </summary>
|
||||
public class AtlasRegionData
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the region for referencial purposes.
|
||||
/// </summary>
|
||||
public string name;
|
||||
/// <summary>
|
||||
/// The location of the patch is designated by this rectangle.
|
||||
/// </summary>
|
||||
public Rectangle location;
|
||||
/// <summary>
|
||||
/// The ninepatch information.
|
||||
/// </summary>
|
||||
public NinePatchData ninePatchData;
|
||||
|
||||
/// <summary>
|
||||
/// Sets position in atlas for convenience.
|
||||
/// </summary>
|
||||
/// <param name="x">X coordinate of the position in the patch.</param>
|
||||
/// <param name="y">Y coordinate of the position in the patch.</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
location.X = x;
|
||||
location.Y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the dimensions of the region on the atlas for convenience.
|
||||
/// </summary>
|
||||
/// <param name="width">Width of the region.</param>
|
||||
/// <param name="height">Height of the region.</param>
|
||||
public void SetSize(int width, int height)
|
||||
{
|
||||
location.Width = width;
|
||||
location.Height = height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets both the coordinates and dimensions of the region on the atlas for convenience.
|
||||
/// </summary>
|
||||
/// <param name="x">X coordinate of the position in the patch.</param>
|
||||
/// <param name="y">Y coordinate of the position in the patch.</param>
|
||||
/// <param name="width">Width of the region.</param>
|
||||
/// <param name="height">Height of the region.</param>
|
||||
public void SetBounds(int x, int y, int width, int height)
|
||||
{
|
||||
SetPosition(x, y);
|
||||
|
@ -23,6 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\RecrownedAthenaeum.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@ -6,7 +6,7 @@ namespace RecrownedAthenaeum.UI.Skin.Definitions
|
||||
/// <summary>
|
||||
/// Definition for a button.
|
||||
/// </summary>
|
||||
public class ButtonSkinDefinition : ISkinDefinition
|
||||
public class ButtonSkinDefinition : ISkinDefinitionData
|
||||
{
|
||||
/// <summary>
|
||||
/// Names for the regions in the texture atlas respectively.
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace RecrownedAthenaeum.UI.Skin.Definitions
|
||||
{
|
||||
/// <summary>
|
||||
/// A definition for the skin system.
|
||||
/// A definition containing the data for the skin system. Should be in data transfer object model.
|
||||
/// </summary>
|
||||
public interface ISkinDefinition
|
||||
public interface ISkinDefinitionData
|
||||
{
|
||||
/// <summary>
|
||||
/// The module type this definition is definining.
|
||||
|
@ -3,7 +3,7 @@ using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.Skin.Definitions
|
||||
{
|
||||
class TextSkinDefinition : ISkinDefinition
|
||||
class TextSkinDefinition : ISkinDefinitionData
|
||||
{
|
||||
public string font;
|
||||
public string color;
|
||||
|
@ -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);
|
||||
|
@ -7,29 +7,72 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.Skin
|
||||
{
|
||||
/// <summary>
|
||||
/// Data transfer object for game skins.
|
||||
/// </summary>
|
||||
public class SkinData
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the atlas with solution of ".tatlas".
|
||||
/// </summary>
|
||||
public string nameOfTextureAtlas;
|
||||
/// <summary>
|
||||
/// The color data containing the name of the color, and red, green, and blue values for the color.
|
||||
/// </summary>
|
||||
public ColorData[] colors;
|
||||
/// <summary>
|
||||
/// The font data containing the name of the font and name of the file for the font.
|
||||
/// </summary>
|
||||
public FontData[] fonts;
|
||||
/// <summary>
|
||||
/// The skin definitions containing a name for the definition, and the definition itself.
|
||||
/// </summary>
|
||||
public DefinitionData[] definitions;
|
||||
|
||||
/// <summary>
|
||||
/// Color data for data transfer.
|
||||
/// </summary>
|
||||
public class ColorData
|
||||
{
|
||||
string name;
|
||||
int r, g, b;
|
||||
/// <summary>
|
||||
/// Name of color to be referenced by.
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// RGB data of this color.
|
||||
/// </summary>
|
||||
public int r, g, b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Font data for data transfer.
|
||||
/// </summary>
|
||||
public class FontData
|
||||
{
|
||||
string name;
|
||||
string font;
|
||||
/// <summary>
|
||||
/// Name of font to be referenced by.
|
||||
/// </summary>
|
||||
public string name;
|
||||
/// <summary>
|
||||
/// Name of the file that contains the font. Shouldn't have extension.
|
||||
/// </summary>
|
||||
public string font;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Definition data for data transfer.
|
||||
/// </summary>
|
||||
public class DefinitionData
|
||||
{
|
||||
string name;
|
||||
ISkinDefinition skin;
|
||||
/// <summary>
|
||||
/// Name of definition to be referenced by.
|
||||
/// </summary>
|
||||
public string name;
|
||||
/// <summary>
|
||||
/// The skin definition data.
|
||||
/// </summary>
|
||||
public ISkinDefinitionData skin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user