added input system to basic button; code cleanup;

This commit is contained in:
2018-11-08 23:49:42 -06:00
parent fcd2278796
commit 17e59397a5
4 changed files with 47 additions and 10 deletions

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.UI.Book
{
class Page : ModuleGroup
class Page : UIModuleGroup
{
private readonly int pageX, pageY;

View File

@@ -1,4 +1,7 @@
using System;
using Microsoft.Xna.Framework.Input;
using RhythmBullet.Zer01HD.UI.Modular;
using RhythmBullet.Zer01HD.Utilities.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,8 +9,40 @@ using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Utilities.UI.Interactive
{
class BasicButton
public delegate bool Clicked();
public class BasicButton : UIModuleGroup
{
public event Clicked Listeners;
public BasicButton()
{
}
public sealed override bool MouseStateChanged(MouseState state)
{
if (InputUtilities.MouseWithinBoundries(Bounds))
{
if (InputUtilities.MouseClicked())
{
OnClick();
}
Highlighted = true;
} else
{
Highlighted = false;
}
return base.MouseStateChanged(state);
}
protected void OnClick()
{
Listeners?.Invoke();
}
public bool Highlighted { get; private set; }
}
}