From cf7518fe4324e34e144d816098d761b171c03420 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Oct 2020 17:42:46 +0200 Subject: [PATCH] - added two more system callbacks for menu customization. --- src/common/engine/i_interface.h | 2 ++ src/common/menu/menu.cpp | 2 ++ src/common/menu/menudef.cpp | 2 +- src/d_main.cpp | 8 ++++++-- src/menu/doommenu.cpp | 6 +++--- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/common/engine/i_interface.h b/src/common/engine/i_interface.h index e482d282d..d50acb81b 100644 --- a/src/common/engine/i_interface.h +++ b/src/common/engine/i_interface.h @@ -24,6 +24,8 @@ struct SystemCallbacks bool (*DispatchEvent)(event_t* ev); bool (*CheckGame)(const char* nm); int (*GetGender)(); + void (*MenuClosed)(); + bool (*CheckMenudefOption)(const char* opt); }; extern SystemCallbacks sysCallbacks; diff --git a/src/common/menu/menu.cpp b/src/common/menu/menu.cpp index 18bfdb106..6431b805d 100644 --- a/src/common/menu/menu.cpp +++ b/src/common/menu/menu.cpp @@ -458,6 +458,7 @@ void M_DoStartControlPanel (bool scaleoverride) delete CurrentScaleOverrider; CurrentScaleOverrider = nullptr; } + } //============================================================================= @@ -869,6 +870,7 @@ void M_ClearMenus() menuactive = MENU_Off; if (CurrentScaleOverrider) delete CurrentScaleOverrider; CurrentScaleOverrider = nullptr; + if (sysCallbacks.MenuClosed) sysCallbacks.MenuClosed(); } //============================================================================= diff --git a/src/common/menu/menudef.cpp b/src/common/menu/menudef.cpp index a879793ad..73978e1f2 100644 --- a/src/common/menu/menudef.cpp +++ b/src/common/menu/menudef.cpp @@ -220,7 +220,7 @@ static bool CheckSkipOptionBlock(FScanner &sc) do { sc.MustGetString(); - if (CheckSkipGameOptionBlock(sc)) filter = true; + if (sysCallbacks.CheckMenudefOption && sysCallbacks.CheckMenudefOption(sc.String)) filter = true; else if (sc.Compare("Windows")) { #ifdef _WIN32 diff --git a/src/d_main.cpp b/src/d_main.cpp index 9e01c9a29..2029cccb8 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -3025,6 +3025,9 @@ static void GC_MarkGameRoots() // NextToThink must not be freed while thinkers are ticking. GC::Mark(NextToThink); } + +bool CheckSkipGameOptionBlock(const char* str); + //========================================================================== // // D_DoomMain @@ -3067,8 +3070,9 @@ static int D_DoomMain_Internal (void) System_GetPlayerName, System_DispatchEvent, StrTable_ValidFilter, - StrTable_GetGender - + StrTable_GetGender, + nullptr, + CheckSkipGameOptionBlock, }; diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index f78652ba2..268e3ddc3 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -1244,11 +1244,11 @@ bool OkForLocalization(FTextureID texnum, const char* substitute) return TexMan.OkForLocalization(texnum, substitute, cl_gfxlocalization); } -bool CheckSkipGameOptionBlock(FScanner &sc) +bool CheckSkipGameOptionBlock(const char *str) { bool filter = false; - if (sc.Compare("ReadThis")) filter |= gameinfo.drawreadthis; - else if (sc.Compare("Swapmenu")) filter |= gameinfo.swapmenu; + if (!stricmp(str, "ReadThis")) filter |= gameinfo.drawreadthis; + else if (!stricmp(str, "Swapmenu")) filter |= gameinfo.swapmenu; return filter; }