From ac1cf57cf0a28a3bfd0aee0165d5bc63f53b502b Mon Sep 17 00:00:00 2001
From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com>
Date: Wed, 27 Aug 2025 08:15:41 +1000
Subject: [PATCH] new djui hud tools: viewport, scissor and render line (#916)
added these new djui hud tools for Lua:
- djui_hud_set_viewport
- djui_hud_reset_viewport
- djui_hud_set_scissor
- djui_hud_reset_scissor
- djui_hud_render_line - this code could already be done exactly. this is just to make rendering lines more efficient.
Also made nametags use a viewport for scaling in the credits.
---
autogen/lua_definitions/functions.lua | 38 ++++++++
docs/lua/functions-3.md | 121 ++++++++++++++++++++++++++
docs/lua/functions.md | 5 ++
src/game/area.c | 26 +++---
src/pc/djui/djui.c | 2 +
src/pc/djui/djui_hud_utils.c | 72 ++++++++++++++-
src/pc/djui/djui_hud_utils.h | 10 +++
src/pc/lua/smlua_functions_autogen.c | 106 ++++++++++++++++++++++
src/pc/nametags.c | 24 +++--
src/pc/pc_main.c | 4 +-
10 files changed, 383 insertions(+), 25 deletions(-)
diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua
index 51a732094..bc9bbc883 100644
--- a/autogen/lua_definitions/functions.lua
+++ b/autogen/lua_definitions/functions.lua
@@ -3950,6 +3950,34 @@ function djui_hud_get_mouse_scroll_y()
-- ...
end
+--- @param x number
+--- @param y number
+--- @param width number
+--- @param height number
+--- Sets the viewport to the specified position and size, this will resize
+function djui_hud_set_viewport(x, y, width, height)
+ -- ...
+end
+
+--- put the description here
+function djui_hud_reset_viewport()
+ -- ...
+end
+
+--- @param x number
+--- @param y number
+--- @param width number
+--- @param height number
+--- put the description here
+function djui_hud_set_scissor(x, y, width, height)
+ -- ...
+end
+
+--- put the description here
+function djui_hud_reset_scissor()
+ -- ...
+end
+
--- @param message string
--- @return number
--- Measures the length of `message` in the current font
@@ -4056,6 +4084,16 @@ function djui_hud_render_rect_interpolated(prevX, prevY, prevWidth, prevHeight,
-- ...
end
+--- @param p1X number
+--- @param p1Y number
+--- @param p2X number
+--- @param p2Y number
+--- @param size number
+--- Renders an DJUI HUD line onto the screen
+function djui_hud_render_line(p1X, p1Y, p2X, p2Y, size)
+ -- ...
+end
+
--- @return number
--- Gets the current camera FOV
function get_current_fov()
diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md
index 96c844c73..5754e7d88 100644
--- a/docs/lua/functions-3.md
+++ b/docs/lua/functions-3.md
@@ -3268,6 +3268,100 @@ Returns the amount scrolled vertically (-down/up+)
+## [djui_hud_set_viewport](#djui_hud_set_viewport)
+
+### Description
+Sets the viewport to the specified position and size, this will resize
+
+### Lua Example
+`djui_hud_set_viewport(x, y, width, height)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| x | `number` |
+| y | `number` |
+| width | `number` |
+| height | `number` |
+
+### Returns
+- None
+
+### C Prototype
+`void djui_hud_set_viewport(f32 x, f32 y, f32 width, f32 height);`
+
+[:arrow_up_small:](#)
+
+
+
+## [djui_hud_reset_viewport](#djui_hud_reset_viewport)
+
+### Description
+put the description here
+
+### Lua Example
+`djui_hud_reset_viewport()`
+
+### Parameters
+- None
+
+### Returns
+- None
+
+### C Prototype
+`void djui_hud_reset_viewport(void);`
+
+[:arrow_up_small:](#)
+
+
+
+## [djui_hud_set_scissor](#djui_hud_set_scissor)
+
+### Description
+put the description here
+
+### Lua Example
+`djui_hud_set_scissor(x, y, width, height)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| x | `number` |
+| y | `number` |
+| width | `number` |
+| height | `number` |
+
+### Returns
+- None
+
+### C Prototype
+`void djui_hud_set_scissor(f32 x, f32 y, f32 width, f32 height);`
+
+[:arrow_up_small:](#)
+
+
+
+## [djui_hud_reset_scissor](#djui_hud_reset_scissor)
+
+### Description
+put the description here
+
+### Lua Example
+`djui_hud_reset_scissor()`
+
+### Parameters
+- None
+
+### Returns
+- None
+
+### C Prototype
+`void djui_hud_reset_scissor(void);`
+
+[:arrow_up_small:](#)
+
+
+
## [djui_hud_measure_text](#djui_hud_measure_text)
### Description
@@ -3526,6 +3620,33 @@ Renders an interpolated DJUI HUD rect onto the screen
+## [djui_hud_render_line](#djui_hud_render_line)
+
+### Description
+Renders an DJUI HUD line onto the screen
+
+### Lua Example
+`djui_hud_render_line(p1X, p1Y, p2X, p2Y, size)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| p1X | `number` |
+| p1Y | `number` |
+| p2X | `number` |
+| p2Y | `number` |
+| size | `number` |
+
+### Returns
+- None
+
+### C Prototype
+`void djui_hud_render_line(f32 p1X, f32 p1Y, f32 p2X, f32 p2Y, f32 size);`
+
+[:arrow_up_small:](#)
+
+
+
## [get_current_fov](#get_current_fov)
### Description
diff --git a/docs/lua/functions.md b/docs/lua/functions.md
index 76fc6a55b..5683b3946 100644
--- a/docs/lua/functions.md
+++ b/docs/lua/functions.md
@@ -776,6 +776,10 @@
- [djui_hud_get_mouse_buttons_released](functions-3.md#djui_hud_get_mouse_buttons_released)
- [djui_hud_get_mouse_scroll_x](functions-3.md#djui_hud_get_mouse_scroll_x)
- [djui_hud_get_mouse_scroll_y](functions-3.md#djui_hud_get_mouse_scroll_y)
+ - [djui_hud_set_viewport](functions-3.md#djui_hud_set_viewport)
+ - [djui_hud_reset_viewport](functions-3.md#djui_hud_reset_viewport)
+ - [djui_hud_set_scissor](functions-3.md#djui_hud_set_scissor)
+ - [djui_hud_reset_scissor](functions-3.md#djui_hud_reset_scissor)
- [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)
@@ -785,6 +789,7 @@
- [djui_hud_render_texture_tile_interpolated](functions-3.md#djui_hud_render_texture_tile_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_render_line](functions-3.md#djui_hud_render_line)
- [get_current_fov](functions-3.md#get_current_fov)
- [djui_hud_get_fov_coeff](functions-3.md#djui_hud_get_fov_coeff)
- [djui_hud_world_pos_to_screen_pos](functions-3.md#djui_hud_world_pos_to_screen_pos)
diff --git a/src/game/area.c b/src/game/area.c
index 38dd6028a..36448abd5 100644
--- a/src/game/area.c
+++ b/src/game/area.c
@@ -47,8 +47,8 @@ struct SpawnInfo *gMarioSpawnInfo = &gPlayerSpawnInfos[0];
struct Area *gAreas = gAreaData;
struct Area *gCurrentArea = NULL;
struct CreditsEntry *gCurrCreditsEntry = NULL;
-Vp *D_8032CE74 = NULL;
-Vp *D_8032CE78 = NULL;
+Vp *gViewportOverride = NULL;
+Vp *gViewportClip = NULL;
s16 gWarpTransDelay = 0;
u32 gFBSetColor = 0;
u32 gWarpTransFBSetColor = 0;
@@ -90,7 +90,7 @@ u8 sSpawnTypeFromWarpBhv[] = {
MARIO_SPAWN_AIRBORNE_STAR_COLLECT, MARIO_SPAWN_AIRBORNE_DEATH, MARIO_SPAWN_LAUNCH_STAR_COLLECT, MARIO_SPAWN_LAUNCH_DEATH,
};
-Vp D_8032CF00 = { {
+Vp gViewportFullscreen = { {
{ 640, 480, 511, 0 },
{ 640, 480, 511, 0 },
} };
@@ -107,8 +107,8 @@ void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e) {
u16 sp6 = ((c >> 3) << 11) | ((d >> 3) << 6) | ((e >> 3) << 1) | 1;
gFBSetColor = (sp6 << 16) | sp6;
- D_8032CE74 = a;
- D_8032CE78 = b;
+ gViewportOverride = a;
+ gViewportClip = b;
}
void set_warp_transition_rgb(u8 red, u8 green, u8 blue) {
@@ -446,9 +446,9 @@ void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 b
void render_game(void) {
dynos_update_gfx();
if (gCurrentArea != NULL && !gWarpTransition.pauseRendering) {
- geo_process_root(gCurrentArea->root, D_8032CE74, D_8032CE78, gFBSetColor);
+ geo_process_root(gCurrentArea->root, gViewportOverride, gViewportClip, gFBSetColor);
- gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_8032CF00));
+ gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gViewportFullscreen));
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
@@ -479,8 +479,8 @@ void render_game(void) {
gSaveOptSelectIndex = gPauseScreenMode;
}
- if (D_8032CE78 != NULL) {
- make_viewport_clip_rect(D_8032CE78);
+ if (gViewportClip != NULL) {
+ make_viewport_clip_rect(gViewportClip);
} else
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
@@ -502,15 +502,15 @@ void render_game(void) {
}
} else {
render_text_labels();
- if (D_8032CE78 != NULL) {
- clear_viewport(D_8032CE78, gWarpTransFBSetColor);
+ if (gViewportClip != NULL) {
+ clear_viewport(gViewportClip, gWarpTransFBSetColor);
} else {
clear_frame_buffer(gWarpTransFBSetColor);
}
}
- D_8032CE74 = NULL;
- D_8032CE78 = NULL;
+ gViewportOverride = NULL;
+ gViewportClip = NULL;
}
void get_area_minimum_y(u8* hasMinY, f32* minY) {
diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c
index f4a22f760..a01bd0a1b 100644
--- a/src/pc/djui/djui.c
+++ b/src/pc/djui/djui.c
@@ -159,6 +159,8 @@ void djui_reset_hud_params(void) {
djui_hud_set_rotation(0, 0, 0);
djui_hud_reset_color();
djui_hud_set_filter(FILTER_NEAREST);
+ djui_hud_reset_viewport();
+ djui_hud_reset_scissor();
}
void djui_render(void) {
diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c
index ea30b9c51..7fe351d93 100644
--- a/src/pc/djui/djui_hud_utils.c
+++ b/src/pc/djui/djui_hud_utils.c
@@ -82,6 +82,24 @@ static void djui_hud_size_translate(f32* size) {
}
}
+// Translates position and scale to N64 resolution
+static void djui_hud_translate_positions(f32 *outX, f32 *outY, f32 *outW, f32 *outH) {
+ // translate position
+ djui_hud_position_translate(outX, outY);
+ *outX -= GFX_DIMENSIONS_FROM_LEFT_EDGE(0);
+ *outY -= SCREEN_HEIGHT;
+
+ // translate scale
+ if (sResolution == RESOLUTION_DJUI) {
+ u32 windowWidth, windowHeight;
+ gfx_get_dimensions(&windowWidth, &windowHeight);
+ f32 screenWidth = (f32) windowWidth / djui_gfx_get_scale();
+ f32 screenHeight = (f32) windowHeight / djui_gfx_get_scale();
+ *outW = (*outW / screenWidth) * SCREEN_WIDTH;
+ *outH = (*outH / screenHeight) * SCREEN_HEIGHT;
+ }
+}
+
////////////
// interp //
////////////
@@ -303,6 +321,43 @@ f32 djui_hud_get_mouse_scroll_y(void) {
return mouse_scroll_y;
}
+void djui_hud_set_viewport(f32 x, f32 y, f32 width, f32 height) {
+ // translate position and scale
+ f32 translatedX = x, translatedY = y, translatedW = width, translatedH = height;
+ djui_hud_translate_positions(&translatedX, &translatedY, &translatedW, &translatedH);
+
+ // convert to viewport structure
+ static Vp vp = {{
+ { 640, 480, 511, 0 },
+ { 640, 480, 511, 0 },
+ }};
+ Vp_t *viewport = &vp.vp;
+ viewport->vscale[0] = translatedW * 2.0f;
+ viewport->vscale[1] = translatedH * 2.0f;
+ viewport->vtrans[0] = (translatedW + translatedX) * 2.0f;
+ viewport->vtrans[1] = (translatedH + translatedY) * 2.0f;
+
+ gSPViewport(gDisplayListHead++, &vp);
+}
+
+void djui_hud_reset_viewport(void) {
+ extern Vp gViewportFullscreen;
+ gSPViewport(gDisplayListHead++, &gViewportFullscreen);
+}
+
+void djui_hud_set_scissor(f32 x, f32 y, f32 width, f32 height) {
+ // translate position and scale
+ f32 translatedX = x, translatedY = y, translatedW = width, translatedH = height;
+ djui_hud_translate_positions(&translatedX, &translatedY, &translatedW, &translatedH);
+
+ // apply the scissor
+ gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, translatedX, translatedY, translatedW, translatedH);
+}
+
+void djui_hud_reset_scissor(void) {
+ gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT);
+}
+
f32 djui_hud_measure_text(const char* message) {
if (message == NULL) { return 0; }
const struct DjuiFont* font = gDjuiFonts[sFont];
@@ -644,6 +699,15 @@ void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32
interp->rotation = sRotation;
}
+void djui_hud_render_line(f32 p1X, f32 p1Y, f32 p2X, f32 p2Y, f32 size) {
+ f32 dx = p2X - p1X;
+ f32 dy = p2Y - p1Y;
+ f32 angle = atan2s(dy, dx) - 0x4000; // -90 degrees to adjust for djui rotation
+ f32 hDist = sqrt(sqr(dx) + sqr(dy));
+ djui_hud_set_rotation(angle, 0, 0.5);
+ djui_hud_render_rect(p1X, p1Y, hDist, size);
+}
+
static void hud_rotate_and_translate_vec3f(Vec3f vec, Mat4* mtx, Vec3f out) {
out[0] = (*mtx)[0][0] * vec[0] + (*mtx)[1][0] * vec[1] + (*mtx)[2][0] * vec[2];
out[1] = (*mtx)[0][1] * vec[0] + (*mtx)[1][1] * vec[1] + (*mtx)[2][1] * vec[2];
@@ -666,6 +730,8 @@ f32 djui_hud_get_fov_coeff() {
return (fovDefault / fovCurrent) * 1.13f;
}
+bool gDjuiHudToWorldCalcViewport = true;
+
bool djui_hud_world_pos_to_screen_pos(Vec3f pos, OUT Vec3f out) {
if (!gCamera) { return false; }
hud_rotate_and_translate_vec3f(pos, &gCamera->mtx, out);
@@ -695,9 +761,9 @@ bool djui_hud_world_pos_to_screen_pos(Vec3f pos, OUT Vec3f out) {
out[0] += screenWidth / 2.0f;
out[1] += screenHeight / 2.0f;
- extern Vp *D_8032CE74;
- if (D_8032CE74) {
- Vp_t *viewport = &D_8032CE74->vp;
+ extern Vp *gViewportOverride;
+ if (gViewportOverride && gDjuiHudToWorldCalcViewport) {
+ Vp_t *viewport = &gViewportOverride->vp;
f32 width = viewport->vscale[0] / 2.0f;
f32 height = viewport->vscale[1] / 2.0f;
f32 x = (viewport->vtrans[0] / 4.0f) - width / 2.0f;
diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h
index 47bd8ff69..2e2748be4 100644
--- a/src/pc/djui/djui_hud_utils.h
+++ b/src/pc/djui/djui_hud_utils.h
@@ -104,6 +104,14 @@ u8 djui_hud_get_mouse_buttons_released(void);
f32 djui_hud_get_mouse_scroll_x(void);
/* |description|Returns the amount scrolled vertically (-down/up+)|descriptionEnd| */
f32 djui_hud_get_mouse_scroll_y(void);
+/* |description|Sets the viewport to the specified position and size, this will resize |descriptionEnd| */
+void djui_hud_set_viewport(f32 x, f32 y, f32 width, f32 height);
+/* |description|put the description here|descriptionEnd| */
+void djui_hud_reset_viewport(void);
+/* |description|put the description here|descriptionEnd| */
+void djui_hud_set_scissor(f32 x, f32 y, f32 width, f32 height);
+/* |description|put the description here|descriptionEnd| */
+void djui_hud_reset_scissor(void);
/* |description|Measures the length of `message` in the current font|descriptionEnd| */
f32 djui_hud_measure_text(const char* message);
@@ -125,6 +133,8 @@ void djui_hud_render_texture_tile_interpolated(struct TextureInfo* texInfo, f32
void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height);
/* |description|Renders an interpolated DJUI HUD rect onto the screen|descriptionEnd| */
void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height);
+/* |description|Renders an DJUI HUD line onto the screen|descriptionEnd| */
+void djui_hud_render_line(f32 p1X, f32 p1Y, f32 p2X, f32 p2Y, f32 size);
/* |description|Gets the current camera FOV|descriptionEnd| */
f32 get_current_fov();
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c
index 14226a5f7..521a08a18 100644
--- a/src/pc/lua/smlua_functions_autogen.c
+++ b/src/pc/lua/smlua_functions_autogen.c
@@ -12790,6 +12790,82 @@ int smlua_func_djui_hud_get_mouse_scroll_y(UNUSED lua_State* L) {
return 1;
}
+int smlua_func_djui_hud_set_viewport(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 4) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_set_viewport", 4, top);
+ return 0;
+ }
+
+ f32 x = smlua_to_number(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_viewport"); return 0; }
+ f32 y = smlua_to_number(L, 2);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_set_viewport"); return 0; }
+ f32 width = smlua_to_number(L, 3);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_set_viewport"); return 0; }
+ f32 height = smlua_to_number(L, 4);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_set_viewport"); return 0; }
+
+ djui_hud_set_viewport(x, y, width, height);
+
+ return 1;
+}
+
+int smlua_func_djui_hud_reset_viewport(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_viewport", 0, top);
+ return 0;
+ }
+
+
+ djui_hud_reset_viewport();
+
+ return 1;
+}
+
+int smlua_func_djui_hud_set_scissor(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 4) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_set_scissor", 4, top);
+ return 0;
+ }
+
+ f32 x = smlua_to_number(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_scissor"); return 0; }
+ f32 y = smlua_to_number(L, 2);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_set_scissor"); return 0; }
+ f32 width = smlua_to_number(L, 3);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_set_scissor"); return 0; }
+ f32 height = smlua_to_number(L, 4);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_set_scissor"); return 0; }
+
+ djui_hud_set_scissor(x, y, width, height);
+
+ return 1;
+}
+
+int smlua_func_djui_hud_reset_scissor(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_scissor", 0, top);
+ return 0;
+ }
+
+
+ djui_hud_reset_scissor();
+
+ return 1;
+}
+
int smlua_func_djui_hud_measure_text(lua_State* L) {
if (L == NULL) { return 0; }
@@ -13045,6 +13121,31 @@ int smlua_func_djui_hud_render_rect_interpolated(lua_State* L) {
return 1;
}
+int smlua_func_djui_hud_render_line(lua_State* L) {
+ if (L == NULL) { return 0; }
+
+ int top = lua_gettop(L);
+ if (top != 5) {
+ LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_render_line", 5, top);
+ return 0;
+ }
+
+ f32 p1X = smlua_to_number(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_render_line"); return 0; }
+ f32 p1Y = smlua_to_number(L, 2);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_render_line"); return 0; }
+ f32 p2X = smlua_to_number(L, 3);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_render_line"); return 0; }
+ f32 p2Y = smlua_to_number(L, 4);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_render_line"); return 0; }
+ f32 size = smlua_to_number(L, 5);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "djui_hud_render_line"); return 0; }
+
+ djui_hud_render_line(p1X, p1Y, p2X, p2Y, size);
+
+ return 1;
+}
+
int smlua_func_get_current_fov(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
@@ -37175,6 +37276,10 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "djui_hud_get_mouse_buttons_released", smlua_func_djui_hud_get_mouse_buttons_released);
smlua_bind_function(L, "djui_hud_get_mouse_scroll_x", smlua_func_djui_hud_get_mouse_scroll_x);
smlua_bind_function(L, "djui_hud_get_mouse_scroll_y", smlua_func_djui_hud_get_mouse_scroll_y);
+ smlua_bind_function(L, "djui_hud_set_viewport", smlua_func_djui_hud_set_viewport);
+ smlua_bind_function(L, "djui_hud_reset_viewport", smlua_func_djui_hud_reset_viewport);
+ smlua_bind_function(L, "djui_hud_set_scissor", smlua_func_djui_hud_set_scissor);
+ smlua_bind_function(L, "djui_hud_reset_scissor", smlua_func_djui_hud_reset_scissor);
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);
@@ -37184,6 +37289,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "djui_hud_render_texture_tile_interpolated", smlua_func_djui_hud_render_texture_tile_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_render_line", smlua_func_djui_hud_render_line);
smlua_bind_function(L, "get_current_fov", smlua_func_get_current_fov);
smlua_bind_function(L, "djui_hud_get_fov_coeff", smlua_func_djui_hud_get_fov_coeff);
smlua_bind_function(L, "djui_hud_world_pos_to_screen_pos", smlua_func_djui_hud_world_pos_to_screen_pos);
diff --git a/src/pc/nametags.c b/src/pc/nametags.c
index 927a3df12..37fe27bf8 100644
--- a/src/pc/nametags.c
+++ b/src/pc/nametags.c
@@ -84,6 +84,8 @@ void nametags_render(void) {
vec3f_copy(pos, m->marioBodyState->headPos);
pos[1] += 100;
+ extern bool gDjuiHudToWorldCalcViewport;
+ gDjuiHudToWorldCalcViewport = false;
if ((i != 0 || (i == 0 && m->action != ACT_FIRST_PERSON)) &&
djui_hud_world_pos_to_screen_pos(pos, out)) {
@@ -114,11 +116,15 @@ void nametags_render(void) {
e->inited = true;
}
- // Scissor to clip during credits
- extern Vp *D_8032CE74;
- extern Vp *D_8032CE78;
- Vp *viewport = D_8032CE74 == NULL ? D_8032CE78 : D_8032CE74;
- if (viewport) { make_viewport_clip_rect(viewport); }
+ // Apply viewport for credits
+ extern Vp *gViewportOverride;
+ extern Vp *gViewportClip;
+ extern Vp gViewportFullscreen;
+ Vp *viewport = gViewportOverride == NULL ? gViewportClip : gViewportOverride;
+ if (viewport) {
+ make_viewport_clip_rect(viewport);
+ gSPViewport(gDisplayListHead++, viewport);
+ }
djui_hud_print_outlined_text_interpolated(name,
e->prevPos[0] - measure, e->prevPos[1], e->prevScale,
@@ -135,12 +141,16 @@ void nametags_render(void) {
);
}
- // Reset scissor
- if (viewport) { gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT); }
+ // Reset viewport
+ if (viewport) {
+ gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT);
+ gSPViewport(gDisplayListHead++, &gViewportFullscreen);
+ }
vec3f_copy(e->prevPos, out);
e->prevScale = scale;
}
+ gDjuiHudToWorldCalcViewport = true;
}
}
diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c
index ddcc6a734..4a3313e00 100644
--- a/src/pc/pc_main.c
+++ b/src/pc/pc_main.c
@@ -76,7 +76,7 @@
#include
#endif
-extern Vp D_8032CF00;
+extern Vp gViewportFullscreen;
OSMesg D_80339BEC;
OSMesgQueue gSIEventMesgQueue;
@@ -363,7 +363,7 @@ void produce_one_dummy_frame(void (*callback)(), u8 clearColorR, u8 clearColorG,
djui_gfx_displaylist_begin();
// fix scaling issues
- gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_8032CF00));
+ gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gViewportFullscreen));
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - BORDER_HEIGHT);
// clear screen