changed content manager controller's generic type to allow for any object instead of IDisposable only.
This commit is contained in:
parent
6ba5274942
commit
2788d9d349
@ -33,11 +33,11 @@
|
||||
<DocumentationFile>bin\Release\RecrownedAthenaeum.Pipeline.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework, Version=3.7.0.1708, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MonoGame.Framework.Portable.3.7.0.1708\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll</HintPath>
|
||||
<Reference Include="MonoGame.Framework, Version=3.7.1.189, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MonoGame.Framework.Portable.3.7.1.189\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MonoGame.Framework.Content.Pipeline, Version=3.7.0.1708, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MonoGame.Framework.Content.Pipeline.Portable.3.7.0.1708\lib\portable-net45+win8+wpa81\MonoGame.Framework.Content.Pipeline.dll</HintPath>
|
||||
<Reference Include="MonoGame.Framework.Content.Pipeline, Version=3.7.1.189, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MonoGame.Framework.Content.Pipeline.Portable.3.7.1.189\lib\portable-net45+win8+wpa81\MonoGame.Framework.Content.Pipeline.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MonoGame.Framework.Content.Pipeline.Portable" version="3.7.0.1708" targetFramework="net45" />
|
||||
<package id="MonoGame.Framework.Portable" version="3.7.0.1708" targetFramework="net45" />
|
||||
<package id="MonoGame.Framework.Content.Pipeline.Portable" version="3.7.1.189" targetFramework="net45" />
|
||||
<package id="MonoGame.Framework.Portable" version="3.7.1.189" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
|
||||
</packages>
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.ContentSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -15,7 +16,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
Thread thread;
|
||||
readonly ContentManager contentManager;
|
||||
readonly Queue<ContentData> queue;
|
||||
Dictionary<string, IDisposable> assets;
|
||||
Dictionary<string, Object> 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>
|
||||
@ -44,7 +45,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
public ContentManagerController(ContentManager contentManager)
|
||||
{
|
||||
this.contentManager = contentManager;
|
||||
assets = new Dictionary<string, IDisposable>();
|
||||
assets = new Dictionary<string, Object>();
|
||||
queue = new Queue<ContentData>();
|
||||
contentPathModifier = new Dictionary<Type, IContentPathResolver>();
|
||||
}
|
||||
@ -59,13 +60,14 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
if (contentPathModifier.ContainsKey(type))
|
||||
{
|
||||
handler = contentPathModifier[type];
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
handler = normalPathModifier;
|
||||
}
|
||||
path = handler.Modify(assetName);
|
||||
}
|
||||
assets.Add(assetName, contentManager.Load<IDisposable>(path));
|
||||
assets.Add(assetName, contentManager.Load<Object>(path));
|
||||
|
||||
}
|
||||
|
||||
@ -89,7 +91,7 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
/// <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
|
||||
public void Queue<T>(string assetName, bool usePathModifier = true)
|
||||
{
|
||||
lock (queue)
|
||||
{
|
||||
@ -145,7 +147,10 @@ namespace RecrownedAthenaeum.ContentSystem
|
||||
{
|
||||
if (assets.ContainsKey(name))
|
||||
{
|
||||
assets[name].Dispose();
|
||||
if (assets[name] is IDisposable)
|
||||
{
|
||||
((IDisposable)assets[name]).Dispose();
|
||||
}
|
||||
assets.Remove(name);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user