mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- added a GenericMenu class, so that all menus can be given a virtual Init method.
Doing this to Menu itself would not work because the different menus require different parameters. This also means that all menus that are routed through menu items must inherit from either ListMenu, OptionMenu or GenericMenu. All other types can only be used internally. This should complete the menu scriptification.
This commit is contained in:
parent
9089beb110
commit
fb52b034b0
3 changed files with 23 additions and 9 deletions
|
@ -469,10 +469,15 @@ void M_SetMenu(FName menu, int param)
|
||||||
const PClass *menuclass = PClass::FindClass(menu);
|
const PClass *menuclass = PClass::FindClass(menu);
|
||||||
if (menuclass != nullptr)
|
if (menuclass != nullptr)
|
||||||
{
|
{
|
||||||
if (menuclass->IsDescendantOf(RUNTIME_CLASS(DMenu)))
|
if (menuclass->IsDescendantOf("GenericMenu"))
|
||||||
{
|
{
|
||||||
DMenu *newmenu = (DMenu*)menuclass->CreateNew();
|
DMenu *newmenu = (DMenu*)menuclass->CreateNew();
|
||||||
newmenu->mParentMenu = CurrentMenu;
|
|
||||||
|
IFVIRTUALPTRNAME(newmenu, "GenericMenu", Init)
|
||||||
|
{
|
||||||
|
VMValue params[3] = { newmenu, CurrentMenu };
|
||||||
|
GlobalVMStack.Call(func, params, 2, nullptr, 0);
|
||||||
|
}
|
||||||
M_ActivateMenu(newmenu);
|
M_ActivateMenu(newmenu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,3 +296,11 @@ class MenuDescriptor : Object native
|
||||||
native static MenuDescriptor GetDescriptor(Name n);
|
native static MenuDescriptor GetDescriptor(Name n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This class is only needed to give it a virtual Init method that doesn't belong to Menu itself
|
||||||
|
class GenericMenu : Menu
|
||||||
|
{
|
||||||
|
virtual void Init(Menu parent)
|
||||||
|
{
|
||||||
|
Super.Init(parent);
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,7 +33,7 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ReadThisMenu : Menu
|
class ReadThisMenu : GenericMenu
|
||||||
{
|
{
|
||||||
int mScreen;
|
int mScreen;
|
||||||
int mInfoTic;
|
int mInfoTic;
|
||||||
|
@ -43,18 +43,19 @@ class ReadThisMenu : Menu
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
override void Init(Menu parent)
|
||||||
|
{
|
||||||
|
Super.Init(parent);
|
||||||
|
mScreen = 1;
|
||||||
|
mInfoTic = gametic;
|
||||||
|
}
|
||||||
|
|
||||||
override void Drawer()
|
override void Drawer()
|
||||||
{
|
{
|
||||||
double alpha;
|
double alpha;
|
||||||
TextureID tex, prevpic;
|
TextureID tex, prevpic;
|
||||||
|
|
||||||
if (mScreen == 0)
|
|
||||||
{
|
|
||||||
mScreen = 1;
|
|
||||||
mInfoTic = gametic;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Did the mapper choose a custom help page via MAPINFO?
|
// Did the mapper choose a custom help page via MAPINFO?
|
||||||
if (level.F1Pic.Length() != 0)
|
if (level.F1Pic.Length() != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue