using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
namespace StardustCore.UIUtilities
{
public class Texture2DExtended
{
/*********
** Accessors
*********/
/// The underlying texture.
public Texture2D Texture { get; }
/// The texture width.
public int Width => this.Texture.Width;
/// The texture height.
public int Height => this.Texture.Height;
/*********
** Public methods
*********/
/// Empty/null constructor.
public Texture2DExtended()
{
this.Texture = null;
}
/// Construct an instance.
public Texture2DExtended(Texture2D texture)
{
this.Texture = texture;
}
public Texture2DExtended(IModHelper helper, string path, ContentSource contentSource = ContentSource.ModFolder)
{
this.Texture = helper.Content.Load(path, contentSource);
}
public Texture2DExtended Copy()
{
Texture2D clone = new Texture2D(this.Texture.GraphicsDevice, this.Texture.Width, this.Texture.Height);
Color[] data = new Color[clone.Width * clone.Height];
this.Texture.GetData(data);
clone.SetData(data);
return new Texture2DExtended(clone);
}
/// Returns the actual 2D texture held by this wrapper class.
public Texture2D getTexture()
{
return this.Texture;
}
}
}