From 15defa37db361d29f0bfd716d4dbee4c641ca85b Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Sun, 20 Jan 2019 19:15:19 -0600 Subject: [PATCH] refactor and added polling for the threading. --- RecrownedAthenaeum/UI/Skin/SkinManager.cs | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/RecrownedAthenaeum/UI/Skin/SkinManager.cs b/RecrownedAthenaeum/UI/Skin/SkinManager.cs index 03a1de3..05c04a1 100644 --- a/RecrownedAthenaeum/UI/Skin/SkinManager.cs +++ b/RecrownedAthenaeum/UI/Skin/SkinManager.cs @@ -30,6 +30,8 @@ namespace RecrownedAthenaeum.UI.Skin private string selectedSkinPath; private SkinData skinDataToUse; + public bool ReadyForUse { get { return (SelectedSkin != null && BaseSkin != null); } } + /// /// The list of paths for all found skins by . May be null. /// @@ -52,7 +54,7 @@ namespace RecrownedAthenaeum.UI.Skin /// /// Having the skin generated to be in a useable state. /// - GENERATE + LOAD } /// @@ -61,9 +63,9 @@ namespace RecrownedAthenaeum.UI.Skin public ISkin Skin { get { return mergedSkin; } } /// - /// The user selected skin. + /// The user selected skin. Set by the skin loaded by calling . /// - public ISkin SelectedSkin { get { return mergedSkin.mainSkin; } set { mergedSkin.mainSkin = value; } } + public ISkin SelectedSkin { get { return mergedSkin.mainSkin; } private set { mergedSkin.mainSkin = value; } } /// /// The fallback skin in case the selected skin doesn't cover a specific definition or color. @@ -85,11 +87,11 @@ namespace RecrownedAthenaeum.UI.Skin } /// - /// Loads skin data if extension is valid. + /// Reads skin data if extension is valid. /// /// the path to load from. /// A that holds all the information and some metadata for the loaded skin. - public SkinData LoadSkinData(string path) + public SkinData ReadSkinData(string path) { if (path.ToLower().EndsWith(EXTENSION)) { @@ -99,14 +101,14 @@ namespace RecrownedAthenaeum.UI.Skin } /// - /// Generates a skin asynchronously. + /// loads a skin asynchronously. /// /// Graphics device to use for texture creation. /// The data to generate from. /// The path pointing to the file with the extension "". - 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();