2018-11-09 05:49:42 +00:00
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
2018-11-21 00:56:41 +00:00
|
|
|
|
using RhythmBullet.UI.Modular;
|
|
|
|
|
using RhythmBullet.Utilities.Input;
|
2018-11-09 05:49:42 +00:00
|
|
|
|
using System;
|
2018-11-02 03:02:25 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2018-11-21 00:56:41 +00:00
|
|
|
|
namespace RhythmBullet.Utilities.UI.Modular.Modules.Interactive
|
2018-11-02 03:02:25 +00:00
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
2018-11-21 00:12:02 +00:00
|
|
|
|
if (InputUtilities.MouseWithinBoundries(bounds))
|
2018-11-09 05:49:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (InputUtilities.MouseClicked())
|
|
|
|
|
{
|
|
|
|
|
OnClick();
|
|
|
|
|
}
|
|
|
|
|
Highlighted = true;
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
Highlighted = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.MouseStateChanged(state);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-21 00:12:02 +00:00
|
|
|
|
public sealed override bool KeyboardStateChanged(KeyboardState state)
|
|
|
|
|
{
|
|
|
|
|
return base.KeyboardStateChanged(state);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-09 05:49:42 +00:00
|
|
|
|
protected void OnClick()
|
|
|
|
|
{
|
|
|
|
|
Listeners?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Highlighted { get; private set; }
|
2018-11-02 03:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|