refactor and moved normal resolver to library (forgot to commit this part last time).

This commit is contained in:
Harrison Deng 2019-01-21 23:38:25 -06:00
parent 010c66aa0e
commit 1b54dd2d28
3 changed files with 26 additions and 8 deletions

View File

@ -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
/// <summary>
/// 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.
/// </summary>
public readonly Dictionary<Type, IContentPathModifier> contentPathModifier;
public readonly Dictionary<Type, IContentPathResolver> contentPathModifier;
/// <summary>
/// Used when no path modifier is defined for that specific type.
/// </summary>
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<string, IDisposable>();
queue = new Queue<ContentData>();
contentPathModifier = new Dictionary<Type, IContentPathModifier>();
contentPathModifier = new Dictionary<Type, IContentPathResolver>();
}
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];

View File

@ -3,13 +3,13 @@
/// <summary>
/// Modifies the given path based on a name. Used to simplify long paths for the <see cref="ContentManagerController"/>
/// </summary>
public interface IContentPathModifier
public interface IContentPathResolver
{
/// <summary>
/// Returns the complete path with the content folder as root.
/// </summary>
/// <param name="assetName">Is the asset's name</param>
/// <param name="contentPath">Is the asset's name</param>
/// <returns></returns>
string Modify(string assetName);
string Modify(string contentPath);
}
}

View File

@ -0,0 +1,18 @@
namespace RecrownedAthenaeum.ContentSystem
{
/// <summary>
/// A resolver that does nothing. Used for looking in the root by default.
/// </summary>
public class NormalContentResolver : IContentPathResolver
{
/// <summary>
/// Passes the path through without modification as this is the normal content resolver and is meant to just pass things on.
/// </summary>
/// <param name="contentPath">The path to modify.</param>
/// <returns></returns>
public string Modify(string contentPath)
{
return contentPath;
}
}
}