2018-02-06 18:13:21 +08:00
|
|
|
using System.IO;
|
2018-12-30 18:00:05 +08:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
using StardewModdingAPI;
|
2018-02-06 18:13:21 +08:00
|
|
|
|
|
|
|
namespace StardustCore.UIUtilities
|
|
|
|
{
|
|
|
|
public class Texture2DExtended
|
|
|
|
{
|
|
|
|
public string Name;
|
2018-08-08 15:12:31 +08:00
|
|
|
public Texture2D texture;
|
2018-02-06 18:13:21 +08:00
|
|
|
public string path;
|
2018-12-30 18:00:05 +08:00
|
|
|
readonly IModHelper helper;
|
2018-08-09 04:18:51 +08:00
|
|
|
public string modID;
|
2018-08-26 09:22:14 +08:00
|
|
|
public ContentSource source;
|
2018-12-30 18:00:05 +08:00
|
|
|
|
|
|
|
/// <summary>Empty/null constructor.</summary>
|
2018-03-31 16:47:10 +08:00
|
|
|
public Texture2DExtended()
|
|
|
|
{
|
|
|
|
this.Name = "";
|
|
|
|
this.texture = null;
|
|
|
|
this.path = "";
|
2018-05-01 09:21:31 +08:00
|
|
|
this.helper = null;
|
2018-08-09 04:18:51 +08:00
|
|
|
this.modID = "";
|
2018-03-31 16:47:10 +08:00
|
|
|
}
|
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Construct an instance.</summary>
|
2018-03-06 12:46:45 +08:00
|
|
|
/// <param name="path">The relative path to file on disk. See StardustCore.Utilities.getRelativePath(modname,path);
|
2018-12-30 18:00:05 +08:00
|
|
|
public Texture2DExtended(IModHelper helper, IManifest manifest, string path, ContentSource contentSource = ContentSource.ModFolder)
|
2018-02-06 18:13:21 +08:00
|
|
|
{
|
2018-08-09 04:18:51 +08:00
|
|
|
this.Name = Path.GetFileNameWithoutExtension(path);
|
2018-02-06 18:13:21 +08:00
|
|
|
this.path = path;
|
2018-12-30 18:00:05 +08:00
|
|
|
this.texture = helper.Content.Load<Texture2D>(path, contentSource);
|
2018-05-01 09:21:31 +08:00
|
|
|
this.helper = helper;
|
2018-08-09 04:18:51 +08:00
|
|
|
this.modID = manifest.UniqueID;
|
2018-08-26 09:22:14 +08:00
|
|
|
this.source = contentSource;
|
2018-02-06 18:13:21 +08:00
|
|
|
}
|
2018-08-09 04:18:51 +08:00
|
|
|
|
2018-08-26 09:22:14 +08:00
|
|
|
public Texture2DExtended(IModHelper helper, string modID, string path, ContentSource contentSource = ContentSource.ModFolder)
|
2018-08-09 04:18:51 +08:00
|
|
|
{
|
|
|
|
this.Name = Path.GetFileNameWithoutExtension(path);
|
|
|
|
this.path = path;
|
2018-12-30 18:00:05 +08:00
|
|
|
this.texture = helper.Content.Load<Texture2D>(path, contentSource);
|
2018-08-09 04:18:51 +08:00
|
|
|
this.helper = helper;
|
|
|
|
this.modID = modID;
|
2018-08-26 09:22:14 +08:00
|
|
|
this.source = contentSource;
|
2018-08-09 04:18:51 +08:00
|
|
|
}
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
public Texture2DExtended Copy()
|
2018-02-06 18:13:21 +08:00
|
|
|
{
|
2018-12-30 18:00:05 +08:00
|
|
|
return new Texture2DExtended(this.helper, this.modID, this.path);
|
|
|
|
}
|
2018-05-01 09:21:31 +08:00
|
|
|
|
|
|
|
public IModHelper getHelper()
|
|
|
|
{
|
|
|
|
return this.helper;
|
|
|
|
}
|
2018-06-13 09:42:31 +08:00
|
|
|
|
2018-12-30 18:00:05 +08:00
|
|
|
/// <summary>Returns the actual 2D texture held by this wrapper class.</summary>
|
2018-06-13 09:42:31 +08:00
|
|
|
public Texture2D getTexture()
|
|
|
|
{
|
|
|
|
return this.texture;
|
|
|
|
}
|
2018-08-08 01:07:33 +08:00
|
|
|
|
|
|
|
public void setTexure(Texture2D text)
|
|
|
|
{
|
|
|
|
this.texture = text;
|
|
|
|
}
|
2018-02-06 18:13:21 +08:00
|
|
|
}
|
|
|
|
}
|