mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
Remove FONT_TINY and introduce legacy compatibility for it
This commit is contained in:
parent
8f2288c88a
commit
bf9c9d5e75
10 changed files with 60 additions and 35 deletions
|
@ -1,5 +1,9 @@
|
|||
math.randomseed(get_time())
|
||||
|
||||
--------------
|
||||
-- CObjects --
|
||||
--------------
|
||||
|
||||
_CObjectPool = {}
|
||||
|
||||
_CObject = {
|
||||
|
@ -88,6 +92,10 @@ _ReadOnlyTable = {
|
|||
end
|
||||
}
|
||||
|
||||
--------------------
|
||||
-- math functions --
|
||||
--------------------
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param src Vec3f
|
||||
--- @return Vec3f
|
||||
|
@ -382,4 +390,9 @@ COURSE_MAX = 25
|
|||
--- @type integer
|
||||
COURSE_COUNT = 25
|
||||
--- @type integer
|
||||
COURSE_MIN = 1
|
||||
COURSE_MIN = 1
|
||||
|
||||
-----------------
|
||||
-- legacy font --
|
||||
-----------------
|
||||
FONT_TINY = -1
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
math.randomseed(get_time())
|
||||
|
||||
--------------
|
||||
-- CObjects --
|
||||
--------------
|
||||
|
||||
_CObjectPool = {}
|
||||
|
||||
_CObject = {
|
||||
|
@ -90,6 +94,10 @@ _ReadOnlyTable = {
|
|||
end
|
||||
}
|
||||
|
||||
--------------------
|
||||
-- math functions --
|
||||
--------------------
|
||||
|
||||
--- @param dest Vec3f
|
||||
--- @param src Vec3f
|
||||
--- @return Vec3f
|
||||
|
@ -386,6 +394,11 @@ COURSE_COUNT = 25
|
|||
--- @type integer
|
||||
COURSE_MIN = 1
|
||||
|
||||
-----------------
|
||||
-- legacy font --
|
||||
-----------------
|
||||
FONT_TINY = -1
|
||||
|
||||
--- @type integer
|
||||
INSTANT_WARP_INDEX_START = 0x00
|
||||
|
||||
|
@ -3462,13 +3475,10 @@ FONT_MENU = 1
|
|||
FONT_HUD = 2
|
||||
|
||||
--- @type DjuiFontType
|
||||
FONT_TINY = 3
|
||||
FONT_ALIASED = 3
|
||||
|
||||
--- @type DjuiFontType
|
||||
FONT_ALIASED = 4
|
||||
|
||||
--- @type DjuiFontType
|
||||
FONT_COUNT = 5
|
||||
FONT_COUNT = 4
|
||||
|
||||
--- @class HudUtilsFilter
|
||||
|
||||
|
|
|
@ -3764,7 +3764,7 @@ function djui_hud_set_filter(filterType)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param fontType DjuiFontType
|
||||
--- @param fontType integer
|
||||
--- @return nil
|
||||
function djui_hud_set_font(fontType)
|
||||
-- ...
|
||||
|
|
|
@ -1169,9 +1169,8 @@
|
|||
| FONT_NORMAL | 0 |
|
||||
| FONT_MENU | 1 |
|
||||
| FONT_HUD | 2 |
|
||||
| FONT_TINY | 3 |
|
||||
| FONT_ALIASED | 4 |
|
||||
| FONT_COUNT | 5 |
|
||||
| FONT_ALIASED | 3 |
|
||||
| FONT_COUNT | 4 |
|
||||
|
||||
### [enum HudUtilsFilter](#HudUtilsFilter)
|
||||
| Identifier | Value |
|
||||
|
|
|
@ -2502,13 +2502,13 @@
|
|||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| fontType | [enum DjuiFontType](constants.md#enum-DjuiFontType) |
|
||||
| fontType | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void djui_hud_set_font(enum DjuiFontType fontType);`
|
||||
`void djui_hud_set_font(s8 fontType);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -133,20 +133,6 @@ static const struct DjuiFont sDjuiFontHud = {
|
|||
.char_width = djui_font_hud_char_width,
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
// font 4 (legacy tiny font) //
|
||||
///////////////////////////////
|
||||
|
||||
static const struct DjuiFont sDjuiFontTiny = {
|
||||
.charWidth = 0.5f,
|
||||
.charHeight = 1.0f,
|
||||
.lineHeight = 0.8125f,
|
||||
.defaultFontScale = 16.0f,
|
||||
.textBeginDisplayList = NULL,
|
||||
.render_char = djui_font_normal_render_char,
|
||||
.char_width = djui_font_normal_char_width,
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
// font 5 (DJ's aliased font) //
|
||||
////////////////////////////////
|
||||
|
@ -187,6 +173,5 @@ const struct DjuiFont* gDjuiFonts[] = {
|
|||
&sDjuiFontNormal,
|
||||
&sDjuiFontTitle,
|
||||
&sDjuiFontHud,
|
||||
&sDjuiFontTiny,
|
||||
&sDjuiFontAliased
|
||||
};
|
|
@ -30,6 +30,7 @@ static enum DjuiFontType sFont = FONT_NORMAL;
|
|||
static struct HudUtilsRotation sRotation = { 0, 0, 0 };
|
||||
static struct DjuiColor sColor = { 255, 255, 255, 255 };
|
||||
static struct DjuiColor sRefColor = { 255, 255, 255, 255 };
|
||||
static bool sLegacy = false;
|
||||
|
||||
f32 gDjuiHudUtilsZ = 0;
|
||||
u8 gDjuiHudLockMouse = false;
|
||||
|
@ -168,8 +169,10 @@ u8 djui_hud_get_font(void) {
|
|||
return sFont;
|
||||
}
|
||||
|
||||
void djui_hud_set_font(enum DjuiFontType fontType) {
|
||||
void djui_hud_set_font(s8 fontType) {
|
||||
if (fontType >= FONT_COUNT) { return; }
|
||||
sLegacy = fontType == -1;
|
||||
if (sLegacy) { fontType = 0; }
|
||||
sFont = fontType;
|
||||
}
|
||||
|
||||
|
@ -270,7 +273,7 @@ f32 djui_hud_measure_text(const char* message) {
|
|||
f32 width = 0;
|
||||
const char* c = message;
|
||||
while(*c != '\0') {
|
||||
width += font->char_width((char*)c);
|
||||
width += font->char_width((char*)c) * (sLegacy ? 0.5f : 1.0f);
|
||||
c = djui_unicode_next_char((char*)c);
|
||||
}
|
||||
return width * font->defaultFontScale;
|
||||
|
@ -280,6 +283,8 @@ void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) {
|
|||
if (message == NULL) { return; }
|
||||
gDjuiHudUtilsZ += 0.01f;
|
||||
|
||||
if (sLegacy) { scale *= 0.5f; }
|
||||
|
||||
const struct DjuiFont* font = gDjuiFonts[sFont];
|
||||
f32 fontScale = font->defaultFontScale * scale;
|
||||
|
||||
|
@ -328,6 +333,11 @@ void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY,
|
|||
f32 savedZ = gDjuiHudUtilsZ;
|
||||
gDjuiHudUtilsZ += 0.01f;
|
||||
|
||||
if (sLegacy) {
|
||||
prevScale *= 0.5f;
|
||||
scale *= 0.5f;
|
||||
}
|
||||
|
||||
const struct DjuiFont* font = gDjuiFonts[sFont];
|
||||
f32 fontScale = font->defaultFontScale * scale;
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ enum DjuiFontType {
|
|||
FONT_NORMAL,
|
||||
FONT_MENU,
|
||||
FONT_HUD,
|
||||
FONT_TINY,
|
||||
FONT_ALIASED,
|
||||
FONT_COUNT,
|
||||
};
|
||||
|
@ -54,7 +53,7 @@ void djui_hud_set_resolution(enum HudUtilsResolution resolutionType);
|
|||
u8 djui_hud_get_filter(void);
|
||||
void djui_hud_set_filter(enum HudUtilsFilter filterType);
|
||||
u8 djui_hud_get_font(void);
|
||||
void djui_hud_set_font(enum DjuiFontType fontType);
|
||||
void djui_hud_set_font(s8 fontType);
|
||||
struct DjuiColor* djui_hud_get_color(void);
|
||||
void djui_hud_set_color(u8 r, u8 g, u8 b, u8 a);
|
||||
void djui_hud_reset_color(void);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
char gSmluaConstants[] = ""
|
||||
"math.randomseed(get_time())\n"
|
||||
"--------------\n"
|
||||
"-- CObjects --\n"
|
||||
"--------------\n"
|
||||
"_CObjectPool = {}\n"
|
||||
"_CObject = {\n"
|
||||
" __index = function (t,k)\n"
|
||||
|
@ -76,6 +79,9 @@ char gSmluaConstants[] = ""
|
|||
" __newindex = function (t,k,v)\n"
|
||||
" end\n"
|
||||
"}\n"
|
||||
"--------------------\n"
|
||||
"-- math functions --\n"
|
||||
"--------------------\n"
|
||||
"--- @param dest Vec3f\n"
|
||||
"--- @param src Vec3f\n"
|
||||
"--- @return Vec3f\n"
|
||||
|
@ -346,6 +352,10 @@ char gSmluaConstants[] = ""
|
|||
"COURSE_COUNT = 25\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_MIN = 1\n"
|
||||
"-----------------\n"
|
||||
"-- legacy font --\n"
|
||||
"-----------------\n"
|
||||
"FONT_TINY = -1\n"
|
||||
"INSTANT_WARP_INDEX_START = 0x00\n"
|
||||
"INSTANT_WARP_INDEX_STOP = 0x04\n"
|
||||
"MAX_AREAS = 16\n"
|
||||
|
@ -1371,9 +1381,8 @@ char gSmluaConstants[] = ""
|
|||
"FONT_NORMAL = 0\n"
|
||||
"FONT_MENU = 1\n"
|
||||
"FONT_HUD = 2\n"
|
||||
"FONT_TINY = 3\n"
|
||||
"FONT_ALIASED = 4\n"
|
||||
"FONT_COUNT = 5\n"
|
||||
"FONT_ALIASED = 3\n"
|
||||
"FONT_COUNT = 4\n"
|
||||
"ENVFX_MODE_NONE = 0\n"
|
||||
"ENVFX_SNOW_NORMAL = 1\n"
|
||||
"ENVFX_SNOW_WATER = 2\n"
|
||||
|
|
|
@ -12471,7 +12471,7 @@ int smlua_func_djui_hud_set_font(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fontType = smlua_to_integer(L, 1);
|
||||
s8 fontType = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_font"); return 0; }
|
||||
|
||||
djui_hud_set_font(fontType);
|
||||
|
|
Loading…
Reference in a new issue