diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 10ffd54111..242e69ace8 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -69,6 +69,7 @@ CVAR(Bool, m_blockcontrollers, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR (Float, snd_menuvolume, 0.6f, CVAR_ARCHIVE) CVAR(Int, m_use_mouse, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Int, m_show_backbutton, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, m_cleanscale, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) static DMenu *GetCurrentMenu() { @@ -147,6 +148,14 @@ void DListMenuDescriptor::Reset() mFontColor = CR_UNTRANSLATED; mFontColor2 = CR_UNTRANSLATED; mFromEngine = false; + mVirtWidth = mVirtHeight = -1; // default to clean scaling +} + +DEFINE_ACTION_FUNCTION(DListMenuDescriptor, Reset) +{ + PARAM_SELF_PROLOGUE(DListMenuDescriptor); + self->Reset(); + return 0; } @@ -1034,6 +1043,8 @@ DEFINE_FIELD(DListMenuDescriptor, mFont) DEFINE_FIELD(DListMenuDescriptor, mFontColor) DEFINE_FIELD(DListMenuDescriptor, mFontColor2) DEFINE_FIELD(DListMenuDescriptor, mCenter) +DEFINE_FIELD(DListMenuDescriptor, mVirtWidth) +DEFINE_FIELD(DListMenuDescriptor, mVirtHeight) DEFINE_FIELD(DOptionMenuDescriptor, mItems) DEFINE_FIELD(DOptionMenuDescriptor, mTitle) diff --git a/src/menu/menu.h b/src/menu/menu.h index f8cbe14d13..b4964a6f95 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -88,6 +88,8 @@ public: EColorRange mFontColor2; bool mCenter; bool mFromEngine; + int mVirtWidth; + int mVirtHeight; void Reset(); size_t PropagateMark() override; diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 7d11dbbe19..947e62abb5 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -366,6 +366,28 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc) sc.MustGetString(); desc->mNetgameMessage = sc.String; } + else if (sc.Compare("size")) + { + if (sc.CheckNumber()) + { + desc->mVirtWidth = sc.Number; + sc.MustGetStringName(","); + sc.MustGetNumber(); + desc->mVirtHeight = sc.Number; + } + else + { + sc.MustGetString(); + if (sc.Compare("clean")) + { + desc->mVirtWidth = -1; + } + if (sc.Compare("optclean")) + { + desc->mVirtWidth = -2; + } + } + } else { bool success = false; @@ -631,6 +653,7 @@ static void ParseListMenu(FScanner &sc) sc.MustGetString(); DListMenuDescriptor *desc = Create(); + desc->Reset(); desc->mMenuName = sc.String; desc->mSelectedItem = -1; desc->mAutoselect = -1; diff --git a/wadsrc/static/zscript/ui/menu/listmenu.zs b/wadsrc/static/zscript/ui/menu/listmenu.zs index 66d2093812..37a896496d 100644 --- a/wadsrc/static/zscript/ui/menu/listmenu.zs +++ b/wadsrc/static/zscript/ui/menu/listmenu.zs @@ -2,6 +2,11 @@ class ListMenuDescriptor : MenuDescriptor native { + enum + { + CleanScale = -1, + OptCleanScale = -2 + }; native Array mItems; native int mSelectedItem; native double mSelectOfsX; @@ -16,21 +21,18 @@ class ListMenuDescriptor : MenuDescriptor native native int mFontColor; native int mFontColor2; native bool mCenter; + native int mVirtWidth, mVirtHeight; - void Reset() + native void Reset(); + int DisplayWidth() { - // Reset the default settings (ignore all other values in the struct) - mSelectOfsX = 0; - mSelectOfsY = 0; - mSelector.SetInvalid(); - mDisplayTop = 0; - mXpos = 0; - mYpos = 0; - mLinespacing = 0; - mNetgameMessage = ""; - mFont = NULL; - mFontColor = Font.CR_UNTRANSLATED; - mFontColor2 = Font.CR_UNTRANSLATED; + if (mVirtWidth == OptCleanScale) return m_cleanscale ? CleanScale : 320; + return mVirtWidth; + } + int DisplayHeight() + { + if (mVirtWidth == OptCleanScale) return m_cleanscale ? CleanScale : 200; + return mVirtHeight; } }