refactor and moved normal resolver to library (forgot to commit this part last time).
This commit is contained in:
parent
010c66aa0e
commit
1b54dd2d28
@ -1,5 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using RecrownedAthenaeum.ContentSystem.ContentResolvers;
|
using RecrownedAthenaeum.ContentSystem;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -19,11 +19,11 @@ namespace RecrownedAthenaeum.ContentSystem
|
|||||||
/// <summary>
|
/// <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.
|
/// 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>
|
/// </summary>
|
||||||
public readonly Dictionary<Type, IContentPathModifier> contentPathModifier;
|
public readonly Dictionary<Type, IContentPathResolver> contentPathModifier;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used when no path modifier is defined for that specific type.
|
/// Used when no path modifier is defined for that specific type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IContentPathModifier normalPathModifier = new NormalContentResolver();
|
public IContentPathResolver normalPathModifier = new NormalContentResolver();
|
||||||
volatile float progress;
|
volatile float progress;
|
||||||
volatile bool running;
|
volatile bool running;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
|||||||
this.contentManager = contentManager;
|
this.contentManager = contentManager;
|
||||||
assets = new Dictionary<string, IDisposable>();
|
assets = new Dictionary<string, IDisposable>();
|
||||||
queue = new Queue<ContentData>();
|
queue = new Queue<ContentData>();
|
||||||
contentPathModifier = new Dictionary<Type, IContentPathModifier>();
|
contentPathModifier = new Dictionary<Type, IContentPathResolver>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Load(string assetName, Type type, bool usePathModifier)
|
private void Load(string assetName, Type type, bool usePathModifier)
|
||||||
@ -55,7 +55,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
|||||||
string path = assetName;
|
string path = assetName;
|
||||||
if (usePathModifier)
|
if (usePathModifier)
|
||||||
{
|
{
|
||||||
IContentPathModifier handler;
|
IContentPathResolver handler;
|
||||||
if (contentPathModifier.ContainsKey(type))
|
if (contentPathModifier.ContainsKey(type))
|
||||||
{
|
{
|
||||||
handler = contentPathModifier[type];
|
handler = contentPathModifier[type];
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modifies the given path based on a name. Used to simplify long paths for the <see cref="ContentManagerController"/>
|
/// Modifies the given path based on a name. Used to simplify long paths for the <see cref="ContentManagerController"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IContentPathModifier
|
public interface IContentPathResolver
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the complete path with the content folder as root.
|
/// Returns the complete path with the content folder as root.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetName">Is the asset's name</param>
|
/// <param name="contentPath">Is the asset's name</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
string Modify(string assetName);
|
string Modify(string contentPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
18
RecrownedAthenaeum/ContentSystem/NormalContentResolver.cs
Normal file
18
RecrownedAthenaeum/ContentSystem/NormalContentResolver.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user