53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Microsoft.Xna.Framework.Input;
 | |
| using RhythmBullet.UI.Modular;
 | |
| using RhythmBullet.Utilities.Input;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Threading.Tasks;
 | |
| 
 | |
| namespace RhythmBullet.Utilities.UI.Modular.Modules.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);
 | |
|         }
 | |
| 
 | |
|         public sealed override bool KeyboardStateChanged(KeyboardState state)
 | |
|         {
 | |
|             return base.KeyboardStateChanged(state);
 | |
|         }
 | |
| 
 | |
|         protected void OnClick()
 | |
|         {
 | |
|             Listeners?.Invoke();
 | |
|         }
 | |
| 
 | |
|         public bool Highlighted { get; private set; }
 | |
|     }
 | |
| }
 |