diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 5f606259..fa65f8ab 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -3478,7 +3478,13 @@ FONT_HUD = 2 FONT_ALIASED = 3 --- @type DjuiFontType -FONT_COUNT = 4 +FONT_CUSTOM_HUD = 4 + +--- @type DjuiFontType +FONT_RECOLOR_HUD = 5 + +--- @type DjuiFontType +FONT_COUNT = 6 --- @class HudUtilsFilter diff --git a/bin/custom_font.c b/bin/custom_font.c index f4e2afce..70661b17 100644 --- a/bin/custom_font.c +++ b/bin/custom_font.c @@ -72,3 +72,30 @@ const f32 font_aliased_widths[] = { }; ////////////////////////////////////////////////////////// + +ALIGNED8 const u8 texture_font_hud[] = { +#include "textures/custom_font/custom_font_hud.rgba32.inc.c" +}; + +ALIGNED8 const u8 texture_font_hud_recolor[] = { +#include "textures/custom_font/custom_font_hud_recolor.rgba32.inc.c" +}; + +const f32 font_hud_widths[] = { +/* ! " # $ % & ' ( ) * + , - . / */ + 0.2596f, 0.2596f, 0.4615f, 0.3750f, 0.3750f, 0.3750f, 0.1442f, 0.2596f, 0.2596f, 0.3750f, 0.3750f, 0.1442f, 0.3750f, 0.1153f, 0.3750f, +/* 0 1 2 3 4 5 6 7 8 9 */ + 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, +/* : ; < = > ? @ */ + 0.1442f, 0.1442f, 0.2307f, 0.3750f, 0.2307f, 0.4615f, 0.4615f, +/* 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.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, +/* [ \ ] ^ _ ` */ + 0.2596f, 0.3750f, 0.2596f, 0.2019f, 0.4615f, 0.1730f, +/* 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.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, +/* { | } ~ DEL */ + 0.2596f, 0.2884f, 0.2596f, 0.4615f, 0.4615f, +}; + +////////////////////////////////////////////////////////// diff --git a/data/dynos_mgr_builtin_externs.h b/data/dynos_mgr_builtin_externs.h index 9c56057a..123828de 100644 --- a/data/dynos_mgr_builtin_externs.h +++ b/data/dynos_mgr_builtin_externs.h @@ -1537,6 +1537,12 @@ extern ALIGNED8 const Texture texture_menu_kurs_upper[]; extern ALIGNED8 const Texture texture_menu_course_lower[]; extern ALIGNED8 const Texture texture_menu_course_upper[]; extern ALIGNED8 const Texture texture_menu_course_lower[]; +extern ALIGNED8 const Texture texture_font_normal[]; +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_coopdx_logo[]; extern ALIGNED8 const Texture pss_seg7_texture_07000000[]; extern ALIGNED8 const Texture pss_seg7_texture_07000800[]; extern ALIGNED8 const Texture pss_seg7_texture_07001000[]; diff --git a/data/dynos_mgr_builtin_tex.cpp b/data/dynos_mgr_builtin_tex.cpp index 17dc3850..871d69c4 100644 --- a/data/dynos_mgr_builtin_tex.cpp +++ b/data/dynos_mgr_builtin_tex.cpp @@ -8,11 +8,6 @@ extern "C" { // Textures // ////////////// -extern ALIGNED8 const Texture texture_font_normal[]; -extern ALIGNED8 const Texture texture_font_title[]; - -extern ALIGNED8 const Texture texture_coopdx_logo[]; - #define define_builtin_tex(_ptr, _path, _width, _height, _bitSize) { (const char*)#_ptr, (const void*)_ptr, (const char*)_path, _width, _height, _bitSize } #define define_builtin_tex_(_ptr, _path, _width, _height, _bitSize) { (const char*)#_ptr "_", (const void*)_ptr, (const char*)_path, _width, _height, _bitSize } @@ -1152,7 +1147,10 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = { // Fonts define_builtin_tex(texture_font_normal, "textures/custom_font/custom_font_normal.rgba32.png", 256, 128, 32), + define_builtin_tex(texture_font_aliased, "textures/custom_font/custom_font_aliased.rgba32.png", 512, 256, 32), 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), // Logo define_builtin_tex(texture_coopdx_logo, "textures/segment2/custom_coopdx_logo.rgba32.png", 2048, 1024, 32), diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 0b66f08a..47d3ea0a 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1170,7 +1170,9 @@ | FONT_MENU | 1 | | FONT_HUD | 2 | | FONT_ALIASED | 3 | -| FONT_COUNT | 4 | +| FONT_CUSTOM_HUD | 4 | +| FONT_RECOLOR_HUD | 5 | +| FONT_COUNT | 6 | ### [enum HudUtilsFilter](#HudUtilsFilter) | Identifier | Value | diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index c67e954a..f5138d6b 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -75,7 +75,7 @@ static const struct DjuiFont sDjuiFontTitle = { }; /////////////////////// - // font 3 (hud font) // + // font 2 (hud font) // /////////////////////// static u8 djui_font_hud_index(char c) { @@ -134,7 +134,7 @@ static const struct DjuiFont sDjuiFontHud = { }; //////////////////////////////// - // font 5 (DJ's aliased font) // + // font 3 (DJ's aliased font) // //////////////////////////////// static void djui_font_aliased_render_char(char* c) { @@ -165,6 +165,64 @@ static const struct DjuiFont sDjuiFontAliased = { .char_width = djui_font_aliased_char_width, }; + //////////////////////////////////////// + // font 4/5 (custom hud font/recolor) // +//////////////////////////////////////// + +static void djui_font_custom_hud_render_char(char* c) { + // replace undisplayable characters + if (*c == ' ') { return; } + + u32 index = djui_unicode_get_sprite_index(c); + + u32 tx = index % 16; + u32 ty = index / 16; + + extern ALIGNED8 const u8 texture_font_hud[]; + djui_gfx_render_texture_tile(texture_font_hud, 512, 512, 32, tx * 32, ty * 32, 32, 32, false); +} + +static void djui_font_custom_hud_recolor_render_char(char* c) { + // replace undisplayable characters + if (*c == ' ') { return; } + + u32 index = djui_unicode_get_sprite_index(c); + + u32 tx = index % 16; + u32 ty = index / 16; + + extern ALIGNED8 const u8 texture_font_hud_recolor[]; + djui_gfx_render_texture_tile(texture_font_hud_recolor, 512, 512, 32, tx * 32, ty * 32, 32, 32, false); +} + +static f32 djui_font_custom_hud_char_width(char* text) { + char c = *text; + if (c == ' ') { return 0.3750f; } + c = djui_unicode_get_base_char(text); + extern const f32 font_hud_widths[]; + return font_hud_widths[(u8)c - '!']; +} + +static const struct DjuiFont sDjuiFontCustomHud = { + .charWidth = 1.0f, + .charHeight = 0.9f, + .lineHeight = 0.7f, + .defaultFontScale = 32.0f, + .textBeginDisplayList = NULL, + .render_char = djui_font_custom_hud_render_char, + .char_width = djui_font_custom_hud_char_width, +}; + +static const struct DjuiFont sDjuiFontCustomHudRecolor = { + .charWidth = 1.0f, + .charHeight = 0.9f, + .lineHeight = 0.7f, + .defaultFontScale = 32.0f, + .textBeginDisplayList = NULL, + .render_char = djui_font_custom_hud_recolor_render_char, + .char_width = djui_font_custom_hud_char_width, +}; + /////////////// // font list // /////////////// @@ -173,5 +231,7 @@ const struct DjuiFont* gDjuiFonts[] = { &sDjuiFontNormal, &sDjuiFontTitle, &sDjuiFontHud, - &sDjuiFontAliased + &sDjuiFontAliased, + &sDjuiFontCustomHud, + &sDjuiFontCustomHudRecolor }; \ No newline at end of file diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h index 9db32aa1..91e8b07f 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -18,6 +18,8 @@ enum DjuiFontType { FONT_MENU, FONT_HUD, FONT_ALIASED, + FONT_CUSTOM_HUD, + FONT_RECOLOR_HUD, FONT_COUNT, }; diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 9f80144e..bccfe77e 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1382,7 +1382,9 @@ char gSmluaConstants[] = "" "FONT_MENU = 1\n" "FONT_HUD = 2\n" "FONT_ALIASED = 3\n" -"FONT_COUNT = 4\n" +"FONT_CUSTOM_HUD = 4\n" +"FONT_RECOLOR_HUD = 5\n" +"FONT_COUNT = 6\n" "ENVFX_MODE_NONE = 0\n" "ENVFX_SNOW_NORMAL = 1\n" "ENVFX_SNOW_WATER = 2\n" diff --git a/textures/custom_font/custom_font_hud.rgba32.png b/textures/custom_font/custom_font_hud.rgba32.png new file mode 100644 index 00000000..8efb3236 Binary files /dev/null and b/textures/custom_font/custom_font_hud.rgba32.png differ diff --git a/textures/custom_font/custom_font_hud_recolor.rgba32.png b/textures/custom_font/custom_font_hud_recolor.rgba32.png new file mode 100644 index 00000000..c8fcf0ca Binary files /dev/null and b/textures/custom_font/custom_font_hud_recolor.rgba32.png differ diff --git a/textures/segment2/custom_hud_comma.rgba16.png b/textures/segment2/custom_hud_comma.rgba16.png index 9c7e0f07..5563a51c 100644 Binary files a/textures/segment2/custom_hud_comma.rgba16.png and b/textures/segment2/custom_hud_comma.rgba16.png differ diff --git a/textures/segment2/custom_hud_exclamation.rgba16.png b/textures/segment2/custom_hud_exclamation.rgba16.png index 6aafcc72..993fcae1 100644 Binary files a/textures/segment2/custom_hud_exclamation.rgba16.png and b/textures/segment2/custom_hud_exclamation.rgba16.png differ diff --git a/textures/segment2/custom_hud_plus.rgba16.png b/textures/segment2/custom_hud_plus.rgba16.png index 598198ad..e90ce888 100644 Binary files a/textures/segment2/custom_hud_plus.rgba16.png and b/textures/segment2/custom_hud_plus.rgba16.png differ diff --git a/textures/segment2/custom_hud_q.rgba16.png b/textures/segment2/custom_hud_q.rgba16.png index fb15e2fa..0c3767da 100644 Binary files a/textures/segment2/custom_hud_q.rgba16.png and b/textures/segment2/custom_hud_q.rgba16.png differ diff --git a/textures/segment2/custom_hud_v.rgba16.png b/textures/segment2/custom_hud_v.rgba16.png index 8137f091..6a41244e 100644 Binary files a/textures/segment2/custom_hud_v.rgba16.png and b/textures/segment2/custom_hud_v.rgba16.png differ diff --git a/textures/segment2/custom_hud_x.rgba16.png b/textures/segment2/custom_hud_x.rgba16.png index e02b2b06..03ba903d 100644 Binary files a/textures/segment2/custom_hud_x.rgba16.png and b/textures/segment2/custom_hud_x.rgba16.png differ diff --git a/textures/segment2/custom_hud_z.rgba16.png b/textures/segment2/custom_hud_z.rgba16.png index 2b3197fb..be1cc01f 100644 Binary files a/textures/segment2/custom_hud_z.rgba16.png and b/textures/segment2/custom_hud_z.rgba16.png differ