From c0940904400d6138c586ba289188a8b7cb48c058 Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:52:30 +0100 Subject: [PATCH] Move to event system --- src/game/ingame_menu.c | 9 +++++++-- src/port/hooks/list/EngineEvent.h | 6 +++++- src/port/hooks/list/PlayerEvent.h | 4 ++-- src/port/mods/PortEnhancements.c | 11 +++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 3992a489..1505930a 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -25,6 +25,8 @@ #include "types.h" #include "port/interpolation/FrameInterpolation.h" #include +#include "port/hooks/impl/EventSystem.h" +#include "port/hooks/list/EngineEvent.h" #ifdef VERSION_EU #undef LANGUAGE_FUNCTION @@ -2302,8 +2304,11 @@ s16 render_pause_courses_and_castle(void) { render_pause_my_score_coins(); render_pause_red_coins(); - if (gMarioStates[0].action & ACT_FLAG_PAUSE_EXIT || CVarGetInteger("gPauseExitWhenever", 0)) { - render_pause_course_options(99, 93, &gDialogLineNum, 15); + bool canPause = gMarioStates[0].action & ACT_FLAG_PAUSE_EXIT; + CALL_CANCELLABLE_EVENT(RenderPauseCourseOptions, &canPause) { + if (canPause) { + render_pause_course_options(99, 93, &gDialogLineNum, 15); + } } #ifdef VERSION_EU diff --git a/src/port/hooks/list/EngineEvent.h b/src/port/hooks/list/EngineEvent.h index 066e5711..95f03473 100644 --- a/src/port/hooks/list/EngineEvent.h +++ b/src/port/hooks/list/EngineEvent.h @@ -2,4 +2,8 @@ #include "port/hooks/impl/EventSystem.h" -DEFINE_EVENT(GameFrameUpdate); \ No newline at end of file +DEFINE_EVENT(GameFrameUpdate); + +DEFINE_EVENT(RenderPauseCourseOptions, + bool* render; +); \ No newline at end of file diff --git a/src/port/hooks/list/PlayerEvent.h b/src/port/hooks/list/PlayerEvent.h index 8c63146a..7ced7aac 100644 --- a/src/port/hooks/list/PlayerEvent.h +++ b/src/port/hooks/list/PlayerEvent.h @@ -2,12 +2,12 @@ #include "port/hooks/impl/EventSystem.h" -DEFINE_EVENT(PlayerHealthChange, +DEFINE_EVENT(PlayerHealthChange, struct MarioState* m; s32 health; ); -DEFINE_EVENT(PlayerLivesChange, +DEFINE_EVENT(PlayerLivesChange, struct MarioState* m; s32 lives; ); \ No newline at end of file diff --git a/src/port/mods/PortEnhancements.c b/src/port/mods/PortEnhancements.c index ca6a26c8..98398bc2 100644 --- a/src/port/mods/PortEnhancements.c +++ b/src/port/mods/PortEnhancements.c @@ -41,6 +41,15 @@ void OnHealthChange(IEvent* event) { event->cancelled = true; } +void OnRenderPauseCourseOptions(IEvent* event) { + if (CVarGetInteger("gPauseExitWhenever", 0) == 0) { + return; + } + + RenderPauseCourseOptions* ev = (RenderPauseCourseOptions*)event; + *ev->render = true; +} + void PatchSetupDList() { Gfx identity = gsSPMatrix(&matrix_patch_identity, G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH); Gfx fullscreen = gsSPMatrix(&matrix_patch_fullscreen, G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH); @@ -87,6 +96,7 @@ void PortEnhancements_Init() { // Register event listeners REGISTER_LISTENER(PlayerHealthChange, OnHealthChange, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(PlayerLivesChange, OnLivesChange, EVENT_PRIORITY_NORMAL); + REGISTER_LISTENER(RenderPauseCourseOptions, OnRenderPauseCourseOptions, EVENT_PRIORITY_NORMAL); } void PortEnhancements_Register() { @@ -94,6 +104,7 @@ void PortEnhancements_Register() { REGISTER_EVENT(GameFrameUpdate); REGISTER_EVENT(PlayerHealthChange); REGISTER_EVENT(PlayerLivesChange); + REGISTER_EVENT(RenderPauseCourseOptions); } void PortEnhancements_Exit() {