49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
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;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RhythmBullet.Zer01HD.Utilities.UI.Interactive
|
|
{
|
|
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; }
|
|
}
|
|
}
|