Merge pull request #62 from xLuigiGamerx/dev

Added a custom hud font and a recolorable version and added dynos support to the aliased font
This commit is contained in:
Agent X 2024-01-21 16:29:09 -05:00 committed by GitHub
commit 2f12326ec1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 114 additions and 11 deletions

View file

@ -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

View file

@ -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,
};
//////////////////////////////////////////////////////////

View file

@ -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[];

View file

@ -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),

View file

@ -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 |

View file

@ -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
};

View file

@ -18,6 +18,8 @@ enum DjuiFontType {
FONT_MENU,
FONT_HUD,
FONT_ALIASED,
FONT_CUSTOM_HUD,
FONT_RECOLOR_HUD,
FONT_COUNT,
};

View file

@ -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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

After

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 492 B