Skip to content

Commit

Permalink
Feedback Update
Browse files Browse the repository at this point in the history
-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
  • Loading branch information
mckinlee committed Sep 19, 2023
1 parent 5ff6df7 commit 4c3b26e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class GameInteractor {

DEFINE_HOOK(OnSetGameLanguage, void());

DEFINE_HOOK(OnPauseMenu, void());

// Helpers
static bool IsSaveLoaded();
static bool IsGameplayPaused();
Expand Down
5 changes: 5 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,8 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode) {
void GameInteractor_ExecuteOnSetGameLanguage() {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnSetGameLanguage>();
}

// MARK: - Pause Menu
void GameInteractor_ExecuteOnPauseMenu() {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnPauseMenu>();
}
4 changes: 4 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode);

// MARK: - Game
void GameInteractor_ExecuteOnSetGameLanguage();

//MARK: - Pause Menu
void GameInteractor_ExecuteOnPauseMenu();

#ifdef __cplusplus
}
#endif
9 changes: 9 additions & 0 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ extern "C" {
extern SaveContext gSaveContext;
extern PlayState* gPlayState;

void PauseWarp_Main();

uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
}
bool performDelayedSave = false;
Expand Down Expand Up @@ -599,6 +601,12 @@ void RegisterMirrorModeHandler() {
});
}

void RegisterPauseWarp() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPauseMenu>([]() {
PauseWarp_Main();
});
}

void InitMods() {
RegisterTTS();
RegisterInfiniteMoney();
Expand All @@ -621,4 +629,5 @@ void InitMods() {
RegisterBonkDamage();
RegisterMenuPathFix();
RegisterMirrorModeHandler();
RegisterPauseWarp();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include <stdint.h>
#include "soh/Enhancements/gameconsole.h"
#include "global.h"
#include "../custom-message/CustomMessageTypes.h"
#include <soh/Enhancements/custom-message/CustomMessageTypes.h>

#include "luslog.h"

// Defining the structure for the pause warp state, which holds different flags and cooldowns
typedef struct {
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion soh/src/code/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ static void RunFrame()
PadMgr_ThreadEntry(&gPadMgr);

Graph_Update(&runFrameContext.gfxCtx, runFrameContext.gameState);
PauseWarp_Main();
ticksB = GetPerfCounter();

Graph_ProcessGfxCommands(runFrameContext.gfxCtx.workBuffer);
Expand Down
2 changes: 2 additions & 0 deletions soh/src/code/z_kaleido_scope_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 4c3b26e

Please sign in to comment.