From d6396e79fba71de0167e618d265c1b91f7930f9d Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 31 Aug 2019 22:45:02 +0700 Subject: [PATCH] add empty line after standard options Rationale: When a mod adds a custom option menu, it adds a space before it, like this: ``` AddOptionMenu OptionsMenu { StaticText "" Submenu "$MYTITLE", MyOptions } ``` to prevent custom option menu being in the same block as the last entries in the standard options list. It's okay. But when more than one such mod is loaded, each one of them adds a space before their option menu entry, and Options Menu becomes unnecessary bloated. This simple edit allows mods to not add a space, still be separated from standard options. --- wadsrc/static/menudef.txt | 1 + wadsrc/static/zscript/ui/menu/optionmenu.zs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index ae9b7c2470..cfd6f751b1 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -385,6 +385,7 @@ OptionMenu "OptionsMenu" protected SafeCommand "$OPTMNU_DEFAULTS", "reset2defaults" SafeCommand "$OPTMNU_RESETTOSAVED", "reset2saved" Command "$OPTMNU_CONSOLE", "menuconsole" + StaticText " " } //------------------------------------------------------------------------------------------- diff --git a/wadsrc/static/zscript/ui/menu/optionmenu.zs b/wadsrc/static/zscript/ui/menu/optionmenu.zs index 51f03e227b..63970bdf3c 100644 --- a/wadsrc/static/zscript/ui/menu/optionmenu.zs +++ b/wadsrc/static/zscript/ui/menu/optionmenu.zs @@ -106,6 +106,19 @@ class OptionMenu : Menu mParentMenu = parent; mDesc = desc; DontDim = desc.mDontDim; + + let last = mDesc.mItems[mDesc.mItems.size() - 1]; + bool lastIsText = (last is "OptionMenuItemStaticText"); + if (lastIsText) + { + String text = last.mLabel; + bool lastIsSpace = (text == "" || text == " "); + if (lastIsSpace) + { + mDesc.mItems.Pop(); + } + } + if (mDesc != NULL && mDesc.mSelectedItem == -1) mDesc.mSelectedItem = FirstSelectable(); mDesc.CalcIndent();