mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
HOOK_ON_DIALOG fixes, expose set_dialog_box_state
This commit is contained in:
parent
932c36ffb3
commit
d53d20c11c
9 changed files with 59 additions and 19 deletions
|
|
@ -87,7 +87,7 @@ override_allowed_functions = {
|
|||
"src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "fade_into_special_warp", "get_instant_warp" ],
|
||||
"src/game/area.h": [ "area_get_warp_node" ],
|
||||
"src/engine/level_script.h": [ "area_create_warp_node" ],
|
||||
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "close_dialog_box", ],
|
||||
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", ],
|
||||
"src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition" ]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12517,7 +12517,7 @@ MAX_VERSION_LENGTH = 32
|
|||
MINOR_VERSION_NUMBER = 1
|
||||
|
||||
--- @type string
|
||||
SM64COOPDX_VERSION = "v1.1.1"
|
||||
SM64COOPDX_VERSION = "v1.2.0"
|
||||
|
||||
--- @type integer
|
||||
VERSION_NUMBER = 38
|
||||
|
|
|
|||
|
|
@ -4214,6 +4214,11 @@ function set_first_person_enabled(enable)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param state integer
|
||||
function set_dialog_box_state(state)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param dialog integer
|
||||
function create_dialog_box(dialog)
|
||||
-- ...
|
||||
|
|
|
|||
|
|
@ -4356,6 +4356,26 @@ Sets if first person is enabled
|
|||
<br />
|
||||
|
||||
|
||||
## [set_dialog_box_state](#set_dialog_box_state)
|
||||
|
||||
### Lua Example
|
||||
`set_dialog_box_state(state)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| state | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_dialog_box_state(u8 state);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [create_dialog_box](#create_dialog_box)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
|||
|
|
@ -842,6 +842,7 @@
|
|||
<br />
|
||||
|
||||
- ingame_menu.h
|
||||
- [set_dialog_box_state](functions-3.md#set_dialog_box_state)
|
||||
- [create_dialog_box](functions-3.md#create_dialog_box)
|
||||
- [create_dialog_box_with_response](functions-3.md#create_dialog_box_with_response)
|
||||
- [create_dialog_box_with_var](functions-3.md#create_dialog_box_with_var)
|
||||
|
|
|
|||
|
|
@ -1160,30 +1160,27 @@ void handle_special_dialog_text(s16 dialogID) { // dialog ID tables, in order
|
|||
static u8 sHookString[255];
|
||||
static bool sOverrideDialogString = false;
|
||||
void convert_string_ascii_to_sm64(u8 *str64, const char *strAscii, bool menu);
|
||||
void handle_dialog_hook(s16 dialogId) {
|
||||
bool handle_dialog_hook(s16 dialogId) {
|
||||
bool open = false;
|
||||
const char *str = smlua_call_event_hooks_int_ret_bool_and_string(HOOK_ON_DIALOG, dialogId, &open);
|
||||
if (!open) {
|
||||
if (gCamera->cutscene == CUTSCENE_READ_MESSAGE) { gCamera->cutscene = 0; }
|
||||
return false;
|
||||
}
|
||||
sOverrideDialogString = str != NULL;
|
||||
if (sOverrideDialogString) { convert_string_ascii_to_sm64(sHookString, str, false); }
|
||||
if (!open) {
|
||||
gDialogLineNum = 1;
|
||||
gDialogBoxState = DIALOG_STATE_CLOSING;
|
||||
gDialogBoxOpenTimer = 20;
|
||||
handle_special_dialog_text(dialogId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void create_dialog_box(s16 dialog) {
|
||||
handle_dialog_hook(dialog);
|
||||
if (gDialogID == -1) {
|
||||
if (handle_dialog_hook(dialog) && gDialogID == -1) {
|
||||
gDialogID = dialog;
|
||||
gDialogBoxType = DIALOG_TYPE_ROTATE;
|
||||
}
|
||||
}
|
||||
|
||||
void create_dialog_box_with_var(s16 dialog, s32 dialogVar) {
|
||||
handle_dialog_hook(dialog);
|
||||
if (gDialogID == -1) {
|
||||
if (handle_dialog_hook(dialog) && gDialogID == -1) {
|
||||
gDialogID = dialog;
|
||||
gDialogVariable = dialogVar;
|
||||
gDialogBoxType = DIALOG_TYPE_ROTATE;
|
||||
|
|
@ -1191,16 +1188,14 @@ void create_dialog_box_with_var(s16 dialog, s32 dialogVar) {
|
|||
}
|
||||
|
||||
void create_dialog_inverted_box(s16 dialog) {
|
||||
handle_dialog_hook(dialog);
|
||||
if (gDialogID == -1) {
|
||||
if (handle_dialog_hook(dialog) && gDialogID == -1) {
|
||||
gDialogID = dialog;
|
||||
gDialogBoxType = DIALOG_TYPE_ZOOM;
|
||||
}
|
||||
}
|
||||
|
||||
void create_dialog_box_with_response(s16 dialog) {
|
||||
handle_dialog_hook(dialog);
|
||||
if (gDialogID == -1) {
|
||||
if (handle_dialog_hook(dialog) && gDialogID == -1) {
|
||||
gDialogID = dialog;
|
||||
gDialogBoxType = DIALOG_TYPE_ROTATE;
|
||||
gLastDialogResponse = 1;
|
||||
|
|
@ -3596,7 +3591,7 @@ void reset_dialog_override_color(void) {
|
|||
gOverrideDialogColor = 0;
|
||||
}
|
||||
|
||||
void close_dialog_box(u8 state) {
|
||||
void set_dialog_box_state(u8 state) {
|
||||
if (state > DIALOG_STATE_CLOSING) { return; }
|
||||
gDialogBoxState = state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,5 +179,6 @@ void set_dialog_override_pos(s16 x, s16 y);
|
|||
void reset_dialog_override_pos();
|
||||
void set_dialog_override_color(u8 bgR, u8 bgG, u8 bgB, u8 bgA, u8 textR, u8 textG, u8 textB, u8 textA);
|
||||
void reset_dialog_override_color();
|
||||
void set_dialog_box_state(u8 state);
|
||||
|
||||
#endif // INGAME_MENU_H
|
||||
|
|
|
|||
|
|
@ -4318,7 +4318,7 @@ char gSmluaConstants[] = ""
|
|||
"COOP_OBJ_FLAG_LUA = (1 << 1)\n"
|
||||
"COOP_OBJ_FLAG_NON_SYNC = (1 << 2)\n"
|
||||
"COOP_OBJ_FLAG_INITIALIZED = (1 << 3)\n"
|
||||
"SM64COOPDX_VERSION = 'v1.1.1'\n"
|
||||
"SM64COOPDX_VERSION = 'v1.2.0'\n"
|
||||
"VERSION_TEXT = 'v'\n"
|
||||
"VERSION_NUMBER = 38\n"
|
||||
"MINOR_VERSION_NUMBER = 1\n"
|
||||
|
|
|
|||
|
|
@ -13388,6 +13388,23 @@ int smlua_func_set_first_person_enabled(lua_State* L) {
|
|||
// ingame_menu.h //
|
||||
///////////////////
|
||||
|
||||
int smlua_func_set_dialog_box_state(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", "set_dialog_box_state", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 state = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_dialog_box_state"); return 0; }
|
||||
|
||||
set_dialog_box_state(state);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_create_dialog_box(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
|
@ -32805,6 +32822,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "set_first_person_enabled", smlua_func_set_first_person_enabled);
|
||||
|
||||
// ingame_menu.h
|
||||
smlua_bind_function(L, "set_dialog_box_state", smlua_func_set_dialog_box_state);
|
||||
smlua_bind_function(L, "create_dialog_box", smlua_func_create_dialog_box);
|
||||
smlua_bind_function(L, "create_dialog_box_with_response", smlua_func_create_dialog_box_with_response);
|
||||
smlua_bind_function(L, "create_dialog_box_with_var", smlua_func_create_dialog_box_with_var);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue