Merge branch 'dev' of github.com:sm64ex-coop-dev/sm64ex-coop into dev

This commit is contained in:
MysterD 2023-11-08 00:39:07 -08:00
commit febed16c1d
32 changed files with 183 additions and 156 deletions

View File

@ -8999,7 +8999,10 @@ HOOK_ON_OBJECT_ANIM_UPDATE = 32
HOOK_ON_DIALOG = 33
--- @type LuaHookedEventType
HOOK_MAX = 34
HOOK_ON_HUD_RENDER_BEHIND = 34
--- @type LuaHookedEventType
HOOK_MAX = 35
--- @class HudDisplayFlags

View File

@ -3742,12 +3742,6 @@ function djui_hud_set_mouse_locked(locked)
-- ...
end
--- @param enable boolean
--- @return nil
function djui_hud_set_render_behind_hud(enable)
-- ...
end
--- @param resolutionType HudUtilsResolution
--- @return nil
function djui_hud_set_resolution(resolutionType)
@ -8266,6 +8260,12 @@ function smlua_collision_util_get(name)
-- ...
end
--- @param enable boolean
--- @return nil
function djui_hud_set_render_behind_hud(enable)
-- ...
end
--- @param localIndex integer
--- @return string
function network_discord_id_from_local_index(localIndex)

View File

@ -1028,6 +1028,7 @@
--- @field public isDirectory boolean
--- @field public name string
--- @field public relativePath string
--- @field public renderBehindHud boolean
--- @field public selectable boolean
--- @class ModFile

View File

@ -3198,7 +3198,8 @@
| HOOK_JOINED_GAME | 31 |
| HOOK_ON_OBJECT_ANIM_UPDATE | 32 |
| HOOK_ON_DIALOG | 33 |
| HOOK_MAX | 34 |
| HOOK_ON_HUD_RENDER_BEHIND | 34 |
| HOOK_MAX | 35 |
[:arrow_up_small:](#)

View File

@ -2406,26 +2406,6 @@
<br />
## [djui_hud_set_render_behind_hud](#djui_hud_set_render_behind_hud)
### Lua Example
`djui_hud_set_render_behind_hud(enable)`
### Parameters
| Field | Type |
| ----- | ---- |
| enable | `boolean` |
### Returns
- None
### C Prototype
`void djui_hud_set_render_behind_hud(bool enable);`
[:arrow_up_small:](#)
<br />
## [djui_hud_set_resolution](#djui_hud_set_resolution)
### Lua Example

View File

@ -738,7 +738,6 @@
- [djui_hud_set_color](functions-3.md#djui_hud_set_color)
- [djui_hud_set_font](functions-3.md#djui_hud_set_font)
- [djui_hud_set_mouse_locked](functions-3.md#djui_hud_set_mouse_locked)
- [djui_hud_set_render_behind_hud](functions-3.md#djui_hud_set_render_behind_hud)
- [djui_hud_set_resolution](functions-3.md#djui_hud_set_resolution)
- [djui_hud_set_rotation](functions-3.md#djui_hud_set_rotation)
- [djui_hud_world_pos_to_screen_pos](functions-3.md#djui_hud_world_pos_to_screen_pos)

View File

@ -1381,6 +1381,7 @@
| isDirectory | `boolean` | read-only |
| name | `string` | read-only |
| relativePath | `string` | read-only |
| renderBehindHud | `boolean` | read-only |
| selectable | `boolean` | read-only |
[:arrow_up_small:](#)

View File

@ -80,7 +80,7 @@ GOD_MODE = "Режим бога"
INFINITE_LIVES = "Бесконечные жизни"
SUPER_SPEED = "Супер скорость"
RESPONSIVE_CONTROLS = "Отзывчивое управление"
RAPID_FIRE = "Быстрый огонь (A)"
RAPID_FIRE = "Быстрое нажатие (A)"
BLJ_ANYWHERE = "BLJ в любом месте"
ALWAYS_TRIPLE_JUMP = "Всегда тройной прыжок"
@ -115,10 +115,10 @@ START = "Старт"
L = "L"
R = "R"
Z = "Z"
C_UP = "C Up"
C_DOWN = "C Down"
C_LEFT = "C Left"
C_RIGHT = "C Right"
C_UP = "C Вверх"
C_DOWN = "C Вниз"
C_LEFT = "C Влево"
C_RIGHT = "C Вправо"
[DISPLAY]
DISPLAY = "DISPLAY"
@ -164,15 +164,15 @@ MODS = "MODS"
[HOST_SAVE]
SAVE_TITLE = "SAVE"
ERASE_TITLE = "ERASE"
CONFIRM = "Вы уверены, что хотите удалить эту ячейку сохранения?"
ERASE = "удалить"
CONFIRM = "Вы уверены, что хотите удалить этот слот сохранения?"
ERASE = "Удалить"
[HOST_SETTINGS]
SETTINGS = "SETTINGS"
NONSOLID = "Нет"
SOLID = "Обычное"
FRIENDLY_FIRE = "Огонь по своим"
PLAYER_INTERACTION = "Взаимодействие с игроком"
PLAYER_INTERACTION = "Взаимодействие с игроками"
WEAK = "Слабая"
NORMAL = "Обычная"
TOO_MUCH = "Чересчур"
@ -228,7 +228,7 @@ MAIN_MENU = "MAIN MENU"
LEVEL = "Уровень"
USE_STAGE_MUSIC = "Использовать музыку уровня"
RANDOM_STAGE = "Случайный уровень"
PLAY_VANILLA_DEMOS = "Воспроизведение демоверсий"
PLAY_VANILLA_DEMOS = "Воспроизведение демо уровня"
[MISC]
DEBUG_TITLE = "DEBUG"
@ -246,7 +246,7 @@ DEBUG = "Отладка"
LANGUAGE = "Язык"
[CONSOLE]
CONSOLE = "пульт"
CONSOLE = "Пульт"
[MODLIST]
MODS = "MODS"
@ -333,9 +333,9 @@ CUSTOM = "Свой"
[PLAYER_LIST]
PLAYERS = "PLAYERS"
NAME = "имя"
LOCATION = "расположение"
ACT = "акт"
NAME = "Имя"
LOCATION = "Расположение"
ACT = "Акт"
[SOUND]
SOUND = "SOUND"

View File

@ -442,11 +442,11 @@ void render_game(void) {
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
if (!gDjuiDisabled && gDjuiRenderBehindHud) {
if (!gDjuiDisabled) {
djui_reset_hud_params();
create_dl_ortho_matrix();
djui_gfx_displaylist_begin();
smlua_call_event_hooks_with_reset_func(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
smlua_call_event_on_hud_render_behind(djui_reset_hud_params);
djui_gfx_displaylist_end();
}
render_hud();

View File

@ -3609,13 +3609,13 @@ void init_camera(struct Camera *c) {
if (sSoftResettingCamera) {
c->cutscene = 0;
sSoftResettingCamera = FALSE;
}
// Set the camera pos to marioOffset (relative to Mario), added to Mario's position
offset_rotated(c->pos, sMarioCamState->pos, marioOffset, sMarioCamState->faceAngle);
if (c->mode != CAMERA_MODE_BEHIND_MARIO) {
c->pos[1] = find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 100.f,
sMarioCamState->pos[2], &floor) + 125.f;
} else {
// Set the camera pos to marioOffset (relative to Mario), added to Mario's position
offset_rotated(c->pos, sMarioCamState->pos, marioOffset, sMarioCamState->faceAngle);
if (c->mode != CAMERA_MODE_BEHIND_MARIO) {
c->pos[1] = find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 100.f,
sMarioCamState->pos[2], &floor) + 125.f;
}
}
vec3f_copy(c->focus, sMarioCamState->pos);
vec3f_copy(gLakituState.curPos, c->pos);

View File

@ -2807,8 +2807,6 @@ void render_pause_castle_course_stars(s16 x, s16 y, s16 fileNum, s16 courseNum)
}
void render_pause_castle_main_strings(s16 x, s16 y) {
void **courseNameTbl = get_course_name_table();
#ifdef VERSION_EU
u8 textCoin[] = { TEXT_COIN };
u8 textX[] = { TEXT_VARIABLE_X };
@ -2816,7 +2814,8 @@ void render_pause_castle_main_strings(s16 x, s16 y) {
u8 textCoin[] = { TEXT_COIN_X };
#endif
void *courseName;
u8 courseNum = gDialogLineNum + 1;
const u8 *courseName = get_level_name_sm64(courseNum, get_level_num_from_course_num(courseNum), 1, 1);
u8 strVal[8];
s16 starNum = gDialogLineNum;
@ -2850,7 +2849,6 @@ void render_pause_castle_main_strings(s16 x, s16 y) {
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha);
if (gDialogLineNum < COURSE_STAGES_COUNT) {
courseName = segmented_to_virtual(courseNameTbl[gDialogLineNum]);
render_pause_castle_course_stars(x, y, gCurrSaveFileNum - 1, gDialogLineNum);
print_generic_string(x + 34, y - 5, textCoin);
#ifdef VERSION_EU
@ -2863,7 +2861,6 @@ void render_pause_castle_main_strings(s16 x, s16 y) {
#endif
} else {
u8 textStarX[] = { TEXT_STAR_X };
courseName = segmented_to_virtual(courseNameTbl[COURSE_MAX]);
print_generic_string(x + 40, y + 13, textStarX);
int_to_str(save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_BONUS_STAGES - 1, COURSE_MAX - 1), strVal);
print_generic_string(x + 60, y + 13, strVal);
@ -3013,11 +3010,10 @@ void render_pause_castle_main_strings_extended(s16 x, s16 y) {
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha);
void **courseNameTbl = get_course_name_table();
const u8 *courseName = get_level_name_sm64(gDialogLineNum, get_level_num_from_course_num(gDialogLineNum), 1, 1);
// Main courses (0-14)
if (gDialogLineNum < COURSE_STAGES_COUNT) {
const u8 *courseName = courseNameTbl[gDialogLineNum];
const u8 textCoin[] = { TEXT_COIN_X };
u8 textCoinCount[8];
render_pause_castle_course_name(courseName, 160, y + 30);
@ -3029,14 +3025,12 @@ void render_pause_castle_main_strings_extended(s16 x, s16 y) {
// Secret courses (15-24)
else if (gDialogLineNum >= COURSE_STAGES_COUNT && gDialogLineNum < INDEX_CASTLE_STARS) {
const u8 *courseName = courseNameTbl[gDialogLineNum];
render_pause_castle_course_name(courseName + 3, 160, y + 30);
render_pause_castle_course_stars_extended(x + 20, y);
}
// Castle stars (25)
else if (gDialogLineNum == INDEX_CASTLE_STARS) {
const u8 *courseName = courseNameTbl[COURSE_MAX];
const u8 textStar[] = { TEXT_STAR_X };
u8 textStarCount[8];
render_pause_castle_course_name(courseName + 3, 160, y + 30);
@ -3313,9 +3307,6 @@ void render_course_complete_lvl_info_and_hud_str(void) {
UNUSED u8 textClear[] = { TEXT_CLEAR };
u8 textSymStar[] = { GLYPH_STAR, GLYPH_SPACE };
#endif
void **actNameTbl = get_act_name_table();
void **courseNameTbl = get_course_name_table();
u8 *name;
u8 strCourseNum[4];
@ -3324,11 +3315,7 @@ void render_course_complete_lvl_info_and_hud_str(void) {
print_hud_course_complete_coins(118, 103);
play_star_fanfare_and_flash_hud(1, 1 << (gLastCompletedStarNum - 1));
if (gLastCompletedStarNum == 7) {
name = segmented_to_virtual(actNameTbl[COURSE_STAGES_MAX * 6 + 1]);
} else {
name = segmented_to_virtual(actNameTbl[(gLastCompletedCourseNum - 1) * 6 + gLastCompletedStarNum - 1]);
}
name = (u8*) get_star_name_sm64(gLastCompletedCourseNum, gLastCompletedStarNum, 1);
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
int_to_str(gLastCompletedCourseNum, strCourseNum);
@ -3340,7 +3327,7 @@ void render_course_complete_lvl_info_and_hud_str(void) {
print_generic_string(CRS_NUM_X3, 167, strCourseNum);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
} else if ((gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS) && gLastCollectedStarOrKey == 1) {
name = segmented_to_virtual(courseNameTbl[gLastCompletedCourseNum - 1]);
name = (u8*) get_level_name_sm64(gLastCompletedCourseNum, gCurrLevelNum, gCurrAreaIndex, 1) + 3;
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, gDialogTextAlpha);
#ifdef VERSION_EU
@ -3361,7 +3348,7 @@ void render_course_complete_lvl_info_and_hud_str(void) {
play_star_fanfare_and_flash_hud(2, 0); //! 2 isn't defined, originally for key hud?
return;
} else {
name = segmented_to_virtual(actNameTbl[COURSE_STAGES_MAX * 6]);
name = (u8*) get_star_name_sm64(gLastCompletedCourseNum, gLastCompletedStarNum, 1);
print_hud_course_complete_coins(118, 103);
play_star_fanfare_and_flash_hud(1, 1 << (gLastCompletedStarNum - 1));
}

View File

@ -202,12 +202,12 @@ const char *get_level_name_ascii(s16 courseNum, s16 levelNum, s16 areaIndex, s16
}
}
if (gReplacedActNameTable[courseNum]->modIndex != -1) {
if (courseNum >= 0 && courseNum <= COURSE_MAX && gReplacedActNameTable[courseNum]->modIndex != -1) {
snprintf(output, 256, "%s", gReplacedActNameTable[courseNum]->name);
}
else if (!hasCustomName) {
if (COURSE_IS_VALID_COURSE(courseNum)) {
if (COURSE_IS_MAIN_COURSE(courseNum)) {
void **courseNameTbl = get_course_name_table();
const u8 *courseName = segmented_to_virtual(courseNameTbl[courseNum - COURSE_BOB]);
convert_string_sm64_to_ascii(output, courseName + 3);
@ -261,15 +261,18 @@ const char *get_level_name(s16 courseNum, s16 levelNum, s16 areaIndex) {
const char *get_star_name_ascii(s16 courseNum, s16 starNum, s16 charCase) {
static char output[256];
if (gReplacedActNameTable[courseNum]->actName && gReplacedActNameTable[courseNum]->actName[starNum - 1].isModified) {
snprintf(output, 256, "%s", gReplacedActNameTable[courseNum]->actName[starNum - 1].name);
s16 starIndex = starNum - 1;
if (starIndex >= 0 && starIndex < MAX_ACTS &&
courseNum >= 0 && courseNum < COURSE_END &&
gReplacedActNameTable[courseNum]->actName && gReplacedActNameTable[courseNum]->actName[starIndex].isModified) {
snprintf(output, 256, "%s", gReplacedActNameTable[courseNum]->actName[starIndex].name);
}
// Main courses: BOB to RR
else if (COURSE_IS_MAIN_COURSE(courseNum)) {
if (starNum >= 1 && starNum <= 6) {
if (starIndex >= 0 && starIndex < MAX_ACTS) {
void **actNameTable = get_act_name_table();
const u8 *starName = segmented_to_virtual(actNameTable[(courseNum - COURSE_BOB) * 6 + (starNum - 1)]);
const u8 *starName = segmented_to_virtual(actNameTable[(courseNum - COURSE_BOB) * MAX_ACTS + starIndex]);
convert_string_sm64_to_ascii(output, starName);
charCase = MIN(charCase, 0); // Don't need to capitalize vanilla act names
} else if (starNum == 7) {

View File

@ -54,9 +54,24 @@ s8 gLevelToCourseNumTable[] = {
#undef STUB_LEVEL
#undef DEFINE_LEVEL
#define STUB_LEVEL(_0, levelenum, _2, _3, _4, _5, _6, _7, _8) levelenum,
#define DEFINE_LEVEL(_0, levelenum, _2, _3, _4, _5, _6, _7, _8, _9, _10) levelenum,
s8 gCourseNumToLevelNumTable[] = {
#include "levels/level_defines.h"
};
#undef STUB_LEVEL
#undef DEFINE_LEVEL
STATIC_ASSERT(ARRAY_COUNT(gLevelToCourseNumTable) == LEVEL_COUNT - 1,
"change this array if you are adding levels");
s8 get_level_num_from_course_num(s16 courseNum) {
if (courseNum < 0 || courseNum >= COURSE_COUNT) {
return LEVEL_NONE;
}
return gCourseNumToLevelNumTable[courseNum];
}
s8 get_level_course_num(s16 levelNum) {
if (levelNum >= CUSTOM_LEVEL_NUM_START) {
struct CustomLevelInfo* info = smlua_level_util_get_info(levelNum);

View File

@ -80,6 +80,7 @@ extern s8 sUnusedGotGlobalCoinHiScore;
extern u8 gGotFileCoinHiScore;
extern u8 gCurrCourseStarFlags;
extern s8 gLevelToCourseNumTable[];
extern s8 gCourseNumToLevelNumTable[];
// game progress flags
#define SAVE_FLAG_FILE_EXISTS /* 0x00000001 */ (1 << 0)
@ -128,6 +129,7 @@ extern struct WarpCheckpoint gWarpCheckpoint;
extern s8 gMainMenuDataModified;
extern s8 gSaveFileModified;
s8 get_level_num_from_course_num(s16 courseNum);
s8 get_level_course_num(s16 levelNum);
void touch_coin_score_age(s32 fileIndex, s32 courseIndex);
void save_file_do_save(s32 fileIndex, s8 forceSave);

View File

@ -279,10 +279,8 @@ void print_act_selector_strings(void) {
#endif
unsigned char starNumbers[] = { TEXT_ZERO };
u8 **levelNameTbl = get_course_name_table();
u8 *currLevelName = segmented_to_virtual(levelNameTbl[gCurrCourseNum - 1]);
u8 **actNameTbl = get_act_name_table();
u8 *selectedActName;
const u8 *currLevelName = get_level_name_sm64(gCurrCourseNum, gCurrLevelNum, gCurrAreaIndex, 1);
const u8 *selectedActName = get_star_name_sm64(gCurrCourseNum, sSelectedActIndex + 1, 1);
#ifndef VERSION_EU
s16 lvlNameX;
s16 actNameX;
@ -313,9 +311,9 @@ void print_act_selector_strings(void) {
if (currLevelName != NULL) {
#ifdef VERSION_EU
print_generic_string(get_str_x_pos_from_center(160, currLevelName + 3, 10.0f), 33, currLevelName + 3);
print_generic_string(get_str_x_pos_from_center(160, (u8*) currLevelName + 3, 10.0f), 33, currLevelName + 3);
#else
lvlNameX = get_str_x_pos_from_center(160, currLevelName + 3, 10.0f);
lvlNameX = get_str_x_pos_from_center(160, (u8*) currLevelName + 3, 10.0f);
print_generic_string(lvlNameX, 33, currLevelName + 3);
#endif
}
@ -332,12 +330,10 @@ void print_act_selector_strings(void) {
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 255);
// Print the name of the selected act.
if (sVisibleStars != 0) {
selectedActName = segmented_to_virtual(actNameTbl[(gCurrCourseNum - 1) * 6 + sSelectedActIndex]);
#ifdef VERSION_EU
print_menu_generic_string(get_str_x_pos_from_center(ACT_NAME_X, selectedActName, 8.0f), 81, selectedActName);
print_menu_generic_string(get_str_x_pos_from_center(ACT_NAME_X, (u8*) selectedActName, 8.0f), 81, selectedActName);
#else
actNameX = get_str_x_pos_from_center(ACT_NAME_X, selectedActName, 8.0f);
actNameX = get_str_x_pos_from_center(ACT_NAME_X, (u8*) selectedActName, 8.0f);
print_menu_generic_string(actNameX, 81, selectedActName);
#endif
}

View File

@ -23,7 +23,6 @@ static struct DjuiText* sDjuiLuaError = NULL;
static u32 sDjuiLuaErrorTimeout = 0;
bool gDjuiInMainMenu = true;
bool gDjuiDisabled = false;
bool gDjuiRenderBehindHud = false;
static bool sDjuiInited = false;
bool sDjuiRendered60fps = false;
@ -49,8 +48,6 @@ void patch_djui_before(void) {
}
void patch_djui_interpolated(UNUSED f32 delta) {
if (gDjuiRenderBehindHud && !gDjuiPanelPauseCreated) { return; }
// reset the head and re-render DJUI
if (delta >= 0.5f && !sDjuiRendered60fps && (gDjuiInMainMenu || gDjuiPanelPauseCreated)) {
sDjuiRendered60fps = true;
@ -132,10 +129,7 @@ void djui_render(void) {
create_dl_ortho_matrix();
djui_gfx_displaylist_begin();
if (!gDjuiRenderBehindHud) {
djui_reset_hud_params();
smlua_call_event_hooks_with_reset_func(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
}
smlua_call_event_on_hud_render(djui_reset_hud_params);
djui_panel_update();
djui_popup_update();

View File

@ -37,7 +37,6 @@
extern struct DjuiRoot* gDjuiRoot;
extern bool gDjuiInMainMenu;
extern bool gDjuiDisabled;
extern bool gDjuiRenderBehindHud;
void djui_init(void);
void djui_init_late(void);

View File

@ -459,11 +459,13 @@ static bool djui_chat_box_input_on_key_down(struct DjuiBase* base, int scancode)
djui_chat_box_input_escape(gDjuiChatBox->chatInput);
return true;
default:
bool returnValueOnOtherKeyDown = djui_inputbox_on_key_down(base, scancode);
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
reset_tab_completion_all();
{
bool returnValueOnOtherKeyDown = djui_inputbox_on_key_down(base, scancode);
if (strcmp(previousText, gDjuiChatBox->chatInput->buffer) != 0) {
reset_tab_completion_all();
}
return returnValueOnOtherKeyDown;
}
return returnValueOnOtherKeyDown;
}
}

View File

@ -554,10 +554,6 @@ bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) {
return true;
}
void djui_hud_set_render_behind_hud(bool enable) {
gDjuiRenderBehindHud = enable;
}
bool djui_hud_is_pause_menu_created(void) {
return gDjuiPanelPauseCreated;
}

View File

@ -64,9 +64,6 @@ void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height);
void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height);
bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out);
void djui_hud_set_render_behind_hud(bool enable);
bool djui_hud_is_pause_menu_created(void);
void djui_open_pause_menu(void);

View File

@ -1131,7 +1131,7 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
{ "waterLevel", LVT_S16, offsetof(struct MarioState, waterLevel), false, LOT_NONE },
};
#define LUA_MOD_FIELD_COUNT 11
#define LUA_MOD_FIELD_COUNT 12
static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = {
{ "basePath", LVT_STRING, offsetof(struct Mod, basePath), true, LOT_NONE },
{ "customBehaviorIndex", LVT_U8, offsetof(struct Mod, customBehaviorIndex), true, LOT_NONE },
@ -1143,6 +1143,7 @@ static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = {
{ "isDirectory", LVT_BOOL, offsetof(struct Mod, isDirectory), true, LOT_NONE },
{ "name", LVT_STRING_P, offsetof(struct Mod, name), true, LOT_NONE },
{ "relativePath", LVT_STRING, offsetof(struct Mod, relativePath), true, LOT_NONE },
{ "renderBehindHud", LVT_BOOL, offsetof(struct Mod, renderBehindHud), true, LOT_NONE },
{ "selectable", LVT_BOOL, offsetof(struct Mod, selectable), true, LOT_NONE },
// { "size", LVT_???, offsetof(struct Mod, size), true, LOT_??? }, <--- UNIMPLEMENTED
};

View File

@ -3193,7 +3193,8 @@ char gSmluaConstants[] = ""
"HOOK_JOINED_GAME = 31\n"
"HOOK_ON_OBJECT_ANIM_UPDATE = 32\n"
"HOOK_ON_DIALOG = 33\n"
"HOOK_MAX = 34\n"
"HOOK_ON_HUD_RENDER_BEHIND = 34\n"
"HOOK_MAX = 35\n"
"ACTION_HOOK_EVERY_FRAME = 0\n"
"ACTION_HOOK_GRAVITY = 1\n"
"ACTION_HOOK_MAX = 2\n"
@ -4298,4 +4299,4 @@ char gSmluaConstants[] = ""
"VERSION_REGION = 'US'\n"
"MAX_VERSION_LENGTH = 32\n"
"MAX_LOCAL_VERSION_LENGTH = 36\n"
;
;

View File

@ -12388,23 +12388,6 @@ int smlua_func_djui_hud_set_mouse_locked(lua_State* L) {
return 1;
}
int smlua_func_djui_hud_set_render_behind_hud(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", "djui_hud_set_render_behind_hud", 1, top);
return 0;
}
bool enable = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_render_behind_hud"); return 0; }
djui_hud_set_render_behind_hud(enable);
return 1;
}
int smlua_func_djui_hud_set_resolution(lua_State* L) {
if (L == NULL) { return 0; }
@ -27510,6 +27493,23 @@ int smlua_func_smlua_collision_util_get(lua_State* L) {
// smlua_deprecated.h //
////////////////////////
int smlua_func_djui_hud_set_render_behind_hud(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", "djui_hud_set_render_behind_hud", 1, top);
return 0;
}
bool enable = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_render_behind_hud"); return 0; }
djui_hud_set_render_behind_hud(enable);
return 1;
}
int smlua_func_network_discord_id_from_local_index(lua_State* L) {
if (L == NULL) { return 0; }
@ -31721,7 +31721,6 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "djui_hud_set_color", smlua_func_djui_hud_set_color);
smlua_bind_function(L, "djui_hud_set_font", smlua_func_djui_hud_set_font);
smlua_bind_function(L, "djui_hud_set_mouse_locked", smlua_func_djui_hud_set_mouse_locked);
smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud);
smlua_bind_function(L, "djui_hud_set_resolution", smlua_func_djui_hud_set_resolution);
smlua_bind_function(L, "djui_hud_set_rotation", smlua_func_djui_hud_set_rotation);
smlua_bind_function(L, "djui_hud_world_pos_to_screen_pos", smlua_func_djui_hud_world_pos_to_screen_pos);
@ -32472,6 +32471,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "smlua_collision_util_get", smlua_func_smlua_collision_util_get);
// smlua_deprecated.h
smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud);
smlua_bind_function(L, "network_discord_id_from_local_index", smlua_func_network_discord_id_from_local_index);
// smlua_level_utils.h

View File

@ -173,20 +173,60 @@ void smlua_call_event_hooks(enum LuaHookedEventType hookType) {
}
}
void smlua_call_event_hooks_with_reset_func(enum LuaHookedEventType hookType, void (*resetFunc)(void)) {
void smlua_call_event_on_hud_render(void (*resetFunc)(void)) {
lua_State* L = gLuaState;
if (L == NULL) { return; }
struct LuaHookedEvent* hook = &sHookedEvents[hookType];
if (resetFunc) { resetFunc(); }
struct LuaHookedEvent* hook = &sHookedEvents[HOOK_ON_HUD_RENDER];
for (int i = 0; i < hook->count; i++) {
// support deprecated render behind hud
if (hook->mod[i]->renderBehindHud) { continue; }
// push the callback onto the stack
lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
// call the callback
if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i])) {
LOG_LUA("Failed to call the event_hook callback: %u", HOOK_ON_HUD_RENDER);
}
if (resetFunc) { resetFunc(); }
}
}
void smlua_call_event_on_hud_render_behind(void (*resetFunc)(void)) {
lua_State* L = gLuaState;
if (L == NULL) { return; }
if (resetFunc) { resetFunc(); }
struct LuaHookedEvent* hook = &sHookedEvents[HOOK_ON_HUD_RENDER_BEHIND];
for (int i = 0; i < hook->count; i++) {
// push the callback onto the stack
lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
// call the callback
if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i])) {
LOG_LUA("Failed to call the event_hook callback: %u", hookType);
LOG_LUA("Failed to call the event_hook callback: %u", HOOK_ON_HUD_RENDER_BEHIND);
}
if (resetFunc) { resetFunc(); }
}
// support deprecated render behind hud
hook = &sHookedEvents[HOOK_ON_HUD_RENDER];
for (int i = 0; i < hook->count; i++) {
// support deprecated render behind hud
if (!hook->mod[i]->renderBehindHud) { continue; }
// push the callback onto the stack
lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
// call the callback
if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i])) {
LOG_LUA("Failed to call the event_hook callback: %u", HOOK_ON_HUD_RENDER);
}
if (resetFunc) { resetFunc(); }
}
}
void smlua_call_event_hooks_bool_param(enum LuaHookedEventType hookType, bool value) {

View File

@ -45,6 +45,7 @@ enum LuaHookedEventType {
HOOK_JOINED_GAME,
HOOK_ON_OBJECT_ANIM_UPDATE,
HOOK_ON_DIALOG,
HOOK_ON_HUD_RENDER_BEHIND,
HOOK_MAX,
};
@ -83,6 +84,7 @@ static const char* LuaHookedEventTypeName[] = {
"HOOK_JOINED_GAME",
"HOOK_ON_OBJECT_ANIM_UPDATE",
"HOOK_ON_DIALOG",
"HOOK_ON_HUD_RENDER_BEHIND",
"HOOK_MAX"
};
@ -103,7 +105,8 @@ extern u32 gLuaMarioActionIndex[];
int smlua_hook_custom_bhv(BehaviorScript *bhvScript, const char *bhvName);
void smlua_call_event_hooks(enum LuaHookedEventType hookType);
void smlua_call_event_hooks_with_reset_func(enum LuaHookedEventType hookType, void (*resetFunc)(void));
void smlua_call_event_on_hud_render(void (*resetFunc)(void));
void smlua_call_event_on_hud_render_behind(void (*resetFunc)(void));
void smlua_call_event_hooks_bool_param(enum LuaHookedEventType hookType, bool value);
void smlua_call_event_hooks_bool_param_ret_bool(enum LuaHookedEventType hookType, bool value, bool* returnValue);
void smlua_call_event_hooks_mario_param(enum LuaHookedEventType hookType, struct MarioState* m);

View File

@ -3,6 +3,7 @@
#ifdef DISCORD_SDK
#include "pc/discord/discord.h"
#endif
#include "pc/lua/smlua.h"
char* network_discord_id_from_local_index(u8 localIndex) {
#ifdef DISCORD_SDK
@ -14,3 +15,8 @@ char* network_discord_id_from_local_index(u8 localIndex) {
#endif
return NULL;
}
void djui_hud_set_render_behind_hud(bool enable) {
if (!gLuaActiveMod) { return; }
gLuaActiveMod->renderBehindHud = enable;
}

View File

@ -1,3 +1,5 @@
#pragma once
char* network_discord_id_from_local_index(u8 localIndex);
void djui_hud_set_render_behind_hud(bool enable);

View File

@ -24,7 +24,7 @@ static bool sReplacedActName[(COURSE_RR+2)*6] = { 0 };
void convert_string_sm64_to_ascii(char *strAscii, const u8 *str64);
struct CourseName *gReplacedActNameTable[COURSE_COUNT];
struct CourseName *gReplacedActNameTable[COURSE_END];
// Save all vanilla act names and course names
AT_STARTUP static void smlua_text_utils_init() {
@ -33,7 +33,7 @@ AT_STARTUP static void smlua_text_utils_init() {
char courseBuffer[50];
char actBuffer[50];
for (s16 courseNum = 0; courseNum < COURSE_COUNT; courseNum++) {
for (s16 courseNum = 0; courseNum < COURSE_END; courseNum++) {
const u8 *courseName = segmented_to_virtual(courseNameTbl[courseNum]);
convert_string_sm64_to_ascii(courseBuffer, courseName);
gReplacedActNameTable[courseNum] = malloc(sizeof(struct CourseName));
@ -44,9 +44,9 @@ AT_STARTUP static void smlua_text_utils_init() {
// Individual acts
if (COURSE_IS_MAIN_COURSE(courseNum)) {
courseActNames->actName = calloc(6, sizeof(struct ActName));
for (s16 actNum = 0; actNum < 6; actNum++) {
const u8 *starName = segmented_to_virtual(actNameTbl[courseNum * 6 + actNum]);
courseActNames->actName = calloc(MAX_ACTS, sizeof(struct ActName));
for (s16 actNum = 0; actNum < MAX_ACTS; actNum++) {
const u8 *starName = segmented_to_virtual(actNameTbl[courseNum * MAX_ACTS + actNum]);
convert_string_sm64_to_ascii(actBuffer, starName);
snprintf(courseActNames->actName[actNum].name, 50, "%s", actBuffer);
snprintf(courseActNames->actName[actNum].orig, 50, "%s", actBuffer);
@ -136,7 +136,7 @@ void smlua_text_utils_reset_all(void) {
// Individual acts
if (COURSE_IS_MAIN_COURSE(courseNum)) {
for (s16 actNum = 0; actNum < 6; actNum++) {
for (s16 actNum = 0; actNum < MAX_ACTS; actNum++) {
snprintf(courseActNames->actName[actNum].name, 50, "%s", courseActNames->actName[actNum].orig);
courseActNames->actName[actNum].isModified = false;
}
@ -179,24 +179,22 @@ void smlua_text_utils_dialog_replace(enum DialogId dialogId, UNUSED u32 unused,
sReplacedDialog[dialogId] = true;
}
#define REPLACE_ACT_NAME(i) \
snprintf(courseActNames->actName[i-1].name, 256, "%s", act##i); \
courseActNames->actName[i-1].isModified = true; \
void smlua_text_utils_course_acts_replace(s16 courseNum, const char* courseName, const char* act1, const char* act2, const char* act3, const char* act4, const char* act5, const char* act6) {
if (courseNum <= 0 || courseNum > COURSE_RR) { return; }
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
snprintf(courseActNames->name, 256, "%s", courseName + 3);
courseActNames->modIndex = gLuaActiveMod->index;
#define REPLACE_ACT_NAME(i) \
snprintf(courseActNames->actName[i-1].name, 256, "%s", act##i); \
courseActNames->actName[i-1].isModified = true; \
REPLACE_ACT_NAME(1);
REPLACE_ACT_NAME(2);
REPLACE_ACT_NAME(3);
REPLACE_ACT_NAME(4);
REPLACE_ACT_NAME(5);
REPLACE_ACT_NAME(6);
LOG_INFO("%d (%s) replacing act names 1-6 of course %d, (%s), act 1: %s", courseActNames->modIndex, gLuaActiveMod->name, courseNum, courseName, act1);
}
void smlua_text_utils_course_name_replace(s16 courseNum, const char* name) {
@ -228,7 +226,7 @@ void smlua_text_utils_course_name_reset(s16 courseNum) {
}
void smlua_text_utils_act_name_replace(s16 courseNum, u8 actNum, const char* name) {
if (INVALID_COURSE_NUM(courseNum) || actNum > 7) { return; }
if (INVALID_COURSE_NUM(courseNum) || actNum >= MAX_ACTS) { return; }
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
@ -237,19 +235,19 @@ void smlua_text_utils_act_name_replace(s16 courseNum, u8 actNum, const char* nam
}
const char* smlua_text_utils_act_name_get(s16 courseNum, u8 actNum) {
if (INVALID_COURSE_NUM(courseNum) || actNum > 7) { return NULL; }
if (INVALID_COURSE_NUM(courseNum) || actNum >= MAX_ACTS) { return NULL; }
return gReplacedActNameTable[courseNum]->actName[actNum].name;
}
bool smlua_text_utils_act_name_is_modified(s16 courseNum, u8 actNum) {
if (INVALID_COURSE_NUM(courseNum) || actNum > 7) { return false; }
if (INVALID_COURSE_NUM(courseNum) || actNum >= MAX_ACTS) { return false; }
return gReplacedActNameTable[courseNum]->actName[actNum].isModified;
}
void smlua_text_utils_act_name_reset(s16 courseNum, u8 actNum) {
if (INVALID_COURSE_NUM(courseNum) || actNum > 7) { return; }
if (INVALID_COURSE_NUM(courseNum) || actNum >= MAX_ACTS) { return; }
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
snprintf(courseActNames->actName[actNum].name, 50, "%s", courseActNames->actName[actNum].orig);

View File

@ -4,6 +4,8 @@
#include "types.h"
#include "dialog_ids.h"
#define MAX_ACTS 6
struct ActName {
char name[256];
char orig[256];

View File

@ -33,6 +33,7 @@ struct Mod {
bool isDirectory;
bool enabled;
bool selectable;
bool renderBehindHud;
size_t size;
u8 customBehaviorIndex;
};

View File

@ -639,7 +639,6 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
gLightingColor[2] = 255;
gOverrideBackground = -1;
gOverrideEnvFx = -1;
gDjuiRenderBehindHud = false;
gRomhackCameraAllowCentering = TRUE;
gRomhackCameraAllowDpad = FALSE;
camera_reset_overrides();

View File

@ -198,6 +198,11 @@ void produce_interpolation_frames_and_delay(void) {
}
inline static void buffer_audio(void) {
const f32 master_mod = (f32)configMasterVolume / 127.0f;
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);
int samples_left = audio_api->buffered();
u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
s16 audio_buffer[SAMPLES_HIGH * 2 * 2];
@ -212,17 +217,10 @@ void produce_one_frame(void) {
CTX_EXTENT(CTX_INTERP, patch_interpolations_before);
const f32 master_mod = (f32)configMasterVolume / 127.0f;
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);
CTX_EXTENT(CTX_GAME_LOOP, game_loop_one_iteration);
CTX_EXTENT(CTX_SMLUA, smlua_update);
thread6_rumble_loop(NULL);
CTX_EXTENT(CTX_AUDIO, buffer_audio);
CTX_EXTENT(CTX_RENDER, produce_interpolation_frames_and_delay);
@ -254,7 +252,7 @@ void game_exit(void) {
exit(0);
}
void *main_game_init(void*) {
void* main_game_init(UNUSED void* arg) {
const char *gamedir = gCLIOpts.GameDir[0] ? gCLIOpts.GameDir : FS_BASEDIR;
const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path();
fs_init(sys_ropaths, gamedir, userpath);
@ -297,7 +295,7 @@ void *main_game_init(void*) {
snprintf(configPlayerName, MAX_PLAYER_STRING, "%s", gCLIOpts.PlayerName);
printf("\nCustom Playername (Start-Parameter): %s\n\n", configPlayerName);
}
if (!gGfxInited) {
gfx_init(&WAPI, &RAPI, TITLE);
WAPI.set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up, keyboard_on_text_input);