reorganized file structure; texture and fonts now have appropriate folder resolver;
This commit is contained in:
@@ -16,7 +16,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
readonly ContentManager contentManager;
|
||||
readonly Queue<ContentLoad> queue;
|
||||
Dictionary<string, IDisposable> assets;
|
||||
readonly Dictionary<Type, IContentResolver> contentResolver;
|
||||
public readonly Dictionary<Type, IContentResolver> contentResolver;
|
||||
|
||||
public ContentSystem(ContentManager contentManager)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
/// <summary>
|
||||
/// Called whenever a batch of assets should be loaded from the queue. Safe to call once every frame.
|
||||
/// </summary>
|
||||
void Update()
|
||||
public void Update()
|
||||
{
|
||||
if (queue.Count > 0)
|
||||
{
|
||||
@@ -81,16 +81,45 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
}
|
||||
}
|
||||
|
||||
void UnloadAll()
|
||||
/// <summary>
|
||||
/// Removes the asset from the list of assets in the system.
|
||||
/// Cannot remove from queue.
|
||||
/// </summary>
|
||||
/// <param name="name">the string name used to load the asset</param>
|
||||
public void Remove(string name)
|
||||
{
|
||||
if (assets.ContainsKey(name))
|
||||
{
|
||||
assets[name].Dispose();
|
||||
assets.Remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the queue.
|
||||
/// </summary>
|
||||
public void ClearQueue()
|
||||
{
|
||||
lock(queue)
|
||||
{
|
||||
queue.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unloads everything from both queue and loaded list while properly disposing of the assets loaded.
|
||||
/// </summary>
|
||||
public void UnloadAll()
|
||||
{
|
||||
foreach (KeyValuePair<string, IDisposable> asset in assets)
|
||||
{
|
||||
asset.Value.Dispose();
|
||||
assets.Remove(asset.Key);
|
||||
}
|
||||
ClearQueue();
|
||||
}
|
||||
|
||||
bool Done()
|
||||
public bool Done()
|
||||
{
|
||||
return queued;
|
||||
}
|
||||
|
@@ -6,8 +6,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
|
||||
{
|
||||
interface IContentResolver
|
||||
public interface IContentResolver
|
||||
{
|
||||
string Load(string path);
|
||||
/// <summary>
|
||||
/// Returns the complete path with the content folder as root.
|
||||
/// </summary>
|
||||
/// <param name="assetName">Is the asset's name</param>
|
||||
/// <returns></returns>
|
||||
string Load(string assetName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user