Added xOffset and yOffset to the DjuiFont struct to align the custom hud fonts (#652)

This commit is contained in:
xLuigiGamerx 2025-02-23 00:58:45 +03:00 committed by GitHub
parent e24431928c
commit 935f871930
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 6 deletions

View file

@ -37,6 +37,8 @@ static const struct DjuiFont sDjuiFontNormal = {
.charWidth = 0.5f,
.charHeight = 1.0f,
.lineHeight = 0.8125f,
.xOffset = 0.0f,
.yOffset = 0.0f,
.defaultFontScale = 32.0f,
.textBeginDisplayList = NULL,
.render_char = djui_font_normal_render_char,
@ -77,6 +79,8 @@ static const struct DjuiFont sDjuiFontTitle = {
.charWidth = 1.0f,
.charHeight = 0.9f,
.lineHeight = 0.7f,
.xOffset = 0.0f,
.yOffset = 0.0f,
.defaultFontScale = 64.0f,
.textBeginDisplayList = NULL,
.render_char = djui_font_title_render_char,
@ -136,6 +140,8 @@ static const struct DjuiFont sDjuiFontHud = {
.charWidth = 1.0f,
.charHeight = 0.9f,
.lineHeight = 0.7f,
.xOffset = 0.0f,
.yOffset = 0.0f,
.defaultFontScale = 16.0f,
.textBeginDisplayList = NULL,
.render_char = djui_font_hud_render_char,
@ -175,6 +181,8 @@ static f32 djui_font_aliased_char_width(char* c) {
static const struct DjuiFont sDjuiFontAliased = {
.charWidth = 0.5f,
.charHeight = 1.0f,
.xOffset = 0.0f,
.yOffset = 0.0f,
.lineHeight = 0.8125f,
.defaultFontScale = 32.0f,
.textBeginDisplayList = NULL,
@ -224,6 +232,8 @@ static const struct DjuiFont sDjuiFontCustomHud = {
.charWidth = 1.0f,
.charHeight = 0.9f,
.lineHeight = 0.7f,
.xOffset = -0.25f,
.yOffset = -10.25f,
.defaultFontScale = 32.0f,
.textBeginDisplayList = NULL,
.render_char = djui_font_custom_hud_render_char,
@ -234,6 +244,8 @@ static const struct DjuiFont sDjuiFontCustomHudRecolor = {
.charWidth = 1.0f,
.charHeight = 0.9f,
.lineHeight = 0.7f,
.xOffset = -0.25f,
.yOffset = -10.25f,
.defaultFontScale = 32.0f,
.textBeginDisplayList = NULL,
.render_char = djui_font_custom_hud_recolor_render_char,
@ -274,6 +286,8 @@ static const struct DjuiFont sDjuiFontSpecial = {
.charWidth = 0.5f,
.charHeight = 1.0f,
.lineHeight = 0.8125f,
.xOffset = 0.0f,
.yOffset = 0.0f,
.defaultFontScale = 32.0f,
.textBeginDisplayList = NULL,
.render_char = djui_font_special_render_char,

View file

@ -5,6 +5,8 @@ struct DjuiFont {
f32 charWidth;
f32 charHeight;
f32 lineHeight;
f32 xOffset;
f32 yOffset;
f32 defaultFontScale;
u8 textureBitSize;
const Gfx* textBeginDisplayList;

View file

@ -312,8 +312,8 @@ void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) {
}
// translate position
f32 translatedX = x;
f32 translatedY = y;
f32 translatedX = x + (font->xOffset * scale);
f32 translatedY = y + (font->yOffset * scale);
djui_hud_position_translate(&translatedX, &translatedY);
create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ);
@ -367,8 +367,8 @@ void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY,
Gfx* savedHeadPos = gDisplayListHead;
// translate position
f32 translatedX = x;
f32 translatedY = y;
f32 translatedX = x + (font->xOffset * scale);
f32 translatedY = y + (font->yOffset * scale);
djui_hud_position_translate(&translatedX, &translatedY);
create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ);
@ -403,8 +403,8 @@ void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY,
if (sInterpHudCount >= MAX_INTERP_HUD) { return; }
struct InterpHud* interp = &sInterpHuds[sInterpHudCount++];
interp->headPos = savedHeadPos;
interp->prevX = prevX;
interp->prevY = prevY;
interp->prevX = prevX + (font->xOffset * prevScale);
interp->prevY = prevY + (font->yOffset * prevScale);
interp->prevScaleW = prevScale;
interp->prevScaleH = prevScale;
interp->x = x;