Added FONT_SPECIAL (#556)

* Fixed player and mod lists not updating on language change

* Added `FONT_SPECIAL` which is based on the special controls letters in dialog boxes
This commit is contained in:
xLuigiGamerx 2024-12-17 16:58:38 +03:00 committed by GitHub
parent e3c1b20f6b
commit 6757a3abb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 73 additions and 8 deletions

View file

@ -3231,7 +3231,10 @@ FONT_CUSTOM_HUD = 4
FONT_RECOLOR_HUD = 5
--- @type DjuiFontType
FONT_COUNT = 6
FONT_SPECIAL = 6
--- @type DjuiFontType
FONT_COUNT = 7
--- @class HudUtilsFilter

View file

@ -24,7 +24,6 @@ const f32 font_normal_widths[] = {
0.3125f, 0.2500f, 0.3125f, 0.5000f, 0.5000f
};
//////////////////////////////////////////////////////////
ALIGNED8 const u8 texture_font_title[] = {
@ -99,3 +98,26 @@ const f32 font_hud_widths[] = {
};
//////////////////////////////////////////////////////////
ALIGNED8 const u8 texture_font_special[] = {
#include "textures/custom_font/custom_font_special.rgba32.inc.c"
};
const f32 font_special_widths[] = {
/* ! " # $ % & ' ( ) * + , - . / */
0.1875f, 0.3750f, 0.5000f, 0.4375f, 0.4375f, 0.4375f, 0.2500f, 0.3125f, 0.3125f, 0.2500f, 0.4375f, 0.2500f, 0.3750f, 0.2500f, 0.3125f,
/* 0 1 2 3 4 5 6 7 8 9 */
0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f,
/* : ; < = > ? @ */
0.2500f, 0.2500f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.5625f,
/* A B C D E F G H I J K L M N O P Q R S T U V W X Y Z */
0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.5000f, 0.5000f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.5000f, 0.4375f, 0.4375f, 0.4375f,
/* [ \ ] ^ _ ` */
0.3125f, 0.3125f, 0.3125f, 0.3750f, 0.4375f, 0.2500f,
/* a b c d e f g h i j k l m n o p q r s t u v w x y z */
0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.5000f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.4375f, 0.5000f, 0.4375f, 0.4375f, 0.4375f,
/* { | } ~ DEL */
0.3125f, 0.1875f, 0.3125f, 0.4375f, 0.5000f
};
//////////////////////////////////////////////////////////

View file

@ -1543,6 +1543,7 @@ extern ALIGNED8 const Texture texture_font_aliased[];
extern ALIGNED8 const Texture texture_font_title[];
extern ALIGNED8 const Texture texture_font_hud[];
extern ALIGNED8 const Texture texture_font_hud_recolor[];
extern ALIGNED8 const Texture texture_font_special[];
extern ALIGNED8 const Texture texture_selectionbox_back_icon[];
extern ALIGNED8 const Texture texture_selectionbox_forward_icon[];
extern ALIGNED8 const Texture texture_coopdx_logo[];

View file

@ -1144,6 +1144,9 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = {
define_builtin_tex(texture_font_title, "textures/custom_font/custom_font_title.rgba32.png", 1024, 512, 32),
define_builtin_tex(texture_font_hud, "textures/custom_font/custom_font_normal.rgba32.png", 512, 512, 32),
define_builtin_tex(texture_font_hud_recolor, "textures/custom_font/custom_font_aliased.rgba32.png", 512, 512, 32),
define_builtin_tex(texture_font_special, "textures/custom_font/custom_font_special.rgba32.png", 512, 512, 32),
// Logo
define_builtin_tex(texture_selectionbox_back_icon, "textures/segment2/custom_selectionbox_back_icon.rgba16.png", 16, 16, 16),
define_builtin_tex(texture_selectionbox_forward_icon, "textures/segment2/custom_selectionbox_forward_icon.rgba16.png", 16, 16, 16),
define_builtin_tex(texture_coopdx_logo, "textures/segment2/custom_coopdx_logo.rgba32.png", 2048, 1024, 32),

View file

@ -1114,7 +1114,8 @@
| FONT_ALIASED | 3 |
| FONT_CUSTOM_HUD | 4 |
| FONT_RECOLOR_HUD | 5 |
| FONT_COUNT | 6 |
| FONT_SPECIAL | 6 |
| FONT_COUNT | 7 |
### [enum HudUtilsFilter](#HudUtilsFilter)
| Identifier | Value |

View file

@ -224,6 +224,38 @@ static const struct DjuiFont sDjuiFontCustomHudRecolor = {
.char_width = djui_font_custom_hud_char_width,
};
///////////////////////////
// font 6 (special font) //
///////////////////////////
static void djui_font_special_render_char(char* c) {
// replace undisplayable characters
if (*c == ' ') { return; }
u32 index = djui_unicode_get_sprite_index(c);
u32 tx = index % 32;
u32 ty = index / 32;
extern ALIGNED8 const u8 texture_font_special[];
djui_gfx_render_texture_tile(texture_font_special, 256, 128, 32, tx * 8, ty * 16, 8, 16, false);
}
static f32 djui_font_special_char_width(char* c) {
if (*c == ' ') { return 0.5f; }
extern const f32 font_special_widths[];
return djui_unicode_get_sprite_width(c, font_special_widths, 32.0f);
}
static const struct DjuiFont sDjuiFontSpecial = {
.charWidth = 0.5f,
.charHeight = 1.0f,
.lineHeight = 0.8125f,
.defaultFontScale = 32.0f,
.textBeginDisplayList = NULL,
.render_char = djui_font_special_render_char,
.char_width = djui_font_special_char_width,
};
///////////////
// font list //
///////////////
@ -234,5 +266,6 @@ const struct DjuiFont* gDjuiFonts[] = {
&sDjuiFontHud,
&sDjuiFontAliased,
&sDjuiFontCustomHud,
&sDjuiFontCustomHudRecolor
&sDjuiFontCustomHudRecolor,
&sDjuiFontSpecial
};

View file

@ -20,6 +20,7 @@ enum DjuiFontType {
FONT_ALIASED,
FONT_CUSTOM_HUD,
FONT_RECOLOR_HUD,
FONT_SPECIAL,
FONT_COUNT,
};

View file

@ -1252,7 +1252,8 @@ char gSmluaConstants[] = ""
"FONT_ALIASED = 3\n"
"FONT_CUSTOM_HUD = 4\n"
"FONT_RECOLOR_HUD = 5\n"
"FONT_COUNT = 6\n"
"FONT_SPECIAL = 6\n"
"FONT_COUNT = 7\n"
"DJUI_RAINBOW_COLOR_RED = 0\n"
"DJUI_RAINBOW_COLOR_GREEN = 1\n"
"DJUI_RAINBOW_COLOR_BLUE = 2\n"

View file

@ -60,7 +60,7 @@ void nametags_render(void) {
}
djui_hud_set_resolution(RESOLUTION_N64);
djui_hud_set_font(FONT_NORMAL);
djui_hud_set_font(FONT_SPECIAL);
for (u8 i = gNametagsSettings.showSelfTag ? 0 : 1; i < MAX_PLAYERS; i++) {
struct MarioState* m = &gMarioStates[i];

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB