HOOK_ON_DJUI_THEME_CHANGED

This commit is contained in:
Agent X 2024-12-11 23:55:10 -05:00
parent cdbc376d1f
commit f7a48d23fe
7 changed files with 18 additions and 143 deletions

View file

@ -193,54 +193,6 @@ function vec3s_dist(v1, v2)
return math.sqrt(dx * dx + dy * dy + dz * dz)
end
--- @param current number
--- @param target number
--- @param inc number
--- @param dec number
--- @return number
function approach_f32(current, target, inc, dec)
if current < target then
current = current + inc
if current > target then
current = target
end
else
current = current - dec
if current < target then
current = target
end
end
return current
end
--- @param current integer
--- @param target integer
--- @param inc integer
--- @param dec integer
--- @return integer
function approach_s32(current, target, inc, dec)
if current < target then
current = current + inc
if current > target then
current = target
end
else
current = current - dec
if current < target then
current = target
end
end
-- keep within 32 bits
if current > 2147483647 then
current = -2147483648 + (current - 2147483647)
elseif current < -2147483648 then
current = 2147483647 + (current - (-2147483648))
end
return current
end
-----------
-- sound --
-----------

View file

@ -195,54 +195,6 @@ function vec3s_dist(v1, v2)
return math.sqrt(dx * dx + dy * dy + dz * dz)
end
--- @param current number
--- @param target number
--- @param inc number
--- @param dec number
--- @return number
function approach_f32(current, target, inc, dec)
if current < target then
current = current + inc
if current > target then
current = target
end
else
current = current - dec
if current < target then
current = target
end
end
return current
end
--- @param current integer
--- @param target integer
--- @param inc integer
--- @param dec integer
--- @return integer
function approach_s32(current, target, inc, dec)
if current < target then
current = current + inc
if current > target then
current = target
end
else
current = current - dec
if current < target then
current = target
end
end
-- keep within 32 bits
if current > 2147483647 then
current = -2147483648 + (current - 2147483647)
elseif current < -2147483648 then
current = 2147483647 + (current - (-2147483648))
end
return current
end
-----------
-- sound --
-----------
@ -333,6 +285,7 @@ COURSE_MIN = 1
--- @param np NetworkPlayer
--- @param part PlayerPart
--- @return Color
--- Gets the palette color of `part` on `np`
function network_player_get_palette_color(np, part)
local color = {
r = network_player_get_palette_color_channel(np, part, 0),
@ -345,6 +298,7 @@ end
--- @param np NetworkPlayer
--- @param part PlayerPart
--- @return Color
--- Gets the override palette color of `part` on `np`
function network_player_get_override_palette_color(np, part)
local color = {
r = network_player_get_override_palette_color_channel(np, part, 0),
@ -9184,7 +9138,10 @@ HOOK_ON_MODS_LOADED = 45
HOOK_ON_NAMETAGS_RENDER = 46
--- @type LuaHookedEventType
HOOK_MAX = 47
HOOK_ON_DJUI_THEME_CHANGED = 47
--- @type LuaHookedEventType
HOOK_MAX = 48
--- @class LuaModMenuElementType

View file

@ -3317,7 +3317,8 @@
| HOOK_ON_LANGUAGE_CHANGED | 44 |
| HOOK_ON_MODS_LOADED | 45 |
| HOOK_ON_NAMETAGS_RENDER | 46 |
| HOOK_MAX | 47 |
| HOOK_ON_DJUI_THEME_CHANGED | 47 |
| HOOK_MAX | 48 |
### [enum LuaModMenuElementType](#LuaModMenuElementType)
| Identifier | Value |

View file

@ -138,6 +138,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
| HOOK_ON_LANGUAGE_CHANGED | Called when the language is changed | `string` language |
| HOOK_ON_MODS_LOADED | Called directly after every mod file is loaded in by smlua | None |
| HOOK_ON_NAMETAGS_RENDER | Called when nametags are rendered. Return a `string` to change what renders on the nametag, return an empty `string` to render nothing. | `string` playerIndex |
| HOOK_ON_DJUI_THEME_CHANGED | Called when the DJUI theme is changed. Run `djui_menu_get_theme()` to get the new theme. | None |
### Parameters

View file

@ -12,6 +12,7 @@
#include "djui_hud_utils.h"
#include "pc/utils/misc.h"
#include "pc/configfile.h"
#include "pc/lua/smlua_hooks.h"
#include "game/level_update.h"
#include "seq_ids.h"
@ -86,6 +87,8 @@ static void djui_panel_menu_options_djui_setting_change(UNUSED struct DjuiBase*
djui_text_set_font(gDjuiPauseOptions, gDjuiFonts[configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED]);
djui_text_set_text(gDjuiPauseOptions, DLANG(MISC, R_BUTTON));
}
smlua_call_event_hooks(HOOK_ON_DJUI_THEME_CHANGED);
}
void djui_panel_main_menu_create(struct DjuiBase* caller) {

View file

@ -171,50 +171,6 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n"
"--- @param current number\n"
"--- @param target number\n"
"--- @param inc number\n"
"--- @param dec number\n"
"--- @return number\n"
"function approach_f32(current, target, inc, dec)\n"
" if current < target then\n"
" current = current + inc\n"
" if current > target then\n"
" current = target\n"
" end\n"
" else\n"
" current = current - dec\n"
" if current < target then\n"
" current = target\n"
" end\n"
" end\n"
" return current\n"
"end\n"
"--- @param current integer\n"
"--- @param target integer\n"
"--- @param inc integer\n"
"--- @param dec integer\n"
"--- @return integer\n"
"function approach_s32(current, target, inc, dec)\n"
" if current < target then\n"
" current = current + inc\n"
" if current > target then\n"
" current = target\n"
" end\n"
" else\n"
" current = current - dec\n"
" if current < target then\n"
" current = target\n"
" end\n"
" end\n"
" -- keep within 32 bits\n"
" if current > 2147483647 then\n"
" current = -2147483648 + (current - 2147483647)\n"
" elseif current < -2147483648 then\n"
" current = 2147483647 + (current - (-2147483648))\n"
" end\n"
" return current\n"
"end\n"
"-----------\n"
"-- sound --\n"
"-----------\n"
@ -298,6 +254,7 @@ char gSmluaConstants[] = ""
"--- @param np NetworkPlayer\n"
"--- @param part PlayerPart\n"
"--- @return Color\n"
"--- Gets the palette color of `part` on `np`\n"
"function network_player_get_palette_color(np, part)\n"
" local color = {\n"
" r = network_player_get_palette_color_channel(np, part, 0),\n"
@ -309,6 +266,7 @@ char gSmluaConstants[] = ""
"--- @param np NetworkPlayer\n"
"--- @param part PlayerPart\n"
"--- @return Color\n"
"--- Gets the override palette color of `part` on `np`\n"
"function network_player_get_override_palette_color(np, part)\n"
" local color = {\n"
" r = network_player_get_override_palette_color_channel(np, part, 0),\n"
@ -3238,7 +3196,8 @@ char gSmluaConstants[] = ""
"HOOK_ON_LANGUAGE_CHANGED = 44\n"
"HOOK_ON_MODS_LOADED = 45\n"
"HOOK_ON_NAMETAGS_RENDER = 46\n"
"HOOK_MAX = 47\n"
"HOOK_ON_DJUI_THEME_CHANGED = 47\n"
"HOOK_MAX = 48\n"
"ACTION_HOOK_EVERY_FRAME = 0\n"
"ACTION_HOOK_GRAVITY = 1\n"
"ACTION_HOOK_MAX = 2\n"

View file

@ -58,6 +58,7 @@ enum LuaHookedEventType {
HOOK_ON_LANGUAGE_CHANGED,
HOOK_ON_MODS_LOADED,
HOOK_ON_NAMETAGS_RENDER,
HOOK_ON_DJUI_THEME_CHANGED,
HOOK_MAX,
};
@ -109,6 +110,7 @@ static const char* LuaHookedEventTypeName[] = {
"HOOK_ON_LANGUAGE_CHANGED",
"HOOK_ON_MODS_LOADED",
"HOOK_ON_NAMETAGS_RENDER",
"HOOK_ON_DJUI_THEME_CHANGED",
"HOOK_MAX"
};