Added FONT_TINY

This commit is contained in:
MysterD 2023-04-02 23:02:14 -07:00
parent dcd1bc7aa8
commit 192d47aea0
15 changed files with 156 additions and 4 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8186,6 +8186,44 @@
<br />
## [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:](#)
<br />
## [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:](#)
<br />
## [network_player_palette_to_color](#network_player_palette_to_color)
### Lua Example

View file

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

View file

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

View file

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

View file

@ -11,6 +11,7 @@ enum DjuiFontType {
FONT_NORMAL,
FONT_MENU,
FONT_HUD,
FONT_TINY,
FONT_COUNT,
};

View file

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

View file

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

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB