refactored.

This commit is contained in:
Harrison Deng 2019-01-20 01:31:01 -06:00
parent ea8f96d877
commit 019b955577
3 changed files with 7 additions and 7 deletions

View File

@ -2,13 +2,13 @@
namespace RecrownedAthenaeum.ContentSystem namespace RecrownedAthenaeum.ContentSystem
{ {
struct LoadableContent struct ContentData
{ {
internal Type type; internal Type type;
internal string assetName; internal string assetName;
internal bool usePathModifier; internal bool usePathModifier;
public LoadableContent(string assetName, Type type, bool usePathModifier) public ContentData(string assetName, Type type, bool usePathModifier)
{ {
this.type = type; this.type = type;
this.assetName = assetName; this.assetName = assetName;

View File

@ -13,7 +13,7 @@ namespace RecrownedAthenaeum.ContentSystem
{ {
Thread thread; Thread thread;
readonly ContentManager contentManager; readonly ContentManager contentManager;
readonly Queue<LoadableContent> queue; readonly Queue<ContentData> queue;
Dictionary<string, IDisposable> assets; Dictionary<string, IDisposable> assets;
/// <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.
@ -40,7 +40,7 @@ namespace RecrownedAthenaeum.ContentSystem
{ {
this.contentManager = contentManager; this.contentManager = contentManager;
assets = new Dictionary<string, IDisposable>(); assets = new Dictionary<string, IDisposable>();
queue = new Queue<LoadableContent>(); queue = new Queue<ContentData>();
contentPathModifier = new Dictionary<Type, IContentPathModifier>(); contentPathModifier = new Dictionary<Type, IContentPathModifier>();
} }
@ -84,7 +84,7 @@ namespace RecrownedAthenaeum.ContentSystem
{ {
if (!assets.ContainsKey(assetName)) if (!assets.ContainsKey(assetName))
{ {
queue.Enqueue(new LoadableContent(assetName, typeof(T), usePathModifier)); queue.Enqueue(new ContentData(assetName, typeof(T), usePathModifier));
Debug.WriteLine("Queued asset: " + assetName); Debug.WriteLine("Queued asset: " + assetName);
} }
else else
@ -115,7 +115,7 @@ namespace RecrownedAthenaeum.ContentSystem
{ {
lock (queue) lock (queue)
{ {
LoadableContent content = queue.Dequeue(); ContentData content = queue.Dequeue();
Load(content.assetName, content.type, content.usePathModifier); Load(content.assetName, content.type, content.usePathModifier);
tasksCompleted++; tasksCompleted++;
progress = (float)tasksCompleted / totalTasks; progress = (float)tasksCompleted / totalTasks;

View File

@ -52,7 +52,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Camera\Camera2D.cs" /> <Compile Include="Camera\Camera2D.cs" />
<Compile Include="ContentSystem\ContentLoad.cs" /> <Compile Include="ContentSystem\ContentData.cs" />
<Compile Include="ContentSystem\ContentManagerController.cs" /> <Compile Include="ContentSystem\ContentManagerController.cs" />
<Compile Include="ContentSystem\ContentResolvers\FontContentResolver.cs" /> <Compile Include="ContentSystem\ContentResolvers\FontContentResolver.cs" />
<Compile Include="ContentSystem\ContentResolvers\ResolutionContentResolver.cs" /> <Compile Include="ContentSystem\ContentResolvers\ResolutionContentResolver.cs" />