mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-03 14:11:10 +00:00
Added chat message creation to Lua
This commit is contained in:
parent
271a375510
commit
a3467bb6dc
5 changed files with 56 additions and 7 deletions
|
@ -27,6 +27,7 @@ in_files = [
|
|||
"src/game/thread6.c",
|
||||
"src/pc/djui/djui_popup.h",
|
||||
"src/pc/network/network_utils.h",
|
||||
"src/pc/djui/djui_chat_message.h",
|
||||
]
|
||||
|
||||
override_allowed_functions = {
|
||||
|
@ -48,6 +49,7 @@ override_disallowed_functions = {
|
|||
"src/game/mario_actions_submerged.c": [ "^[us]32 act_.*" ],
|
||||
"src/game/mario_step.h": [ " stub_mario_step", "transfer_bully_speed"],
|
||||
"src/game/mario.h": [ " init_mario" ],
|
||||
"src/pc/djui/djui_chat_message.h": [ "create_from" ],
|
||||
}
|
||||
|
||||
###########################################################
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
|
||||
<br />
|
||||
|
||||
- djui_chat_message.h
|
||||
- [djui_chat_message_create](#djui_chat_message_create)
|
||||
|
||||
<br />
|
||||
|
||||
- djui_popup.h
|
||||
- [djui_popup_create](#djui_popup_create)
|
||||
|
||||
|
@ -502,6 +507,32 @@
|
|||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from djui_chat_message.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [djui_chat_message_create](#djui_chat_message_create)
|
||||
|
||||
### Lua Example
|
||||
`djui_chat_message_create(message)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| message | string |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void djui_chat_message_create(const char* message);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from djui_popup.h
|
||||
|
||||
|
|
|
@ -43,16 +43,16 @@ static void djui_chat_message_destroy(struct DjuiBase* base) {
|
|||
free(chatMessage);
|
||||
}
|
||||
|
||||
struct DjuiChatMessage* djui_chat_message_create_from(u8 globalIndex, char* message) {
|
||||
void djui_chat_message_create_from(u8 globalIndex, const char* message) {
|
||||
struct NetworkPlayer* np = network_player_from_global_index(globalIndex);
|
||||
u8* rgb = get_player_color(np->paletteIndex, 0);
|
||||
char chatMsg[256] = { 0 };
|
||||
snprintf(chatMsg, 256, "\\#%02x%02x%02x\\%s:\\#dcdcdc\\ %s", rgb[0], rgb[1], rgb[2], (np != NULL) ? np->name : "Player", message);
|
||||
play_sound((globalIndex == gNetworkPlayerLocal->globalIndex) ? SOUND_MENU_MESSAGE_DISAPPEAR : SOUND_MENU_MESSAGE_APPEAR, gDefaultSoundArgs);
|
||||
return djui_chat_message_create(chatMsg);
|
||||
djui_chat_message_create(chatMsg);
|
||||
}
|
||||
|
||||
struct DjuiChatMessage* djui_chat_message_create(char* message) {
|
||||
void djui_chat_message_create(const char* message) {
|
||||
struct DjuiChatMessage* chatMessage = calloc(1, sizeof(struct DjuiChatMessage));
|
||||
struct DjuiBase* base = &chatMessage->base;
|
||||
djui_base_init(&gDjuiChatBox->chatFlow->base, base, djui_chat_message_render, djui_chat_message_destroy);
|
||||
|
@ -86,6 +86,4 @@ struct DjuiChatMessage* djui_chat_message_create(char* message) {
|
|||
// figure out chat message width
|
||||
f32 messageWidth = djui_text_find_width(chatText, 10);
|
||||
chatMessage->messageWidth = messageWidth + 8;
|
||||
|
||||
return chatMessage;
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ struct DjuiChatMessage {
|
|||
f32 createTime;
|
||||
};
|
||||
|
||||
struct DjuiChatMessage* djui_chat_message_create_from(u8 globalIndex, char* message);
|
||||
struct DjuiChatMessage* djui_chat_message_create(char* message);
|
||||
void djui_chat_message_create_from(u8 globalIndex, const char* message);
|
||||
void djui_chat_message_create(const char* message);
|
||||
|
|
|
@ -185,6 +185,21 @@ int smlua_func_update_character_anim_offset(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// djui_chat_message.h //
|
||||
/////////////////////////
|
||||
|
||||
int smlua_func_djui_chat_message_create(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
const char* message = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
djui_chat_message_create(message);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// djui_popup.h //
|
||||
//////////////////
|
||||
|
@ -2904,6 +2919,9 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "play_character_sound_offset", smlua_func_play_character_sound_offset);
|
||||
smlua_bind_function(L, "update_character_anim_offset", smlua_func_update_character_anim_offset);
|
||||
|
||||
// djui_chat_message.h
|
||||
smlua_bind_function(L, "djui_chat_message_create", smlua_func_djui_chat_message_create);
|
||||
|
||||
// djui_popup.h
|
||||
smlua_bind_function(L, "djui_popup_create", smlua_func_djui_popup_create);
|
||||
|
||||
|
|
Loading…
Reference in a new issue