diff --git a/docs/lua/functions.md b/docs/lua/functions.md index d18b101c..64585c0f 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -624,6 +624,8 @@ - smlua_misc_utils.h - [get_network_area_timer](#get_network_area_timer) + - [hud_hide](#hud_hide) + - [hud_show](#hud_show)
@@ -11461,6 +11463,42 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
+## [hud_hide](#hud_hide) + +### Lua Example +`hud_hide()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void hud_hide(void);` + +[:arrow_up_small:](#) + +
+ +## [hud_show](#hud_show) + +### Lua Example +`hud_show()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void hud_show(void);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_obj_utils.h diff --git a/mods/football.lua b/mods/football.lua index 39a27336..f5d6389b 100644 --- a/mods/football.lua +++ b/mods/football.lua @@ -679,6 +679,9 @@ gGlobalSyncTable.scoreRed = 0 gGlobalSyncTable.scoreBlue = 0 function gamemode_initialize() + -- hide the SM64 HUD + hud_hide() + -- prevent warp doors from working local wasRefreshed = false local obj = obj_get_first(OBJ_LIST_SURFACE) diff --git a/src/game/hud.c b/src/game/hud.c index a4c12b0d..70434769 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -18,6 +18,7 @@ #include "pc/network/network.h" extern bool gDjuiInMainMenu; +u8 gOverrideHideHud; /* @file hud.c * This file implements HUD rendering and power meter animations. @@ -492,32 +493,34 @@ void render_hud(void) { create_dl_ortho_matrix(); #endif + bool showHud = (configHUD && !gDjuiInMainMenu && !gOverrideHideHud); + if (gCurrentArea != NULL && gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) { render_hud_cannon_reticle(); } - if (hudDisplayFlags & HUD_DISPLAY_FLAG_LIVES && configHUD && !gDjuiInMainMenu) { + if (hudDisplayFlags & HUD_DISPLAY_FLAG_LIVES && showHud) { render_hud_mario_lives(); } - if (hudDisplayFlags & HUD_DISPLAY_FLAG_COIN_COUNT && configHUD && !gDjuiInMainMenu) { + if (hudDisplayFlags & HUD_DISPLAY_FLAG_COIN_COUNT && showHud) { render_hud_coins(); } - if (hudDisplayFlags & HUD_DISPLAY_FLAG_STAR_COUNT && configHUD && !gDjuiInMainMenu) { + if (hudDisplayFlags & HUD_DISPLAY_FLAG_STAR_COUNT && showHud) { render_hud_stars(); } - if (hudDisplayFlags & HUD_DISPLAY_FLAG_KEYS && configHUD && !gDjuiInMainMenu) { + if (hudDisplayFlags & HUD_DISPLAY_FLAG_KEYS && showHud) { render_hud_keys(); } - if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER && configHUD && !gDjuiInMainMenu) { + if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER && showHud) { render_hud_power_meter(); render_hud_camera_status(); } - if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && configHUD && !gDjuiInMainMenu) { + if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && showHud) { render_hud_timer(); } } diff --git a/src/game/hud.h b/src/game/hud.h index fb0da74c..9eff6992 100644 --- a/src/game/hud.h +++ b/src/game/hud.h @@ -25,6 +25,8 @@ enum CameraHUDLut { GLYPH_CAM_WARIO_HEAD, }; +u8 gOverrideHideHud; + void set_hud_camera_status(s16 status); void render_hud(void); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index ea5d82fb..3a55d933 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -7304,6 +7304,24 @@ int smlua_func_get_network_area_timer(UNUSED lua_State* L) { return 1; } +int smlua_func_hud_hide(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + hud_hide(); + + return 1; +} + +int smlua_func_hud_show(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + hud_show(); + + return 1; +} + /////////////////////// // smlua_obj_utils.h // /////////////////////// @@ -8618,6 +8636,8 @@ void smlua_bind_functions_autogen(void) { // smlua_misc_utils.h smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer); + smlua_bind_function(L, "hud_hide", smlua_func_hud_hide); + smlua_bind_function(L, "hud_show", smlua_func_hud_show); // smlua_obj_utils.h smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 5dc9bb1c..40965db1 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -1,9 +1,19 @@ #include "types.h" +#include "game/hud.h" #include "pc/lua/smlua.h" #include "smlua_misc_utils.h" #include "pc/debuglog.h" u32 get_network_area_timer(void) { return gNetworkAreaTimer; -} \ No newline at end of file +} + +void hud_hide(void) { + gOverrideHideHud = 1; +} + +void hud_show(void) { + gOverrideHideHud = 0; +} + diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 53363d33..fe5bacef 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -3,4 +3,7 @@ u32 get_network_area_timer(void); +void hud_hide(void); +void hud_show(void); + #endif diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 00d72862..2b5c47cb 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -66,6 +66,10 @@ void network_set_system(enum NetworkSystemType nsType) { } bool network_init(enum NetworkType inNetworkType) { + // reset override hide hud + extern u8 gOverrideHideHud; + gOverrideHideHud = 0; + // sanity check network system if (gNetworkSystem == NULL) { LOG_ERROR("no network system attached"); diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index fc80b985..8e41b6b3 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -120,16 +120,20 @@ struct NetworkPlayer* get_network_player_smallest_global(void) { } void network_player_update(void) { + for (int i = 0; i < MAX_PLAYERS; i++) { + struct NetworkPlayer* np = &gNetworkPlayers[i]; + if (!np->connected && i > 0) { continue; } + + network_player_update_model(i); + } + if (!network_player_any_connected()) { return; } if (gNetworkType == NT_SERVER) { - for (int i = 0; i < MAX_PLAYERS; i++) { + for (int i = 1; i < MAX_PLAYERS; i++) { struct NetworkPlayer* np = &gNetworkPlayers[i]; if (!np->connected && i > 0) { continue; } - network_player_update_model(i); - if (i == 0) { continue; } - float elapsed = (clock_elapsed() - np->lastReceived); #ifndef DEVELOPMENT if (elapsed > NETWORK_PLAYER_TIMEOUT) {