added basic image ui module
This commit is contained in:
26
RhythmBullet/Zer01HD/Utilities/UI/Modular/Modules/Image.cs
Normal file
26
RhythmBullet/Zer01HD/Utilities/UI/Modular/Modules/Image.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RhythmBullet.Zer01HD.UI.Modular;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBullet.Zer01HD.Utilities.UI.Modular.Modules
|
||||
{
|
||||
class Image : UIModule
|
||||
{
|
||||
Texture2D texture;
|
||||
|
||||
public Image(Texture2D texture)
|
||||
{
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch batch)
|
||||
{
|
||||
batch.Draw(texture, Bounds, Color);
|
||||
base.Draw(batch);
|
||||
}
|
||||
}
|
||||
}
|
44
RhythmBullet/Zer01HD/Utilities/UI/Modular/Modules/Text.cs
Normal file
44
RhythmBullet/Zer01HD/Utilities/UI/Modular/Modules/Text.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RhythmBullet.Zer01HD.Utilities.Camera;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RhythmBullet.Zer01HD.UI.Modular.Modules
|
||||
{
|
||||
public class Text : UIModule
|
||||
{
|
||||
private SpriteFont font;
|
||||
private float scale;
|
||||
private Vector2 position;
|
||||
public string DisplayedText
|
||||
{
|
||||
get
|
||||
{
|
||||
return DisplayedText;
|
||||
}
|
||||
set
|
||||
{
|
||||
Vector2 size = font.MeasureString(value);
|
||||
Bounds.Width = (int) size.X;
|
||||
scale = Bounds.Height / size.Y;
|
||||
}
|
||||
}
|
||||
public Text(string displayedText, SpriteFont font, int height)
|
||||
{
|
||||
Bounds.Height = height;
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch batch)
|
||||
{
|
||||
position.X = Bounds.X;
|
||||
position.Y = Bounds.Y;
|
||||
batch.DrawString(font, DisplayedText, position, Color);
|
||||
base.Draw(batch);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user