diff options
| author | Ben Beltran <ben@nsovocal.com> | 2013-11-23 13:54:16 -0600 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2013-11-23 13:54:16 -0600 |
| commit | b587e9d8e0cc5eb1edf972fd3b644704441e5289 (patch) | |
| tree | 7ad7c006afa1d7101111d8b2418c8a96a824eafc /Super Polarity/InputController.cs | |
| parent | 097781e6ad3f7bb1c13c16ff7b6bb7219764fb29 (diff) | |
Protoshow sprint.
Diffstat (limited to 'Super Polarity/InputController.cs')
| -rw-r--r-- | Super Polarity/InputController.cs | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/Super Polarity/InputController.cs b/Super Polarity/InputController.cs index 79bd039..c92bb9c 100644 --- a/Super Polarity/InputController.cs +++ b/Super Polarity/InputController.cs @@ -37,11 +37,42 @@ namespace SuperPolarity public static void UpdateInput() { - Poll(); DispatchMoveEvents(); DispatchRegisteredEvents(); } + public static void UpdateInput(bool highPriorityOnly) + { + Poll(); + DispatchPauseEvent(); + if (!highPriorityOnly) + { + UpdateInput(); + } + } + + public static void DispatchPauseEvent() + { + // OK THIS IS ALL KINDS OF WRONG. THIS IS A PLACEHOLDER BECAUSE DEMO! + var keyPressed = false; + if ((InputKeyboardState.IsKeyDown(Keys.Enter) || InputGamePadState.IsButtonDown(Buttons.Start))) { + keyPressed = true; + if(!BlockedButtons.Contains("pause") && !BlockedKeys.Contains("pause")) + { + BlockedButtons.Add("pause"); + BlockedKeys.Add("pause"); + Console.WriteLine("Dispatch"); + Dispatch("pause", 0); + } + } + + if (!keyPressed) + { + BlockedButtons.Remove("pause"); + BlockedKeys.Remove("pause"); + } + } + private static void Poll() { InputGamePadState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One); @@ -175,6 +206,21 @@ namespace SuperPolarity listenerList.Add(listener); } + public static void Unbind(string eventName, Action<float> listener) + { + List<Action<float>> listenerList; + bool foundListeners; + + if (!Listeners.ContainsKey(eventName)) + { + return; + } + + foundListeners = Listeners.TryGetValue(eventName, out listenerList); + + listenerList.Remove(listener); + } + public static void Dispatch(string eventName, float value) { List<Action<float>> listenerList; @@ -187,9 +233,9 @@ namespace SuperPolarity return; } - foreach (Action<float> method in listenerList) + for (var i = listenerList.Count - 1; i >= 0; i--) { - method(value); + listenerList[i](value); } } |