added default path modifier.

This commit is contained in:
Harrison Deng 2019-01-20 21:31:20 -06:00
parent 5f4e870656
commit 54ebaa0fff

View File

@ -1,4 +1,5 @@
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
using RecrownedAthenaeum.ContentSystem.ContentResolvers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -19,6 +20,10 @@ 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. /// 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, IContentPathModifier> contentPathModifier;
/// <summary>
/// Used when no path modifier is defined for that specific type.
/// </summary>
public IContentPathModifier normalPathModifier = new NormalContentResolver();
volatile float progress; volatile float progress;
volatile bool running; volatile bool running;
@ -46,16 +51,22 @@ namespace RecrownedAthenaeum.ContentSystem
private void Load(string assetName, Type type, bool usePathModifier) private void Load(string assetName, Type type, bool usePathModifier)
{ {
Debug.WriteLine("Loading asset: " + assetName);
string path = assetName; string path = assetName;
if (usePathModifier) if (usePathModifier)
{ {
IContentPathModifier handler = contentPathModifier[type]; IContentPathModifier handler;
if (contentPathModifier.ContainsKey(type))
{
handler = contentPathModifier[type];
} else
{
handler = normalPathModifier;
}
path = handler.Modify(assetName); path = handler.Modify(assetName);
} }
assets.Add(assetName, contentManager.Load<IDisposable>(path)); assets.Add(assetName, contentManager.Load<IDisposable>(path));
Debug.WriteLine("Loaded asset: " + assetName);
} }
/// <summary> /// <summary>