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 SkinData skinDataToUse;
|
||||
|
||||
public bool ReadyForUse { get { return (SelectedSkin != null && BaseSkin != null); } }
|
||||
|
||||
/// <summary>
|
||||
/// The list of paths for all found skins by <see cref="SearchSkinDirectory"/>. May be null.
|
||||
/// </summary>
|
||||
@ -52,7 +54,7 @@ namespace RecrownedAthenaeum.UI.Skin
|
||||
/// <summary>
|
||||
/// Having the skin generated to be in a useable state.
|
||||
/// </summary>
|
||||
GENERATE
|
||||
LOAD
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -61,9 +63,9 @@ namespace RecrownedAthenaeum.UI.Skin
|
||||
public ISkin Skin { get { return mergedSkin; } }
|
||||
|
||||
/// <summary>
|
||||
/// The user selected skin.
|
||||
/// The user selected skin. Set by the skin loaded by calling <see cref="LoadSkin(GraphicsDevice, SkinData, string)"/>.
|
||||
/// </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>
|
||||
/// 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>
|
||||
/// Loads skin data if extension is valid.
|
||||
/// Reads skin data if extension is valid.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public SkinData LoadSkinData(string path)
|
||||
public SkinData ReadSkinData(string path)
|
||||
{
|
||||
if (path.ToLower().EndsWith(EXTENSION))
|
||||
{
|
||||
@ -99,14 +101,14 @@ namespace RecrownedAthenaeum.UI.Skin
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a skin asynchronously.
|
||||
/// loads a skin asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="graphicsDevice">Graphics device to use for texture creation.</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>
|
||||
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.selectedSkinPath = path;
|
||||
this.skinDataToUse = skinData;
|
||||
@ -128,8 +130,8 @@ namespace RecrownedAthenaeum.UI.Skin
|
||||
SearchForSkins();
|
||||
OnAsyncComplete(action);
|
||||
break;
|
||||
case Action.GENERATE:
|
||||
SelectedSkin = GenerateSkinFromData(skinDataToUse, selectedSkinPath, graphicsDevice);
|
||||
case Action.LOAD:
|
||||
SelectedSkin = LoadSkinFromData(skinDataToUse, selectedSkinPath, graphicsDevice);
|
||||
OnAsyncComplete(action);
|
||||
break;
|
||||
}
|
||||
@ -141,7 +143,7 @@ namespace RecrownedAthenaeum.UI.Skin
|
||||
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();
|
||||
FileInfo[] skinFiles = Directory.GetParent(path).GetFiles();
|
||||
|
Loading…
Reference in New Issue
Block a user