diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index e482d282d..d50acb81b 100644 --- a/source/common/engine/i_interface.h +++ b/source/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/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 7e6ce1404..eb8320687 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -460,6 +460,17 @@ void M_DoStartControlPanel (bool scaleoverride) } } + +bool M_IsAnimated() +{ + if (ConsoleState == c_down) return false; + if (!CurrentMenu) return false; + if (CurrentMenu->Animated) return true; + if (transition.previous) return true; + return false; +} + + //============================================================================= // // @@ -855,6 +866,8 @@ void M_Drawer (void) void M_ClearMenus() { + if (menuactive == MENU_Off) return; + transition.previous = transition.current = nullptr; transition.dir = 0; @@ -867,6 +880,7 @@ void M_ClearMenus() menuactive = MENU_Off; if (CurrentScaleOverrider) delete CurrentScaleOverrider; CurrentScaleOverrider = nullptr; + if (sysCallbacks.MenuClosed) sysCallbacks.MenuClosed(); } //============================================================================= @@ -980,6 +994,7 @@ DEFINE_FIELD(DMenu, mBackbuttonSelected); DEFINE_FIELD(DMenu, DontDim); DEFINE_FIELD(DMenu, DontBlur); DEFINE_FIELD(DMenu, AnimatedTransition); +DEFINE_FIELD(DMenu, Animated); DEFINE_FIELD(DMenuDescriptor, mMenuName) DEFINE_FIELD(DMenuDescriptor, mNetgameMessage) diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 9be66b2ec..e57052c99 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -213,6 +213,7 @@ public: bool mBackbuttonSelected; bool DontDim; bool DontBlur; + bool Animated; bool AnimatedTransition; static int InMenu; @@ -297,7 +298,7 @@ void M_MarkMenus(); FTextureID GetMenuTexture(const char* const name); void DeinitMenus(); bool M_Active(); -inline bool M_IsAnimated() { return false; } +bool M_IsAnimated(); struct IJoystickConfig; diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index a879793ad..73978e1f2 100644 --- a/source/common/menu/menudef.cpp +++ b/source/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/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 8513a9e88..ac14f74c3 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -492,6 +492,7 @@ void CheckFrontend(int flags) void I_StartupJoysticks(); void I_ShutdownInput(); int RunGame(); +void System_MenuClosed(); int GameMain() { @@ -516,6 +517,8 @@ int GameMain() System_DispatchEvent, validFilter, StrTable_GetGender, + System_MenuClosed, + nullptr }; try diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index 5dab7a6d3..371d4de94 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -174,6 +174,14 @@ void M_StartControlPanel(bool makeSound, bool) } +void System_MenuClosed() +{ + GSnd->SetSfxPaused(false, PAUSESFX_MENU); + inputState.ClearAllInput(); + gi->MenuClosed(); +} + + //========================================================================== // // M_Dim diff --git a/source/exhumed/src/d_menu.cpp b/source/exhumed/src/d_menu.cpp index 5dd6e92cc..c0a271153 100644 --- a/source/exhumed/src/d_menu.cpp +++ b/source/exhumed/src/d_menu.cpp @@ -90,12 +90,6 @@ void GameInterface::QuitToTitle() gameaction = ga_mainmenu; } -void GameInterface::MenuClosed() -{ - -} - - bool GameInterface::StartGame(FNewGameStartup& gs) { auto map = FindMapByLevelNum(gs.Episode); diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 338a68898..92f2bbf92 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -239,7 +239,6 @@ struct GameInterface : ::GameInterface bool GenerateSavePic() override; void MenuOpened() override; void MenuSound(EMenuSounds snd) override; - void MenuClosed() override; bool StartGame(FNewGameStartup& gs) override; FSavegameInfo GetSaveSig() override; bool LoadGame() override; diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index cab642e94..2f8628157 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -99,10 +99,6 @@ void GameInterface::MenuSound(EMenuSounds snd) } } -void GameInterface::MenuClosed() -{ -} - bool GameInterface::CanSave() { if (ud.recstat == 2 || gamestate != GS_LEVEL) return false; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 9b151e5e1..0abfab077 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -38,7 +38,6 @@ struct GameInterface : public ::GameInterface GameStats getStats() override; void MenuOpened() override; void MenuSound(EMenuSounds snd) override; - void MenuClosed() override; bool CanSave() override; bool StartGame(FNewGameStartup& gs) override; FSavegameInfo GetSaveSig() override; diff --git a/source/sw/src/d_menu.cpp b/source/sw/src/d_menu.cpp index 2a7198f53..6ca302cc7 100644 --- a/source/sw/src/d_menu.cpp +++ b/source/sw/src/d_menu.cpp @@ -88,10 +88,6 @@ void GameInterface::QuitToTitle() } -void GameInterface::MenuOpened() -{ -} - void GameInterface::MenuSound(EMenuSounds snd) { switch (snd) @@ -115,10 +111,6 @@ void GameInterface::MenuSound(EMenuSounds snd) } } -void GameInterface::MenuClosed() -{ -} - bool GameInterface::CanSave() { return (gamestate == GS_LEVEL && !CommEnabled && numplayers ==1 && /*!DemoMode &&*/ !TEST(Player[myconnectindex].Flags, PF_DEAD)); diff --git a/source/sw/src/game.h b/source/sw/src/game.h index f26663419..df7ef09df 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2186,9 +2186,7 @@ struct GameInterface : ::GameInterface void FreeGameData() override; void FreeLevelData() override; bool GenerateSavePic() override; - void MenuOpened() override; void MenuSound(EMenuSounds snd) override; - void MenuClosed() override; bool CanSave() override; bool StartGame(FNewGameStartup& gs) override; FSavegameInfo GetSaveSig() override; diff --git a/wadsrc/static/zscript/ui/menu/menu.zs b/wadsrc/static/zscript/ui/menu/menu.zs index 7c08a1f45..a9a7a01b8 100644 --- a/wadsrc/static/zscript/ui/menu/menu.zs +++ b/wadsrc/static/zscript/ui/menu/menu.zs @@ -95,6 +95,7 @@ class Menu : Object native ui version("2.4") native bool DontDim; native bool DontBlur; native bool AnimatedTransition; + native bool Animated; native static int MenuTime(); native static Menu GetCurrentMenu(); @@ -118,6 +119,7 @@ class Menu : Object native ui version("2.4") DontDim = false; DontBlur = false; AnimatedTransition = false; + Animated = false; } //=============================================================================