documentation.
This commit is contained in:
@@ -6,16 +6,36 @@ using System.Threading;
|
||||
|
||||
namespace RecrownedAthenaeum.ContentSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Wrapper for the content manager that helps with controlling it by adding automated multithreaded content loading.
|
||||
/// </summary>
|
||||
public class ContentManagerController
|
||||
{
|
||||
Thread thread;
|
||||
readonly ContentManager contentManager;
|
||||
readonly Queue<LoadableContent> queue;
|
||||
Dictionary<string, IDisposable> assets;
|
||||
/// <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;
|
||||
volatile float progress;
|
||||
volatile bool running;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the queue is empty and all content is loaded.
|
||||
/// </summary>
|
||||
public bool Done { get { return !running && queue.Count == 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// The progress of the loading. 1 is complete while 0 is incomplete.
|
||||
/// </summary>
|
||||
public float Progress { get { return progress; } }
|
||||
|
||||
/// <summary>
|
||||
/// Wraps the <see cref="ContentManager"/>.
|
||||
/// </summary>
|
||||
/// <param name="contentManager">The manager to wrap.</param>
|
||||
public ContentManagerController(ContentManager contentManager)
|
||||
{
|
||||
this.contentManager = contentManager;
|
||||
@@ -38,6 +58,12 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
Debug.WriteLine("Loaded asset: " + assetName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the requested asset.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the asset for an alternative way to cast.</typeparam>
|
||||
/// <param name="assetName">The name of the asset.</param>
|
||||
/// <returns>The asset casted to the type given with T.</returns>
|
||||
public T Get<T>(string assetName)
|
||||
{
|
||||
lock (queue)
|
||||
@@ -46,6 +72,12 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues an asset to be loaded.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the asset to be queued.</typeparam>
|
||||
/// <param name="assetName">Name of asset to look for.</param>
|
||||
/// <param name="usePathModifier">Whether or not to use the path modifiers.</param>
|
||||
public void Queue<T>(string assetName, bool usePathModifier = true) where T : IDisposable
|
||||
{
|
||||
lock (queue)
|
||||
@@ -133,20 +165,6 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
}
|
||||
}
|
||||
|
||||
public bool Done
|
||||
{
|
||||
get
|
||||
{
|
||||
return !running && queue.Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
return progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,8 @@
|
||||
namespace RecrownedAthenaeum.ContentSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Modifies the given path based on a name. Used to simplify long paths for the <see cref="ContentManagerController"/>
|
||||
/// </summary>
|
||||
public interface IContentPathModifier
|
||||
{
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user