Allow course names/acts to be changed from Lua
This commit is contained in:
parent
c75e71f24e
commit
653ab58a5d
|
@ -38,8 +38,9 @@ in_files = [
|
|||
"include/behavior_table.h",
|
||||
"src/pc/lua/utils/smlua_obj_utils.h",
|
||||
"src/pc/lua/utils/smlua_misc_utils.h",
|
||||
'src/pc/lua/utils/smlua_collision_utils.h',
|
||||
'src/pc/lua/utils/smlua_model_utils.h',
|
||||
"src/pc/lua/utils/smlua_collision_utils.h",
|
||||
"src/pc/lua/utils/smlua_model_utils.h",
|
||||
"src/pc/lua/utils/smlua_text_utils.h",
|
||||
"src/game/object_helpers.c",
|
||||
"src/game/obj_behaviors.c",
|
||||
"src/game/obj_behaviors_2.c",
|
||||
|
|
|
@ -268,3 +268,56 @@ function SOUND_ARG_LOAD(bank, soundID, priority, flags)
|
|||
if flags == nil then flags = 0 end
|
||||
return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING
|
||||
end
|
||||
|
||||
--- @type integer
|
||||
COURSE_NONE = 0
|
||||
--- @type integer
|
||||
COURSE_BOB = 1
|
||||
--- @type integer
|
||||
COURSE_WF = 2
|
||||
--- @type integer
|
||||
COURSE_JRB = 3
|
||||
--- @type integer
|
||||
COURSE_CCM = 4
|
||||
--- @type integer
|
||||
COURSE_BBH = 5
|
||||
--- @type integer
|
||||
COURSE_HMC = 6
|
||||
--- @type integer
|
||||
COURSE_LLL = 7
|
||||
--- @type integer
|
||||
COURSE_SSL = 8
|
||||
--- @type integer
|
||||
COURSE_DDD = 9
|
||||
--- @type integer
|
||||
COURSE_SL = 10
|
||||
--- @type integer
|
||||
COURSE_WDW = 11
|
||||
--- @type integer
|
||||
COURSE_TTM = 12
|
||||
--- @type integer
|
||||
COURSE_THI = 13
|
||||
--- @type integer
|
||||
COURSE_TTC = 14
|
||||
--- @type integer
|
||||
COURSE_RR = 15
|
||||
--- @type integer
|
||||
COURSE_BITDW = 16
|
||||
--- @type integer
|
||||
COURSE_BITFS = 17
|
||||
--- @type integer
|
||||
COURSE_BITS = 18
|
||||
--- @type integer
|
||||
COURSE_PSS = 19
|
||||
--- @type integer
|
||||
COURSE_COTMC = 20
|
||||
--- @type integer
|
||||
COURSE_TOTWC = 21
|
||||
--- @type integer
|
||||
COURSE_VCUTM = 22
|
||||
--- @type integer
|
||||
COURSE_WMOTR = 23
|
||||
--- @type integer
|
||||
COURSE_SA = 24
|
||||
--- @type integer
|
||||
COURSE_CAKE_END = 25
|
|
@ -271,6 +271,58 @@ function SOUND_ARG_LOAD(bank, soundID, priority, flags)
|
|||
return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING
|
||||
end
|
||||
|
||||
--- @type integer
|
||||
COURSE_NONE = 0
|
||||
--- @type integer
|
||||
COURSE_BOB = 1
|
||||
--- @type integer
|
||||
COURSE_WF = 2
|
||||
--- @type integer
|
||||
COURSE_JRB = 3
|
||||
--- @type integer
|
||||
COURSE_CCM = 4
|
||||
--- @type integer
|
||||
COURSE_BBH = 5
|
||||
--- @type integer
|
||||
COURSE_HMC = 6
|
||||
--- @type integer
|
||||
COURSE_LLL = 7
|
||||
--- @type integer
|
||||
COURSE_SSL = 8
|
||||
--- @type integer
|
||||
COURSE_DDD = 9
|
||||
--- @type integer
|
||||
COURSE_SL = 10
|
||||
--- @type integer
|
||||
COURSE_WDW = 11
|
||||
--- @type integer
|
||||
COURSE_TTM = 12
|
||||
--- @type integer
|
||||
COURSE_THI = 13
|
||||
--- @type integer
|
||||
COURSE_TTC = 14
|
||||
--- @type integer
|
||||
COURSE_RR = 15
|
||||
--- @type integer
|
||||
COURSE_BITDW = 16
|
||||
--- @type integer
|
||||
COURSE_BITFS = 17
|
||||
--- @type integer
|
||||
COURSE_BITS = 18
|
||||
--- @type integer
|
||||
COURSE_PSS = 19
|
||||
--- @type integer
|
||||
COURSE_COTMC = 20
|
||||
--- @type integer
|
||||
COURSE_TOTWC = 21
|
||||
--- @type integer
|
||||
COURSE_VCUTM = 22
|
||||
--- @type integer
|
||||
COURSE_WMOTR = 23
|
||||
--- @type integer
|
||||
COURSE_SA = 24
|
||||
--- @type integer
|
||||
COURSE_CAKE_END = 25
|
||||
|
||||
--- @class BehaviorId
|
||||
|
||||
|
|
|
@ -7045,22 +7045,6 @@ function deref_s32_pointer(pointer)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param dialogId DialogId
|
||||
--- @param unused integer
|
||||
--- @param linesPerBox integer
|
||||
--- @param leftOffset integer
|
||||
--- @param width integer
|
||||
--- @param str string
|
||||
--- @return nil
|
||||
function dialog_replace(dialogId, unused, linesPerBox, leftOffset, width, str)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function dialog_reset_all()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function get_current_save_file_num()
|
||||
-- ...
|
||||
|
@ -7277,6 +7261,55 @@ function spawn_sync_object(behaviorId, modelId, x, y, z, objSetupFunction)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param name string
|
||||
--- @return nil
|
||||
function smlua_text_utils_castle_secret_stars_replace(name)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param courseNum integer
|
||||
--- @param courseName string
|
||||
--- @param act1 string
|
||||
--- @param act2 string
|
||||
--- @param act3 string
|
||||
--- @param act4 string
|
||||
--- @param act5 string
|
||||
--- @param act6 string
|
||||
--- @return nil
|
||||
function smlua_text_utils_course_acts_replace(courseNum, courseName, act1, act2, act3, act4, act5, act6)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dialogId DialogId
|
||||
--- @param unused integer
|
||||
--- @param linesPerBox integer
|
||||
--- @param leftOffset integer
|
||||
--- @param width integer
|
||||
--- @param str string
|
||||
--- @return nil
|
||||
function smlua_text_utils_dialog_replace(dialogId, unused, linesPerBox, leftOffset, width, str)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param text string
|
||||
--- @return nil
|
||||
function smlua_text_utils_extra_text_replace(index, text)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function smlua_text_utils_reset_all()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param courseNum integer
|
||||
--- @param courseName string
|
||||
--- @return nil
|
||||
function smlua_text_utils_secret_star_replace(courseNum, courseName)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function disable_background_sound()
|
||||
-- ...
|
||||
|
|
|
@ -34,6 +34,63 @@ gLevelValues = {}
|
|||
--- @type BehaviorValues
|
||||
gBehaviorValues = {}
|
||||
|
||||
---------------
|
||||
-- constants --
|
||||
---------------
|
||||
|
||||
--- @type integer
|
||||
COURSE_NONE = 0
|
||||
--- @type integer
|
||||
COURSE_BOB = 1
|
||||
--- @type integer
|
||||
COURSE_WF = 2
|
||||
--- @type integer
|
||||
COURSE_JRB = 3
|
||||
--- @type integer
|
||||
COURSE_CCM = 4
|
||||
--- @type integer
|
||||
COURSE_BBH = 5
|
||||
--- @type integer
|
||||
COURSE_HMC = 6
|
||||
--- @type integer
|
||||
COURSE_LLL = 7
|
||||
--- @type integer
|
||||
COURSE_SSL = 8
|
||||
--- @type integer
|
||||
COURSE_DDD = 9
|
||||
--- @type integer
|
||||
COURSE_SL = 10
|
||||
--- @type integer
|
||||
COURSE_WDW = 11
|
||||
--- @type integer
|
||||
COURSE_TTM = 12
|
||||
--- @type integer
|
||||
COURSE_THI = 13
|
||||
--- @type integer
|
||||
COURSE_TTC = 14
|
||||
--- @type integer
|
||||
COURSE_RR = 15
|
||||
--- @type integer
|
||||
COURSE_BITDW = 16
|
||||
--- @type integer
|
||||
COURSE_BITFS = 17
|
||||
--- @type integer
|
||||
COURSE_BITS = 18
|
||||
--- @type integer
|
||||
COURSE_PSS = 19
|
||||
--- @type integer
|
||||
COURSE_COTMC = 20
|
||||
--- @type integer
|
||||
COURSE_TOTWC = 21
|
||||
--- @type integer
|
||||
COURSE_VCUTM = 22
|
||||
--- @type integer
|
||||
COURSE_WMOTR = 23
|
||||
--- @type integer
|
||||
COURSE_SA = 24
|
||||
--- @type integer
|
||||
COURSE_CAKE_END = 25
|
||||
|
||||
-----------
|
||||
-- hooks --
|
||||
-----------
|
||||
|
|
|
@ -228,6 +228,7 @@ s32 DynOS_Level_GetCourse(s32 aLevel) {
|
|||
void DynOS_Level_Override(void* originalScript, void* newScript) {
|
||||
for (s32 i = 0; i < LEVEL_COUNT; i++) {
|
||||
if (sDynosLevelScripts[i] == originalScript) {
|
||||
sDynosCurrentLevelNum = i;
|
||||
sDynosLevelWarps[i].Clear();
|
||||
DynOS_Level_ParseScript(newScript, DynOS_Level_PreprocessScript);
|
||||
sDynosLevelScripts[i] = newScript;
|
||||
|
|
|
@ -18,6 +18,9 @@ Array<Pair<const char*, GfxData*>> &DynOS_Lvl_GetArray() {
|
|||
}
|
||||
|
||||
void DynOS_Lvl_Activate(s32 modIndex, const SysPath &aPackFolder, const char *aLevelName) {
|
||||
// make sure vanilla levels were parsed
|
||||
DynOS_Level_GetCount();
|
||||
|
||||
// check for duplicates
|
||||
for (s32 i = 0; i < sDynosCustomLevelScripts.Count(); ++i) {
|
||||
if (!strcmp(sDynosCustomLevelScripts[i].first, aLevelName)) {
|
||||
|
|
|
@ -36,7 +36,7 @@ static s32 sDynosExitAreaNum = -1;
|
|||
//
|
||||
|
||||
bool DynOS_Warp_ToLevel(s32 aLevel, s32 aArea, s32 aAct) {
|
||||
if (DynOS_Level_GetCourse(aLevel) == COURSE_NONE || !DynOS_Level_GetWarpEntry(aLevel, aArea)) {
|
||||
if (/*DynOS_Level_GetCourse(aLevel) == COURSE_NONE || */!DynOS_Level_GetWarpEntry(aLevel, aArea)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1311,8 +1311,6 @@
|
|||
- smlua_misc_utils.h
|
||||
- [allocate_mario_action](#allocate_mario_action)
|
||||
- [deref_s32_pointer](#deref_s32_pointer)
|
||||
- [dialog_replace](#dialog_replace)
|
||||
- [dialog_reset_all](#dialog_reset_all)
|
||||
- [get_current_save_file_num](#get_current_save_file_num)
|
||||
- [get_environment_region](#get_environment_region)
|
||||
- [get_hand_foot_pos_x](#get_hand_foot_pos_x)
|
||||
|
@ -1356,6 +1354,16 @@
|
|||
|
||||
<br />
|
||||
|
||||
- smlua_text_utils.h
|
||||
- [smlua_text_utils_castle_secret_stars_replace](#smlua_text_utils_castle_secret_stars_replace)
|
||||
- [smlua_text_utils_course_acts_replace](#smlua_text_utils_course_acts_replace)
|
||||
- [smlua_text_utils_dialog_replace](#smlua_text_utils_dialog_replace)
|
||||
- [smlua_text_utils_extra_text_replace](#smlua_text_utils_extra_text_replace)
|
||||
- [smlua_text_utils_reset_all](#smlua_text_utils_reset_all)
|
||||
- [smlua_text_utils_secret_star_replace](#smlua_text_utils_secret_star_replace)
|
||||
|
||||
<br />
|
||||
|
||||
- sound_init.h
|
||||
- [disable_background_sound](#disable_background_sound)
|
||||
- [enable_background_sound](#enable_background_sound)
|
||||
|
@ -24635,49 +24643,6 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
## [dialog_replace](#dialog_replace)
|
||||
|
||||
### Lua Example
|
||||
`dialog_replace(dialogId, unused, linesPerBox, leftOffset, width, str)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| dialogId | [enum DialogId](constants.md#enum-DialogId) |
|
||||
| unused | `integer` |
|
||||
| linesPerBox | `integer` |
|
||||
| leftOffset | `integer` |
|
||||
| width | `integer` |
|
||||
| str | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void dialog_replace(enum DialogId dialogId, u32 unused, s8 linesPerBox, s16 leftOffset, s16 width, const char* str);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [dialog_reset_all](#dialog_reset_all)
|
||||
|
||||
### Lua Example
|
||||
`dialog_reset_all()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void dialog_reset_all(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_current_save_file_num](#get_current_save_file_num)
|
||||
|
||||
### Lua Example
|
||||
|
@ -25348,6 +25313,144 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from smlua_text_utils.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [smlua_text_utils_castle_secret_stars_replace](#smlua_text_utils_castle_secret_stars_replace)
|
||||
|
||||
### Lua Example
|
||||
`smlua_text_utils_castle_secret_stars_replace(name)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| name | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_text_utils_castle_secret_stars_replace(const char* name);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_text_utils_course_acts_replace](#smlua_text_utils_course_acts_replace)
|
||||
|
||||
### Lua Example
|
||||
`smlua_text_utils_course_acts_replace(courseNum, courseName, act1, act2, act3, act4, act5, act6)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| courseNum | `integer` |
|
||||
| courseName | `string` |
|
||||
| act1 | `string` |
|
||||
| act2 | `string` |
|
||||
| act3 | `string` |
|
||||
| act4 | `string` |
|
||||
| act5 | `string` |
|
||||
| act6 | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`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);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_text_utils_dialog_replace](#smlua_text_utils_dialog_replace)
|
||||
|
||||
### Lua Example
|
||||
`smlua_text_utils_dialog_replace(dialogId, unused, linesPerBox, leftOffset, width, str)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| dialogId | [enum DialogId](constants.md#enum-DialogId) |
|
||||
| unused | `integer` |
|
||||
| linesPerBox | `integer` |
|
||||
| leftOffset | `integer` |
|
||||
| width | `integer` |
|
||||
| str | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_text_utils_dialog_replace(enum DialogId dialogId, u32 unused, s8 linesPerBox, s16 leftOffset, s16 width, const char* str);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_text_utils_extra_text_replace](#smlua_text_utils_extra_text_replace)
|
||||
|
||||
### Lua Example
|
||||
`smlua_text_utils_extra_text_replace(index, text)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
| text | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_text_utils_extra_text_replace(s16 index, const char* text);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_text_utils_reset_all](#smlua_text_utils_reset_all)
|
||||
|
||||
### Lua Example
|
||||
`smlua_text_utils_reset_all()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_text_utils_reset_all(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [smlua_text_utils_secret_star_replace](#smlua_text_utils_secret_star_replace)
|
||||
|
||||
### Lua Example
|
||||
`smlua_text_utils_secret_star_replace(courseNum, courseName)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| courseNum | `integer` |
|
||||
| courseName | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from sound_init.h
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "level_table.h"
|
||||
#include "types.h"
|
||||
|
||||
extern u8 seg2_course_name_table[];
|
||||
extern u8* seg2_course_name_table[];
|
||||
|
||||
static const char charset[0xFF + 1] = {
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
#include <PR/gbi.h>
|
||||
#include "dialog_ids.h"
|
||||
|
||||
extern u8 seg2_course_name_table[];
|
||||
extern u8 seg2_act_name_table[];
|
||||
extern u8* seg2_course_name_table[];
|
||||
extern u8* seg2_course_name_table_original[];
|
||||
extern u8* seg2_act_name_table[];
|
||||
extern u8* seg2_act_name_table_original[];
|
||||
extern Gfx dl_rgba16_text_begin[];
|
||||
extern Gfx dl_rgba16_text_end[];
|
||||
extern Gfx dl_ia_text_begin[];
|
||||
|
|
|
@ -46,7 +46,7 @@ static void debug_warp_level1() {
|
|||
}
|
||||
|
||||
static void debug_warp_level2() {
|
||||
dynos_warp_to_level(LEVEL_WDW, 1, 1);
|
||||
dynos_warp_to_level(gCurrLevelNum, gCurrAreaIndex^3, 1);
|
||||
}
|
||||
|
||||
static void debug_grand_star(void) {
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
|
||||
extern s16 gCurrCourseNum;
|
||||
extern s16 gCurrActNum;
|
||||
extern u8 seg2_course_name_table[];
|
||||
extern u8 seg2_act_name_table[];
|
||||
extern u8* seg2_course_name_table[];
|
||||
extern u8* seg2_act_name_table[];
|
||||
|
||||
static time_t lastUpdatedTime;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "pc/mods/mods.h"
|
||||
#include "pc/mods/mods_utils.h"
|
||||
#include "pc/crash_handler.h"
|
||||
#include "pc/lua/utils/smlua_misc_utils.h"
|
||||
#include "pc/lua/utils/smlua_text_utils.h"
|
||||
|
||||
lua_State* gLuaState = NULL;
|
||||
u8 gLuaInitializingScript = 0;
|
||||
|
@ -142,7 +142,7 @@ void smlua_update(void) {
|
|||
}
|
||||
|
||||
void smlua_shutdown(void) {
|
||||
dialog_reset_all();
|
||||
smlua_text_utils_reset_all();
|
||||
smlua_cobject_allowlist_shutdown();
|
||||
smlua_cpointer_allowlist_shutdown();
|
||||
lua_State* L = gLuaState;
|
||||
|
|
|
@ -244,6 +244,58 @@ char gSmluaConstants[] = ""
|
|||
" if flags == nil then flags = 0 end\n"
|
||||
" return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n"
|
||||
"end\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_NONE = 0\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_BOB = 1\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_WF = 2\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_JRB = 3\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_CCM = 4\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_BBH = 5\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_HMC = 6\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_LLL = 7\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_SSL = 8\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_DDD = 9\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_SL = 10\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_WDW = 11\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_TTM = 12\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_THI = 13\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_TTC = 14\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_RR = 15\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_BITDW = 16\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_BITFS = 17\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_BITS = 18\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_PSS = 19\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_COTMC = 20\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_TOTWC = 21\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_VCUTM = 22\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_WMOTR = 23\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_SA = 24\n"
|
||||
"--- @type integer\n"
|
||||
"COURSE_CAKE_END = 25\n"
|
||||
"id_bhv1Up = 0\n"
|
||||
"id_bhv1upJumpOnApproach = 1\n"
|
||||
"id_bhv1upRunningAway = 2\n"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "src/pc/lua/utils/smlua_misc_utils.h"
|
||||
#include "src/pc/lua/utils/smlua_collision_utils.h"
|
||||
#include "src/pc/lua/utils/smlua_model_utils.h"
|
||||
#include "src/pc/lua/utils/smlua_text_utils.h"
|
||||
#include "src/engine/surface_load.h"
|
||||
#include "src/game/object_list_processor.h"
|
||||
#include "src/game/behavior_actions.h"
|
||||
|
@ -14656,36 +14657,6 @@ int smlua_func_deref_s32_pointer(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_dialog_replace(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 6)) { return 0; }
|
||||
|
||||
int dialogId = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
u32 unused = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s8 linesPerBox = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 leftOffset = smlua_to_integer(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 width = smlua_to_integer(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* str = smlua_to_string(L, 6);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
dialog_replace(dialogId, unused, linesPerBox, leftOffset, width, str);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_dialog_reset_all(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
dialog_reset_all();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_current_save_file_num(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
@ -15094,6 +15065,102 @@ int smlua_func_spawn_sync_object(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// smlua_text_utils.h //
|
||||
////////////////////////
|
||||
|
||||
int smlua_func_smlua_text_utils_castle_secret_stars_replace(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
const char* name = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_text_utils_castle_secret_stars_replace(name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_smlua_text_utils_course_acts_replace(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 8)) { return 0; }
|
||||
|
||||
s16 courseNum = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* courseName = smlua_to_string(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* act1 = smlua_to_string(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* act2 = smlua_to_string(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* act3 = smlua_to_string(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* act4 = smlua_to_string(L, 6);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* act5 = smlua_to_string(L, 7);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* act6 = smlua_to_string(L, 8);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_text_utils_course_acts_replace(courseNum, courseName, act1, act2, act3, act4, act5, act6);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_smlua_text_utils_dialog_replace(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 6)) { return 0; }
|
||||
|
||||
int dialogId = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
u32 unused = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s8 linesPerBox = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 leftOffset = smlua_to_integer(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s16 width = smlua_to_integer(L, 5);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* str = smlua_to_string(L, 6);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_text_utils_dialog_replace(dialogId, unused, linesPerBox, leftOffset, width, str);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_smlua_text_utils_extra_text_replace(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
s16 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* text = smlua_to_string(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_text_utils_extra_text_replace(index, text);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_smlua_text_utils_reset_all(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
smlua_text_utils_reset_all();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_smlua_text_utils_secret_star_replace(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
s16 courseNum = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* courseName = smlua_to_string(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_text_utils_secret_star_replace(courseNum, courseName);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// sound_init.h //
|
||||
//////////////////
|
||||
|
@ -16848,8 +16915,6 @@ void smlua_bind_functions_autogen(void) {
|
|||
// smlua_misc_utils.h
|
||||
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
|
||||
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
|
||||
smlua_bind_function(L, "dialog_replace", smlua_func_dialog_replace);
|
||||
smlua_bind_function(L, "dialog_reset_all", smlua_func_dialog_reset_all);
|
||||
smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num);
|
||||
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);
|
||||
|
@ -16887,6 +16952,14 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "spawn_non_sync_object", smlua_func_spawn_non_sync_object);
|
||||
smlua_bind_function(L, "spawn_sync_object", smlua_func_spawn_sync_object);
|
||||
|
||||
// smlua_text_utils.h
|
||||
smlua_bind_function(L, "smlua_text_utils_castle_secret_stars_replace", smlua_func_smlua_text_utils_castle_secret_stars_replace);
|
||||
smlua_bind_function(L, "smlua_text_utils_course_acts_replace", smlua_func_smlua_text_utils_course_acts_replace);
|
||||
smlua_bind_function(L, "smlua_text_utils_dialog_replace", smlua_func_smlua_text_utils_dialog_replace);
|
||||
smlua_bind_function(L, "smlua_text_utils_extra_text_replace", smlua_func_smlua_text_utils_extra_text_replace);
|
||||
smlua_bind_function(L, "smlua_text_utils_reset_all", smlua_func_smlua_text_utils_reset_all);
|
||||
smlua_bind_function(L, "smlua_text_utils_secret_star_replace", smlua_func_smlua_text_utils_secret_star_replace);
|
||||
|
||||
// sound_init.h
|
||||
smlua_bind_function(L, "disable_background_sound", smlua_func_disable_background_sound);
|
||||
smlua_bind_function(L, "enable_background_sound", smlua_func_enable_background_sound);
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
#include "pc/lua/smlua.h"
|
||||
#include "smlua_misc_utils.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "game/ingame_menu.h"
|
||||
#include "game/segment2.h"
|
||||
|
||||
#include "game/object_list_processor.h"
|
||||
|
||||
u32 get_network_area_timer(void) {
|
||||
|
@ -108,42 +105,3 @@ void set_environment_region(u8 index, s32 value) {
|
|||
gEnvironmentRegions[6 * (int)index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
static bool sReplacedDialog[DIALOG_COUNT] = { 0 };
|
||||
|
||||
void dialog_reset_all(void) {
|
||||
void **dialogTable = segmented_to_virtual(seg2_dialog_table);
|
||||
|
||||
for (s32 i = 0; i < DIALOG_COUNT; i++) {
|
||||
struct DialogEntry *dialog = segmented_to_virtual(dialogTable[i]);
|
||||
if (sReplacedDialog[i]) {
|
||||
free((u8*)dialog->str);
|
||||
dialog->str = seg2_dialog_original[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dialog_replace(enum DialogId dialogId, UNUSED u32 unused, s8 linesPerBox, s16 leftOffset, s16 width, const char* str) {
|
||||
if (dialogId >= DIALOG_COUNT) { return; }
|
||||
|
||||
void **dialogTable = segmented_to_virtual(seg2_dialog_table);
|
||||
struct DialogEntry *dialog = segmented_to_virtual(dialogTable[dialogId]);
|
||||
|
||||
s32 len = strlen(str);
|
||||
u8* dialogStr = calloc(len + 1, sizeof(u8));
|
||||
str_ascii_to_dialog(str, dialogStr, len);
|
||||
|
||||
if (sReplacedDialog[dialogId]) {
|
||||
free((u8*)dialog->str);
|
||||
}
|
||||
|
||||
dialog->unused = unused;
|
||||
dialog->linesPerBox = linesPerBox;
|
||||
dialog->leftOffset = leftOffset;
|
||||
dialog->width = width;
|
||||
dialog->str = (const u8*)dialogStr;
|
||||
sReplacedDialog[dialogId] = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@ f32 get_hand_foot_pos_x(struct MarioState* m, u8 index);
|
|||
f32 get_hand_foot_pos_y(struct MarioState* m, u8 index);
|
||||
f32 get_hand_foot_pos_z(struct MarioState* m, u8 index);
|
||||
|
||||
void dialog_reset_all(void);
|
||||
void dialog_replace(enum DialogId dialogId, u32 unused, s8 linesPerBox, s16 leftOffset, s16 width, const char* str);
|
||||
|
||||
s16 get_current_save_file_num(void);
|
||||
|
||||
void movtexqc_register(const char* name, s16 level, s16 area, s16 type);
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
#include "sm64.h"
|
||||
#include "types.h"
|
||||
#include "course_table.h"
|
||||
#include "game/memory.h"
|
||||
#include "game/ingame_menu.h"
|
||||
#include "game/segment2.h"
|
||||
|
||||
static bool sReplacedDialog[DIALOG_COUNT] = { 0 };
|
||||
static bool sReplacedCourseName[COURSE_COUNT+2] = { 0 };
|
||||
static bool sReplacedActName[(COURSE_RR+2)*6] = { 0 };
|
||||
|
||||
static u8* smlua_text_utils_convert(const char* str) {
|
||||
s32 len = strlen(str);
|
||||
u8* dialogStr = calloc(len + 2, sizeof(u8));
|
||||
str_ascii_to_dialog(str, dialogStr, len + 1);
|
||||
return dialogStr;
|
||||
}
|
||||
|
||||
void smlua_text_utils_reset_all(void) {
|
||||
void **dialogTable = segmented_to_virtual(seg2_dialog_table);
|
||||
|
||||
for (s32 i = 0; i < DIALOG_COUNT; i++) {
|
||||
if (!sReplacedDialog[i]) { continue; }
|
||||
struct DialogEntry *dialog = segmented_to_virtual(dialogTable[i]);
|
||||
free((u8*)dialog->str);
|
||||
dialog->str = seg2_dialog_original[i];
|
||||
sReplacedDialog[i] = false;
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < COURSE_COUNT+2; i++) {
|
||||
if (!sReplacedCourseName[i]) { continue; }
|
||||
free((u8*)seg2_course_name_table[i]);
|
||||
seg2_course_name_table[i] = seg2_course_name_table_original[i];
|
||||
sReplacedCourseName[i] = false;
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < (COURSE_RR+2)*6; i++) {
|
||||
if (!sReplacedActName[i]) { continue; }
|
||||
free((u8*)seg2_act_name_table[i]);
|
||||
seg2_act_name_table[i] = seg2_act_name_table_original[i];
|
||||
sReplacedActName[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void smlua_text_utils_dialog_replace(enum DialogId dialogId, UNUSED u32 unused, s8 linesPerBox, s16 leftOffset, s16 width, const char* str) {
|
||||
if (dialogId >= DIALOG_COUNT) { return; }
|
||||
|
||||
void **dialogTable = segmented_to_virtual(seg2_dialog_table);
|
||||
struct DialogEntry *dialog = segmented_to_virtual(dialogTable[dialogId]);
|
||||
|
||||
if (sReplacedDialog[dialogId]) {
|
||||
free((u8*)dialog->str);
|
||||
}
|
||||
|
||||
dialog->unused = unused;
|
||||
dialog->linesPerBox = linesPerBox;
|
||||
dialog->leftOffset = leftOffset;
|
||||
dialog->width = width;
|
||||
dialog->str = smlua_text_utils_convert(str);
|
||||
sReplacedDialog[dialogId] = 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; }
|
||||
s16 courseOffset = courseNum - 1;
|
||||
|
||||
// replace course name
|
||||
if (sReplacedCourseName[courseOffset]) {
|
||||
free(seg2_course_name_table[courseOffset]);
|
||||
}
|
||||
seg2_course_name_table[courseOffset] = smlua_text_utils_convert(courseName);
|
||||
sReplacedCourseName[courseOffset] = true;
|
||||
|
||||
// replace act names
|
||||
const char* newActs[] = { act1, act2, act3, act4, act5, act6 };
|
||||
for (s32 i = 0; i < 6; i++) {
|
||||
s32 index = (courseOffset * 6 + i);
|
||||
|
||||
if (sReplacedActName[index]) {
|
||||
free(seg2_act_name_table[index]);
|
||||
}
|
||||
|
||||
seg2_act_name_table[index] = smlua_text_utils_convert(newActs[i]);
|
||||
sReplacedActName[index] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName) {
|
||||
if (courseNum <= COURSE_RR || courseNum > COURSE_COUNT) { return; }
|
||||
s16 courseOffset = courseNum - 1;
|
||||
|
||||
if (sReplacedCourseName[courseOffset]) {
|
||||
free(seg2_course_name_table[courseOffset]);
|
||||
}
|
||||
|
||||
seg2_course_name_table[courseOffset] = smlua_text_utils_convert(courseName);
|
||||
sReplacedCourseName[courseOffset] = true;
|
||||
}
|
||||
|
||||
void smlua_text_utils_castle_secret_stars_replace(const char* name) {
|
||||
s16 courseOffset = COURSE_COUNT;
|
||||
|
||||
if (sReplacedCourseName[courseOffset]) {
|
||||
free(seg2_course_name_table[courseOffset]);
|
||||
}
|
||||
|
||||
seg2_course_name_table[courseOffset] = smlua_text_utils_convert(name);
|
||||
sReplacedCourseName[courseOffset] = true;
|
||||
}
|
||||
|
||||
void smlua_text_utils_extra_text_replace(s16 index, const char* text) {
|
||||
if (index < 0 || index > 6) { return; }
|
||||
index = (COURSE_RR * 6 + index);
|
||||
|
||||
if (sReplacedActName[index]) {
|
||||
free(seg2_act_name_table[index]);
|
||||
}
|
||||
|
||||
seg2_act_name_table[index] = smlua_text_utils_convert(text);
|
||||
sReplacedActName[index] = true;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef SMLUA_TEXT_UTILS_H
|
||||
#define SMLUA_TEXT_UTILS_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dialog_ids.h"
|
||||
|
||||
void smlua_text_utils_reset_all(void);
|
||||
void smlua_text_utils_dialog_replace(enum DialogId dialogId, u32 unused, s8 linesPerBox, s16 leftOffset, s16 width, const char* str);
|
||||
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);
|
||||
void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName);
|
||||
void smlua_text_utils_castle_secret_stars_replace(const char* name);
|
||||
void smlua_text_utils_extra_text_replace(s16 index, const char* text);
|
||||
|
||||
#endif
|
|
@ -19,7 +19,12 @@
|
|||
#define SECRET_STAR(id, name) GLUE2(COURSE_TABLE, _ ## id),
|
||||
#define CASTLE_SECRET_STARS(str) GLUE2(COURSE_TABLE, _castle_secret_stars),
|
||||
|
||||
const u8 *const COURSE_TABLE[] = {
|
||||
const u8* COURSE_TABLE[] = {
|
||||
#include "courses.h"
|
||||
NULL
|
||||
};
|
||||
|
||||
const u8* GLUE2(COURSE_TABLE, _original)[] = {
|
||||
#include "courses.h"
|
||||
NULL
|
||||
};
|
||||
|
|
|
@ -104,7 +104,12 @@ const struct DialogEntry *const seg2_dialog_table[] = {
|
|||
act_name_ ## id ## _4, act_name_ ## id ## _5, act_name_ ## id ## _6,
|
||||
#define EXTRA_TEXT(id, str) extra_text_ ## id,
|
||||
|
||||
const u8 *const seg2_act_name_table[] = {
|
||||
const u8* seg2_act_name_table[] = {
|
||||
#include "courses.h"
|
||||
NULL
|
||||
};
|
||||
|
||||
const u8* seg2_act_name_table_original[] = {
|
||||
#include "courses.h"
|
||||
NULL
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue