actually fix extended pause menu + improve act/course replacement (#523)

This commit is contained in:
Isaac0-dev 2023-11-21 09:53:33 +10:00 committed by GitHub
parent 217173f82c
commit 2fe3dd8005
10 changed files with 214 additions and 215 deletions

View File

@ -9176,8 +9176,8 @@ end
--- @param courseNum integer
--- @param actNum integer
--- @return boolean
function smlua_text_utils_act_name_is_modified(courseNum, actNum)
--- @return integer
function smlua_text_utils_act_name_mod_index(courseNum, actNum)
-- ...
end

View File

@ -8601,6 +8601,182 @@
[:arrow_up_small:](#)
<br />
---
# functions from network_player.h
<br />
## [get_network_player_from_area](#get_network_player_from_area)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_area(courseNum, actNum, levelNum, areaIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
| areaIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_area(s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);`
[:arrow_up_small:](#)
<br />
## [get_network_player_from_level](#get_network_player_from_level)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_level(courseNum, actNum, levelNum)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_level(s16 courseNum, s16 actNum, s16 levelNum);`
[:arrow_up_small:](#)
<br />
## [get_network_player_smallest_global](#get_network_player_smallest_global)
### Lua Example
`local NetworkPlayerValue = get_network_player_smallest_global()`
### Parameters
- None
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_smallest_global(void);`
[:arrow_up_small:](#)
<br />
## [network_player_color_to_palette](#network_player_color_to_palette)
### Lua Example
`network_player_color_to_palette(np, part, color)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| color | `Color` |
### Returns
- None
### C Prototype
`void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerParts part, Color color);`
[:arrow_up_small:](#)
<br />
## [network_player_connected_count](#network_player_connected_count)
### Lua Example
`local integerValue = network_player_connected_count()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u8 network_player_connected_count(void);`
[:arrow_up_small:](#)
<br />
## [network_player_from_global_index](#network_player_from_global_index)
### Lua Example
`local NetworkPlayerValue = network_player_from_global_index(globalIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| globalIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* network_player_from_global_index(u8 globalIndex);`
[:arrow_up_small:](#)
<br />
## [network_player_palette_to_color](#network_player_palette_to_color)
### Lua Example
`network_player_palette_to_color(np, part, out)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| out | `Color` |
### Returns
- None
### C Prototype
`void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerParts part, Color out);`
[:arrow_up_small:](#)
<br />
## [network_player_set_description](#network_player_set_description)
### Lua Example
`network_player_set_description(np, description, r, g, b, a)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| description | `string` |
| r | `integer` |
| g | `integer` |
| b | `integer` |
| a | `integer` |
### Returns
- None
### C Prototype
`void network_player_set_description(struct NetworkPlayer* np, const char* description, u8 r, u8 g, u8 b, u8 a);`
[:arrow_up_small:](#)
<br />
---

View File

@ -5,182 +5,6 @@
[< prev](functions-3.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | 4 | [5](functions-5.md) | [next >](functions-5.md)]
---
# functions from network_player.h
<br />
## [get_network_player_from_area](#get_network_player_from_area)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_area(courseNum, actNum, levelNum, areaIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
| areaIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_area(s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);`
[:arrow_up_small:](#)
<br />
## [get_network_player_from_level](#get_network_player_from_level)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_level(courseNum, actNum, levelNum)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_level(s16 courseNum, s16 actNum, s16 levelNum);`
[:arrow_up_small:](#)
<br />
## [get_network_player_smallest_global](#get_network_player_smallest_global)
### Lua Example
`local NetworkPlayerValue = get_network_player_smallest_global()`
### Parameters
- None
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_smallest_global(void);`
[:arrow_up_small:](#)
<br />
## [network_player_color_to_palette](#network_player_color_to_palette)
### Lua Example
`network_player_color_to_palette(np, part, color)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| color | `Color` |
### Returns
- None
### C Prototype
`void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerParts part, Color color);`
[:arrow_up_small:](#)
<br />
## [network_player_connected_count](#network_player_connected_count)
### Lua Example
`local integerValue = network_player_connected_count()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u8 network_player_connected_count(void);`
[:arrow_up_small:](#)
<br />
## [network_player_from_global_index](#network_player_from_global_index)
### Lua Example
`local NetworkPlayerValue = network_player_from_global_index(globalIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| globalIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* network_player_from_global_index(u8 globalIndex);`
[:arrow_up_small:](#)
<br />
## [network_player_palette_to_color](#network_player_palette_to_color)
### Lua Example
`network_player_palette_to_color(np, part, out)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| out | `Color` |
### Returns
- None
### C Prototype
`void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerParts part, Color out);`
[:arrow_up_small:](#)
<br />
## [network_player_set_description](#network_player_set_description)
### Lua Example
`network_player_set_description(np, description, r, g, b, a)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| description | `string` |
| r | `integer` |
| g | `integer` |
| b | `integer` |
| a | `integer` |
### Returns
- None
### C Prototype
`void network_player_set_description(struct NetworkPlayer* np, const char* description, u8 r, u8 g, u8 b, u8 a);`
[:arrow_up_small:](#)
<br />
---
# functions from network_utils.h

View File

@ -2445,10 +2445,10 @@
<br />
## [smlua_text_utils_act_name_is_modified](#smlua_text_utils_act_name_is_modified)
## [smlua_text_utils_act_name_mod_index](#smlua_text_utils_act_name_mod_index)
### Lua Example
`local booleanValue = smlua_text_utils_act_name_is_modified(courseNum, actNum)`
`local integerValue = smlua_text_utils_act_name_mod_index(courseNum, actNum)`
### Parameters
| Field | Type |
@ -2457,10 +2457,10 @@
| actNum | `integer` |
### Returns
- `boolean`
- `integer`
### C Prototype
`bool smlua_text_utils_act_name_is_modified(s16 courseNum, u8 actNum);`
`s32 smlua_text_utils_act_name_mod_index(s16 courseNum, u8 actNum);`
[:arrow_up_small:](#)

View File

@ -1118,14 +1118,14 @@
<br />
- network_player.h
- [get_network_player_from_area](functions-4.md#get_network_player_from_area)
- [get_network_player_from_level](functions-4.md#get_network_player_from_level)
- [get_network_player_smallest_global](functions-4.md#get_network_player_smallest_global)
- [network_player_color_to_palette](functions-4.md#network_player_color_to_palette)
- [network_player_connected_count](functions-4.md#network_player_connected_count)
- [network_player_from_global_index](functions-4.md#network_player_from_global_index)
- [network_player_palette_to_color](functions-4.md#network_player_palette_to_color)
- [network_player_set_description](functions-4.md#network_player_set_description)
- [get_network_player_from_area](functions-3.md#get_network_player_from_area)
- [get_network_player_from_level](functions-3.md#get_network_player_from_level)
- [get_network_player_smallest_global](functions-3.md#get_network_player_smallest_global)
- [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_palette_to_color](functions-3.md#network_player_palette_to_color)
- [network_player_set_description](functions-3.md#network_player_set_description)
<br />
@ -1704,7 +1704,7 @@
- smlua_text_utils.h
- [smlua_text_utils_act_name_get](functions-5.md#smlua_text_utils_act_name_get)
- [smlua_text_utils_act_name_is_modified](functions-5.md#smlua_text_utils_act_name_is_modified)
- [smlua_text_utils_act_name_mod_index](functions-5.md#smlua_text_utils_act_name_mod_index)
- [smlua_text_utils_act_name_replace](functions-5.md#smlua_text_utils_act_name_replace)
- [smlua_text_utils_act_name_reset](functions-5.md#smlua_text_utils_act_name_reset)
- [smlua_text_utils_castle_secret_stars_replace](functions-5.md#smlua_text_utils_castle_secret_stars_replace)

View File

@ -2888,7 +2888,7 @@ void render_pause_castle_main_strings(s16 x, s16 y) {
static u32 pause_castle_get_stars(s32 index) {
// Main courses (0-14), Secret courses (15-24)
if (COURSE_IS_VALID_COURSE(index + 1)) {
if (index >= 0 && index < INDEX_CASTLE_STARS) {
return save_file_get_star_flags(gCurrSaveFileNum - 1, index);
}

View File

@ -187,8 +187,6 @@ void *get_act_name_table() {
return actNameTbl;
}
extern struct CourseName *gReplacedActNameTable[];
const char *get_level_name_ascii(s16 courseNum, s16 levelNum, s16 areaIndex, s16 charCase) {
static char output[256];
@ -207,7 +205,7 @@ const char *get_level_name_ascii(s16 courseNum, s16 levelNum, s16 areaIndex, s16
}
else if (!hasCustomName) {
if (COURSE_IS_VALID_COURSE(courseNum)) {
if (courseNum >= COURSE_MIN && courseNum < COURSE_MAX) {
void **courseNameTbl = get_course_name_table();
const u8 *courseName = segmented_to_virtual(courseNameTbl[courseNum - COURSE_BOB]);
convert_string_sm64_to_ascii(output, courseName + 3);
@ -264,7 +262,7 @@ const char *get_star_name_ascii(s16 courseNum, s16 starNum, s16 charCase) {
s16 starIndex = starNum - 1;
if (starIndex >= 0 && starIndex < MAX_ACTS &&
courseNum >= 0 && courseNum < COURSE_END &&
gReplacedActNameTable[courseNum]->actName && gReplacedActNameTable[courseNum]->actName[starIndex].isModified) {
gReplacedActNameTable[courseNum]->actName && gReplacedActNameTable[courseNum]->actName[starIndex].modIndex != -1) {
snprintf(output, 256, "%s", gReplacedActNameTable[courseNum]->actName[starIndex].name);
}

View File

@ -30058,21 +30058,21 @@ int smlua_func_smlua_text_utils_act_name_get(lua_State* L) {
return 1;
}
int smlua_func_smlua_text_utils_act_name_is_modified(lua_State* L) {
int smlua_func_smlua_text_utils_act_name_mod_index(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 2) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "smlua_text_utils_act_name_is_modified", 2, top);
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "smlua_text_utils_act_name_mod_index", 2, top);
return 0;
}
s16 courseNum = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_text_utils_act_name_is_modified"); return 0; }
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_text_utils_act_name_mod_index"); return 0; }
u8 actNum = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "smlua_text_utils_act_name_is_modified"); return 0; }
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "smlua_text_utils_act_name_mod_index"); return 0; }
lua_pushboolean(L, smlua_text_utils_act_name_is_modified(courseNum, actNum));
lua_pushinteger(L, smlua_text_utils_act_name_mod_index(courseNum, actNum));
return 1;
}
@ -32632,7 +32632,7 @@ void smlua_bind_functions_autogen(void) {
// smlua_text_utils.h
smlua_bind_function(L, "smlua_text_utils_act_name_get", smlua_func_smlua_text_utils_act_name_get);
smlua_bind_function(L, "smlua_text_utils_act_name_is_modified", smlua_func_smlua_text_utils_act_name_is_modified);
smlua_bind_function(L, "smlua_text_utils_act_name_mod_index", smlua_func_smlua_text_utils_act_name_mod_index);
smlua_bind_function(L, "smlua_text_utils_act_name_replace", smlua_func_smlua_text_utils_act_name_replace);
smlua_bind_function(L, "smlua_text_utils_act_name_reset", smlua_func_smlua_text_utils_act_name_reset);
smlua_bind_function(L, "smlua_text_utils_castle_secret_stars_replace", smlua_func_smlua_text_utils_castle_secret_stars_replace);

View File

@ -33,11 +33,11 @@ AT_STARTUP static void smlua_text_utils_init() {
char courseBuffer[50];
char actBuffer[50];
// Course/Star names
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));
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
convert_string_sm64_to_ascii(courseBuffer, segmented_to_virtual(courseNameTbl[courseNum]));
snprintf(courseActNames->name, 50, "%s", courseBuffer);
snprintf(courseActNames->orig, 50, "%s", courseBuffer);
courseActNames->modIndex = -1;
@ -46,11 +46,10 @@ AT_STARTUP static void smlua_text_utils_init() {
if (COURSE_IS_MAIN_COURSE(courseNum)) {
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);
convert_string_sm64_to_ascii(actBuffer, segmented_to_virtual(actNameTbl[courseNum * MAX_ACTS + actNum]));
snprintf(courseActNames->actName[actNum].name, 50, "%s", actBuffer);
snprintf(courseActNames->actName[actNum].orig, 50, "%s", actBuffer);
courseActNames->actName[actNum].isModified = false;
courseActNames->actName[actNum].modIndex = -1;
}
}
}
@ -138,7 +137,7 @@ void smlua_text_utils_reset_all(void) {
if (COURSE_IS_MAIN_COURSE(courseNum)) {
for (s16 actNum = 0; actNum < MAX_ACTS; actNum++) {
snprintf(courseActNames->actName[actNum].name, 50, "%s", courseActNames->actName[actNum].orig);
courseActNames->actName[actNum].isModified = false;
courseActNames->actName[actNum].modIndex = -1;
}
}
}
@ -187,7 +186,7 @@ void smlua_text_utils_course_acts_replace(s16 courseNum, const char* courseName,
#define REPLACE_ACT_NAME(i) \
snprintf(courseActNames->actName[i-1].name, 256, "%s", act##i); \
courseActNames->actName[i-1].isModified = true; \
courseActNames->actName[i-1].modIndex = gLuaActiveMod->index; \
REPLACE_ACT_NAME(1);
REPLACE_ACT_NAME(2);
@ -231,7 +230,7 @@ void smlua_text_utils_act_name_replace(s16 courseNum, u8 actNum, const char* nam
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
snprintf(courseActNames->actName[actNum].name, 256, "%s", name);
courseActNames->actName[actNum].isModified = true;
courseActNames->actName[actNum].modIndex = gLuaActiveMod->index;
}
const char* smlua_text_utils_act_name_get(s16 courseNum, u8 actNum) {
@ -240,10 +239,10 @@ const char* smlua_text_utils_act_name_get(s16 courseNum, u8 actNum) {
return gReplacedActNameTable[courseNum]->actName[actNum].name;
}
bool smlua_text_utils_act_name_is_modified(s16 courseNum, u8 actNum) {
s32 smlua_text_utils_act_name_mod_index(s16 courseNum, u8 actNum) {
if (INVALID_COURSE_NUM(courseNum) || actNum >= MAX_ACTS) { return false; }
return gReplacedActNameTable[courseNum]->actName[actNum].isModified;
return gReplacedActNameTable[courseNum]->actName[actNum].modIndex;
}
void smlua_text_utils_act_name_reset(s16 courseNum, u8 actNum) {
@ -251,7 +250,7 @@ void smlua_text_utils_act_name_reset(s16 courseNum, u8 actNum) {
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
snprintf(courseActNames->actName[actNum].name, 50, "%s", courseActNames->actName[actNum].orig);
courseActNames->actName[actNum].isModified = false;
courseActNames->actName[actNum].modIndex = gLuaActiveMod->index;
}
void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName) {

View File

@ -9,7 +9,7 @@
struct ActName {
char name[256];
char orig[256];
bool isModified;
s32 modIndex;
};
struct CourseName {
@ -19,6 +19,8 @@ struct CourseName {
s32 modIndex;
};
extern struct CourseName *gReplacedActNameTable[];
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);
@ -29,7 +31,7 @@ s32 smlua_text_utils_course_name_mod_index(s16 courseNum);
void smlua_text_utils_course_name_reset(s16 courseNum);
void smlua_text_utils_act_name_replace(s16 courseNum, u8 actNum, const char* name);
const char* smlua_text_utils_act_name_get(s16 courseNum, u8 actNum);
bool smlua_text_utils_act_name_is_modified(s16 courseNum, u8 actNum);
s32 smlua_text_utils_act_name_mod_index(s16 courseNum, u8 actNum);
void smlua_text_utils_act_name_reset(s16 courseNum, u8 actNum);
void smlua_text_utils_castle_secret_stars_replace(const char* name);
void smlua_text_utils_extra_text_replace(s16 index, const char* text);