progress on text buttons (untested)

This commit is contained in:
2018-11-22 01:12:40 -06:00
parent f63a7b76e3
commit 6f43cbffbb
7 changed files with 76 additions and 13 deletions

View File

@@ -1,5 +1,7 @@
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RhythmBullet.UI.Modular;
using RhythmBullet.Utilities.DataTypes;
using RhythmBullet.Utilities.Input;
using System;
using System.Collections.Generic;
@@ -11,13 +13,20 @@ namespace RhythmBullet.Utilities.UI.Modular.Modules.Interactive
{
public delegate bool Clicked();
public class BasicButton : UIModuleGroup
public class Button : UIModule
{
private NinePatch background;
public event Clicked Listeners;
public BasicButton()
public Button(NinePatch background = null)
{
this.background = background;
}
public override void Draw(SpriteBatch batch)
{
background?.Draw(batch, bounds);
base.Draw(batch);
}
public sealed override bool MouseStateChanged(MouseState state)
@@ -29,7 +38,8 @@ namespace RhythmBullet.Utilities.UI.Modular.Modules.Interactive
OnClick();
}
Highlighted = true;
} else
}
else
{
Highlighted = false;
}

View File

@@ -0,0 +1,37 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RhythmBullet.UI.Modular.Modules;
using RhythmBullet.Utilities.DataTypes;
using RhythmBullet.Utilities.UI.Modular.Modules.Interactive;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Utilities.UI.Modular.Modules.Interactive
{
internal class TextButton : Button
{
private TextLabel label;
internal TextButton(string text, SpriteFont font, NinePatch background) : base(background)
{
label = new TextLabel(font, text);
label.autoScale = true;
}
public override void Update(GameTime gameTime)
{
label.bounds = bounds;
label.Update(gameTime);
base.Update(gameTime);
}
public override void Draw(SpriteBatch batch)
{
label.Draw(batch);
base.Draw(batch);
}
}
}