2018-12-30 18:00:05 +08:00
|
|
|
using System;
|
2018-03-06 12:46:45 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace StardustCore.UIUtilities
|
|
|
|
{
|
|
|
|
public class TextureManager
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
public Dictionary<string, Texture2DExtended> textures;
|
2018-03-06 12:46:45 +08:00
|
|
|
|
|
|
|
public TextureManager()
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
this.textures = new Dictionary<string, Texture2DExtended>();
|
2018-03-06 12:46:45 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
public void addTexture(string name, Texture2DExtended texture)
|
2018-03-06 12:46:45 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
this.textures.Add(name, texture);
|
2018-03-06 12:46:45 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Returns a Texture2DExtended held by the manager.</summary>
|
2018-03-06 12:46:45 +08:00
|
|
|
public Texture2DExtended getTexture(string name)
|
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
foreach (var v in this.textures)
|
2018-03-06 12:46:45 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
if (v.Key == name)
|
|
|
|
return v.Value.Copy();
|
2018-03-06 12:46:45 +08:00
|
|
|
}
|
2018-12-16 03:49:56 +08:00
|
|
|
throw new Exception("Error, texture name not found!!!");
|
2018-03-06 12:46:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|