parent
81b3d0ae15
commit
3e52c4f5db
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/bash
|
||||
python3 ./autogen/convert_structs.py $1
|
||||
python3 ./autogen/convert_functions.py $1
|
||||
python3 ./autogen/convert_constants.py $1
|
||||
python3 ./autogen/convert_constants.py $1
|
||||
|
|
|
@ -8400,6 +8400,13 @@ function deref_s32_pointer(pointer)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param message string
|
||||
--- @param lines integer
|
||||
--- @return nil
|
||||
function djui_popup_create_global(message, lines)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function get_current_save_file_num()
|
||||
-- ...
|
||||
|
|
|
@ -546,6 +546,27 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [djui_popup_create_global](#djui_popup_create_global)
|
||||
|
||||
### Lua Example
|
||||
`djui_popup_create_global(message, lines)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| message | `string` |
|
||||
| lines | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void djui_popup_create_global(const char* message, int lines);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_current_save_file_num](#get_current_save_file_num)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -1567,6 +1567,7 @@
|
|||
- [camera_unfreeze](functions-5.md#camera_unfreeze)
|
||||
- [course_is_main_course](functions-5.md#course_is_main_course)
|
||||
- [deref_s32_pointer](functions-5.md#deref_s32_pointer)
|
||||
- [djui_popup_create_global](functions-5.md#djui_popup_create_global)
|
||||
- [get_current_save_file_num](functions-5.md#get_current_save_file_num)
|
||||
- [get_dialog_box_state](functions-5.md#get_dialog_box_state)
|
||||
- [get_dialog_id](functions-5.md#get_dialog_id)
|
||||
|
|
|
@ -27903,6 +27903,25 @@ int smlua_func_deref_s32_pointer(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_djui_popup_create_global(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", "djui_popup_create_global", 2, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* message = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_popup_create_global"); return 0; }
|
||||
int lines = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_popup_create_global"); return 0; }
|
||||
|
||||
djui_popup_create_global(message, lines);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_current_save_file_num(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -31554,6 +31573,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze);
|
||||
smlua_bind_function(L, "course_is_main_course", smlua_func_course_is_main_course);
|
||||
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
|
||||
smlua_bind_function(L, "djui_popup_create_global", smlua_func_djui_popup_create_global);
|
||||
smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num);
|
||||
smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state);
|
||||
smlua_bind_function(L, "get_dialog_id", smlua_func_get_dialog_id);
|
||||
|
|
|
@ -44,6 +44,11 @@ s32 deref_s32_pointer(s32* pointer) {
|
|||
|
||||
///
|
||||
|
||||
void djui_popup_create_global(const char* message, int lines) {
|
||||
djui_popup_create(message, lines);
|
||||
network_send_global_popup(message, lines);
|
||||
}
|
||||
|
||||
void hud_hide(void) {
|
||||
gOverrideHideHud = 1;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ enum HudDisplayFlags {
|
|||
HUD_DISPLAY_FLAGS_EMPHASIZE_POWER = 0x8000,
|
||||
};
|
||||
|
||||
void djui_popup_create_global(const char* message, int lines);
|
||||
void hud_hide(void);
|
||||
void hud_show(void);
|
||||
bool hud_is_hidden(void);
|
||||
|
|
|
@ -85,7 +85,7 @@ void packet_process(struct Packet* p) {
|
|||
case PACKET_COLLECT_STAR: network_receive_collect_star(p); break;
|
||||
case PACKET_COLLECT_COIN: network_receive_collect_coin(p); break;
|
||||
case PACKET_COLLECT_ITEM: network_receive_collect_item(p); break;
|
||||
case PACKET_UNUSED1: break;
|
||||
case PACKET_GLOBAL_POPUP: network_receive_global_popup(p); break;
|
||||
case PACKET_DEBUG_SYNC: network_receive_debug_sync(p); break;
|
||||
case PACKET_JOIN_REQUEST: network_receive_join_request(p); break;
|
||||
case PACKET_JOIN: network_receive_join(p); break;
|
||||
|
|
|
@ -23,7 +23,7 @@ enum PacketType {
|
|||
PACKET_COLLECT_STAR,
|
||||
PACKET_COLLECT_COIN,
|
||||
PACKET_COLLECT_ITEM,
|
||||
PACKET_UNUSED1,
|
||||
PACKET_GLOBAL_POPUP,
|
||||
PACKET_DEBUG_SYNC,
|
||||
PACKET_JOIN_REQUEST,
|
||||
PACKET_JOIN,
|
||||
|
@ -352,6 +352,10 @@ void network_receive_download_request(struct Packet* p);
|
|||
void network_send_download(u64 offset);
|
||||
void network_receive_download(struct Packet* p);
|
||||
|
||||
// packet_global_popup.c
|
||||
void network_send_global_popup(const char* message, int lines);
|
||||
void network_receive_global_popup(struct Packet* p);
|
||||
|
||||
// packet_lua_sync_table.c
|
||||
void network_send_lua_sync_table_request(void);
|
||||
void network_receive_lua_sync_table_request(struct Packet* p);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#include <stdio.h>
|
||||
#include "../network.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "pc/djui/djui.h"
|
||||
|
||||
void network_send_global_popup(const char* message, int lines) {
|
||||
// get message length
|
||||
u16 messageLength = strlen(message);
|
||||
|
||||
// make message mutable
|
||||
char mutableMessage[messageLength];
|
||||
strcpy(mutableMessage, message);
|
||||
|
||||
// configure packet
|
||||
struct Packet p = { 0 };
|
||||
packet_init(&p, PACKET_GLOBAL_POPUP, true, PLMT_NONE);
|
||||
packet_write(&p, &lines, sizeof(int));
|
||||
packet_write(&p, &messageLength, sizeof(u16));
|
||||
packet_write(&p, mutableMessage, messageLength * sizeof(u8));
|
||||
|
||||
// send the packet
|
||||
network_send(&p);
|
||||
}
|
||||
|
||||
void network_receive_global_popup(struct Packet* p) {
|
||||
|
||||
u16 messageLength = 0;
|
||||
char message[256] = { 0 };
|
||||
int lines;
|
||||
|
||||
// read data
|
||||
packet_read(p, &lines, sizeof(int));
|
||||
packet_read(p, &messageLength, sizeof(u16));
|
||||
if (messageLength >= 255) { messageLength = 255; }
|
||||
packet_read(p, &message, messageLength * sizeof(u8));
|
||||
// show popup
|
||||
djui_popup_create(&message, lines);
|
||||
}
|
Loading…
Reference in New Issue