From 9f8241865b178a2381f9c3dbb9fc9f920f04f8b8 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 25a4e2d9b..f4c503b1b 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -359,6 +359,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 5b1763d51..76c7d64bd 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();