Small improvements to HUD and new functions (#268)

* Small improvements to HUD and new functions

- Split HUD_DISPLAY_FLAG_CAMERA_AND_POWER into HUD_DISPLAY_FLAG_CAMERA and HUD_DISPLAY_FLAG_POWER
- Added hud_is_hidden()
- Added camera_is_frozen()
- Added extra sanity check to hud.c

* Re-add old flags

* Fixes and improvements

* Mod compatibility
This commit is contained in:
Agent X 2023-02-21 00:23:15 -05:00 committed by GitHub
parent a5a3dfdec9
commit ea7f0a11c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 128 additions and 11 deletions

View File

@ -3913,6 +3913,12 @@ HUD_DISPLAY_FLAG_UNKNOWN_0020 = 0x0020
--- @type HUDDisplayFlag
HUD_DISPLAY_FLAG_TIMER = 0x0040
--- @type HUDDisplayFlag
HUD_DISPLAY_FLAG_CAMERA = 0x0080
--- @type HUDDisplayFlag
HUD_DISPLAY_FLAG_POWER = 0x0100
--- @type HUDDisplayFlag
HUD_DISPLAY_FLAG_EMPHASIZE_POWER = 0x8000
@ -3920,7 +3926,7 @@ HUD_DISPLAY_FLAG_EMPHASIZE_POWER = 0x8000
HUD_DISPLAY_NONE = 0x0000
--- @type HUDDisplayFlag
HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020
HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA | HUD_DISPLAY_FLAG_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020
--- @class MarioAnimID
@ -8174,6 +8180,12 @@ HUD_DISPLAY_FLAGS_UNKNOWN_0020 = 0x0020
--- @type HudDisplayFlags
HUD_DISPLAY_FLAGS_TIMER = 0x0040
--- @type HudDisplayFlags
HUD_DISPLAY_FLAGS_CAMERA = 0x0080
--- @type HudDisplayFlags
HUD_DISPLAY_FLAGS_POWER = 0x0100
--- @type HudDisplayFlags
HUD_DISPLAY_FLAGS_EMPHASIZE_POWER = 0x8000

View File

@ -8214,6 +8214,11 @@ function camera_freeze()
-- ...
end
--- @return boolean
function camera_is_frozen()
-- ...
end
--- @return nil
function camera_unfreeze()
-- ...
@ -8300,6 +8305,11 @@ function hud_hide()
-- ...
end
--- @return boolean
function hud_is_hidden()
-- ...
end
--- @param health integer
--- @param x number
--- @param y number

View File

@ -1360,9 +1360,11 @@
| HUD_DISPLAY_FLAG_KEYS | 0x0010 |
| HUD_DISPLAY_FLAG_UNKNOWN_0020 | 0x0020 |
| HUD_DISPLAY_FLAG_TIMER | 0x0040 |
| HUD_DISPLAY_FLAG_CAMERA | 0x0080 |
| HUD_DISPLAY_FLAG_POWER | 0x0100 |
| HUD_DISPLAY_FLAG_EMPHASIZE_POWER | 0x8000 |
| HUD_DISPLAY_NONE | 0x0000 |
| HUD_DISPLAY_DEFAULT | HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020 |
| HUD_DISPLAY_DEFAULT | HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA | HUD_DISPLAY_FLAG_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020 |
[:arrow_up_small:](#)
@ -2911,6 +2913,8 @@
| HUD_DISPLAY_FLAGS_KEYS | 0x0010 |
| HUD_DISPLAY_FLAGS_UNKNOWN_0020 | 0x0020 |
| HUD_DISPLAY_FLAGS_TIMER | 0x0040 |
| HUD_DISPLAY_FLAGS_CAMERA | 0x0080 |
| HUD_DISPLAY_FLAGS_POWER | 0x0100 |
| HUD_DISPLAY_FLAGS_EMPHASIZE_POWER | 0x8000 |
### [enum HudDisplayValue](#HudDisplayValue)

View File

@ -8066,6 +8066,24 @@
<br />
## [camera_is_frozen](#camera_is_frozen)
### Lua Example
`local booleanValue = camera_is_frozen()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool camera_is_frozen(void);`
[:arrow_up_small:](#)
<br />
## [camera_unfreeze](#camera_unfreeze)
### Lua Example
@ -8355,6 +8373,24 @@
<br />
## [hud_is_hidden](#hud_is_hidden)
### Lua Example
`local booleanValue = hud_is_hidden()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool hud_is_hidden(void);`
[:arrow_up_small:](#)
<br />
## [hud_render_power_meter](#hud_render_power_meter)
### Lua Example

View File

@ -1526,6 +1526,7 @@
- [camera_config_set_x_sensitivity](functions-4.md#camera_config_set_x_sensitivity)
- [camera_config_set_y_sensitivity](functions-4.md#camera_config_set_y_sensitivity)
- [camera_freeze](functions-4.md#camera_freeze)
- [camera_is_frozen](functions-4.md#camera_is_frozen)
- [camera_unfreeze](functions-4.md#camera_unfreeze)
- [course_is_main_course](functions-4.md#course_is_main_course)
- [deref_s32_pointer](functions-4.md#deref_s32_pointer)
@ -1541,6 +1542,7 @@
- [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer)
- [hud_get_value](functions-4.md#hud_get_value)
- [hud_hide](functions-4.md#hud_hide)
- [hud_is_hidden](functions-4.md#hud_is_hidden)
- [hud_render_power_meter](functions-4.md#hud_render_power_meter)
- [hud_set_value](functions-4.md#hud_set_value)
- [hud_show](functions-4.md#hud_show)

View File

@ -494,7 +494,7 @@ void render_hud(void) {
bool showHud = (configHUD && !gDjuiInMainMenu && !gOverrideHideHud);
if (gCurrentArea != NULL && gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
if (gCurrentArea != NULL && gCurrentArea->camera != NULL && gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
render_hud_cannon_reticle();
}
@ -515,21 +515,24 @@ void render_hud(void) {
}
if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER && showHud) {
render_hud_power_meter();
render_hud_camera_status();
if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA && showHud) {
render_hud_camera_status();
}
if (hudDisplayFlags & HUD_DISPLAY_FLAG_POWER && showHud) {
render_hud_power_meter();
}
}
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER && showHud) {
render_hud_timer();
}
if (gSurfacePoolError & NOT_ENOUGH_ROOM_FOR_SURFACES)
{
if (gSurfacePoolError & NOT_ENOUGH_ROOM_FOR_SURFACES) {
print_text(10, 40, "SURFACE POOL FULL");
}
if (gSurfacePoolError & NOT_ENOUGH_ROOM_FOR_NODES)
{
if (gSurfacePoolError & NOT_ENOUGH_ROOM_FOR_NODES) {
print_text(10, 60, "SURFACE NODE POOL FULL");
}

View File

@ -133,10 +133,12 @@ enum HUDDisplayFlag {
HUD_DISPLAY_FLAG_KEYS = 0x0010,
HUD_DISPLAY_FLAG_UNKNOWN_0020 = 0x0020,
HUD_DISPLAY_FLAG_TIMER = 0x0040,
HUD_DISPLAY_FLAG_CAMERA = 0x0080,
HUD_DISPLAY_FLAG_POWER = 0x0100,
HUD_DISPLAY_FLAG_EMPHASIZE_POWER = 0x8000,
HUD_DISPLAY_NONE = 0x0000,
HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020
HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_CAMERA | HUD_DISPLAY_FLAG_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020
};
u8 level_control_timer_running(void);

View File

@ -1492,9 +1492,11 @@ char gSmluaConstants[] = ""
"HUD_DISPLAY_FLAG_KEYS = 0x0010\n"
"HUD_DISPLAY_FLAG_UNKNOWN_0020 = 0x0020\n"
"HUD_DISPLAY_FLAG_TIMER = 0x0040\n"
"HUD_DISPLAY_FLAG_CAMERA = 0x0080\n"
"HUD_DISPLAY_FLAG_POWER = 0x0100\n"
"HUD_DISPLAY_FLAG_EMPHASIZE_POWER = 0x8000\n"
"HUD_DISPLAY_NONE = 0x0000\n"
"HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020\n"
"HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA | HUD_DISPLAY_FLAG_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020\n"
"MARIO_ANIM_SLOW_LEDGE_GRAB = 0\n"
"MARIO_ANIM_FALL_OVER_BACKWARDS = 1\n"
"MARIO_ANIM_BACKWARD_AIR_KB = 2\n"
@ -2910,6 +2912,8 @@ char gSmluaConstants[] = ""
"HUD_DISPLAY_FLAGS_KEYS = 0x0010\n"
"HUD_DISPLAY_FLAGS_UNKNOWN_0020 = 0x0020\n"
"HUD_DISPLAY_FLAGS_TIMER = 0x0040\n"
"HUD_DISPLAY_FLAGS_CAMERA = 0x0080\n"
"HUD_DISPLAY_FLAGS_POWER = 0x0100\n"
"HUD_DISPLAY_FLAGS_EMPHASIZE_POWER = 0x8000\n"
"E_MODEL_NONE = 0\n"
"E_MODEL_MARIO = 1\n"

View File

@ -26833,6 +26833,21 @@ int smlua_func_camera_freeze(UNUSED lua_State* L) {
return 1;
}
int smlua_func_camera_is_frozen(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", "camera_is_frozen", 0, top);
return 0;
}
lua_pushboolean(L, camera_is_frozen());
return 1;
}
int smlua_func_camera_unfreeze(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
@ -27080,6 +27095,21 @@ int smlua_func_hud_hide(UNUSED lua_State* L) {
return 1;
}
int smlua_func_hud_is_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", "hud_is_hidden", 0, top);
return 0;
}
lua_pushboolean(L, hud_is_hidden());
return 1;
}
int smlua_func_hud_render_power_meter(lua_State* L) {
if (L == NULL) { return 0; }
@ -30246,6 +30276,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "camera_config_set_x_sensitivity", smlua_func_camera_config_set_x_sensitivity);
smlua_bind_function(L, "camera_config_set_y_sensitivity", smlua_func_camera_config_set_y_sensitivity);
smlua_bind_function(L, "camera_freeze", smlua_func_camera_freeze);
smlua_bind_function(L, "camera_is_frozen", smlua_func_camera_is_frozen);
smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze);
smlua_bind_function(L, "course_is_main_course", smlua_func_course_is_main_course);
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
@ -30261,6 +30292,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer);
smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value);
smlua_bind_function(L, "hud_hide", smlua_func_hud_hide);
smlua_bind_function(L, "hud_is_hidden", smlua_func_hud_is_hidden);
smlua_bind_function(L, "hud_render_power_meter", smlua_func_hud_render_power_meter);
smlua_bind_function(L, "hud_set_value", smlua_func_hud_set_value);
smlua_bind_function(L, "hud_show", smlua_func_hud_show);

View File

@ -49,6 +49,10 @@ void hud_show(void) {
gOverrideHideHud = 0;
}
bool hud_is_hidden(void) {
return gOverrideHideHud;
}
extern u8 gLastCollectedStarOrKey;
s32 get_last_star_or_key(void) {
return gLastCollectedStarOrKey;
@ -129,6 +133,10 @@ void camera_unfreeze(void) {
gOverrideFreezeCamera = FALSE;
}
bool camera_is_frozen(void) {
return gOverrideFreezeCamera;
}
bool camera_config_is_free_cam_enabled(void) {
#ifdef BETTERCAMERA
return configEnableCamera;

View File

@ -27,17 +27,21 @@ enum HudDisplayFlags {
HUD_DISPLAY_FLAGS_KEYS = 0x0010,
HUD_DISPLAY_FLAGS_UNKNOWN_0020 = 0x0020,
HUD_DISPLAY_FLAGS_TIMER = 0x0040,
HUD_DISPLAY_FLAGS_CAMERA = 0x0080,
HUD_DISPLAY_FLAGS_POWER = 0x0100,
HUD_DISPLAY_FLAGS_EMPHASIZE_POWER = 0x8000,
};
void hud_hide(void);
void hud_show(void);
bool hud_is_hidden(void);
s32 hud_get_value(enum HudDisplayValue type);
void hud_set_value(enum HudDisplayValue type, s32 value);
void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height);
void camera_freeze(void);
void camera_unfreeze(void);
bool camera_is_frozen(void);
bool camera_config_is_free_cam_enabled(void);
bool camera_config_is_analog_cam_enabled(void);