From 46b3167cce9287bc9176dcf63c4ba58296d8488c Mon Sep 17 00:00:00 2001 From: xLuigiGamerx <88401287+xLuigiGamerx@users.noreply.github.com> Date: Fri, 20 Oct 2023 19:16:49 +0300 Subject: [PATCH] Playerlist Improvements and Username Character Limit Increase (#476) * xLuigiGamerxsDevFork * xLuigiGamerxsDevFork * Fixed Accidentally used older character.c file * Modified the playerlist so that it can support more than 16 players if it is to be added and increased the username character limit from 20 to 60 so people with longer names can use hex codes * Changed the Makefile back * Just Fixing up the makefile which for some reason changed * Fr this time I hopefully fixed the Makefile * Bruh why did this even change it's fucking annoying * Modified the playerlist so that it can support more than 16 players if it is to be added and increased the username character limit from 20 to 60 so people with longer names can use hex codes (Removed Whitespace lol) * Modified the playerlist so that it can support more than 16 players if it is to be added and increased the username character limit from 20 to 60 so people with longer names can use hex codes (Removed Whitespace V2 lol) * Used MAX_PLAYER_STRING instead of a number * Apparently math.h wasn't needed * Me when I use google translate only for it to fuck up french: * Used MAX_PLAYER_STRING and removed ceils and removed multiplicaion by sPlayerListSize * Added comment for p variable * Removed 16 * Update djui_panel_playerlist.c --------- Co-authored-by: xLuigiGamerx Co-authored-by: PeachyPeach <72323920+PeachyPeachSM64@users.noreply.github.com> --- lang/Czech.ini | 2 ++ lang/Dutch.ini | 2 ++ lang/English.ini | 2 ++ lang/French.ini | 2 ++ lang/German.ini | 2 ++ lang/Italian.ini | 2 ++ lang/Portuguese.ini | 2 ++ lang/Russian.ini | 2 ++ lang/Spanish.ini | 2 ++ src/pc/configfile.c | 4 ++++ src/pc/configfile.h | 4 +++- src/pc/djui/djui_interactable.c | 18 ++++++++++++++++++ src/pc/djui/djui_interactable.h | 2 ++ src/pc/djui/djui_panel_controls_extra.c | 4 +++- src/pc/djui/djui_panel_player.c | 4 ++-- src/pc/djui/djui_panel_playerlist.c | 12 ++++++++++-- 16 files changed, 60 insertions(+), 6 deletions(-) diff --git a/lang/Czech.ini b/lang/Czech.ini index 32c285b2..637f9443 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -102,6 +102,8 @@ D_LEFT = "D-Pad vlevo" D_RIGHT = "D-Pad vpravo" X = "X" Y = "Y" +PREV = "Před Stránka" +NEXT = "Další Strana" UP = "Nahoru" DOWN = "Dolů" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index 53eb4938..b2f8ec1f 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -101,6 +101,8 @@ D_LEFT = "D Links" D_RIGHT = "D Rechts" X = "X" Y = "Y" +PREV = "Vori Bladzijde" +NEXT = "Volg Bladzijde" UP = "Omhoog" DOWN = "Naar Beneden" diff --git a/lang/English.ini b/lang/English.ini index 95725c63..30f24953 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -102,6 +102,8 @@ D_LEFT = "D Left" D_RIGHT = "D Right" X = "X" Y = "Y" +PREV = "Prev Page" +NEXT = "Next Page" UP = "Up" DOWN = "Down" diff --git a/lang/French.ini b/lang/French.ini index 58f8d9e9..758f6a3e 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -102,6 +102,8 @@ D_LEFT = "D Gauche" D_RIGHT = "D Droite" X = "X" Y = "Y" +PREV = "Page Préc" +NEXT = "Page Suiv" UP = "Haut" DOWN = "Bas" diff --git a/lang/German.ini b/lang/German.ini index 6865c696..a10b9c94 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -102,6 +102,8 @@ D_LEFT = "D Links" D_RIGHT = "D Rechts" X = "X" Y = "Y" +PREV = "Vorh Seite" +NEXT = "Näch Seite" UP = "Hoch" DOWN = "Unten" diff --git a/lang/Italian.ini b/lang/Italian.ini index 3ceec56e..63af67ed 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -100,6 +100,8 @@ D_LEFT = "D Sinistra" D_RIGHT = "D Destra" X = "X" Y = "Y" +PREV = "Pagina Prec" +NEXT = "Pagina Succ" UP = "Su" DOWN = "Giù" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index d3573237..33b53c80 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -102,6 +102,8 @@ D_LEFT = "D LEFT" D_RIGHT = "D RIGHT" X = "X" Y = "Y" +PREV = "Página Ante" +NEXT = "Próx Página" UP = "UP" DOWN = "DOWN" diff --git a/lang/Russian.ini b/lang/Russian.ini index 34d11b56..639fad9a 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -101,6 +101,8 @@ D_LEFT = "Крестовина влево" D_RIGHT = "Крестовина вправо" X = "X" Y = "Y" +PREV = "Пред Cтраница" +NEXT = "След Cтраница" UP = "Вверх" DOWN = "Вниз" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index 73506d53..8d9f64f4 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -102,6 +102,8 @@ D_LEFT = "Cruz Izquierda" D_RIGHT = "Cruz Derecha" X = "X" Y = "Y" +PREV = "Pagina Ante" +NEXT = "Sigu Página" UP = "Arriba" DOWN = "Abajo" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 285bfa48..25169cca 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -97,6 +97,8 @@ unsigned int configKeyDUp[MAX_BINDS] = { 0x0147, 0x100b, VK_INVALID unsigned int configKeyDDown[MAX_BINDS] = { 0x014f, 0x100c, VK_INVALID }; unsigned int configKeyDLeft[MAX_BINDS] = { 0x0153, 0x100d, VK_INVALID }; unsigned int configKeyDRight[MAX_BINDS] = { 0x0151, 0x100e, VK_INVALID }; +unsigned int configKeyPrevPage[MAX_BINDS] = { 0x0016, VK_INVALID, VK_INVALID }; +unsigned int configKeyNextPage[MAX_BINDS] = { 0x0018, VK_INVALID, VK_INVALID }; unsigned int configStickDeadzone = 16; // 16*DEADZONE_STEP=4960 (the original default deadzone) unsigned int configRumbleStrength = 50; #ifdef EXTERNAL_DATA @@ -196,6 +198,8 @@ static const struct ConfigOption options[] = { {.name = "key_ddown", .type = CONFIG_TYPE_BIND, .uintValue = configKeyDDown}, {.name = "key_dleft", .type = CONFIG_TYPE_BIND, .uintValue = configKeyDLeft}, {.name = "key_dright", .type = CONFIG_TYPE_BIND, .uintValue = configKeyDRight}, + {.name = "key_prev", .type = CONFIG_TYPE_BIND, .uintValue = configKeyPrevPage}, + {.name = "key_next", .type = CONFIG_TYPE_BIND, .uintValue = configKeyNextPage}, {.name = "stick_deadzone", .type = CONFIG_TYPE_UINT, .uintValue = &configStickDeadzone}, {.name = "rumble_strength", .type = CONFIG_TYPE_UINT, .uintValue = &configRumbleStrength}, #ifdef EXTERNAL_DATA diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 1ee53e25..17f74a9a 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -11,7 +11,7 @@ #define MAX_BINDS 3 #define MAX_VOLUME 127 #define MAX_CONFIG_STRING 64 -#define MAX_PLAYER_STRING 20 +#define MAX_PLAYER_STRING 60 #define MAX_DESCRIPTION_STRING 20 #define DEFAULT_PORT 7777 @@ -56,6 +56,8 @@ extern unsigned int configKeyDUp[]; extern unsigned int configKeyDDown[]; extern unsigned int configKeyDLeft[]; extern unsigned int configKeyDRight[]; +extern unsigned int configKeyPrevPage[]; +extern unsigned int configKeyNextPage[]; extern unsigned int configStickDeadzone; extern unsigned int configRumbleStrength; extern unsigned int configGamepadNumber; diff --git a/src/pc/djui/djui_interactable.c b/src/pc/djui/djui_interactable.c index 0accb576..7b5f322a 100644 --- a/src/pc/djui/djui_interactable.c +++ b/src/pc/djui/djui_interactable.c @@ -251,6 +251,24 @@ bool djui_interactable_on_key_down(int scancode) { } break; } + if (gDjuiPlayerList->base.visible) { + if (scancode == (int)configKeyNextPage[i]) { + sPageIndex++; + if (sPageIndex > ((network_player_connected_count() - 1) / sPlayerListSize)) { + sPageIndex = 0; + } + break; + } + if (scancode == (int)configKeyPrevPage[i]) { + if (sPageIndex == 0) { + sPageIndex = ((network_player_connected_count() - 1) / sPlayerListSize); + } + else { + sPageIndex--; + } + break; + } + } } } diff --git a/src/pc/djui/djui_interactable.h b/src/pc/djui/djui_interactable.h index 2ac9895b..481f7efc 100644 --- a/src/pc/djui/djui_interactable.h +++ b/src/pc/djui/djui_interactable.h @@ -47,6 +47,8 @@ extern struct DjuiBase* gDjuiCursorDownOn; extern struct DjuiBase* gInteractableFocus; extern struct DjuiBase* gInteractableBinding; extern struct DjuiBase* gInteractableMouseDown; +extern const u8 sPlayerListSize; +extern u8 sPageIndex; bool djui_interactable_is_binding(void); void djui_interactable_set_binding(struct DjuiBase* base); diff --git a/src/pc/djui/djui_panel_controls_extra.c b/src/pc/djui/djui_panel_controls_extra.c index f6b3f5f1..09479b6e 100644 --- a/src/pc/djui/djui_panel_controls_extra.c +++ b/src/pc/djui/djui_panel_controls_extra.c @@ -4,7 +4,7 @@ #include "src/pc/configfile.h" void djui_panel_controls_extra_create(struct DjuiBase* caller) { - f32 bindBodyHeight = 28 * 8 + 1 * 7; + f32 bindBodyHeight = 28 * 10 + 1 * 7; struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(CONTROLS, CONTROLS)); struct DjuiBase* body = djui_three_panel_get_body(panel); @@ -23,6 +23,8 @@ void djui_panel_controls_extra_create(struct DjuiBase* caller) { djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_RIGHT), configKeyDRight); djui_bind_create(&bindBody->base, DLANG(CONTROLS, X), configKeyX); djui_bind_create(&bindBody->base, DLANG(CONTROLS, Y), configKeyY); + djui_bind_create(&bindBody->base, DLANG(CONTROLS, PREV), configKeyPrevPage); + djui_bind_create(&bindBody->base, DLANG(CONTROLS, NEXT), configKeyNextPage); } djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); diff --git a/src/pc/djui/djui_panel_player.c b/src/pc/djui/djui_panel_player.c index 22e0e2d5..44560f87 100644 --- a/src/pc/djui/djui_panel_player.c +++ b/src/pc/djui/djui_panel_player.c @@ -190,7 +190,7 @@ static void djui_panel_player_name_on_focus_end(struct DjuiBase* caller) { if (!djui_panel_player_name_valid(inputbox1->buffer)) { djui_inputbox_set_text(inputbox1, DLANG(PLAYER, PLAYER)); } - snprintf(configPlayerName, 20, "%s", inputbox1->buffer); + snprintf(configPlayerName, MAX_PLAYER_STRING, "%s", inputbox1->buffer); djui_inputbox_set_text_color(inputbox1, 0, 0, 0, 255); if (gNetworkType != NT_NONE) { @@ -246,7 +246,7 @@ void djui_panel_player_create(struct DjuiBase* caller) { djui_base_set_size(&text1->base, 0.585f, 64); djui_base_set_alignment(&text1->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP); - struct DjuiInputbox* inputbox1 = djui_inputbox_create(&rect1->base, 20); + struct DjuiInputbox* inputbox1 = djui_inputbox_create(&rect1->base, MAX_PLAYER_STRING); djui_base_set_size_type(&inputbox1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&inputbox1->base, 0.4f, 32); djui_base_set_alignment(&inputbox1->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP); diff --git a/src/pc/djui/djui_panel_playerlist.c b/src/pc/djui/djui_panel_playerlist.c index 60ed69bb..6ace8d6f 100644 --- a/src/pc/djui/djui_panel_playerlist.c +++ b/src/pc/djui/djui_panel_playerlist.c @@ -18,6 +18,10 @@ static struct DjuiText* djuiTextDescriptions[MAX_PLAYERS] = { 0 }; static struct DjuiText* djuiTextLocations[MAX_PLAYERS] = { 0 }; static struct DjuiText* djuiTextAct[MAX_PLAYERS] = { 0 }; +const u8 sPlayerListSize = 16; +u8 sPageIndex = 0; +static u8 p = 0; // All player slots always exist this switches their visibility on and off if they're connected or not + static void playerlist_update_row(u8 i, struct NetworkPlayer *np) { u8 charIndex = np->overrideModelIndex; char sActNum[7]; @@ -34,6 +38,9 @@ static void playerlist_update_row(u8 i, struct NetworkPlayer *np) { u8 visible = np->connected; if (np == gNetworkPlayerServer && gServerSettings.headlessServer) { visible = false; + } else if (p < sPlayerListSize * sPageIndex) { + visible = false; + p++; } djui_base_set_visible(&djuiRow[i]->base, visible); @@ -51,6 +58,7 @@ static void playerlist_update_row(u8 i, struct NetworkPlayer *np) { void djui_panel_playerlist_on_render_pre(UNUSED struct DjuiBase* base, UNUSED bool* skipRender) { s32 j = 0; + p = 0; for (s32 i = 0; i < MAX_PLAYERS; i++) { struct NetworkPlayer *np = &gNetworkPlayers[i]; @@ -65,7 +73,7 @@ void djui_panel_playerlist_on_render_pre(UNUSED struct DjuiBase* base, UNUSED bo } void djui_panel_playerlist_create(UNUSED struct DjuiBase* caller) { - f32 bodyHeight = (MAX_PLAYERS * 32) + (MAX_PLAYERS - 1) * 4; + f32 bodyHeight = (sPlayerListSize * 32) + (sPlayerListSize - 1) * 4; struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(PLAYER_LIST, PLAYERS)); djui_three_panel_set_body_size(panel, bodyHeight); @@ -78,7 +86,7 @@ void djui_panel_playerlist_create(UNUSED struct DjuiBase* caller) { struct DjuiBase* body = djui_three_panel_get_body(panel); djui_flow_layout_set_margin((struct DjuiFlowLayout*)body, 4); - for (s32 i = 0; i < MAX_PLAYERS; i++) { + for (u8 i = 0; i < MAX_PLAYERS; i++) { struct DjuiFlowLayout* row = djui_flow_layout_create(body); djui_base_set_size_type(&row->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&row->base, 1.0f, 32.0f);