Address peachy review

This commit is contained in:
Agent X 2025-11-15 17:45:51 -05:00
parent 25ba1f330c
commit c87ae6a263
12 changed files with 230 additions and 133 deletions

View file

@ -93,7 +93,7 @@ override_allowed_functions = {
"src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ],
"src/game/platform_displacement.h": [ "apply_platform_displacement" ],
"src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*", "geo_get_.*_state" ],
"src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "pressed_pause", "fade_into_special_warp", "get_instant_warp", "game_pause", "game_unpause" ],
"src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "pressed_pause", "fade_into_special_warp", "get_instant_warp" ],
"src/game/area.h": [ "get_mario_spawn_type", "area_get_warp_node", "area_get_any_warp_node", "play_transition" ],
"src/engine/level_script.h": [ "area_create_warp_node" ],
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", "handle_special_dialog_text" ],

View file

@ -4993,7 +4993,7 @@ function level_control_timer_running()
-- ...
end
--- @return integer
--- @return boolean
--- Checks if the start button has been pressed as well as some other conditions for opening the pause menu depending on if pause anywhere is enabled
function pressed_pause()
-- ...
@ -5047,16 +5047,6 @@ function lvl_set_current_level(param, levelNum)
-- ...
end
--- Pauses the game
function game_pause()
-- ...
end
--- Unpauses the game
function game_unpause()
-- ...
end
--- @return boolean
--- Gets whether the lighting engine has been enabled or not. It becomes enabled once a light is added or the ambient color is set
function le_is_enabled()
@ -11289,6 +11279,28 @@ function is_game_paused()
-- ...
end
--- @return boolean
--- Gets if the pause menu elements are hidden, useful for creating custom pause menus
function is_pause_menu_hidden()
-- ...
end
--- @param hidden boolean
--- Sets if the pause menu elements are hidden, useful for creating custom pause menus
function set_pause_menu_hidden(hidden)
-- ...
end
--- Pauses the game
function game_pause()
-- ...
end
--- Unpauses the game
function game_unpause()
-- ...
end
--- @return boolean
--- Checks if a screen transition is playing
function is_transition_playing()

View file

@ -6613,16 +6613,16 @@ Returns if the level timer is running
Checks if the start button has been pressed as well as some other conditions for opening the pause menu depending on if pause anywhere is enabled
### Lua Example
`local integerValue = pressed_pause()`
`local booleanValue = pressed_pause()`
### Parameters
- None
### Returns
- `integer`
- `boolean`
### C Prototype
`u32 pressed_pause(void);`
`bool pressed_pause(void);`
[:arrow_up_small:](#)
@ -6788,48 +6788,6 @@ Sets the level number and handles the act select screen. `param` is used for ove
[:arrow_up_small:](#)
<br />
## [game_pause](#game_pause)
### Description
Pauses the game
### Lua Example
`game_pause()`
### Parameters
- None
### Returns
- None
### C Prototype
`void game_pause(void);`
[:arrow_up_small:](#)
<br />
## [game_unpause](#game_unpause)
### Description
Unpauses the game
### Lua Example
`game_unpause()`
### Parameters
- None
### Returns
- None
### C Prototype
`void game_unpause(void);`
[:arrow_up_small:](#)
<br />
---

View file

@ -1189,6 +1189,92 @@ Checks if the game is paused
<br />
## [is_pause_menu_hidden](#is_pause_menu_hidden)
### Description
Gets if the pause menu elements are hidden, useful for creating custom pause menus
### Lua Example
`local booleanValue = is_pause_menu_hidden()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool is_pause_menu_hidden(void);`
[:arrow_up_small:](#)
<br />
## [set_pause_menu_hidden](#set_pause_menu_hidden)
### Description
Sets if the pause menu elements are hidden, useful for creating custom pause menus
### Lua Example
`set_pause_menu_hidden(hidden)`
### Parameters
| Field | Type |
| ----- | ---- |
| hidden | `boolean` |
### Returns
- None
### C Prototype
`void set_pause_menu_hidden(bool hidden);`
[:arrow_up_small:](#)
<br />
## [game_pause](#game_pause)
### Description
Pauses the game
### Lua Example
`game_pause()`
### Parameters
- None
### Returns
- None
### C Prototype
`void game_pause(void);`
[:arrow_up_small:](#)
<br />
## [game_unpause](#game_unpause)
### Description
Unpauses the game
### Lua Example
`game_unpause()`
### Parameters
- None
### Returns
- None
### C Prototype
`void game_unpause(void);`
[:arrow_up_small:](#)
<br />
## [is_transition_playing](#is_transition_playing)
### Description

View file

@ -965,8 +965,6 @@
- [level_trigger_warp](functions-3.md#level_trigger_warp)
- [warp_special](functions-3.md#warp_special)
- [lvl_set_current_level](functions-3.md#lvl_set_current_level)
- [game_pause](functions-3.md#game_pause)
- [game_unpause](functions-3.md#game_unpause)
<br />
@ -2018,6 +2016,10 @@
- [act_select_hud_show](functions-7.md#act_select_hud_show)
- [act_select_hud_is_hidden](functions-7.md#act_select_hud_is_hidden)
- [is_game_paused](functions-7.md#is_game_paused)
- [is_pause_menu_hidden](functions-7.md#is_pause_menu_hidden)
- [set_pause_menu_hidden](functions-7.md#set_pause_menu_hidden)
- [game_pause](functions-7.md#game_pause)
- [game_unpause](functions-7.md#game_unpause)
- [is_transition_playing](functions-7.md#is_transition_playing)
- [allocate_mario_action](functions-7.md#allocate_mario_action)
- [get_hand_foot_pos_x](functions-7.md#get_hand_foot_pos_x)

View file

@ -141,7 +141,7 @@ u8 gMenuHoldKeyIndex = 0;
u8 gMenuHoldKeyTimer = 0;
s32 gDialogResponse = 0;
static bool sPauseMenuHidden = false;
bool gPauseMenuHidden = false;
#if defined(VERSION_JP) || defined(VERSION_SH) || defined(VERSION_EU)
#ifdef VERSION_EU
@ -2031,14 +2031,6 @@ void set_menu_mode(s16 mode) {
}
}
bool get_pause_menu_hidden(void) {
return sPauseMenuHidden;
}
void set_pause_menu_hidden(bool hidden) {
sPauseMenuHidden = hidden;
}
void reset_cutscene_msg_fade(void) {
gCutsceneMsgFade = 0;
}
@ -2985,7 +2977,7 @@ s16 render_pause_courses_and_castle(void) {
}
break;
case DIALOG_STATE_VERTICAL:
if (!gDjuiPanelPauseCreated && !sPauseMenuHidden) {
if (!gDjuiPanelPauseCreated && !gPauseMenuHidden) {
shade_screen();
render_pause_my_score_coins();
render_pause_red_coins();
@ -3026,7 +3018,7 @@ s16 render_pause_courses_and_castle(void) {
}
break;
case DIALOG_STATE_HORIZONTAL:
if (!gDjuiPanelPauseCreated && !sPauseMenuHidden) {
if (!gDjuiPanelPauseCreated && !gPauseMenuHidden) {
shade_screen();
print_hud_pause_colorful_str();

View file

@ -176,10 +176,6 @@ void reset_dialog_render_state(void);
Sets the in-game menu state. 0-1 is the courses box with the castle secret stars and 2-3 is the course completion screen.
|descriptionEnd| */
void set_menu_mode(s16 mode);
/* |description|Gets if the pause menu elements are hidden, useful for creating custom pause menus|descriptionEnd| */
bool get_pause_menu_hidden(void);
/* |description|Sets if the pause menu elements are hidden, useful for creating custom pause menus|descriptionEnd| */
void set_pause_menu_hidden(bool hidden);
void reset_cutscene_msg_fade(void);
void dl_rgba16_begin_cutscene_msg_fade(void);
void dl_rgba16_stop_cutscene_msg_fade(void);

View file

@ -249,7 +249,7 @@ u16 level_control_timer(s32 timerOp) {
return gHudDisplay.timer;
}
u32 pressed_pause(void) {
bool pressed_pause(void) {
if (gServerSettings.pauseAnywhere) {
if (get_dialog_id() == DIALOG_NONE && sCurrPlayMode == PLAY_MODE_NORMAL && sDelayedWarpOp == WARP_OP_NONE) {
return gPlayer1Controller->buttonPressed & START_BUTTON;
@ -264,7 +264,7 @@ u32 pressed_pause(void) {
}
}
return FALSE;
return false;
}
void set_play_mode(s16 playMode) {
@ -2033,21 +2033,3 @@ void lvl_skip_credits(void) {
gMarioStates[0].health = 0x880;
play_transition(0x09, 0x14, 0x00, 0x00, 0x00);
}
void game_pause(void) {
if (gMenuMode != -1) { return; }
lower_background_noise(1);
cancel_rumble();
gCameraMovementFlags |= CAM_MOVE_PAUSE_SCREEN;
set_play_mode(PLAY_MODE_PAUSED);
}
void game_unpause(void) {
if (gMenuMode == -1) { return; }
level_set_transition(0, NULL);
gMenuMode = -1;
gDialogBoxState = 0;
gPauseScreenMode = 1;
}

View file

@ -179,7 +179,7 @@ enum HUDDisplayFlag {
u8 level_control_timer_running(void);
u16 level_control_timer(s32 timerOp);
/* |description|Checks if the start button has been pressed as well as some other conditions for opening the pause menu depending on if pause anywhere is enabled|descriptionEnd|*/
u32 pressed_pause(void);
bool pressed_pause(void);
/* |description|Fades into a special warp with `arg` and using `color`|descriptionEnd| */
void fade_into_special_warp(u32 arg, u32 color);
void load_level_init_text(u32 arg);
@ -217,9 +217,4 @@ void lvl_skip_credits(void);
void update_menu_level(void);
void stop_demo(UNUSED struct DjuiBase* caller);
/* |description|Pauses the game|descriptionEnd| */
void game_pause(void);
/* |description|Unpauses the game|descriptionEnd| */
void game_unpause(void);
#endif // LEVEL_UPDATE_H

View file

@ -15478,7 +15478,7 @@ int smlua_func_pressed_pause(UNUSED lua_State* L) {
}
lua_pushinteger(L, pressed_pause());
lua_pushboolean(L, pressed_pause());
return 1;
}
@ -15606,36 +15606,6 @@ int smlua_func_lvl_set_current_level(lua_State* L) {
return 1;
}
int smlua_func_game_pause(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "game_pause", 0, top);
return 0;
}
game_pause();
return 1;
}
int smlua_func_game_unpause(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "game_unpause", 0, top);
return 0;
}
game_unpause();
return 1;
}
///////////////////////
// lighting_engine.h //
///////////////////////
@ -33849,6 +33819,68 @@ int smlua_func_is_game_paused(UNUSED lua_State* L) {
return 1;
}
int smlua_func_is_pause_menu_hidden(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "is_pause_menu_hidden", 0, top);
return 0;
}
lua_pushboolean(L, is_pause_menu_hidden());
return 1;
}
int smlua_func_set_pause_menu_hidden(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_pause_menu_hidden", 1, top);
return 0;
}
bool hidden = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_pause_menu_hidden"); return 0; }
set_pause_menu_hidden(hidden);
return 1;
}
int smlua_func_game_pause(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "game_pause", 0, top);
return 0;
}
game_pause();
return 1;
}
int smlua_func_game_unpause(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "game_unpause", 0, top);
return 0;
}
game_unpause();
return 1;
}
int smlua_func_is_transition_playing(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
@ -37737,8 +37769,6 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "level_trigger_warp", smlua_func_level_trigger_warp);
smlua_bind_function(L, "warp_special", smlua_func_warp_special);
smlua_bind_function(L, "lvl_set_current_level", smlua_func_lvl_set_current_level);
smlua_bind_function(L, "game_pause", smlua_func_game_pause);
smlua_bind_function(L, "game_unpause", smlua_func_game_unpause);
// lighting_engine.h
smlua_bind_function(L, "le_is_enabled", smlua_func_le_is_enabled);
@ -38741,6 +38771,10 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "act_select_hud_show", smlua_func_act_select_hud_show);
smlua_bind_function(L, "act_select_hud_is_hidden", smlua_func_act_select_hud_is_hidden);
smlua_bind_function(L, "is_game_paused", smlua_func_is_game_paused);
smlua_bind_function(L, "is_pause_menu_hidden", smlua_func_is_pause_menu_hidden);
smlua_bind_function(L, "set_pause_menu_hidden", smlua_func_set_pause_menu_hidden);
smlua_bind_function(L, "game_pause", smlua_func_game_pause);
smlua_bind_function(L, "game_unpause", smlua_func_game_unpause);
smlua_bind_function(L, "is_transition_playing", smlua_func_is_transition_playing);
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);

View file

@ -28,6 +28,8 @@
#include "include/course_table.h"
#include "game/level_geo.h"
#include "game/first_person_cam.h"
#include "game/rumble_init.h"
#include "game/sound_init.h"
#include "pc/lua/utils/smlua_audio_utils.h"
#ifdef DISCORD_SDK
@ -298,6 +300,36 @@ bool is_game_paused(void) {
return gMenuMode != -1;
}
extern bool gPauseMenuHidden;
bool is_pause_menu_hidden(void) {
return gPauseMenuHidden;
}
void set_pause_menu_hidden(bool hidden) {
gPauseMenuHidden = hidden;
}
extern void set_play_mode(s16);
void game_pause(void) {
if (gMenuMode != -1) { return; }
lower_background_noise(1);
cancel_rumble();
gCameraMovementFlags |= CAM_MOVE_PAUSE_SCREEN;
set_play_mode(PLAY_MODE_PAUSED);
}
extern s8 gDialogBoxState;
extern s16 gPauseScreenMode;
void game_unpause(void) {
if (gMenuMode == -1) { return; }
level_set_transition(0, NULL);
gMenuMode = -1;
gDialogBoxState = 0;
gPauseScreenMode = 1;
}
///
bool is_transition_playing(void) {

View file

@ -138,6 +138,14 @@ bool act_select_hud_is_hidden(enum ActSelectHudPart part);
/* |description|Checks if the game is paused|descriptionEnd| */
bool is_game_paused(void);
/* |description|Gets if the pause menu elements are hidden, useful for creating custom pause menus|descriptionEnd| */
bool is_pause_menu_hidden(void);
/* |description|Sets if the pause menu elements are hidden, useful for creating custom pause menus|descriptionEnd| */
void set_pause_menu_hidden(bool hidden);
/* |description|Pauses the game|descriptionEnd| */
void game_pause(void);
/* |description|Unpauses the game|descriptionEnd| */
void game_unpause(void);
/* |description|Checks if a screen transition is playing|descriptionEnd| */
bool is_transition_playing(void);