rhythmbullet/RhythmBullet/Zer01HD/Utilities/UI/Interactive/BasicButton.cs

49 lines
1.1 KiB
C#
Raw Normal View History

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; }
}
}