mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Added ability for Lua to show/hide SM64 HUD
This commit is contained in:
parent
497a250476
commit
859feb530d
9 changed files with 98 additions and 11 deletions
|
|
@ -624,6 +624,8 @@
|
||||||
|
|
||||||
- smlua_misc_utils.h
|
- smlua_misc_utils.h
|
||||||
- [get_network_area_timer](#get_network_area_timer)
|
- [get_network_area_timer](#get_network_area_timer)
|
||||||
|
- [hud_hide](#hud_hide)
|
||||||
|
- [hud_show](#hud_show)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
@ -11461,6 +11463,42 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [hud_hide](#hud_hide)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`hud_hide()`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
- None
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void hud_hide(void);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
## [hud_show](#hud_show)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`hud_show()`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
- None
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void hud_show(void);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
---
|
---
|
||||||
# functions from smlua_obj_utils.h
|
# functions from smlua_obj_utils.h
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -679,6 +679,9 @@ gGlobalSyncTable.scoreRed = 0
|
||||||
gGlobalSyncTable.scoreBlue = 0
|
gGlobalSyncTable.scoreBlue = 0
|
||||||
|
|
||||||
function gamemode_initialize()
|
function gamemode_initialize()
|
||||||
|
-- hide the SM64 HUD
|
||||||
|
hud_hide()
|
||||||
|
|
||||||
-- prevent warp doors from working
|
-- prevent warp doors from working
|
||||||
local wasRefreshed = false
|
local wasRefreshed = false
|
||||||
local obj = obj_get_first(OBJ_LIST_SURFACE)
|
local obj = obj_get_first(OBJ_LIST_SURFACE)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "pc/network/network.h"
|
#include "pc/network/network.h"
|
||||||
|
|
||||||
extern bool gDjuiInMainMenu;
|
extern bool gDjuiInMainMenu;
|
||||||
|
u8 gOverrideHideHud;
|
||||||
|
|
||||||
/* @file hud.c
|
/* @file hud.c
|
||||||
* This file implements HUD rendering and power meter animations.
|
* This file implements HUD rendering and power meter animations.
|
||||||
|
|
@ -492,32 +493,34 @@ void render_hud(void) {
|
||||||
create_dl_ortho_matrix();
|
create_dl_ortho_matrix();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool showHud = (configHUD && !gDjuiInMainMenu && !gOverrideHideHud);
|
||||||
|
|
||||||
if (gCurrentArea != NULL && gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
|
if (gCurrentArea != NULL && gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
|
||||||
render_hud_cannon_reticle();
|
render_hud_cannon_reticle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hudDisplayFlags & HUD_DISPLAY_FLAG_LIVES && configHUD && !gDjuiInMainMenu) {
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_LIVES && showHud) {
|
||||||
render_hud_mario_lives();
|
render_hud_mario_lives();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hudDisplayFlags & HUD_DISPLAY_FLAG_COIN_COUNT && configHUD && !gDjuiInMainMenu) {
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_COIN_COUNT && showHud) {
|
||||||
render_hud_coins();
|
render_hud_coins();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hudDisplayFlags & HUD_DISPLAY_FLAG_STAR_COUNT && configHUD && !gDjuiInMainMenu) {
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_STAR_COUNT && showHud) {
|
||||||
render_hud_stars();
|
render_hud_stars();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hudDisplayFlags & HUD_DISPLAY_FLAG_KEYS && configHUD && !gDjuiInMainMenu) {
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_KEYS && showHud) {
|
||||||
render_hud_keys();
|
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_power_meter();
|
||||||
render_hud_camera_status();
|
render_hud_camera_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && configHUD && !gDjuiInMainMenu) {
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && showHud) {
|
||||||
render_hud_timer();
|
render_hud_timer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ enum CameraHUDLut {
|
||||||
GLYPH_CAM_WARIO_HEAD,
|
GLYPH_CAM_WARIO_HEAD,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
u8 gOverrideHideHud;
|
||||||
|
|
||||||
void set_hud_camera_status(s16 status);
|
void set_hud_camera_status(s16 status);
|
||||||
void render_hud(void);
|
void render_hud(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7304,6 +7304,24 @@ int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
|
||||||
return 1;
|
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 //
|
// smlua_obj_utils.h //
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
@ -8618,6 +8636,8 @@ void smlua_bind_functions_autogen(void) {
|
||||||
|
|
||||||
// smlua_misc_utils.h
|
// smlua_misc_utils.h
|
||||||
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
|
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_obj_utils.h
|
||||||
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
|
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,19 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include "game/hud.h"
|
||||||
#include "pc/lua/smlua.h"
|
#include "pc/lua/smlua.h"
|
||||||
#include "smlua_misc_utils.h"
|
#include "smlua_misc_utils.h"
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
|
|
||||||
u32 get_network_area_timer(void) {
|
u32 get_network_area_timer(void) {
|
||||||
return gNetworkAreaTimer;
|
return gNetworkAreaTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hud_hide(void) {
|
||||||
|
gOverrideHideHud = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hud_show(void) {
|
||||||
|
gOverrideHideHud = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,7 @@
|
||||||
|
|
||||||
u32 get_network_area_timer(void);
|
u32 get_network_area_timer(void);
|
||||||
|
|
||||||
|
void hud_hide(void);
|
||||||
|
void hud_show(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,10 @@ void network_set_system(enum NetworkSystemType nsType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool network_init(enum NetworkType inNetworkType) {
|
bool network_init(enum NetworkType inNetworkType) {
|
||||||
|
// reset override hide hud
|
||||||
|
extern u8 gOverrideHideHud;
|
||||||
|
gOverrideHideHud = 0;
|
||||||
|
|
||||||
// sanity check network system
|
// sanity check network system
|
||||||
if (gNetworkSystem == NULL) {
|
if (gNetworkSystem == NULL) {
|
||||||
LOG_ERROR("no network system attached");
|
LOG_ERROR("no network system attached");
|
||||||
|
|
|
||||||
|
|
@ -120,16 +120,20 @@ struct NetworkPlayer* get_network_player_smallest_global(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_player_update(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 (!network_player_any_connected()) { return; }
|
||||||
|
|
||||||
if (gNetworkType == NT_SERVER) {
|
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];
|
struct NetworkPlayer* np = &gNetworkPlayers[i];
|
||||||
if (!np->connected && i > 0) { continue; }
|
if (!np->connected && i > 0) { continue; }
|
||||||
|
|
||||||
network_player_update_model(i);
|
|
||||||
if (i == 0) { continue; }
|
|
||||||
|
|
||||||
float elapsed = (clock_elapsed() - np->lastReceived);
|
float elapsed = (clock_elapsed() - np->lastReceived);
|
||||||
#ifndef DEVELOPMENT
|
#ifndef DEVELOPMENT
|
||||||
if (elapsed > NETWORK_PLAYER_TIMEOUT) {
|
if (elapsed > NETWORK_PLAYER_TIMEOUT) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue