diff --git a/src/common/engine/namedef.h b/src/common/engine/namedef.h index e2b31a1b6..121527192 100644 --- a/src/common/engine/namedef.h +++ b/src/common/engine/namedef.h @@ -278,6 +278,8 @@ xx(OptionMenuItemColorPicker) xx(OptionMenuItemStaticText) xx(OptionMenuItemStaticTextSwitchable) +xx(Handler) + xx(Color) xx(Mididevices) diff --git a/src/common/menu/messagebox.cpp b/src/common/menu/messagebox.cpp index 21f22d190..7c5938243 100644 --- a/src/common/menu/messagebox.cpp +++ b/src/common/menu/messagebox.cpp @@ -47,9 +47,10 @@ CVAR(Bool, m_quickexit, false, CVAR_ARCHIVE) typedef void(*hfunc)(); DEFINE_ACTION_FUNCTION(DMessageBoxMenu, CallHandler) { - PARAM_PROLOGUE; - PARAM_POINTERTYPE(Handler, hfunc); - Handler(); + PARAM_SELF_PROLOGUE(DMenu); + auto handler = reinterpret_cast(self->PointerVar(NAME_Handler)); + if (handler != nullptr) + handler(); return 0; } @@ -68,7 +69,8 @@ DMenu *CreateMessageBoxMenu(DMenu *parent, const char *message, int messagemode, IFVIRTUALPTRNAME(p, NAME_MessageBoxMenu, Init) { - VMValue params[] = { p, parent, &namestr, messagemode, playsound, action.GetIndex(), reinterpret_cast(handler) }; + p->PointerVar(NAME_Handler) = reinterpret_cast(handler); + VMValue params[] = { p, parent, &namestr, messagemode, playsound, action.GetIndex() }; VMCall(func, params, countof(params), nullptr, 0); return (DMenu*)p; } diff --git a/wadsrc/static/zscript/engine/ui/menu/messagebox.zs b/wadsrc/static/zscript/engine/ui/menu/messagebox.zs index 52734cf04..32dce5038 100644 --- a/wadsrc/static/zscript/engine/ui/menu/messagebox.zs +++ b/wadsrc/static/zscript/engine/ui/menu/messagebox.zs @@ -35,7 +35,7 @@ class MessageBoxMenu : Menu { BrokenLines mMessage; - readonly internal voidptr Handler; + readonly voidptr Handler; int mMessageMode; int messageSelection; int mMouseLeft, mMouseRight, mMouseY; @@ -45,7 +45,7 @@ class MessageBoxMenu : Menu int destWidth, destHeight; String selector; - private native static void CallHandler(voidptr hnd); + native void CallHandler(); //============================================================================= @@ -54,7 +54,7 @@ class MessageBoxMenu : Menu // //============================================================================= - virtual void Init(Menu parent, String message, int messagemode, bool playsound = false, Name cmd = 'None', voidptr native_handler = null) + virtual void Init(Menu parent, String message, int messagemode, bool playsound = false, Name cmd = 'None') { Super.Init(parent); mAction = cmd; @@ -95,7 +95,6 @@ class MessageBoxMenu : Menu { MenuSound ("menu/prompt"); } - Handler = native_handler; } //============================================================================= @@ -164,7 +163,7 @@ class MessageBoxMenu : Menu { if (res) { - CallHandler(Handler); + CallHandler(); } else {