2018-11-09 05:49:42 +00:00
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
|
using RhythmBullet.Zer01HD.UI.Modular;
|
|
|
|
|
using RhythmBullet.Zer01HD.Utilities.Input;
|
|
|
|
|
using System;
|
2018-11-02 03:02:25 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace RhythmBullet.Zer01HD.Utilities.UI.Interactive
|
|
|
|
|
{
|
2018-11-09 05:49:42 +00:00
|
|
|
|
public delegate bool Clicked();
|
|
|
|
|
|
|
|
|
|
public class BasicButton : UIModuleGroup
|
2018-11-02 03:02:25 +00:00
|
|
|
|
{
|
2018-11-09 05:49:42 +00:00
|
|
|
|
public event Clicked Listeners;
|
2018-11-13 00:34:11 +00:00
|
|
|
|
|
2018-11-09 05:49:42 +00:00
|
|
|
|
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; }
|
2018-11-02 03:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|