From 1b54dd2d28dd192a4967f0bf257a057bd50e64a0 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Mon, 21 Jan 2019 23:38:25 -0600 Subject: [PATCH] refactor and moved normal resolver to library (forgot to commit this part last time). --- .../ContentSystem/ContentManagerController.cs | 10 +++++----- ...PathModifier.cs => IContentPathResolver.cs} | 6 +++--- .../ContentSystem/NormalContentResolver.cs | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) rename RecrownedAthenaeum/ContentSystem/{IContentPathModifier.cs => IContentPathResolver.cs} (71%) create mode 100644 RecrownedAthenaeum/ContentSystem/NormalContentResolver.cs diff --git a/RecrownedAthenaeum/ContentSystem/ContentManagerController.cs b/RecrownedAthenaeum/ContentSystem/ContentManagerController.cs index e7749a7..7fd41e3 100644 --- a/RecrownedAthenaeum/ContentSystem/ContentManagerController.cs +++ b/RecrownedAthenaeum/ContentSystem/ContentManagerController.cs @@ -1,5 +1,5 @@ using Microsoft.Xna.Framework.Content; -using RecrownedAthenaeum.ContentSystem.ContentResolvers; +using RecrownedAthenaeum.ContentSystem; using System; using System.Collections.Generic; using System.Diagnostics; @@ -19,11 +19,11 @@ namespace RecrownedAthenaeum.ContentSystem /// /// Path modifiers to change the path in which the content manager looks to load a file. Used for better organizing things while not needing to type entire path. /// - public readonly Dictionary contentPathModifier; + public readonly Dictionary contentPathModifier; /// /// Used when no path modifier is defined for that specific type. /// - public IContentPathModifier normalPathModifier = new NormalContentResolver(); + public IContentPathResolver normalPathModifier = new NormalContentResolver(); volatile float progress; volatile bool running; @@ -46,7 +46,7 @@ namespace RecrownedAthenaeum.ContentSystem this.contentManager = contentManager; assets = new Dictionary(); queue = new Queue(); - contentPathModifier = new Dictionary(); + contentPathModifier = new Dictionary(); } private void Load(string assetName, Type type, bool usePathModifier) @@ -55,7 +55,7 @@ namespace RecrownedAthenaeum.ContentSystem string path = assetName; if (usePathModifier) { - IContentPathModifier handler; + IContentPathResolver handler; if (contentPathModifier.ContainsKey(type)) { handler = contentPathModifier[type]; diff --git a/RecrownedAthenaeum/ContentSystem/IContentPathModifier.cs b/RecrownedAthenaeum/ContentSystem/IContentPathResolver.cs similarity index 71% rename from RecrownedAthenaeum/ContentSystem/IContentPathModifier.cs rename to RecrownedAthenaeum/ContentSystem/IContentPathResolver.cs index ad64344..e2cd9b7 100644 --- a/RecrownedAthenaeum/ContentSystem/IContentPathModifier.cs +++ b/RecrownedAthenaeum/ContentSystem/IContentPathResolver.cs @@ -3,13 +3,13 @@ /// /// Modifies the given path based on a name. Used to simplify long paths for the /// - public interface IContentPathModifier + public interface IContentPathResolver { /// /// Returns the complete path with the content folder as root. /// - /// Is the asset's name + /// Is the asset's name /// - string Modify(string assetName); + string Modify(string contentPath); } } diff --git a/RecrownedAthenaeum/ContentSystem/NormalContentResolver.cs b/RecrownedAthenaeum/ContentSystem/NormalContentResolver.cs new file mode 100644 index 0000000..c0d1968 --- /dev/null +++ b/RecrownedAthenaeum/ContentSystem/NormalContentResolver.cs @@ -0,0 +1,18 @@ +namespace RecrownedAthenaeum.ContentSystem +{ + /// + /// A resolver that does nothing. Used for looking in the root by default. + /// + public class NormalContentResolver : IContentPathResolver + { + /// + /// Passes the path through without modification as this is the normal content resolver and is meant to just pass things on. + /// + /// The path to modify. + /// + public string Modify(string contentPath) + { + return contentPath; + } + } +}