mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-26 05:55:15 +00:00
Add djui_hud_world_pos_to_screen_pos, and render interpolated rect/texture
This commit is contained in:
parent
2fd452059b
commit
933914d984
10 changed files with 394 additions and 1 deletions
|
@ -160,6 +160,7 @@ manual_index_documentation = """
|
||||||
- [network_send](#network_send)
|
- [network_send](#network_send)
|
||||||
- [djui_hud_render_texture](#djui_hud_render_texture)
|
- [djui_hud_render_texture](#djui_hud_render_texture)
|
||||||
- [get_texture_info](#get_texture_info)
|
- [get_texture_info](#get_texture_info)
|
||||||
|
- [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
@ -334,6 +335,34 @@ Retrieves a texture by name.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`djui_hud_render_texture_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| texInfo | [TextureInfo](structs.md#TextureInfo) |
|
||||||
|
| prevX | `number` |
|
||||||
|
| prevY | `number` |
|
||||||
|
| prevScaleW | `number` |
|
||||||
|
| prevScaleH | `number` |
|
||||||
|
| x | `number` |
|
||||||
|
| y | `number` |
|
||||||
|
| scaleW | `number` |
|
||||||
|
| scaleH | `number` |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void djui_hud_render_texture_interpolated(struct TextureInfo* texInfo, f32 prevX, f32 prevY, f32 prevScaleW, f32 prevScaleH, f32 x, f32 y, f32 scaleW, f32 scaleH);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
|
@ -3609,6 +3609,19 @@ function djui_hud_render_rect(x, y, width, height)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @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 djui_hud_render_rect_interpolated(prevX, prevY, prevWidth, prevHeight, x, y, width, height)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param r integer
|
--- @param r integer
|
||||||
--- @param g integer
|
--- @param g integer
|
||||||
--- @param b integer
|
--- @param b integer
|
||||||
|
@ -3630,6 +3643,13 @@ function djui_hud_set_resolution(resolutionType)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param pos Vec3f
|
||||||
|
--- @param out Vec3f
|
||||||
|
--- @return nil
|
||||||
|
function djui_hud_world_pos_to_screen_pos(pos, out)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param message string
|
--- @param message string
|
||||||
--- @param lines integer
|
--- @param lines integer
|
||||||
--- @return nil
|
--- @return nil
|
||||||
|
|
|
@ -159,3 +159,17 @@ end
|
||||||
function djui_hud_render_texture(texInfo, x, y, scaleW, scaleH)
|
function djui_hud_render_texture(texInfo, x, y, scaleW, scaleH)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param texInfo TextureInfo
|
||||||
|
--- @param prevX number
|
||||||
|
--- @param prevY number
|
||||||
|
--- @param prevScaleW number
|
||||||
|
--- @param prevScaleH number
|
||||||
|
--- @param x number
|
||||||
|
--- @param y number
|
||||||
|
--- @param scaleW number
|
||||||
|
--- @param scaleH number
|
||||||
|
--- @return nil
|
||||||
|
function djui_hud_render_texture_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
|
@ -2135,6 +2135,33 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [djui_hud_render_rect_interpolated](#djui_hud_render_rect_interpolated)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`djui_hud_render_rect_interpolated(prevX, prevY, prevWidth, prevHeight, x, y, width, height)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| prevX | `number` |
|
||||||
|
| prevY | `number` |
|
||||||
|
| prevWidth | `number` |
|
||||||
|
| prevHeight | `number` |
|
||||||
|
| x | `number` |
|
||||||
|
| y | `number` |
|
||||||
|
| width | `number` |
|
||||||
|
| height | `number` |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [djui_hud_set_color](#djui_hud_set_color)
|
## [djui_hud_set_color](#djui_hud_set_color)
|
||||||
|
|
||||||
### Lua Example
|
### Lua Example
|
||||||
|
@ -2198,6 +2225,27 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [djui_hud_world_pos_to_screen_pos](#djui_hud_world_pos_to_screen_pos)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`djui_hud_world_pos_to_screen_pos(pos, out)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| pos | [Vec3f](structs.md#Vec3f) |
|
||||||
|
| out | [Vec3f](structs.md#Vec3f) |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
---
|
---
|
||||||
# functions from djui_popup.h
|
# functions from djui_popup.h
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
- [network_send](#network_send)
|
- [network_send](#network_send)
|
||||||
- [djui_hud_render_texture](#djui_hud_render_texture)
|
- [djui_hud_render_texture](#djui_hud_render_texture)
|
||||||
- [get_texture_info](#get_texture_info)
|
- [get_texture_info](#get_texture_info)
|
||||||
|
- [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
@ -708,9 +709,11 @@
|
||||||
- [djui_hud_measure_text](functions-3.md#djui_hud_measure_text)
|
- [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](functions-3.md#djui_hud_print_text)
|
||||||
- [djui_hud_render_rect](functions-3.md#djui_hud_render_rect)
|
- [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_set_color](functions-3.md#djui_hud_set_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_font](functions-3.md#djui_hud_set_font)
|
||||||
- [djui_hud_set_resolution](functions-3.md#djui_hud_set_resolution)
|
- [djui_hud_set_resolution](functions-3.md#djui_hud_set_resolution)
|
||||||
|
- [djui_hud_world_pos_to_screen_pos](functions-3.md#djui_hud_world_pos_to_screen_pos)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
@ -1643,6 +1646,34 @@ Retrieves a texture by name.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [djui_hud_render_texture_interpolated](#djui_hud_render_texture_interpolated)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`djui_hud_render_texture_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| texInfo | [TextureInfo](structs.md#TextureInfo) |
|
||||||
|
| prevX | `number` |
|
||||||
|
| prevY | `number` |
|
||||||
|
| prevScaleW | `number` |
|
||||||
|
| prevScaleH | `number` |
|
||||||
|
| x | `number` |
|
||||||
|
| y | `number` |
|
||||||
|
| scaleW | `number` |
|
||||||
|
| scaleH | `number` |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- None
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`void djui_hud_render_texture_interpolated(struct TextureInfo* texInfo, f32 prevX, f32 prevY, f32 prevScaleW, f32 prevScaleH, f32 x, f32 y, f32 scaleW, f32 scaleH);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
1 | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [next >](functions-2.md)]
|
1 | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [next >](functions-2.md)]
|
||||||
|
|
|
@ -8,12 +8,15 @@
|
||||||
#include "pc/gfx/gfx_pc.h"
|
#include "pc/gfx/gfx_pc.h"
|
||||||
#include "pc/gfx/gfx_window_manager_api.h"
|
#include "pc/gfx/gfx_window_manager_api.h"
|
||||||
#include "pc/pc_main.h"
|
#include "pc/pc_main.h"
|
||||||
|
#include "pc/utils/misc.h"
|
||||||
|
|
||||||
#include "djui_gfx.h"
|
#include "djui_gfx.h"
|
||||||
#include "gfx_dimensions.h"
|
#include "gfx_dimensions.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "djui.h"
|
#include "djui.h"
|
||||||
#include "djui_hud_utils.h"
|
#include "djui_hud_utils.h"
|
||||||
|
#include "game/camera.h"
|
||||||
|
|
||||||
|
|
||||||
static enum HudUtilsResolution sResolution = RESOLUTION_DJUI;
|
static enum HudUtilsResolution sResolution = RESOLUTION_DJUI;
|
||||||
static enum DjuiFontType sFont = FONT_NORMAL;
|
static enum DjuiFontType sFont = FONT_NORMAL;
|
||||||
|
@ -53,6 +56,66 @@ static void djui_hud_size_translate(f32* size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// interp //
|
||||||
|
////////////
|
||||||
|
|
||||||
|
#define MAX_INTERP_HUD 128
|
||||||
|
struct InterpHud {
|
||||||
|
Gfx* headPos;
|
||||||
|
f32 z;
|
||||||
|
f32 prevX;
|
||||||
|
f32 prevY;
|
||||||
|
f32 x;
|
||||||
|
f32 y;
|
||||||
|
f32 prevScaleW;
|
||||||
|
f32 prevScaleH;
|
||||||
|
f32 scaleW;
|
||||||
|
f32 scaleH;
|
||||||
|
f32 width;
|
||||||
|
f32 height;
|
||||||
|
};
|
||||||
|
static struct InterpHud sInterpHuds[MAX_INTERP_HUD] = { 0 };
|
||||||
|
static u16 sInterpHudCount = 0;
|
||||||
|
|
||||||
|
void patch_djui_hud_before(void) {
|
||||||
|
sInterpHudCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void patch_djui_hud(f32 delta) {
|
||||||
|
f32 savedZ = gDjuiHudUtilsZ;
|
||||||
|
Gfx* savedHeadPos = gDisplayListHead;
|
||||||
|
for (u16 i = 0; i < sInterpHudCount; i++) {
|
||||||
|
struct InterpHud* interp = &sInterpHuds[i];
|
||||||
|
f32 x = delta_interpolate_f32(interp->prevX, interp->x, delta);
|
||||||
|
f32 y = delta_interpolate_f32(interp->prevY, interp->y, delta);
|
||||||
|
f32 scaleW = delta_interpolate_f32(interp->prevScaleW, interp->scaleW, delta);
|
||||||
|
f32 scaleH = delta_interpolate_f32(interp->prevScaleH, interp->scaleH, delta);
|
||||||
|
|
||||||
|
gDjuiHudUtilsZ = interp->z;
|
||||||
|
gDisplayListHead = interp->headPos;
|
||||||
|
|
||||||
|
// translate position
|
||||||
|
f32 translatedX = x;
|
||||||
|
f32 translatedY = y;
|
||||||
|
djui_hud_position_translate(&translatedX, &translatedY);
|
||||||
|
create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ);
|
||||||
|
|
||||||
|
// translate scale
|
||||||
|
f32 translatedW = scaleW;
|
||||||
|
f32 translatedH = scaleH;
|
||||||
|
djui_hud_size_translate(&translatedW);
|
||||||
|
djui_hud_size_translate(&translatedH);
|
||||||
|
create_dl_scale_matrix(DJUI_MTX_NOPUSH, interp->width * translatedW, interp->height * translatedH, 1.0f);
|
||||||
|
}
|
||||||
|
gDisplayListHead = savedHeadPos;
|
||||||
|
gDjuiHudUtilsZ = savedZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// others //
|
||||||
|
////////////
|
||||||
|
|
||||||
void djui_hud_set_resolution(enum HudUtilsResolution resolutionType) {
|
void djui_hud_set_resolution(enum HudUtilsResolution resolutionType) {
|
||||||
if (resolutionType >= RESOLUTION_COUNT) { return; }
|
if (resolutionType >= RESOLUTION_COUNT) { return; }
|
||||||
sResolution = resolutionType;
|
sResolution = resolutionType;
|
||||||
|
@ -183,6 +246,28 @@ void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scal
|
||||||
djui_hud_render_texture_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->height, x, y, scaleW, scaleH);
|
djui_hud_render_texture_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->height, x, y, scaleW, scaleH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void djui_hud_render_texture_interpolated(struct TextureInfo* texInfo, f32 prevX, f32 prevY, f32 prevScaleW, f32 prevScaleH, f32 x, f32 y, f32 scaleW, f32 scaleH) {
|
||||||
|
Gfx* savedHeadPos = gDisplayListHead;
|
||||||
|
f32 savedZ = gDjuiHudUtilsZ;
|
||||||
|
|
||||||
|
djui_hud_render_texture_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->height, prevX, prevY, prevScaleW, prevScaleH);
|
||||||
|
|
||||||
|
if (sInterpHudCount >= MAX_INTERP_HUD) { return; }
|
||||||
|
struct InterpHud* interp = &sInterpHuds[sInterpHudCount++];
|
||||||
|
interp->headPos = savedHeadPos;
|
||||||
|
interp->prevX = prevX;
|
||||||
|
interp->prevY = prevY;
|
||||||
|
interp->prevScaleW = prevScaleW;
|
||||||
|
interp->prevScaleH = prevScaleH;
|
||||||
|
interp->x = x;
|
||||||
|
interp->y = y;
|
||||||
|
interp->scaleW = scaleW;
|
||||||
|
interp->scaleH = scaleH;
|
||||||
|
interp->width = texInfo->width;
|
||||||
|
interp->height = texInfo->height;
|
||||||
|
interp->z = savedZ;
|
||||||
|
}
|
||||||
|
|
||||||
void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height) {
|
void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height) {
|
||||||
gDjuiHudUtilsZ += 0.01f;
|
gDjuiHudUtilsZ += 0.01f;
|
||||||
|
|
||||||
|
@ -205,3 +290,51 @@ void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height) {
|
||||||
// pop
|
// pop
|
||||||
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height) {
|
||||||
|
Gfx* savedHeadPos = gDisplayListHead;
|
||||||
|
f32 savedZ = gDjuiHudUtilsZ;
|
||||||
|
|
||||||
|
djui_hud_render_rect(prevX, prevY, prevWidth, prevHeight);
|
||||||
|
|
||||||
|
if (sInterpHudCount >= MAX_INTERP_HUD) { return; }
|
||||||
|
struct InterpHud* interp = &sInterpHuds[sInterpHudCount++];
|
||||||
|
interp->headPos = savedHeadPos;
|
||||||
|
interp->prevX = prevX;
|
||||||
|
interp->prevY = prevY;
|
||||||
|
interp->prevScaleW = prevWidth;
|
||||||
|
interp->prevScaleH = prevHeight;
|
||||||
|
interp->x = x;
|
||||||
|
interp->y = y;
|
||||||
|
interp->scaleW = width;
|
||||||
|
interp->scaleH = height;
|
||||||
|
interp->width = 1;
|
||||||
|
interp->height = 1;
|
||||||
|
interp->z = savedZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
out[2] = (*mtx)[0][2] * vec[0] + (*mtx)[1][2] * vec[1] + (*mtx)[2][2] * vec[2];
|
||||||
|
out[0] += (*mtx)[3][0];
|
||||||
|
out[1] += (*mtx)[3][1];
|
||||||
|
out[2] += (*mtx)[3][2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) {
|
||||||
|
hud_rotate_and_translate_vec3f(pos, &gCamera->mtx, out);
|
||||||
|
if (out[2] > -256.0f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
out[0] *= 256.0 / -out[2];
|
||||||
|
out[1] *= 256.0 / out[2];
|
||||||
|
|
||||||
|
// TODO: this is a hack to correct for the FOV. It only sort of works for the default fov
|
||||||
|
out[0] *= 1.135;
|
||||||
|
out[1] *= 1.135;
|
||||||
|
|
||||||
|
out[0] += djui_hud_get_screen_width() / 2.0f;
|
||||||
|
out[1] += djui_hud_get_screen_height() / 2.0f;
|
||||||
|
}
|
|
@ -41,6 +41,10 @@ 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, float x, float y, float scale);
|
||||||
void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH);
|
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_raw(const u8* texture, u32 bitSize, u32 width, u32 height, f32 x, f32 y, f32 scaleW, f32 scaleH);
|
||||||
|
void djui_hud_render_texture_interpolated(struct TextureInfo* texInfo, f32 prevX, f32 prevY, f32 prevScaleW, f32 prevScaleH, f32 x, f32 y, f32 scaleW, f32 scaleH);
|
||||||
void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height);
|
void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height);
|
||||||
|
void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height);
|
||||||
|
|
||||||
|
void djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -271,6 +271,59 @@ int smlua_func_djui_hud_render_texture(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_djui_hud_render_texture_interpolated(lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 9)) { return 0; }
|
||||||
|
|
||||||
|
struct TextureInfo tmpTexInfo = { 0 };
|
||||||
|
struct TextureInfo* texInfo = &tmpTexInfo;
|
||||||
|
|
||||||
|
if (smlua_is_cobject(L, 1, LOT_TEXTUREINFO)) {
|
||||||
|
texInfo = (struct TextureInfo*)smlua_to_cobject(L, 1, LOT_TEXTUREINFO);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||||
|
} else {
|
||||||
|
int top = lua_gettop(L);
|
||||||
|
lua_pushvalue(L, 1);
|
||||||
|
|
||||||
|
lua_pushstring(L, "texture");
|
||||||
|
lua_gettable(L, top+1);
|
||||||
|
tmpTexInfo.texture = smlua_to_cpointer(L, lua_gettop(L), LVT_U8_P);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'texture' field"); return 0; }
|
||||||
|
|
||||||
|
tmpTexInfo.bitSize = smlua_get_integer_field(top+1, "bitSize");
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'bitSize' field"); return 0; }
|
||||||
|
|
||||||
|
tmpTexInfo.width = smlua_get_integer_field(top+1, "width");
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'width' field"); return 0; }
|
||||||
|
|
||||||
|
tmpTexInfo.height = smlua_get_integer_field(top+1, "height");
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1's 'height' field"); return 0; }
|
||||||
|
|
||||||
|
lua_settop(L, top);
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 prevX = smlua_to_number(L, 2);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||||
|
f32 prevY = smlua_to_number(L, 3);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; }
|
||||||
|
f32 prevScaleW = smlua_to_number(L, 4);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 4"); return 0; }
|
||||||
|
f32 prevScaleH = smlua_to_number(L, 5);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 5"); return 0; }
|
||||||
|
f32 x = smlua_to_number(L, 6);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 6"); return 0; }
|
||||||
|
f32 y = smlua_to_number(L, 7);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 7"); return 0; }
|
||||||
|
f32 scaleW = smlua_to_number(L, 8);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 8"); return 0; }
|
||||||
|
f32 scaleH = smlua_to_number(L, 9);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 9"); return 0; }
|
||||||
|
|
||||||
|
djui_hud_render_texture_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, x, y, scaleW, scaleH);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// bind //
|
// bind //
|
||||||
//////////
|
//////////
|
||||||
|
@ -290,4 +343,5 @@ void smlua_bind_functions(void) {
|
||||||
smlua_bind_function(L, "network_send_to", smlua_func_network_send_to);
|
smlua_bind_function(L, "network_send_to", smlua_func_network_send_to);
|
||||||
smlua_bind_function(L, "get_texture_info", smlua_func_get_texture_info);
|
smlua_bind_function(L, "get_texture_info", smlua_func_get_texture_info);
|
||||||
smlua_bind_function(L, "djui_hud_render_texture", smlua_func_djui_hud_render_texture);
|
smlua_bind_function(L, "djui_hud_render_texture", smlua_func_djui_hud_render_texture);
|
||||||
|
smlua_bind_function(L, "djui_hud_render_texture_interpolated", smlua_func_djui_hud_render_texture_interpolated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7267,6 +7267,31 @@ int smlua_func_djui_hud_render_rect(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_djui_hud_render_rect_interpolated(lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 8)) { return 0; }
|
||||||
|
|
||||||
|
f32 prevX = smlua_to_number(L, 1);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||||
|
f32 prevY = smlua_to_number(L, 2);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||||
|
f32 prevWidth = smlua_to_number(L, 3);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; }
|
||||||
|
f32 prevHeight = smlua_to_number(L, 4);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 4"); return 0; }
|
||||||
|
f32 x = smlua_to_number(L, 5);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 5"); return 0; }
|
||||||
|
f32 y = smlua_to_number(L, 6);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 6"); return 0; }
|
||||||
|
f32 width = smlua_to_number(L, 7);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 7"); return 0; }
|
||||||
|
f32 height = smlua_to_number(L, 8);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 8"); return 0; }
|
||||||
|
|
||||||
|
djui_hud_render_rect_interpolated(prevX, prevY, prevWidth, prevHeight, x, y, width, height);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int smlua_func_djui_hud_set_color(lua_State* L) {
|
int smlua_func_djui_hud_set_color(lua_State* L) {
|
||||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||||
|
|
||||||
|
@ -7306,6 +7331,35 @@ int smlua_func_djui_hud_set_resolution(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_djui_hud_world_pos_to_screen_pos(lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||||
|
|
||||||
|
|
||||||
|
f32* pos = smlua_get_vec3f_from_buffer();
|
||||||
|
pos[0] = smlua_get_number_field(1, "x");
|
||||||
|
pos[1] = smlua_get_number_field(1, "y");
|
||||||
|
pos[2] = smlua_get_number_field(1, "z");
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||||
|
|
||||||
|
f32* out = smlua_get_vec3f_from_buffer();
|
||||||
|
out[0] = smlua_get_number_field(2, "x");
|
||||||
|
out[1] = smlua_get_number_field(2, "y");
|
||||||
|
out[2] = smlua_get_number_field(2, "z");
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; }
|
||||||
|
|
||||||
|
djui_hud_world_pos_to_screen_pos(pos, out);
|
||||||
|
|
||||||
|
smlua_push_number_field(1, "x", pos[0]);
|
||||||
|
smlua_push_number_field(1, "y", pos[1]);
|
||||||
|
smlua_push_number_field(1, "z", pos[2]);
|
||||||
|
|
||||||
|
smlua_push_number_field(2, "x", out[0]);
|
||||||
|
smlua_push_number_field(2, "y", out[1]);
|
||||||
|
smlua_push_number_field(2, "z", out[2]);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// djui_popup.h //
|
// djui_popup.h //
|
||||||
//////////////////
|
//////////////////
|
||||||
|
@ -16807,9 +16861,11 @@ void smlua_bind_functions_autogen(void) {
|
||||||
smlua_bind_function(L, "djui_hud_measure_text", smlua_func_djui_hud_measure_text);
|
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", smlua_func_djui_hud_print_text);
|
||||||
smlua_bind_function(L, "djui_hud_render_rect", smlua_func_djui_hud_render_rect);
|
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_set_color", smlua_func_djui_hud_set_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_font", smlua_func_djui_hud_set_font);
|
||||||
smlua_bind_function(L, "djui_hud_set_resolution", smlua_func_djui_hud_set_resolution);
|
smlua_bind_function(L, "djui_hud_set_resolution", smlua_func_djui_hud_set_resolution);
|
||||||
|
smlua_bind_function(L, "djui_hud_world_pos_to_screen_pos", smlua_func_djui_hud_world_pos_to_screen_pos);
|
||||||
|
|
||||||
// djui_popup.h
|
// djui_popup.h
|
||||||
smlua_bind_function(L, "djui_popup_create", smlua_func_djui_popup_create);
|
smlua_bind_function(L, "djui_popup_create", smlua_func_djui_popup_create);
|
||||||
|
|
|
@ -124,6 +124,7 @@ static void patch_interpolations_before(void) {
|
||||||
extern void patch_bubble_particles_before(void);
|
extern void patch_bubble_particles_before(void);
|
||||||
extern void patch_snow_particles_before(void);
|
extern void patch_snow_particles_before(void);
|
||||||
extern void patch_djui_before(void);
|
extern void patch_djui_before(void);
|
||||||
|
extern void patch_djui_hud_before(void);
|
||||||
patch_mtx_before();
|
patch_mtx_before();
|
||||||
patch_screen_transition_before();
|
patch_screen_transition_before();
|
||||||
patch_title_screen_before();
|
patch_title_screen_before();
|
||||||
|
@ -133,6 +134,7 @@ static void patch_interpolations_before(void) {
|
||||||
patch_bubble_particles_before();
|
patch_bubble_particles_before();
|
||||||
patch_snow_particles_before();
|
patch_snow_particles_before();
|
||||||
patch_djui_before();
|
patch_djui_before();
|
||||||
|
patch_djui_hud_before();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void patch_interpolations(f32 delta) {
|
static inline void patch_interpolations(f32 delta) {
|
||||||
|
@ -145,6 +147,7 @@ static inline void patch_interpolations(f32 delta) {
|
||||||
extern void patch_bubble_particles_interpolated(f32 delta);
|
extern void patch_bubble_particles_interpolated(f32 delta);
|
||||||
extern void patch_snow_particles_interpolated(f32 delta);
|
extern void patch_snow_particles_interpolated(f32 delta);
|
||||||
extern void patch_djui_interpolated(f32 delta);
|
extern void patch_djui_interpolated(f32 delta);
|
||||||
|
extern void patch_djui_hud(f32 delta);
|
||||||
patch_mtx_interpolated(delta);
|
patch_mtx_interpolated(delta);
|
||||||
patch_screen_transition_interpolated(delta);
|
patch_screen_transition_interpolated(delta);
|
||||||
patch_title_screen_interpolated(delta);
|
patch_title_screen_interpolated(delta);
|
||||||
|
@ -154,6 +157,7 @@ static inline void patch_interpolations(f32 delta) {
|
||||||
patch_bubble_particles_interpolated(delta);
|
patch_bubble_particles_interpolated(delta);
|
||||||
patch_snow_particles_interpolated(delta);
|
patch_snow_particles_interpolated(delta);
|
||||||
patch_djui_interpolated(delta);
|
patch_djui_interpolated(delta);
|
||||||
|
patch_djui_hud(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delay_frame(void) {
|
static void delay_frame(void) {
|
||||||
|
|
Loading…
Reference in a new issue