refactor and added polling for the threading.
This commit is contained in:
parent
1ae2b0cf8d
commit
15defa37db
@ -30,6 +30,8 @@ namespace RecrownedAthenaeum.UI.Skin
|
|||||||
private string selectedSkinPath;
|
private string selectedSkinPath;
|
||||||
private SkinData skinDataToUse;
|
private SkinData skinDataToUse;
|
||||||
|
|
||||||
|
public bool ReadyForUse { get { return (SelectedSkin != null && BaseSkin != null); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of paths for all found skins by <see cref="SearchSkinDirectory"/>. May be null.
|
/// The list of paths for all found skins by <see cref="SearchSkinDirectory"/>. May be null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -52,7 +54,7 @@ namespace RecrownedAthenaeum.UI.Skin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Having the skin generated to be in a useable state.
|
/// Having the skin generated to be in a useable state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
GENERATE
|
LOAD
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -61,9 +63,9 @@ namespace RecrownedAthenaeum.UI.Skin
|
|||||||
public ISkin Skin { get { return mergedSkin; } }
|
public ISkin Skin { get { return mergedSkin; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The user selected skin.
|
/// The user selected skin. Set by the skin loaded by calling <see cref="LoadSkin(GraphicsDevice, SkinData, string)"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ISkin SelectedSkin { get { return mergedSkin.mainSkin; } set { mergedSkin.mainSkin = value; } }
|
public ISkin SelectedSkin { get { return mergedSkin.mainSkin; } private set { mergedSkin.mainSkin = value; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The fallback skin in case the selected skin doesn't cover a specific definition or color.
|
/// The fallback skin in case the selected skin doesn't cover a specific definition or color.
|
||||||
@ -85,11 +87,11 @@ namespace RecrownedAthenaeum.UI.Skin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads skin data if extension is valid.
|
/// Reads skin data if extension is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">the path to load from.</param>
|
/// <param name="path">the path to load from.</param>
|
||||||
/// <returns>A <see cref="SkinData"/> that holds all the information and some metadata for the loaded skin.</returns>
|
/// <returns>A <see cref="SkinData"/> that holds all the information and some metadata for the loaded skin.</returns>
|
||||||
public SkinData LoadSkinData(string path)
|
public SkinData ReadSkinData(string path)
|
||||||
{
|
{
|
||||||
if (path.ToLower().EndsWith(EXTENSION))
|
if (path.ToLower().EndsWith(EXTENSION))
|
||||||
{
|
{
|
||||||
@ -99,14 +101,14 @@ namespace RecrownedAthenaeum.UI.Skin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a skin asynchronously.
|
/// loads a skin asynchronously.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="graphicsDevice">Graphics device to use for texture creation.</param>
|
/// <param name="graphicsDevice">Graphics device to use for texture creation.</param>
|
||||||
/// <param name="skinData">The data to generate from.</param>
|
/// <param name="skinData">The data to generate from.</param>
|
||||||
/// <param name="path">The path pointing to the file with the extension "<see cref="EXTENSION"/>".</param>
|
/// <param name="path">The path pointing to the file with the extension "<see cref="EXTENSION"/>".</param>
|
||||||
public void GenerateSkin(GraphicsDevice graphicsDevice, SkinData skinData, string path)
|
public void LoadSkin(GraphicsDevice graphicsDevice, SkinData skinData, string path)
|
||||||
{
|
{
|
||||||
action = Action.GENERATE;
|
action = Action.LOAD;
|
||||||
this.graphicsDevice = graphicsDevice;
|
this.graphicsDevice = graphicsDevice;
|
||||||
this.selectedSkinPath = path;
|
this.selectedSkinPath = path;
|
||||||
this.skinDataToUse = skinData;
|
this.skinDataToUse = skinData;
|
||||||
@ -128,8 +130,8 @@ namespace RecrownedAthenaeum.UI.Skin
|
|||||||
SearchForSkins();
|
SearchForSkins();
|
||||||
OnAsyncComplete(action);
|
OnAsyncComplete(action);
|
||||||
break;
|
break;
|
||||||
case Action.GENERATE:
|
case Action.LOAD:
|
||||||
SelectedSkin = GenerateSkinFromData(skinDataToUse, selectedSkinPath, graphicsDevice);
|
SelectedSkin = LoadSkinFromData(skinDataToUse, selectedSkinPath, graphicsDevice);
|
||||||
OnAsyncComplete(action);
|
OnAsyncComplete(action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -141,7 +143,7 @@ namespace RecrownedAthenaeum.UI.Skin
|
|||||||
skinPaths = RecursiveSkinSearch(skinsDirectory);
|
skinPaths = RecursiveSkinSearch(skinsDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Skin GenerateSkinFromData(SkinData skinData, string path, GraphicsDevice graphicsDevice)
|
private Skin LoadSkinFromData(SkinData skinData, string path, GraphicsDevice graphicsDevice)
|
||||||
{
|
{
|
||||||
TextureAtlasDataReader textureAtlasDataReader = new TextureAtlasDataReader();
|
TextureAtlasDataReader textureAtlasDataReader = new TextureAtlasDataReader();
|
||||||
FileInfo[] skinFiles = Directory.GetParent(path).GetFiles();
|
FileInfo[] skinFiles = Directory.GetParent(path).GetFiles();
|
||||||
|
Loading…
Reference in New Issue
Block a user