From 45deae140cc77303b8060fe125d5eb6945f457ed Mon Sep 17 00:00:00 2001 From: Harrison Date: Sat, 28 Dec 2019 16:02:11 -0600 Subject: [PATCH] Removed monogame based input listener setup. --- RecrownedAthenaeum/Input/IInputListener.cs | 23 ------ RecrownedAthenaeum/Input/InputListener.cs | 17 ----- RecrownedAthenaeum/Input/InputUtilities.cs | 87 ---------------------- 3 files changed, 127 deletions(-) delete mode 100644 RecrownedAthenaeum/Input/IInputListener.cs delete mode 100644 RecrownedAthenaeum/Input/InputListener.cs delete mode 100644 RecrownedAthenaeum/Input/InputUtilities.cs diff --git a/RecrownedAthenaeum/Input/IInputListener.cs b/RecrownedAthenaeum/Input/IInputListener.cs deleted file mode 100644 index 9350245..0000000 --- a/RecrownedAthenaeum/Input/IInputListener.cs +++ /dev/null @@ -1,23 +0,0 @@ - -namespace RecrownedAthenaeum.Input -{ - /// - /// Input listener for . - /// - public interface IInputListener - { - /// - /// Called when the state of the keyboard has changed. - /// - /// The new state. - /// True to continue calling other listeners. - bool KeyboardStateChanged(KeyboardState state); - - /// - /// Called when the state of the mouse has changed. - /// - /// The new state. - /// True to continue calling other listeners. - bool MouseStateChanged(MouseState state); - } -} diff --git a/RecrownedAthenaeum/Input/InputListener.cs b/RecrownedAthenaeum/Input/InputListener.cs deleted file mode 100644 index 7c60af9..0000000 --- a/RecrownedAthenaeum/Input/InputListener.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.Xna.Framework.Input; - -namespace RecrownedAthenaeum.Input -{ - class InputListener : IInputListener - { - public bool KeyboardStateChanged(KeyboardState state) - { - return true; - } - - public bool MouseStateChanged(MouseState state) - { - return true; - } - } -} diff --git a/RecrownedAthenaeum/Input/InputUtilities.cs b/RecrownedAthenaeum/Input/InputUtilities.cs deleted file mode 100644 index 63b18a6..0000000 --- a/RecrownedAthenaeum/Input/InputUtilities.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; -using System.Collections.Generic; - -namespace RecrownedAthenaeum.Input -{ - /// - /// Utilities to better manage input for the game. - /// - public static class InputUtilities - { - /// - /// Listeners for changes in input. - /// - public static List InputListeners; - static KeyboardState keyboardState; - static MouseState mouseState; - - static InputUtilities() - { - InputListeners = new List(); - } - - /// - /// Updates inputs. - /// Should be called once every game update to be up to date with new states of inputs. - /// - public static void Update() - { - KeyboardState updatedKeyboardState = Keyboard.GetState(); - MouseState updatedMouseState = Mouse.GetState(); - bool disableKeyboard = false; - bool disableMouse = false; - foreach (IInputListener inputListener in InputListeners) - { - if (!disableKeyboard && keyboardState != updatedKeyboardState) - { - disableKeyboard = inputListener.KeyboardStateChanged(updatedKeyboardState); - } - if (!disableMouse && mouseState != updatedMouseState) - { - disableMouse = inputListener.MouseStateChanged(updatedMouseState); - } - if (disableKeyboard && disableMouse) - { - break; - } - } - - UpdateStates(); - } - - /// - /// Poll used to check if mouse was clicked. - /// - /// True if clicked. - public static bool MouseClicked() - { - if (mouseState.LeftButton == ButtonState.Pressed) - { - return Mouse.GetState().LeftButton != ButtonState.Pressed; - } - return false; - } - - private static void UpdateStates() - { - keyboardState = Keyboard.GetState(); - mouseState = Mouse.GetState(); - } - - /// - /// Checks whether mouse is within boundaries. - /// - /// Boundaries to check. - /// - public static bool MouseWithinBoundries(Rectangle bounds) - { - MouseState mouseState = Mouse.GetState(); - if (mouseState.X >= bounds.X && mouseState.X <= (bounds.X + bounds.Width) && mouseState.Y >= bounds.Y && mouseState.Y <= (bounds.Y + bounds.Height)) - { - return true; - } - return false; - } - } -}