From 5e35ebc8fe698f86c8b0c4c98774bc397f30e7d4 Mon Sep 17 00:00:00 2001 From: DyNaM1Kk Date: Wed, 4 Jun 2025 04:21:42 +0400 Subject: [PATCH] Added two option menu items for double binds 1. DoubleTapControl: Simply assigns a double-tap key to a command. 2. DoubleControl: Assigns a standard key press to a command and uses the same key to make a double-tap bind to the second specified command. --- .../zscript/engine/ui/menu/optionmenuitems.zs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs b/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs index 39430278a..00a9b23f6 100644 --- a/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs +++ b/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs @@ -569,6 +569,52 @@ class OptionMenuItemControl : OptionMenuItemControlBase } } +class OptionMenuItemDoubleTapControl : OptionMenuItemControlBase +{ + OptionMenuItemDoubleTapControl Init(String label, Name command) + { + Super.Init(label, command, DoubleBindings); + return self; + } +} + +class OptionMenuItemDoubleControl : OptionMenuItemControlBase +{ + string mDoubleAction; + KeyBindings mDoubleBindings; + + OptionMenuItemDoubleControl Init(String label, Name command, Name doublecommand) + { + Super.Init(label, command, Bindings); + mDoubleAction = doublecommand; + mDoubleBindings = DoubleBindings; + return self; + } + + override bool MenuEvent(int mkey, bool fromcontroller) + { + if (mkey == Menu.MKEY_Input) + { + mWaiting = false; + mBindings.SetBind(mInput, mAction); + mDoubleBindings.SetBind(mInput, mDoubleAction); + return true; + } + else if (mkey == Menu.MKEY_Clear) + { + mBindings.UnbindACommand(mAction); + mDoubleBindings.UnbindACommand(mDoubleAction); + return true; + } + else if (mkey == Menu.MKEY_Abort) + { + mWaiting = false; + return true; + } + return false; + } +} + class OptionMenuItemMapControl : OptionMenuItemControlBase { OptionMenuItemMapControl Init(String label, Name command)