From efed3d9e12351647c416ee09eeae501fdd3b9123 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 4 May 2020 16:41:54 +0200 Subject: [PATCH] some controls helper methods --- MLEM.Ui/UiControls.cs | 4 ++++ MLEM/Input/InputHandler.cs | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/MLEM.Ui/UiControls.cs b/MLEM.Ui/UiControls.cs index f2af41e..5cfdc3b 100644 --- a/MLEM.Ui/UiControls.cs +++ b/MLEM.Ui/UiControls.cs @@ -256,5 +256,9 @@ namespace MLEM.Ui { this.SelectElement(this.ActiveRoot, next); } + public static void AddButtons(ref object[] controls, params object[] additional) { + controls = controls.Concat(additional).ToArray(); + } + } } \ No newline at end of file diff --git a/MLEM/Input/InputHandler.cs b/MLEM/Input/InputHandler.cs index 8ffbed1..2d40444 100644 --- a/MLEM/Input/InputHandler.cs +++ b/MLEM/Input/InputHandler.cs @@ -303,6 +303,18 @@ namespace MLEM.Input { throw new ArgumentException(nameof(control)); } + public bool IsAnyDown(params object[] control) { + return control.Any(c => this.IsDown(c)); + } + + public bool IsAnyUp(params object[] control) { + return control.Any(c => this.IsUp(c)); + } + + public bool IsAnyPressed(params object[] control) { + return control.Any(c => this.IsPressed(c)); + } + public static void EnableGestures(params GestureType[] gestures) { foreach (var gesture in gestures) TouchPanel.EnabledGestures |= gesture;