2018-11-30 02:41:06 +00:00
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2018-12-14 06:42:51 +00:00
|
|
|
|
using RecrownedAthenaeum.DataTypes;
|
2018-11-30 02:41:06 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2018-12-04 13:45:09 +00:00
|
|
|
|
namespace RecrownedAthenaeum.UI.Modular.Modules
|
2018-11-30 02:41:06 +00:00
|
|
|
|
{
|
2018-12-14 06:42:51 +00:00
|
|
|
|
public class Image : UIModule, ISpecialDrawable
|
2018-11-30 02:41:06 +00:00
|
|
|
|
{
|
|
|
|
|
public float rotation = 0f;
|
|
|
|
|
public Texture2D Texture { get; set; }
|
|
|
|
|
public float ScaleX
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (float)bounds.Width / Texture.Width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
bounds.Width = (int)(Texture.Width * value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float ScaleY
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (float)bounds.Height / Texture.Height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
bounds.Height = (int)(Texture.Height * value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Scale
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
bounds.Height = (int)(Texture.Height * value);
|
|
|
|
|
bounds.Width = (int)(Texture.Width * value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Image(Texture2D texture)
|
|
|
|
|
{
|
|
|
|
|
Texture = texture ?? throw new ArgumentException("Image requires a texture.");
|
|
|
|
|
bounds = texture.Bounds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(SpriteBatch batch)
|
|
|
|
|
{
|
|
|
|
|
batch.Draw(Texture, bounds, null, color, rotation, origin, SpriteEffects.None, 0f);
|
|
|
|
|
base.Draw(batch);
|
|
|
|
|
}
|
2018-12-14 06:42:51 +00:00
|
|
|
|
|
|
|
|
|
public void Draw(SpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
|
|
|
|
|
{
|
|
|
|
|
this.color = color;
|
|
|
|
|
this.rotation = rotation;
|
|
|
|
|
this.origin = origin;
|
|
|
|
|
bounds = destination;
|
|
|
|
|
Draw(spriteBatch);
|
|
|
|
|
}
|
2018-11-30 02:41:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|