diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 37295519..16200c55 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -343,7 +343,13 @@ INSTANT_WARP_INDEX_START = 0x00 INSTANT_WARP_INDEX_STOP = 0x04 --- @type integer -MAX_LOADED_GRAPH_NODES = 0x100 +LOADED_GRAPH_NODES_EXTENDED = 512 + +--- @type integer +LOADED_GRAPH_NODES_VANILLA = 256 + +--- @type integer +MAX_LOADED_GRAPH_NODES = (LOADED_GRAPH_NODES_VANILLA + LOADED_GRAPH_NODES_EXTENDED) --- @type integer WARP_TRANSITION_FADE_FROM_BOWSER = 0x12 diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 93ab667e..b60b668c 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3663,6 +3663,18 @@ function djui_hud_print_text(message, x, y, scale) -- ... end +--- @param message string +--- @param prevX number +--- @param prevY number +--- @param prevScale number +--- @param x number +--- @param y number +--- @param scale number +--- @return nil +function djui_hud_print_text_interpolated(message, prevX, prevY, prevScale, x, y, scale) + -- ... +end + --- @param x number --- @param y number --- @param width number @@ -3685,6 +3697,11 @@ function djui_hud_render_rect_interpolated(prevX, prevY, prevWidth, prevHeight, -- ... end +--- @return nil +function djui_hud_reset_color() + -- ... +end + --- @param r integer --- @param g integer --- @param b integer @@ -8418,6 +8435,20 @@ function hud_render_power_meter(health, x, y, width, height) -- ... end +--- @param health integer +--- @param prevX number +--- @param prevY number +--- @param prevWidth number +--- @param prevHeight number +--- @param x number +--- @param y number +--- @param width number +--- @param height number +--- @return nil +function hud_render_power_meter_interpolated(health, prevX, prevY, prevWidth, prevHeight, x, y, width, height) + -- ... +end + --- @param type HudDisplayValue --- @param value integer --- @return nil diff --git a/docs/lua/constants.md b/docs/lua/constants.md index d43fb20b..4d402e1c 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -70,6 +70,8 @@ ## [area.h](#area.h) - INSTANT_WARP_INDEX_START - INSTANT_WARP_INDEX_STOP +- LOADED_GRAPH_NODES_EXTENDED +- LOADED_GRAPH_NODES_VANILLA - MAX_LOADED_GRAPH_NODES - WARP_TRANSITION_FADE_FROM_BOWSER - WARP_TRANSITION_FADE_FROM_CIRCLE diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index a163d824..caaa6453 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -2198,7 +2198,33 @@ - None ### C Prototype -`void djui_hud_print_text(const char* message, float x, float y, float scale);` +`void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale);` + +[:arrow_up_small:](#) + +
+ +## [djui_hud_print_text_interpolated](#djui_hud_print_text_interpolated) + +### Lua Example +`djui_hud_print_text_interpolated(message, prevX, prevY, prevScale, x, y, scale)` + +### Parameters +| Field | Type | +| ----- | ---- | +| message | `string` | +| prevX | `number` | +| prevY | `number` | +| prevScale | `number` | +| x | `number` | +| y | `number` | +| scale | `number` | + +### Returns +- None + +### C Prototype +`void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale);` [:arrow_up_small:](#) @@ -2254,6 +2280,24 @@
+## [djui_hud_reset_color](#djui_hud_reset_color) + +### Lua Example +`djui_hud_reset_color()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void djui_hud_reset_color(void);` + +[:arrow_up_small:](#) + +
+ ## [djui_hud_set_color](#djui_hud_set_color) ### Lua Example diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 52a92822..c72d6c19 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -8553,6 +8553,34 @@
+## [hud_render_power_meter_interpolated](#hud_render_power_meter_interpolated) + +### Lua Example +`hud_render_power_meter_interpolated(health, prevX, prevY, prevWidth, prevHeight, x, y, width, height)` + +### Parameters +| Field | Type | +| ----- | ---- | +| health | `integer` | +| prevX | `number` | +| prevY | `number` | +| prevWidth | `number` | +| prevHeight | `number` | +| x | `number` | +| y | `number` | +| width | `number` | +| height | `number` | + +### Returns +- None + +### C Prototype +`void hud_render_power_meter_interpolated(s32 health, f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height);` + +[:arrow_up_small:](#) + +
+ ## [hud_set_value](#hud_set_value) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 283ae7aa..67bad391 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -724,8 +724,10 @@ - [djui_hud_is_pause_menu_created](functions-3.md#djui_hud_is_pause_menu_created) - [djui_hud_measure_text](functions-3.md#djui_hud_measure_text) - [djui_hud_print_text](functions-3.md#djui_hud_print_text) + - [djui_hud_print_text_interpolated](functions-3.md#djui_hud_print_text_interpolated) - [djui_hud_render_rect](functions-3.md#djui_hud_render_rect) - [djui_hud_render_rect_interpolated](functions-3.md#djui_hud_render_rect_interpolated) + - [djui_hud_reset_color](functions-3.md#djui_hud_reset_color) - [djui_hud_set_color](functions-3.md#djui_hud_set_color) - [djui_hud_set_font](functions-3.md#djui_hud_set_font) - [djui_hud_set_mouse_locked](functions-3.md#djui_hud_set_mouse_locked) @@ -1568,6 +1570,7 @@ - [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_render_power_meter_interpolated](functions-4.md#hud_render_power_meter_interpolated) - [hud_set_value](functions-4.md#hud_set_value) - [hud_show](functions-4.md#hud_show) - [is_game_paused](functions-4.md#is_game_paused) diff --git a/mods/nametags.lua b/mods/nametags.lua index c86891bf..18bf03ee 100644 --- a/mods/nametags.lua +++ b/mods/nametags.lua @@ -9,6 +9,17 @@ gGlobalSyncTable.health = true showSelfTag = false +gStateExtras = {} +for i = 0, (MAX_PLAYERS - 1) do + gStateExtras[i] = {} + local e = gStateExtras[i] + e.prevPos = {} + e.prevPos.x = 0 + e.prevPos.y = 0 + e.prevPos.z = 0 + e.prevScale = 1 +end + for k, v in pairs(gActiveMods) do local name = v.name:lower() if v.enabled and (name:find("hide") or name:find("hns") or name:find("hunt")) then @@ -62,16 +73,19 @@ function djui_hud_set_adjusted_color(r, g, b, a) djui_hud_set_color(r * multiplier, g * multiplier, b * multiplier, a) end -function djui_hud_print_outlined_text(text, x, y, scale, r, g, b, a, outlineDarkness) +function djui_hud_print_outlined_text(text, prevx, prevy, prevscale, x, y, scale, r, g, b, a, outlineDarkness) + djui_hud_set_resolution(RESOLUTION_N64) -- render outline djui_hud_set_adjusted_color(r * outlineDarkness, g * outlineDarkness, b * outlineDarkness, a) - djui_hud_print_text(text, x - (1*(scale*2)), y, scale) - djui_hud_print_text(text, x + (1*(scale*2)), y, scale) - djui_hud_print_text(text, x, y - (1*(scale*2)), scale) - djui_hud_print_text(text, x, y + (1*(scale*2)), scale) + local offset = (1*(scale*2)) + local prevoffset = (1*(prevscale*2)) + djui_hud_print_text_interpolated(text, prevx - prevoffset, prevy, prevscale, x - offset, y, scale) + djui_hud_print_text_interpolated(text, prevx + prevoffset, prevy, prevscale, x + offset, y, scale) + djui_hud_print_text_interpolated(text, prevx, prevy - prevoffset, prevscale, x, y - offset, scale) + djui_hud_print_text_interpolated(text, prevx, prevy + prevoffset, prevscale, x, y + offset, scale) -- render text djui_hud_set_adjusted_color(r, g, b, 255) - djui_hud_print_text(text, x, y, scale) + djui_hud_print_text_interpolated(text, prevx, prevy, prevscale, x, y, scale) djui_hud_set_color(255, 255, 255, 255) end @@ -113,13 +127,24 @@ function on_hud_render() network_player_palette_to_color(gNetworkPlayers[i], SHIRT, color) local measure = djui_hud_measure_text(name) * scale * 0.5 local alpha = if_then_else(m.action ~= ACT_CROUCHING and m.action ~= ACT_START_CRAWLING and m.action ~= ACT_CRAWLING and m.action ~= ACT_STOP_CRAWLING, 255, 100) - djui_hud_print_outlined_text(name, out.x - measure, out.y, scale, color.r, color.g, color.b, alpha, 0.25) + + local e = gStateExtras[i] + + djui_hud_print_outlined_text(name, e.prevPos.x - measure, e.prevPos.y, e.prevScale, out.x - measure, out.y, scale, color.r, color.g, color.b, alpha, 0.25) if m.playerIndex ~= 0 and gGlobalSyncTable.health then djui_hud_set_adjusted_color(255, 255, 255, alpha) local healthScale = 75 * scale - hud_render_power_meter(m.health, out.x - (healthScale * 0.5), out.y - healthScale, healthScale, healthScale) + local prevHealthScale = 75 * e.prevScale + hud_render_power_meter_interpolated(m.health, + e.prevPos.x - (prevHealthScale * 0.5), e.prevPos.y - prevHealthScale, prevHealthScale, prevHealthScale, + out.x - (healthScale * 0.5), out.y - healthScale, healthScale, healthScale) end + + e.prevPos.x = out.x + e.prevPos.y = out.y + e.prevPos.z = out.z + e.prevScale = scale end end end diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index 98df9546..88001b45 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -79,7 +79,7 @@ static void djui_hud_size_translate(f32* size) { // interp // //////////// -#define MAX_INTERP_HUD 128 +#define MAX_INTERP_HUD 512 struct InterpHud { Gfx* headPos; f32 z; @@ -228,7 +228,7 @@ f32 djui_hud_measure_text(const char* message) { return width * font->defaultFontScale; } -void djui_hud_print_text(const char* message, float x, float y, float scale) { +void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) { if (message == NULL) { return; } gDjuiHudUtilsZ += 0.01f; @@ -275,6 +275,72 @@ void djui_hud_print_text(const char* message, float x, float y, float scale) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); } +void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale) { + if (message == NULL) { return; } + f32 savedZ = gDjuiHudUtilsZ; + gDjuiHudUtilsZ += 0.01f; + + const struct DjuiFont* font = gDjuiFonts[sFont]; + f32 fontScale = font->defaultFontScale * scale; + + // setup display list + if (font->textBeginDisplayList != NULL) { + gSPDisplayList(gDisplayListHead++, font->textBeginDisplayList); + } + + Gfx* savedHeadPos = gDisplayListHead; + + // translate position + f32 translatedX = x; + f32 translatedY = y; + djui_hud_position_translate(&translatedX, &translatedY); + create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ); + + // compute font size + f32 translatedFontSize = fontScale; + djui_hud_size_translate(&translatedFontSize); + create_dl_scale_matrix(DJUI_MTX_NOPUSH, translatedFontSize, translatedFontSize, 1.0f); + + // render the line + f32 addX = 0; + char* c = (char*)message; + while (*c != '\0') { + f32 charWidth = font->char_width(c); + + if (*c == '\n' && *c == ' ') { + addX += charWidth; + c++; + continue; + } + + // render + font->render_char(c); + create_dl_translation_matrix(DJUI_MTX_NOPUSH, charWidth + addX, 0, 0); + addX = 0; + + c = djui_unicode_next_char(c); + } + + // pop + gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); + + if (sInterpHudCount >= MAX_INTERP_HUD) { return; } + struct InterpHud* interp = &sInterpHuds[sInterpHudCount++]; + interp->headPos = savedHeadPos; + interp->prevX = prevX; + interp->prevY = prevY; + interp->prevScaleW = prevScale; + interp->prevScaleH = prevScale; + interp->x = x; + interp->y = y; + interp->scaleW = scale; + interp->scaleH = scale; + interp->width = font->defaultFontScale; + interp->height = font->defaultFontScale; + interp->z = savedZ; + interp->resolution = sResolution; +} + void djui_hud_render_texture_raw(const u8* texture, u32 bitSize, u32 width, u32 height, f32 x, f32 y, f32 scaleW, f32 scaleH) { gDjuiHudUtilsZ += 0.01f; diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h index 377a91ca..09822b9e 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -52,7 +52,8 @@ f32 djui_hud_get_raw_mouse_y(void); void djui_hud_set_mouse_locked(bool locked); f32 djui_hud_measure_text(const char* message); -void djui_hud_print_text(const char* message, float x, float y, float scale); +void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale); +void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale); void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH); void djui_hud_render_texture_raw(const u8* texture, u32 bitSize, u32 width, u32 height, f32 x, f32 y, f32 scaleW, f32 scaleH); void djui_hud_render_texture_tile(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH); diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 8dc73118..b875b073 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -1931,7 +1931,7 @@ static struct LuaObjectField sSpawnParticlesInfoFields[LUA_SPAWN_PARTICLES_INFO_ { "forwardVelBase", LVT_S8, offsetof(struct SpawnParticlesInfo, forwardVelBase), false, LOT_NONE }, { "forwardVelRange", LVT_S8, offsetof(struct SpawnParticlesInfo, forwardVelRange), false, LOT_NONE }, { "gravity", LVT_S8, offsetof(struct SpawnParticlesInfo, gravity), false, LOT_NONE }, - { "model", LVT_U8, offsetof(struct SpawnParticlesInfo, model), true, LOT_NONE }, + { "model", LVT_U16, offsetof(struct SpawnParticlesInfo, model), true, LOT_NONE }, { "offsetY", LVT_S8, offsetof(struct SpawnParticlesInfo, offsetY), false, LOT_NONE }, { "sizeBase", LVT_F32, offsetof(struct SpawnParticlesInfo, sizeBase), false, LOT_NONE }, { "sizeRange", LVT_F32, offsetof(struct SpawnParticlesInfo, sizeRange), false, LOT_NONE }, diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index d8b649ef..8c529f6a 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -307,7 +307,9 @@ char gSmluaConstants[] = "" "COURSE_COUNT = 25\n" "--- @type integer\n" "COURSE_MIN = 1\n" -"MAX_LOADED_GRAPH_NODES = 0x100\n" +"LOADED_GRAPH_NODES_VANILLA = 256\n" +"LOADED_GRAPH_NODES_EXTENDED = 512\n" +"MAX_LOADED_GRAPH_NODES = (LOADED_GRAPH_NODES_VANILLA + LOADED_GRAPH_NODES_EXTENDED)\n" "INSTANT_WARP_INDEX_START = 0x00\n" "INSTANT_WARP_INDEX_STOP = 0x04\n" "WARP_TRANSITION_FADE_FROM_COLOR = 0x00\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 642b6691..998949af 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -11614,11 +11614,11 @@ int smlua_func_djui_hud_print_text(lua_State* L) { const char* message = smlua_to_string(L, 1); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_print_text"); return 0; } - float x = smlua_to_number(L, 2); + f32 x = smlua_to_number(L, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_print_text"); return 0; } - float y = smlua_to_number(L, 3); + f32 y = smlua_to_number(L, 3); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_print_text"); return 0; } - float scale = smlua_to_number(L, 4); + f32 scale = smlua_to_number(L, 4); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_print_text"); return 0; } djui_hud_print_text(message, x, y, scale); @@ -11626,6 +11626,35 @@ int smlua_func_djui_hud_print_text(lua_State* L) { return 1; } +int smlua_func_djui_hud_print_text_interpolated(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 7) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_print_text_interpolated", 7, top); + return 0; + } + + const char* message = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_print_text_interpolated"); return 0; } + f32 prevX = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_print_text_interpolated"); return 0; } + f32 prevY = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_print_text_interpolated"); return 0; } + f32 prevScale = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_print_text_interpolated"); return 0; } + f32 x = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "djui_hud_print_text_interpolated"); return 0; } + f32 y = smlua_to_number(L, 6); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "djui_hud_print_text_interpolated"); return 0; } + f32 scale = smlua_to_number(L, 7); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 7, "djui_hud_print_text_interpolated"); return 0; } + + djui_hud_print_text_interpolated(message, prevX, prevY, prevScale, x, y, scale); + + return 1; +} + int smlua_func_djui_hud_render_rect(lua_State* L) { if (L == NULL) { return 0; } @@ -11680,6 +11709,21 @@ int smlua_func_djui_hud_render_rect_interpolated(lua_State* L) { return 1; } +int smlua_func_djui_hud_reset_color(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", "djui_hud_reset_color", 0, top); + return 0; + } + + + djui_hud_reset_color(); + + return 1; +} + int smlua_func_djui_hud_set_color(lua_State* L) { if (L == NULL) { return 0; } @@ -27427,6 +27471,39 @@ int smlua_func_hud_render_power_meter(lua_State* L) { return 1; } +int smlua_func_hud_render_power_meter_interpolated(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 9) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "hud_render_power_meter_interpolated", 9, top); + return 0; + } + + s32 health = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "hud_render_power_meter_interpolated"); return 0; } + f32 prevX = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "hud_render_power_meter_interpolated"); return 0; } + f32 prevY = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "hud_render_power_meter_interpolated"); return 0; } + f32 prevWidth = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "hud_render_power_meter_interpolated"); return 0; } + f32 prevHeight = smlua_to_number(L, 5); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "hud_render_power_meter_interpolated"); return 0; } + f32 x = smlua_to_number(L, 6); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "hud_render_power_meter_interpolated"); return 0; } + f32 y = smlua_to_number(L, 7); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 7, "hud_render_power_meter_interpolated"); return 0; } + f32 width = smlua_to_number(L, 8); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 8, "hud_render_power_meter_interpolated"); return 0; } + f32 height = smlua_to_number(L, 9); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 9, "hud_render_power_meter_interpolated"); return 0; } + + hud_render_power_meter_interpolated(health, prevX, prevY, prevWidth, prevHeight, x, y, width, height); + + return 1; +} + int smlua_func_hud_set_value(lua_State* L) { if (L == NULL) { return 0; } @@ -29903,8 +29980,10 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_hud_is_pause_menu_created", smlua_func_djui_hud_is_pause_menu_created); smlua_bind_function(L, "djui_hud_measure_text", smlua_func_djui_hud_measure_text); smlua_bind_function(L, "djui_hud_print_text", smlua_func_djui_hud_print_text); + smlua_bind_function(L, "djui_hud_print_text_interpolated", smlua_func_djui_hud_print_text_interpolated); smlua_bind_function(L, "djui_hud_render_rect", smlua_func_djui_hud_render_rect); smlua_bind_function(L, "djui_hud_render_rect_interpolated", smlua_func_djui_hud_render_rect_interpolated); + smlua_bind_function(L, "djui_hud_reset_color", smlua_func_djui_hud_reset_color); smlua_bind_function(L, "djui_hud_set_color", smlua_func_djui_hud_set_color); smlua_bind_function(L, "djui_hud_set_font", smlua_func_djui_hud_set_font); smlua_bind_function(L, "djui_hud_set_mouse_locked", smlua_func_djui_hud_set_mouse_locked); @@ -30692,6 +30771,7 @@ void smlua_bind_functions_autogen(void) { 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_render_power_meter_interpolated", smlua_func_hud_render_power_meter_interpolated); smlua_bind_function(L, "hud_set_value", smlua_func_hud_set_value); smlua_bind_function(L, "hud_show", smlua_func_hud_show); smlua_bind_function(L, "is_game_paused", smlua_func_is_game_paused); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index e112502a..228bec23 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -125,6 +125,45 @@ void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height) { djui_hud_render_texture(&sPowerMeterTexturesInfo[numWedges + 1], x + width / 4, y + height / 4, width / 64, height / 64); } } +void hud_render_power_meter_interpolated(s32 health, f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height) { + extern const u8 texture_power_meter_left_side[]; + extern const u8 texture_power_meter_right_side[]; + extern const u8 texture_power_meter_full[]; + extern const u8 texture_power_meter_seven_segments[]; + extern const u8 texture_power_meter_six_segments[]; + extern const u8 texture_power_meter_five_segments[]; + extern const u8 texture_power_meter_four_segments[]; + extern const u8 texture_power_meter_three_segments[]; + extern const u8 texture_power_meter_two_segments[]; + extern const u8 texture_power_meter_one_segments[]; + static struct TextureInfo sPowerMeterTexturesInfo[] = { + { (u8*)texture_power_meter_left_side, 8, 32, 64 }, + { (u8*)texture_power_meter_right_side, 8, 32, 64 }, + { (u8*)texture_power_meter_one_segments, 8, 32, 32 }, + { (u8*)texture_power_meter_two_segments, 8, 32, 32 }, + { (u8*)texture_power_meter_three_segments, 8, 32, 32 }, + { (u8*)texture_power_meter_four_segments, 8, 32, 32 }, + { (u8*)texture_power_meter_five_segments, 8, 32, 32 }, + { (u8*)texture_power_meter_six_segments, 8, 32, 32 }, + { (u8*)texture_power_meter_seven_segments, 8, 32, 32 }, + { (u8*)texture_power_meter_full, 8, 32, 32 }, + }; + + djui_hud_render_texture_interpolated(&sPowerMeterTexturesInfo[0], + prevX, prevY, prevWidth / 64, prevHeight / 64, + x, y, width / 64, height / 64); + + djui_hud_render_texture_interpolated(&sPowerMeterTexturesInfo[1], + prevX + prevWidth / 2, prevY, prevWidth / 64, prevHeight / 64, + x + width / 2, y, width / 64, height / 64); + + s32 numWedges = MIN(MAX(health >> 8, 0), 8); + if (numWedges != 0) { + djui_hud_render_texture_interpolated(&sPowerMeterTexturesInfo[numWedges + 1], + prevX + prevWidth / 4, prevY + prevHeight / 4, prevWidth / 64, prevHeight / 64, + x + width / 4, y + height / 4, width / 64, height / 64); + } +} /// diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 467d177d..b3c336ce 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -38,6 +38,7 @@ 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 hud_render_power_meter_interpolated(s32 health, f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height); void camera_freeze(void); void camera_unfreeze(void);