Reset resolution, font, and rotation before and after HOOK_ON_HUD_RENDER

This commit is contained in:
MysterD 2023-04-24 13:04:46 -07:00
parent 105869fd5f
commit 85026a2a2f
3 changed files with 25 additions and 1 deletions

View File

@ -91,6 +91,12 @@ void djui_lua_error(char* text) {
sDjuiLuaErrorTimeout = 30 * 5; sDjuiLuaErrorTimeout = 30 * 5;
} }
static void djui_reset_hud_params(void) {
djui_hud_set_resolution(RESOLUTION_DJUI);
djui_hud_set_font(FONT_NORMAL);
djui_hud_set_rotation(0, 0, 0);
}
void djui_render(void) { void djui_render(void) {
if (gDjuiDisabled) { return; } if (gDjuiDisabled) { return; }
@ -100,7 +106,8 @@ void djui_render(void) {
create_dl_ortho_matrix(); create_dl_ortho_matrix();
djui_gfx_displaylist_begin(); djui_gfx_displaylist_begin();
smlua_call_event_hooks(HOOK_ON_HUD_RENDER); djui_reset_hud_params();
smlua_call_event_hooks_with_reset_func(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
djui_panel_update(); djui_panel_update();
djui_popup_update(); djui_popup_update();

View File

@ -157,6 +157,22 @@ void smlua_call_event_hooks(enum LuaHookedEventType hookType) {
} }
} }
void smlua_call_event_hooks_with_reset_func(enum LuaHookedEventType hookType, void (*resetFunc)(void)) {
lua_State* L = gLuaState;
if (L == NULL) { return; }
struct LuaHookedEvent* hook = &sHookedEvents[hookType];
for (int i = 0; i < hook->count; i++) {
// push the callback onto the stack
lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
// call the callback
if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i])) {
LOG_LUA("Failed to call the event_hook callback: %u", hookType);
}
if (resetFunc) { resetFunc(); }
}
}
void smlua_call_event_hooks_bool_param(enum LuaHookedEventType hookType, bool value) { void smlua_call_event_hooks_bool_param(enum LuaHookedEventType hookType, bool value) {
lua_State* L = gLuaState; lua_State* L = gLuaState;
if (L == NULL) { return; } if (L == NULL) { return; }

View File

@ -99,6 +99,7 @@ extern u32 gLuaMarioActionIndex;
int smlua_hook_custom_bhv(BehaviorScript *bhvScript, const char *bhvName); int smlua_hook_custom_bhv(BehaviorScript *bhvScript, const char *bhvName);
void smlua_call_event_hooks(enum LuaHookedEventType hookType); void smlua_call_event_hooks(enum LuaHookedEventType hookType);
void smlua_call_event_hooks_with_reset_func(enum LuaHookedEventType hookType, void (*resetFunc)(void));
void smlua_call_event_hooks_bool_param(enum LuaHookedEventType hookType, bool value); void smlua_call_event_hooks_bool_param(enum LuaHookedEventType hookType, bool value);
void smlua_call_event_hooks_bool_param_ret_bool(enum LuaHookedEventType hookType, bool value, bool* returnValue); void smlua_call_event_hooks_bool_param_ret_bool(enum LuaHookedEventType hookType, bool value, bool* returnValue);
void smlua_call_event_hooks_mario_param(enum LuaHookedEventType hookType, struct MarioState* m); void smlua_call_event_hooks_mario_param(enum LuaHookedEventType hookType, struct MarioState* m);