-menuCustomizer from GZDoom.

This commit is contained in:
Christoph Oelckers 2020-10-05 00:23:30 +02:00
parent f670d35ba1
commit 7c89db69bd
5 changed files with 23 additions and 0 deletions

View file

@ -100,6 +100,8 @@ float BackbuttonAlpha;
static bool MenuEnabled = true; static bool MenuEnabled = true;
DMenu *CurrentMenu; DMenu *CurrentMenu;
int MenuTime; int MenuTime;
DObject* menuCustomizer;
extern PClass *DefaultListMenuClass; extern PClass *DefaultListMenuClass;
extern PClass *DefaultOptionMenuClass; extern PClass *DefaultOptionMenuClass;
@ -190,7 +192,9 @@ void M_MarkMenus()
GC::Mark(pair->Value); GC::Mark(pair->Value);
} }
GC::Mark(CurrentMenu); GC::Mark(CurrentMenu);
GC::Mark(menuCustomizer);
} }
//============================================================================ //============================================================================
// //
// DMenu base class // DMenu base class
@ -884,6 +888,7 @@ DEFINE_GLOBAL(menuactive)
DEFINE_GLOBAL(BackbuttonTime) DEFINE_GLOBAL(BackbuttonTime)
DEFINE_GLOBAL(BackbuttonAlpha) DEFINE_GLOBAL(BackbuttonAlpha)
DEFINE_GLOBAL(GameTicRate) DEFINE_GLOBAL(GameTicRate)
DEFINE_GLOBAL(menuCustomizer)
DEFINE_FIELD(DMenu, mParentMenu) DEFINE_FIELD(DMenu, mParentMenu)
DEFINE_FIELD(DMenu, mMouseCapture); DEFINE_FIELD(DMenu, mMouseCapture);

View file

@ -47,6 +47,7 @@ class DMenu;
extern DMenu *CurrentMenu; extern DMenu *CurrentMenu;
extern int MenuTime; extern int MenuTime;
class DMenuItemBase; class DMenuItemBase;
extern DObject* menuCustomizer;
//============================================================================= //=============================================================================
// //

View file

@ -151,6 +151,11 @@ void DeinitMenus()
} }
MenuDescriptors.Clear(); MenuDescriptors.Clear();
OptionValues.Clear(); OptionValues.Clear();
if (menuCustomizer)
{
menuCustomizer->Destroy();
menuCustomizer = nullptr;
}
} }
FTextureID GetMenuTexture(const char* const name) FTextureID GetMenuTexture(const char* const name)

View file

@ -18,3 +18,5 @@ version "4.3"
#include "zscript/ui/menu/optionmenuitems.zs" #include "zscript/ui/menu/optionmenuitems.zs"
#include "zscript/ui/menu/reverbedit.zs" #include "zscript/ui/menu/reverbedit.zs"
#include "zscript/ui/menu/textentermenu.zs" #include "zscript/ui/menu/textentermenu.zs"
#include "zscript/ui/menu/menucustomize.zs"

View file

@ -0,0 +1,10 @@
// This class allows global customization of certain menu aspects, e.g. replacing the menu caption.
class MenuCustomize
{
virtual int DrawCaption(String title, Font fnt, int y, bool drawit)
{
screen.DrawText(fnt, OptionMenuSettings.mTitleColor, (screen.GetWidth() - fnt.StringWidth(title) * CleanXfac_1) / 2, 10 * CleanYfac_1, title, DTA_CleanNoMove_1, true);
return y + fnt.GetHeight();
}
}