Fix HOOK_ON_HUD_RENDER rate at 30hz (#1022)

This commit is contained in:
PeachyPeach 2025-11-20 02:44:43 +01:00 committed by GitHub
parent c3e5843c53
commit 7bc28a25d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,6 +18,8 @@
#include "pc/utils/misc.h"
static Gfx* sSavedDisplayListHead = NULL;
static Gfx* sHookHudRenderGfx = NULL;
static size_t sHookHudRenderGfxSize = 0;
struct DjuiRoot* gDjuiRoot = NULL;
struct DjuiText* gDjuiPauseOptions = NULL;
@ -187,7 +189,23 @@ void djui_render(void) {
djui_base_render(&sDjuiRootBehind->base);
}
smlua_call_event_hooks(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
// To maintain consistency with other hooks, HOOK_ON_HUD_RENDER must run at 30 fps
// During interpolated frames, copy the generated display list without running the hook again
if (!sDjuiRendered60fps) {
Gfx *hookHudRenderStart = gDisplayListHead;
smlua_call_event_hooks(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
size_t gfxSize = sizeof(Gfx) * (gDisplayListHead - hookHudRenderStart);
if (gfxSize > 0) {
if (gfxSize > sHookHudRenderGfxSize) {
sHookHudRenderGfx = realloc(sHookHudRenderGfx, gfxSize);
}
memcpy(sHookHudRenderGfx, hookHudRenderStart, gfxSize);
}
sHookHudRenderGfxSize = gfxSize;
} else if (sHookHudRenderGfx != NULL && sHookHudRenderGfxSize > 0) {
memcpy(gDisplayListHead, sHookHudRenderGfx, sHookHudRenderGfxSize);
gDisplayListHead += sHookHudRenderGfxSize / sizeof(Gfx);
}
djui_panel_update();
djui_popup_update();