Prevent Pause Exit when it actually happens (#71)

* call level exit hook sooner

call the hook here so you can actually prevent the exit from happening, also no separate hook calls anymore

* instead of here

* compliance
This commit is contained in:
Cooliokid956 2024-06-17 16:20:30 -05:00 committed by GitHub
parent 56b96a97e2
commit e76e212312
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 27 deletions

View File

@ -3110,18 +3110,26 @@ s16 render_pause_courses_and_castle(void) {
|| gPlayer1Controller->buttonPressed & START_BUTTON) || gPlayer1Controller->buttonPressed & START_BUTTON)
#endif #endif
{ {
level_set_transition(0, NULL); bool allowExit = true;
play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
gDialogBoxState = DIALOG_STATE_OPENING;
gMenuMode = -1;
if (gDialogLineNum == 2 || gDialogLineNum == 3) { if (gDialogLineNum == 2 || gDialogLineNum == 3) {
num = gDialogLineNum; smlua_call_event_hooks_bool_param_ret_bool(HOOK_ON_PAUSE_EXIT, (gDialogLineNum == 3), &allowExit);
} else {
num = 1;
} }
if (allowExit) {
level_set_transition(0, NULL);
play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
gDialogBoxState = DIALOG_STATE_OPENING;
gMenuMode = -1;
return num; if (gDialogLineNum == 2 || gDialogLineNum == 3) {
num = gDialogLineNum;
} else {
num = 1;
}
return num;
} else {
play_sound(SOUND_MENU_CAMERA_BUZZ | (0xFF << 8), gGlobalSoundSource);
}
} }
} }
break; break;

View File

@ -1337,26 +1337,18 @@ s32 play_mode_paused(void) {
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN; gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
set_play_mode(PLAY_MODE_NORMAL); set_play_mode(PLAY_MODE_NORMAL);
} else if (gPauseScreenMode == 2) { } else if (gPauseScreenMode == 2) {
bool allowExit = true; level_trigger_warp(&gMarioStates[0], WARP_OP_EXIT);
smlua_call_event_hooks_bool_param_ret_bool(HOOK_ON_PAUSE_EXIT, false, &allowExit); set_play_mode(PLAY_MODE_NORMAL);
if (allowExit) {
level_trigger_warp(&gMarioStates[0], WARP_OP_EXIT);
set_play_mode(PLAY_MODE_NORMAL);
}
} else if (gPauseScreenMode == 3) { } else if (gPauseScreenMode == 3) {
bool allowExit = true; // Exit level
smlua_call_event_hooks_bool_param_ret_bool(HOOK_ON_PAUSE_EXIT, true, &allowExit); if (gDebugLevelSelect) {
if (allowExit) { fade_into_special_warp(-9, 1);
// Exit level } else {
if (gDebugLevelSelect) { initiate_warp(gLevelValues.exitCastleLevel, gLevelValues.exitCastleArea, gLevelValues.exitCastleWarpNode, 0);
fade_into_special_warp(-9, 1); fade_into_special_warp(0, 0);
} else { gSavedCourseNum = COURSE_NONE;
initiate_warp(gLevelValues.exitCastleLevel, gLevelValues.exitCastleArea, gLevelValues.exitCastleWarpNode, 0);
fade_into_special_warp(0, 0);
gSavedCourseNum = COURSE_NONE;
}
set_play_mode(PLAY_MODE_CHANGE_LEVEL);
} }
set_play_mode(PLAY_MODE_CHANGE_LEVEL);
} /* else if (gPauseScreenMode == 4) { } /* else if (gPauseScreenMode == 4) {
// We should only be getting "int 4" to here // We should only be getting "int 4" to here
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0); initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);