Add djui_attempting_to_open_playerlist (#195)

This commit is contained in:
EmeraldLockdown 2024-09-06 16:08:22 -05:00 committed by GitHub
parent 8636d26726
commit 39e035239c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 57 additions and 6 deletions

View file

@ -8181,6 +8181,11 @@ function deref_s32_pointer(pointer)
-- ... -- ...
end end
--- @return boolean
function djui_attempting_to_open_playerlist()
-- ...
end
--- @return boolean --- @return boolean
function djui_is_playerlist_open() function djui_is_playerlist_open()
-- ... -- ...

View file

@ -1953,6 +1953,24 @@
<br /> <br />
## [djui_attempting_to_open_playerlist](#djui_attempting_to_open_playerlist)
### Lua Example
`local booleanValue = djui_attempting_to_open_playerlist()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool djui_attempting_to_open_playerlist(void);`
[:arrow_up_small:](#)
<br />
## [djui_is_playerlist_open](#djui_is_playerlist_open) ## [djui_is_playerlist_open](#djui_is_playerlist_open)
### Lua Example ### Lua Example

View file

@ -1719,6 +1719,7 @@
- [allocate_mario_action](functions-5.md#allocate_mario_action) - [allocate_mario_action](functions-5.md#allocate_mario_action)
- [course_is_main_course](functions-5.md#course_is_main_course) - [course_is_main_course](functions-5.md#course_is_main_course)
- [deref_s32_pointer](functions-5.md#deref_s32_pointer) - [deref_s32_pointer](functions-5.md#deref_s32_pointer)
- [djui_attempting_to_open_playerlist](functions-5.md#djui_attempting_to_open_playerlist)
- [djui_is_playerlist_open](functions-5.md#djui_is_playerlist_open) - [djui_is_playerlist_open](functions-5.md#djui_is_playerlist_open)
- [djui_is_popup_disabled](functions-5.md#djui_is_popup_disabled) - [djui_is_popup_disabled](functions-5.md#djui_is_popup_disabled)
- [djui_menu_get_font](functions-5.md#djui_menu_get_font) - [djui_menu_get_font](functions-5.md#djui_menu_get_font)

View file

@ -235,15 +235,18 @@ bool djui_interactable_on_key_down(int scancode) {
} }
} }
if ((gDjuiPlayerList != NULL || gDjuiModList != NULL) && gServerSettings.enablePlayerList) { if ((gDjuiPlayerList != NULL || gDjuiModList != NULL)) {
for (int i = 0; i < MAX_BINDS; i++) { for (int i = 0; i < MAX_BINDS; i++) {
if (scancode == (int)configKeyPlayerList[i] && !gDjuiInMainMenu && gNetworkType != NT_NONE) { if (scancode == (int)configKeyPlayerList[i] && !gDjuiInMainMenu && gNetworkType != NT_NONE) {
if (gServerSettings.enablePlayerList) {
if (gDjuiPlayerList != NULL) { if (gDjuiPlayerList != NULL) {
djui_base_set_visible(&gDjuiPlayerList->base, true); djui_base_set_visible(&gDjuiPlayerList->base, true);
} }
if (gDjuiModList != NULL) { if (gDjuiModList != NULL) {
djui_base_set_visible(&gDjuiModList->base, true); djui_base_set_visible(&gDjuiModList->base, true);
} }
}
gAttemptingToOpenPlayerlist = true;
break; break;
} }
if (gDjuiPlayerList->base.visible) { if (gDjuiPlayerList->base.visible) {
@ -295,6 +298,7 @@ void djui_interactable_on_key_up(int scancode) {
if (gDjuiModList != NULL) { if (gDjuiModList != NULL) {
djui_base_set_visible(&gDjuiModList->base, false); djui_base_set_visible(&gDjuiModList->base, false);
} }
gAttemptingToOpenPlayerlist = false;
break; break;
} }
} }

View file

@ -11,6 +11,7 @@
#include "pc/utils/misc.h" #include "pc/utils/misc.h"
struct DjuiThreePanel* gDjuiPlayerList = NULL; struct DjuiThreePanel* gDjuiPlayerList = NULL;
bool gAttemptingToOpenPlayerlist = false;
static struct DjuiFlowLayout* djuiRow[MAX_PLAYERS] = { 0 }; static struct DjuiFlowLayout* djuiRow[MAX_PLAYERS] = { 0 };
static struct DjuiImage* djuiImages[MAX_PLAYERS] = { 0 }; static struct DjuiImage* djuiImages[MAX_PLAYERS] = { 0 };

View file

@ -2,6 +2,7 @@
#include "djui.h" #include "djui.h"
extern struct DjuiThreePanel* gDjuiPlayerList; extern struct DjuiThreePanel* gDjuiPlayerList;
extern bool gAttemptingToOpenPlayerlist;
extern const u8 sPlayerListSize; extern const u8 sPlayerListSize;
extern u8 sPageIndex; extern u8 sPageIndex;

View file

@ -30152,6 +30152,21 @@ int smlua_func_deref_s32_pointer(lua_State* L) {
return 1; return 1;
} }
int smlua_func_djui_attempting_to_open_playerlist(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_attempting_to_open_playerlist", 0, top);
return 0;
}
lua_pushboolean(L, djui_attempting_to_open_playerlist());
return 1;
}
int smlua_func_djui_is_playerlist_open(UNUSED lua_State* L) { int smlua_func_djui_is_playerlist_open(UNUSED lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -34668,6 +34683,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action); smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
smlua_bind_function(L, "course_is_main_course", smlua_func_course_is_main_course); 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, "deref_s32_pointer", smlua_func_deref_s32_pointer);
smlua_bind_function(L, "djui_attempting_to_open_playerlist", smlua_func_djui_attempting_to_open_playerlist);
smlua_bind_function(L, "djui_is_playerlist_open", smlua_func_djui_is_playerlist_open); smlua_bind_function(L, "djui_is_playerlist_open", smlua_func_djui_is_playerlist_open);
smlua_bind_function(L, "djui_is_popup_disabled", smlua_func_djui_is_popup_disabled); smlua_bind_function(L, "djui_is_popup_disabled", smlua_func_djui_is_popup_disabled);
smlua_bind_function(L, "djui_menu_get_font", smlua_func_djui_menu_get_font); smlua_bind_function(L, "djui_menu_get_font", smlua_func_djui_menu_get_font);

View file

@ -91,6 +91,10 @@ bool djui_is_playerlist_open(void) {
return gDjuiPlayerList->base.visible; return gDjuiPlayerList->base.visible;
} }
bool djui_attempting_to_open_playerlist(void) {
return gAttemptingToOpenPlayerlist;
}
enum DjuiFontType djui_menu_get_font(void) { enum DjuiFontType djui_menu_get_font(void) {
return configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED; return configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED;
} }

View file

@ -50,6 +50,7 @@ bool djui_is_popup_disabled(void);
void djui_set_popup_disabled_override(bool value); void djui_set_popup_disabled_override(bool value);
void djui_reset_popup_disabled_override(void); void djui_reset_popup_disabled_override(void);
bool djui_is_playerlist_open(void); bool djui_is_playerlist_open(void);
bool djui_attempting_to_open_playerlist(void);
enum DjuiFontType djui_menu_get_font(void); enum DjuiFontType djui_menu_get_font(void);
s8 get_dialog_box_state(void); s8 get_dialog_box_state(void);