From fad7984cd4b2dcbb6022071ad6edc9e9ba8e2a52 Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Thu, 11 May 2023 20:10:25 +1000 Subject: [PATCH] add djui_open_pause_menu() (#391) --- autogen/lua_definitions/functions.lua | 5 +++++ docs/lua/functions-3.md | 18 ++++++++++++++++++ docs/lua/functions.md | 1 + src/game/interaction.c | 2 +- src/game/mario_actions_airborne.c | 2 +- src/game/mario_step.c | 3 ++- src/pc/djui/djui_hud_utils.c | 4 ++++ src/pc/djui/djui_hud_utils.h | 2 ++ src/pc/lua/smlua_functions_autogen.c | 16 ++++++++++++++++ 9 files changed, 50 insertions(+), 3 deletions(-) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 2368f405..7c60af80 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3750,6 +3750,11 @@ function djui_hud_world_pos_to_screen_pos(pos, out) -- ... end +--- @return nil +function djui_open_pause_menu() + -- ... +end + --- @param message string --- @param lines integer --- @return nil diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index 17274cfa..07547fd7 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -2444,6 +2444,24 @@
+## [djui_open_pause_menu](#djui_open_pause_menu) + +### Lua Example +`djui_open_pause_menu()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void djui_open_pause_menu(void);` + +[:arrow_up_small:](#) + +
+ --- # functions from djui_popup.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 11f7b230..0ab3fd85 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -735,6 +735,7 @@ - [djui_hud_set_resolution](functions-3.md#djui_hud_set_resolution) - [djui_hud_set_rotation](functions-3.md#djui_hud_set_rotation) - [djui_hud_world_pos_to_screen_pos](functions-3.md#djui_hud_world_pos_to_screen_pos) + - [djui_open_pause_menu](functions-3.md#djui_open_pause_menu)
diff --git a/src/game/interaction.c b/src/game/interaction.c index fd6ce58f..7c15f85a 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -2360,7 +2360,7 @@ void pss_end_slide(struct MarioState *m) { } void mario_handle_special_floors(struct MarioState *m) { - if ((m->action & ACT_GROUP_MASK) == ACT_GROUP_CUTSCENE) { + if ((m->action & ACT_GROUP_MASK) == ACT_GROUP_CUTSCENE || gDjuiInMainMenu) { return; } diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 5eab3854..e28ee43d 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -55,7 +55,7 @@ void play_knockback_sound(struct MarioState *m) { s32 lava_boost_on_wall(struct MarioState *m) { bool allow = true; smlua_call_event_hooks_mario_param_and_int_ret_bool(HOOK_ALLOW_HAZARD_SURFACE, m, HAZARD_TYPE_LAVA_WALL, &allow); - if ((gServerSettings.enableCheats && gCheats.godMode) || (!allow)) { return FALSE; } + if ((gServerSettings.enableCheats && gCheats.godMode) || (!allow) || gDjuiInMainMenu) { return FALSE; } m->faceAngle[1] = atan2s(m->wallNormal[2], m->wallNormal[0]); if (m->forwardVel < 24.0f) { diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 443b428e..23f96b6b 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -111,7 +111,8 @@ void mario_bonk_reflection(struct MarioState *m, u32 negateSpeed) { u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed) { bool allow = true; smlua_call_event_hooks_mario_param_and_int_ret_bool(HOOK_ALLOW_HAZARD_SURFACE, m, HAZARD_TYPE_QUICKSAND, &allow); - if (m->action & ACT_FLAG_RIDING_SHELL || (gServerSettings.enableCheats && gCheats.godMode && m->playerIndex == 0) || (!allow)) { + extern bool gDjuiInMainMenu; + if (m->action & ACT_FLAG_RIDING_SHELL || (gServerSettings.enableCheats && gCheats.godMode && m->playerIndex == 0) || (!allow) || gDjuiInMainMenu) { m->quicksandDepth = 0.0f; } else { if (m->quicksandDepth < 1.1f) { diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index 4132bf26..d6f58eb3 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -560,3 +560,7 @@ void djui_hud_set_render_behind_hud(bool enable) { bool djui_hud_is_pause_menu_created(void) { return gDjuiPanelPauseCreated; } + +void djui_open_pause_menu(void) { + djui_panel_pause_create(NULL); +} diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h index d069153f..7372338b 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -69,4 +69,6 @@ void djui_hud_set_render_behind_hud(bool enable); bool djui_hud_is_pause_menu_created(void); +void djui_open_pause_menu(void); + #endif \ No newline at end of file diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 6f3c2b3b..8b0b78b0 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -12422,6 +12422,21 @@ int smlua_func_djui_hud_world_pos_to_screen_pos(lua_State* L) { return 1; } +int smlua_func_djui_open_pause_menu(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", "djui_open_pause_menu", 0, top); + return 0; + } + + + djui_open_pause_menu(); + + return 1; +} + ////////////////// // djui_popup.h // ////////////////// @@ -30727,6 +30742,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_hud_set_resolution", smlua_func_djui_hud_set_resolution); smlua_bind_function(L, "djui_hud_set_rotation", smlua_func_djui_hud_set_rotation); smlua_bind_function(L, "djui_hud_world_pos_to_screen_pos", smlua_func_djui_hud_world_pos_to_screen_pos); + smlua_bind_function(L, "djui_open_pause_menu", smlua_func_djui_open_pause_menu); // djui_popup.h smlua_bind_function(L, "djui_popup_create", smlua_func_djui_popup_create);