Remove crash-prone mod menu force unpause feature

This commit is contained in:
Agent X 2024-06-09 10:32:43 -04:00
parent cb729dc40a
commit 6471da0a07
4 changed files with 6 additions and 25 deletions

View File

@ -147,7 +147,7 @@ end
--- @param name string The text to show on the button --- @param name string The text to show on the button
--- @param func fun(index:integer) The function that is called when the button is pressed --- @param func fun(index:integer) The function that is called when the button is pressed
--- Hooks a DJUI button into the mod menu. If you want to unpause the game when the button is pressed, return `true` from `func` to do so --- Hooks a DJUI button into the mod menu
function hook_mod_menu_button(name, func) function hook_mod_menu_button(name, func)
-- ... -- ...
end end

View File

@ -28,6 +28,7 @@
#include "hardcoded.h" #include "hardcoded.h"
#include "pc/network/network.h" #include "pc/network/network.h"
#include "pc/djui/djui.h" #include "pc/djui/djui.h"
#include "pc/djui/djui_panel.h"
#include "pc/djui/djui_panel_pause.h" #include "pc/djui/djui_panel_pause.h"
#include "pc/utils/misc.h" #include "pc/utils/misc.h"
#include "data/dynos_mgr_builtin_externs.h" #include "data/dynos_mgr_builtin_externs.h"
@ -139,7 +140,6 @@ s8 gLastDialogResponse = 0;
u8 gMenuHoldKeyIndex = 0; u8 gMenuHoldKeyIndex = 0;
u8 gMenuHoldKeyTimer = 0; u8 gMenuHoldKeyTimer = 0;
s32 gDialogResponse = 0; s32 gDialogResponse = 0;
bool gForceUnpause = false;
#if defined(VERSION_JP) || defined(VERSION_SH) || defined(VERSION_EU) #if defined(VERSION_JP) || defined(VERSION_SH) || defined(VERSION_EU)
#ifdef VERSION_EU #ifdef VERSION_EU
@ -3104,19 +3104,16 @@ s16 render_pause_courses_and_castle(void) {
} }
#ifdef VERSION_EU #ifdef VERSION_EU
if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON) if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON))
|| gForceUnpause)
#else #else
if (gPlayer1Controller->buttonPressed & A_BUTTON if (gPlayer1Controller->buttonPressed & A_BUTTON
|| gPlayer1Controller->buttonPressed & START_BUTTON || gPlayer1Controller->buttonPressed & START_BUTTON)
|| gForceUnpause)
#endif #endif
{ {
level_set_transition(0, NULL); level_set_transition(0, NULL);
play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource); play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
gDialogBoxState = DIALOG_STATE_OPENING; gDialogBoxState = DIALOG_STATE_OPENING;
gMenuMode = -1; gMenuMode = -1;
gForceUnpause = false;
if (gDialogLineNum == 2 || gDialogLineNum == 3) { if (gDialogLineNum == 2 || gDialogLineNum == 3) {
num = gDialogLineNum; num = gDialogLineNum;
@ -3142,19 +3139,16 @@ s16 render_pause_courses_and_castle(void) {
} }
#ifdef VERSION_EU #ifdef VERSION_EU
if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON) if (gPlayer1Controller->buttonPressed & (A_BUTTON | Z_TRIG | START_BUTTON))
|| gForceUnpause)
#else #else
if (gPlayer1Controller->buttonPressed & A_BUTTON if (gPlayer1Controller->buttonPressed & A_BUTTON
|| gPlayer1Controller->buttonPressed & START_BUTTON || gPlayer1Controller->buttonPressed & START_BUTTON)
|| gForceUnpause)
#endif #endif
{ {
level_set_transition(0, NULL); level_set_transition(0, NULL);
play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource); play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
gMenuMode = -1; gMenuMode = -1;
gDialogBoxState = DIALOG_STATE_OPENING; gDialogBoxState = DIALOG_STATE_OPENING;
gForceUnpause = false;
return 1; return 1;
} }

View File

@ -129,7 +129,6 @@ extern u8 gDialogTextColorR;
extern u8 gDialogTextColorG; extern u8 gDialogTextColorG;
extern u8 gDialogTextColorB; extern u8 gDialogTextColorB;
extern u8 gDialogTextColorA; extern u8 gDialogTextColorA;
extern bool gForceUnpause;
void create_dl_identity_matrix(void); void create_dl_identity_matrix(void);
void create_dl_translation_matrix(s8 pushOp, f32 x, f32 y, f32 z); void create_dl_translation_matrix(s8 pushOp, f32 x, f32 y, f32 z);

View File

@ -2248,18 +2248,6 @@ void smlua_call_mod_menu_element_hook(struct LuaHookedModMenuElement* hooked, in
LOG_LUA("Failed to call the mod menu element callback: %s", hooked->name); LOG_LUA("Failed to call the mod menu element callback: %s", hooked->name);
return; return;
} }
// output the return value
bool returnValue = false;
if (lua_type(L, -1) == LUA_TBOOLEAN) {
returnValue = smlua_to_boolean(L, -1);
}
lua_pop(L, 1);
if (!gSmLuaConvertSuccess || !returnValue || hooked->element != MOD_MENU_ELEMENT_BUTTON) { return; }
gForceUnpause = true;
djui_panel_shutdown();
} }