From 4d99b58f968157000bfd7bf83b50c3c27adae198 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Feb 2017 17:45:04 +0100 Subject: [PATCH] - allow using the default menu settings classes when none is specified in MENUDEFS. --- src/dobjgc.cpp | 2 +- src/menu/menu.cpp | 10 ++++++++-- src/menu/menudef.cpp | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index 8ac991aa8..4fe609a5a 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -544,7 +544,7 @@ void FullGC() void Barrier(DObject *pointing, DObject *pointed) { - assert(pointed->GetClass() < (void*)0x1000000000000000); + assert(pointed->GetClass() != nullptr); assert(pointing == NULL || (pointing->IsBlack() && !pointing->IsDead())); assert(pointed->IsWhite() && !pointed->IsDead()); assert(State != GCS_Finalize && State != GCS_Pause); diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index a8dac6b54..c5b1b4071 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -94,6 +94,8 @@ float BackbuttonAlpha; static bool MenuEnabled = true; void M_InitVideoModes(); +extern PClass *DefaultListMenuClass; +extern PClass *DefaultOptionMenuClass; #define KEY_REPEAT_DELAY (TICRATE*5/12) @@ -623,7 +625,9 @@ void M_SetMenu(FName menu, int param) } else { - const PClass *cls = ld->mClass == nullptr? RUNTIME_CLASS(DListMenu) : ld->mClass; + PClass *cls = ld->mClass; + if (cls == nullptr) cls = DefaultListMenuClass; + if (cls == nullptr) cls = PClass::FindClass("ListMenu"); DListMenu *newmenu = (DListMenu *)cls->CreateNew(); newmenu->Init(DMenu::CurrentMenu, ld); @@ -633,7 +637,9 @@ void M_SetMenu(FName menu, int param) else if ((*desc)->IsKindOf(RUNTIME_CLASS(DOptionMenuDescriptor))) { DOptionMenuDescriptor *ld = static_cast(*desc); - const PClass *cls = ld->mClass == nullptr? PClass::FindClass("OptionMenu") : ld->mClass; + PClass *cls = ld->mClass; + if (cls == nullptr) cls = DefaultOptionMenuClass; + if (cls == nullptr) cls = PClass::FindClass("OptionMenu"); DMenu *newmenu = (DMenu*)cls->CreateNew(); IFVIRTUALPTRNAME(newmenu, "OptionMenu", Init) diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 057f544c5..5ada8a2dc 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -62,6 +62,8 @@ static DOptionMenuDescriptor *DefaultOptionMenuSettings; // contains common sett FOptionMenuSettings OptionSettings; FOptionMap OptionValues; bool mustPrintErrors; +PClass *DefaultListMenuClass; +PClass *DefaultOptionMenuClass; void I_BuildALDeviceList(FOptionValues *opt); @@ -948,7 +950,9 @@ void M_ParseMenuDefs() } } } + DefaultListMenuClass = DefaultListMenuSettings->GetClass(); DefaultListMenuSettings = nullptr; + DefaultOptionMenuClass = DefaultOptionMenuSettings->GetClass(); DefaultOptionMenuSettings = nullptr; }