From 192d47aea09c25d335976891279d4deb5f569590 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 2 Apr 2023 23:02:14 -0700 Subject: [PATCH] Added FONT_TINY --- autogen/lua_definitions/constants.lua | 5 ++- autogen/lua_definitions/functions.lua | 11 +++++ autogen/lua_definitions/structs.lua | 1 + bin/custom_font.c | 23 +++++++++++ data/dynos_mgr_builtin_tex.cpp | 2 + docs/lua/constants.md | 3 +- docs/lua/functions-3.md | 38 ++++++++++++++++++ docs/lua/functions.md | 2 + docs/lua/structs.md | 1 + src/pc/djui/djui_font.c | 33 +++++++++++++++ src/pc/djui/djui_hud_utils.h | 1 + src/pc/lua/smlua_cobject_autogen.c | 3 +- src/pc/lua/smlua_constants_autogen.c | 3 +- src/pc/lua/smlua_functions_autogen.c | 34 ++++++++++++++++ .../custom_font/custom_font_tiny.rgba32.png | Bin 0 -> 3868 bytes 15 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 textures/custom_font/custom_font_tiny.rgba32.png diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 469d5893..84078962 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -3250,7 +3250,10 @@ FONT_MENU = 1 FONT_HUD = 2 --- @type DjuiFontType -FONT_COUNT = 3 +FONT_TINY = 3 + +--- @type DjuiFontType +FONT_COUNT = 4 --- @class HudUtilsResolution diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 1465c5c9..bf1d15bd 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -5614,6 +5614,17 @@ function network_player_from_global_index(globalIndex) -- ... end +--- @return nil +function network_player_local_restore_lag_state() + -- ... +end + +--- @param otherNp NetworkPlayer +--- @return nil +function network_player_local_set_lag_state(otherNp) + -- ... +end + --- @param np NetworkPlayer --- @param part PlayerParts --- @param out Color diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 2b459602..694dbd5f 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -709,6 +709,7 @@ --- @field public angleVel Vec3s --- @field public animation MarioAnimation --- @field public area Area +--- @field public bounceSquishTimer integer --- @field public bubbleObj Object --- @field public cap integer --- @field public capTimer integer diff --git a/bin/custom_font.c b/bin/custom_font.c index c4e05876..8748fca3 100644 --- a/bin/custom_font.c +++ b/bin/custom_font.c @@ -49,6 +49,29 @@ const f32 font_title_widths[] = { ////////////////////////////////////////////////////////// +ALIGNED8 const u8 texture_font_tiny[] = { +#include "textures/custom_font/custom_font_tiny.rgba32.inc.c" +}; + +const f32 font_tiny_widths[] = { +/* ! " # $ % & ' ( ) * + , - . / */ + 0.3125f, 0.3750f, 0.4375f, 0.3750f, 0.4375f, 0.5000f, 0.2500f, 0.3125f, 0.3125f, 0.3750f, 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.3125f, 0.3750f, 0.3125f, 0.4375f, 0.5750f, +/* 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.3125f, 0.3750f, 0.3750f, 0.3125f, 0.5000f, 0.5000f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3750f, 0.3125f, 0.3750f, 0.3750f, 0.5000f, 0.4375f, 0.3750f, 0.3750f, +/* [ \ ] ^ _ ` */ + 0.3125f, 0.3125f, 0.3125f, 0.3750f, 0.3750f, 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.3750f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.2500f, 0.3125f, 0.3125f, 0.1875f, 0.4375f, 0.3125f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.3125f, 0.3125f, 0.3125f, 0.3125f, 0.4375f, 0.4375f, 0.3125f, 0.3125f, +/* { | } ~ DEL */ + 0.3125f, 0.2500f, 0.3125f, 0.5000f, 0.5000f +}; + +////////////////////////////////////////////////////////// + ALIGNED8 u8 texture_selectionbox_icon[] = { #include "textures/segment2/custom_selectionbox_icon.rgba16.inc.c" }; diff --git a/data/dynos_mgr_builtin_tex.cpp b/data/dynos_mgr_builtin_tex.cpp index 8d33dfbe..b804e894 100644 --- a/data/dynos_mgr_builtin_tex.cpp +++ b/data/dynos_mgr_builtin_tex.cpp @@ -10,6 +10,7 @@ extern "C" { extern ALIGNED8 const u8 texture_font_normal[]; extern ALIGNED8 const u8 texture_font_title[]; +extern ALIGNED8 const u8 texture_font_tiny[]; #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 } @@ -1693,6 +1694,7 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = { // Fonts define_builtin_tex(texture_font_normal, "textures/custom_font/custom_font_normal.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_tiny, "textures/custom_font/custom_font_tiny.rgba32.png", 256, 128, 32), }; const Texture* DynOS_Builtin_Tex_GetFromName(const char* aDataName) { diff --git a/docs/lua/constants.md b/docs/lua/constants.md index ee22998f..839127cf 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1089,7 +1089,8 @@ | FONT_NORMAL | 0 | | FONT_MENU | 1 | | FONT_HUD | 2 | -| FONT_COUNT | 3 | +| FONT_TINY | 3 | +| FONT_COUNT | 4 | ### [enum HudUtilsResolution](#HudUtilsResolution) | Identifier | Value | diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index 7b86c458..d4a98321 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -8186,6 +8186,44 @@
+## [network_player_local_restore_lag_state](#network_player_local_restore_lag_state) + +### Lua Example +`network_player_local_restore_lag_state()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void network_player_local_restore_lag_state(void);` + +[:arrow_up_small:](#) + +
+ +## [network_player_local_set_lag_state](#network_player_local_set_lag_state) + +### Lua Example +`network_player_local_set_lag_state(otherNp)` + +### Parameters +| Field | Type | +| ----- | ---- | +| otherNp | [NetworkPlayer](structs.md#NetworkPlayer) | + +### Returns +- None + +### C Prototype +`void network_player_local_set_lag_state(struct NetworkPlayer* otherNp);` + +[:arrow_up_small:](#) + +
+ ## [network_player_palette_to_color](#network_player_palette_to_color) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 13868490..6e32ac9f 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1085,6 +1085,8 @@ - [network_player_color_to_palette](functions-3.md#network_player_color_to_palette) - [network_player_connected_count](functions-3.md#network_player_connected_count) - [network_player_from_global_index](functions-3.md#network_player_from_global_index) + - [network_player_local_restore_lag_state](functions-3.md#network_player_local_restore_lag_state) + - [network_player_local_set_lag_state](functions-3.md#network_player_local_set_lag_state) - [network_player_palette_to_color](functions-3.md#network_player_palette_to_color) - [network_player_set_description](functions-3.md#network_player_set_description) diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 828074fe..6f77e822 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -1035,6 +1035,7 @@ | angleVel | [Vec3s](structs.md#Vec3s) | read-only | | animation | [MarioAnimation](structs.md#MarioAnimation) | | | area | [Area](structs.md#Area) | | +| bounceSquishTimer | `integer` | | | bubbleObj | [Object](structs.md#Object) | | | cap | `integer` | | | capTimer | `integer` | | diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index bc96207b..cb9a0cd4 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -126,6 +126,38 @@ static const struct DjuiFont sDjuiFontHud = { .char_width = djui_font_hud_char_width, }; + ///////////////////////////////// + // font 4 (built-in tiny font) // +///////////////////////////////// + +static void djui_font_tiny_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_tiny[]; + djui_gfx_render_texture_tile(texture_font_tiny, 256, 128, 32, tx * 8, ty * 16, 8, 16); +} + +static f32 djui_font_tiny_char_width(char* c) { + if (*c == ' ') { return 0.30f; } + extern const f32 font_tiny_widths[]; + return djui_unicode_get_sprite_width(c, font_tiny_widths); +} + +static const struct DjuiFont sDjuiFontTiny = { + .charWidth = 0.5f, + .charHeight = 1.0f, + .lineHeight = 0.8125f, + .defaultFontScale = 16.0f, + .textBeginDisplayList = NULL, + .render_char = djui_font_tiny_render_char, + .char_width = djui_font_tiny_char_width, +}; + /////////////// // font list // /////////////// @@ -134,4 +166,5 @@ const struct DjuiFont* gDjuiFonts[] = { &sDjuiFontNormal, &sDjuiFontTitle, &sDjuiFontHud, + &sDjuiFontTiny, }; \ 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 a82cbec9..9b73a4da 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -11,6 +11,7 @@ enum DjuiFontType { FONT_NORMAL, FONT_MENU, FONT_HUD, + FONT_TINY, FONT_COUNT, }; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index ff015aab..bc121b77 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -811,7 +811,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO { "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE }, }; -#define LUA_MARIO_STATE_FIELD_COUNT 77 +#define LUA_MARIO_STATE_FIELD_COUNT 78 static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { { "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE }, { "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE }, @@ -820,6 +820,7 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { { "angleVel", LVT_COBJECT, offsetof(struct MarioState, angleVel), true, LOT_VEC3S }, { "animation", LVT_COBJECT_P, offsetof(struct MarioState, animation), false, LOT_MARIOANIMATION }, { "area", LVT_COBJECT_P, offsetof(struct MarioState, area), false, LOT_AREA }, + { "bounceSquishTimer", LVT_U8, offsetof(struct MarioState, bounceSquishTimer), false, LOT_NONE }, { "bubbleObj", LVT_COBJECT_P, offsetof(struct MarioState, bubbleObj), false, LOT_OBJECT }, { "cap", LVT_U32, offsetof(struct MarioState, cap), false, LOT_NONE }, { "capTimer", LVT_U16, offsetof(struct MarioState, capTimer), false, LOT_NONE }, diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index f2dd71f4..bf6469a6 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1277,7 +1277,8 @@ char gSmluaConstants[] = "" "FONT_NORMAL = 0\n" "FONT_MENU = 1\n" "FONT_HUD = 2\n" -"FONT_COUNT = 3\n" +"FONT_TINY = 3\n" +"FONT_COUNT = 4\n" "ENVFX_MODE_NONE = 0\n" "ENVFX_SNOW_NORMAL = 1\n" "ENVFX_SNOW_WATER = 2\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 97f445e8..8a3b549a 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -18659,6 +18659,38 @@ int smlua_func_network_player_from_global_index(lua_State* L) { return 1; } +int smlua_func_network_player_local_restore_lag_state(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_local_restore_lag_state", 0, top); + return 0; + } + + + network_player_local_restore_lag_state(); + + return 1; +} + +int smlua_func_network_player_local_set_lag_state(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_local_set_lag_state", 1, top); + return 0; + } + + struct NetworkPlayer* otherNp = (struct NetworkPlayer*)smlua_to_cobject(L, 1, LOT_NETWORKPLAYER); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_local_set_lag_state"); return 0; } + + network_player_local_set_lag_state(otherNp); + + return 1; +} + int smlua_func_network_player_palette_to_color(lua_State* L) { if (L == NULL) { return 0; } @@ -30142,6 +30174,8 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "network_player_color_to_palette", smlua_func_network_player_color_to_palette); smlua_bind_function(L, "network_player_connected_count", smlua_func_network_player_connected_count); smlua_bind_function(L, "network_player_from_global_index", smlua_func_network_player_from_global_index); + smlua_bind_function(L, "network_player_local_restore_lag_state", smlua_func_network_player_local_restore_lag_state); + smlua_bind_function(L, "network_player_local_set_lag_state", smlua_func_network_player_local_set_lag_state); smlua_bind_function(L, "network_player_palette_to_color", smlua_func_network_player_palette_to_color); smlua_bind_function(L, "network_player_set_description", smlua_func_network_player_set_description); diff --git a/textures/custom_font/custom_font_tiny.rgba32.png b/textures/custom_font/custom_font_tiny.rgba32.png new file mode 100644 index 0000000000000000000000000000000000000000..43e8a70f7a0d1469f18640c143e92241144295ee GIT binary patch literal 3868 zcmeHK`8N~}_Z~u)ER(X!E)`+MmWi>AQG^zIOd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