From b1e621b3751892609e3c02e76c8b3e0d80e5537a Mon Sep 17 00:00:00 2001 From: mckinlee Date: Tue, 19 Sep 2023 17:33:40 -0400 Subject: [PATCH] Feedback Update -A new hook was created 'OnPauseMenu' so now PauseWarp_Main is only called when the pause menu is open -Moved pauswarp.c to the Enhancements folder -Removed from graph.c PR Change: Changing to the main branch instead of sulu --- soh/soh/Enhancements/game-interactor/GameInteractor.h | 2 ++ .../Enhancements/game-interactor/GameInteractor_Hooks.cpp | 5 +++++ .../Enhancements/game-interactor/GameInteractor_Hooks.h | 4 ++++ soh/soh/Enhancements/mods.cpp | 8 ++++++++ soh/soh/Enhancements/{randomizer => }/pausewarp.c | 5 ++++- soh/src/code/z_kaleido_scope_call.c | 2 ++ 6 files changed, 25 insertions(+), 1 deletion(-) rename soh/soh/Enhancements/{randomizer => }/pausewarp.c (97%) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index 036483f2e..cfb4483ac 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -184,6 +184,8 @@ public: DEFINE_HOOK(OnSetGameLanguage, void()); + DEFINE_HOOK(OnPauseMenu, void()); + // Helpers static bool IsSaveLoaded(); static bool IsGameplayPaused(); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index dfd90c084..190302fc8 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -161,3 +161,8 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode) { void GameInteractor_ExecuteOnSetGameLanguage() { GameInteractor::Instance->ExecuteHooks(); } + +// MARK: - Pause Menu +void GameInteractor_ExecuteOnPauseMenu() { + GameInteractor::Instance->ExecuteHooks(); +} \ No newline at end of file diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index a1d2cbb31..31d998a5d 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -51,6 +51,10 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode); // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage(); + +//MARK: - Pause Menu +void GameInteractor_ExecuteOnPauseMenu(); + #ifdef __cplusplus } #endif diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 6fc3b35b2..aadcfe790 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -32,6 +32,7 @@ extern SaveContext gSaveContext; extern PlayState* gPlayState; extern void Overlay_DisplayText(float duration, const char* text); uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum); +void PauseWarp_Main(); } bool performDelayedSave = false; bool performSave = false; @@ -974,6 +975,12 @@ void RegisterRandomizerSheikSpawn() { }); } +void RegisterPauseWarp() { + GameInteractor::Instance->RegisterGameHook([]() { + PauseWarp_Main(); + }); +} + void InitMods() { RegisterTTS(); RegisterInfiniteMoney(); @@ -1000,4 +1007,5 @@ void InitMods() { RegisterAltTrapTypes(); RegisterRandomizerSheikSpawn(); NameTag_RegisterHooks(); + RegisterPauseWarp(); } diff --git a/soh/soh/Enhancements/randomizer/pausewarp.c b/soh/soh/Enhancements/pausewarp.c similarity index 97% rename from soh/soh/Enhancements/randomizer/pausewarp.c rename to soh/soh/Enhancements/pausewarp.c index 537016c10..cbd8552c8 100644 --- a/soh/soh/Enhancements/randomizer/pausewarp.c +++ b/soh/soh/Enhancements/pausewarp.c @@ -3,7 +3,9 @@ #include #include "soh/Enhancements/gameconsole.h" #include "global.h" -#include "../custom-message/CustomMessageTypes.h" +#include + +#include "luslog.h" // Defining the structure for the pause warp state, which holds different flags and cooldowns typedef struct { @@ -67,6 +69,7 @@ void HandleCooldowns(PauseWarpState* state) { // The main function that gets called every frame void PauseWarp_Main() { + LUSLOG_CRITICAL("PauseWarp_Main Called"); static PauseWarpState state; // The state is static so it retains its value between function calls // Checking if the pause warp feature is enabled diff --git a/soh/src/code/z_kaleido_scope_call.c b/soh/src/code/z_kaleido_scope_call.c index 6f0648e08..c85a3e80d 100644 --- a/soh/src/code/z_kaleido_scope_call.c +++ b/soh/src/code/z_kaleido_scope_call.c @@ -56,6 +56,8 @@ void KaleidoScopeCall_Update(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; PauseContext* pauseCtx = &play->pauseCtx; + GameInteractor_ExecuteOnPauseMenu(); + if (!gSaveContext.sohStats.gameComplete && (!gSaveContext.isBossRush || !gSaveContext.isBossRushPaused)) { gSaveContext.sohStats.pauseTimer++;