diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index b69be8e75..937a787c2 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -11022,6 +11022,12 @@ function djui_menu_get_theme() -- ... end +--- @return boolean +--- Checks if the DJUI playerlist ping icon is visible +function djui_is_playerlist_ping_visible() + -- ... +end + --- @return integer --- Gets the current state of the dialog box function get_dialog_box_state() diff --git a/bin/custom_textures.c b/bin/custom_textures.c index e8efda4d9..8136a1fcb 100644 --- a/bin/custom_textures.c +++ b/bin/custom_textures.c @@ -34,3 +34,27 @@ ALIGNED8 const Texture texture_selectionbox_forward_icon[] = { ALIGNED8 const Texture texture_coopdx_logo[] = { #include "textures/segment2/custom_coopdx_logo.rgba32.inc.c" }; + +ALIGNED8 const Texture texture_ping_empty[] = { +#include "textures/segment2/custom_ping_empty.rgba16.inc.c" +}; + +ALIGNED8 const Texture texture_ping_one[] = { +#include "textures/segment2/custom_ping_one.rgba16.inc.c" +}; + +ALIGNED8 const Texture texture_ping_two[] = { +#include "textures/segment2/custom_ping_two.rgba16.inc.c" +}; + +ALIGNED8 const Texture texture_ping_three[] = { +#include "textures/segment2/custom_ping_three.rgba16.inc.c" +}; + +ALIGNED8 const Texture texture_ping_four[] = { +#include "textures/segment2/custom_ping_four.rgba16.inc.c" +}; + +ALIGNED8 const Texture texture_ping_full[] = { +#include "textures/segment2/custom_ping_full.rgba16.inc.c" +}; \ No newline at end of file diff --git a/data/dynos_mgr_builtin_externs.h b/data/dynos_mgr_builtin_externs.h index b3485172b..6e6b28f58 100644 --- a/data/dynos_mgr_builtin_externs.h +++ b/data/dynos_mgr_builtin_externs.h @@ -1554,6 +1554,12 @@ extern ALIGNED8 const Texture texture_selectionbox_forward_icon[]; extern ALIGNED8 const Texture texture_font_jp[]; extern ALIGNED8 const Texture texture_font_jp_aliased[]; extern ALIGNED8 const Texture texture_coopdx_logo[]; +extern ALIGNED8 const Texture texture_ping_empty[]; +extern ALIGNED8 const Texture texture_ping_one[]; +extern ALIGNED8 const Texture texture_ping_two[]; +extern ALIGNED8 const Texture texture_ping_three[]; +extern ALIGNED8 const Texture texture_ping_four[]; +extern ALIGNED8 const Texture texture_ping_full[]; extern ALIGNED8 const Texture pss_seg7_texture_07000000[]; extern ALIGNED8 const Texture pss_seg7_texture_07000800[]; extern ALIGNED8 const Texture pss_seg7_texture_07001000[]; diff --git a/data/dynos_mgr_builtin_tex.cpp b/data/dynos_mgr_builtin_tex.cpp index 29e0b8cbd..4aed3a50c 100644 --- a/data/dynos_mgr_builtin_tex.cpp +++ b/data/dynos_mgr_builtin_tex.cpp @@ -1154,6 +1154,14 @@ static const struct BuiltinTexInfo sDynosBuiltinTexs[] = { define_builtin_tex(texture_selectionbox_forward_icon, "textures/segment2/custom_selectionbox_forward_icon.rgba16.png", 16, 16, 16), define_builtin_tex(texture_coopdx_logo, "textures/segment2/custom_coopdx_logo.rgba32.png", 2048, 1024, 32), + // Playerlist Exclusives + define_builtin_tex(texture_ping_empty, "textures/segment2/custom_ping_empty.rgba16.png", 16, 16, 16), + define_builtin_tex(texture_ping_one, "textures/segment2/custom_ping_one.rgba16.png", 16, 16, 16), + define_builtin_tex(texture_ping_two, "textures/segment2/custom_ping_two.rgba16.png", 16, 16, 16), + define_builtin_tex(texture_ping_three, "textures/segment2/custom_ping_three.rgba16.png", 16, 16, 16), + define_builtin_tex(texture_ping_four, "textures/segment2/custom_ping_four.rgba16.png", 16, 16, 16), + define_builtin_tex(texture_ping_full, "textures/segment2/custom_ping_full.rgba16.png", 16, 16, 16), + // Goddard define_builtin_tex(gd_texture_hand_open, "textures/intro_raw/hand_open.rgba16.png", 32, 32, 16), define_builtin_tex(gd_texture_hand_closed, "textures/intro_raw/hand_closed.rgba16.png", 32, 32, 16), diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index 4ee1939ac..ebefc2e88 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -4407,6 +4407,27 @@ Gets the DJUI menu theme
+## [djui_is_playerlist_ping_visible](#djui_is_playerlist_ping_visible) + +### Description +Checks if the DJUI playerlist ping icon is visible + +### Lua Example +`local booleanValue = djui_is_playerlist_ping_visible()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool djui_is_playerlist_ping_visible(void);` + +[:arrow_up_small:](#) + +
+ ## [get_dialog_box_state](#get_dialog_box_state) ### Description diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 2d4ac051d..8656b5289 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1977,6 +1977,7 @@ - [djui_get_playerlist_page_index](functions-6.md#djui_get_playerlist_page_index) - [djui_menu_get_font](functions-6.md#djui_menu_get_font) - [djui_menu_get_theme](functions-6.md#djui_menu_get_theme) + - [djui_is_playerlist_ping_visible](functions-6.md#djui_is_playerlist_ping_visible) - [get_dialog_box_state](functions-6.md#get_dialog_box_state) - [get_dialog_id](functions-6.md#get_dialog_id) - [get_last_star_or_key](functions-6.md#get_last_star_or_key) diff --git a/lang/Czech.ini b/lang/Czech.ini index 304cf89fb..f11f8065c 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Anti-aliasing" OFF = "Vypnuto" MUST_RESTART = "Musíte restartovat hru pro aplikování změn." SHOW_FPS = "Zobrazit FPS" +SHOW_PING = "Zobrazit Ping" [DJUI_THEMES] DJUI_THEME = "Téma DJUI" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index dfb179065..bf4f6f53e 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Anti-aliasing" OFF = "UIT" MUST_RESTART = "Je moet de game opnieuw opstarten voor sommige veranderingen om effect te hebben." SHOW_FPS = "Toon FPS" +SHOW_PING = "Toon Ping" [DJUI_THEMES] DJUI_THEME = "DJUI Thema" diff --git a/lang/English.ini b/lang/English.ini index ad2b93f66..5977aa9e0 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Anti-aliasing" OFF = "Off" MUST_RESTART = "Restart the game to apply changes." SHOW_FPS = "Show FPS" +SHOW_PING = "Show Ping" [DJUI_THEMES] DJUI_THEME = "DJUI Theme" diff --git a/lang/French.ini b/lang/French.ini index 62379a286..4886e0540 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Anti-aliasing" OFF = "Désactivé" MUST_RESTART = "Vous devez relancer le jeu pour que certains changements prennent effet." SHOW_FPS = "Afficher FPS" +SHOW_PING = "Afficher Ping" [DJUI_THEMES] DJUI_THEME = "Thème DJUI" diff --git a/lang/German.ini b/lang/German.ini index 7e78a8e86..15248f8d9 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Kantenglättung" OFF = "Aus" MUST_RESTART = "Um einige Änderungen zu übernehmen, muss das Spiel neugestartet werden." SHOW_FPS = "FPS anzeigen" +SHOW_PING = "Ping anzeigen" [DJUI_THEMES] DJUI_THEME = "DJUI-Theme" diff --git a/lang/Italian.ini b/lang/Italian.ini index bbcf1825e..eec74d0b7 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -169,6 +169,7 @@ ANTIALIASING = "Anti-aliasing" OFF = "Off" MUST_RESTART = "Devi riavviare il gioco perché alcuni cambiamenti abbiano effetto." SHOW_FPS = "Mostra FPS" +SHOW_PING = "Mostra Ping" [DJUI_THEMES] DJUI_THEME = "Tema DJUI" diff --git a/lang/Japanese.ini b/lang/Japanese.ini index 3b84851c4..058bd1679 100644 --- a/lang/Japanese.ini +++ b/lang/Japanese.ini @@ -172,6 +172,7 @@ ANTIALIASING = "アンチエイリアス" OFF = "オフ" MUST_RESTART = "変更を適用するにはゲームを再起動してください。" SHOW_FPS = "FPSを表示する" +SHOW_PING = "Pingを表示する" [DJUI_THEMES] DJUI_THEME = "DJUIのテーマ" diff --git a/lang/Polish.ini b/lang/Polish.ini index 0c3db14c4..b06b94414 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Anti-aliasing" OFF = "Wyłączone" MUST_RESTART = "Musisz zrestartować grę, aby zastosować zmiany." SHOW_FPS = "Pokaż Klatki na Sekundę" +SHOW_PING = "Pokaż Ping" [DJUI_THEMES] DJUI_THEME = "Motyw DJUI" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index 7b0196d11..d236ff701 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Antisserrilhamento" OFF = "Desligado" MUST_RESTART = "Reinicie o jogo para aplicar as mudanças." SHOW_FPS = "Mostrar FPS" +SHOW_PING = "Mostrar Ping" [DJUI_THEMES] DJUI_THEME = "Tema da DJUI" diff --git a/lang/Russian.ini b/lang/Russian.ini index f2be7ae57..0def17f6b 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -170,6 +170,7 @@ ANTIALIASING = "Анизотропная фильтрация" OFF = "Выкл" MUST_RESTART = "Перезапустите игру, чтобы изменения вступили в силу" SHOW_FPS = "Показывать FPS" +SHOW_PING = "Показывать пинг" [DJUI_THEMES] DJUI_THEME = "Темы DJUI" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index d070411c6..7eeecb085 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -171,6 +171,7 @@ ANTIALIASING = "Anti-aliasing" OFF = "Desactivado" MUST_RESTART = "Tienes que reiniciar el juego para que algunos cambios surtan efecto." SHOW_FPS = "Mostrar FPS" +SHOW_PING = "Mostrar Ping" [DJUI_THEMES] DJUI_THEME = "Tema de DJUI" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 74fdf878e..f2267a7db 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -84,6 +84,7 @@ ConfigStick configStick = { 0 }; // display settings unsigned int configFiltering = 2; // 0 = Nearest, 1 = Bilinear, 2 = Trilinear bool configShowFPS = false; +bool configShowPing = false; enum RefreshRateMode configFramerateMode = RRM_AUTO; unsigned int configFrameLimit = 60; unsigned int configInterpolationMode = 1; @@ -226,6 +227,7 @@ static const struct ConfigOption options[] = { // display settings {.name = "texture_filtering", .type = CONFIG_TYPE_UINT, .uintValue = &configFiltering}, {.name = "show_fps", .type = CONFIG_TYPE_BOOL, .boolValue = &configShowFPS}, + {.name = "show_ping", .type = CONFIG_TYPE_BOOL, .boolValue = &configShowPing}, {.name = "framerate_mode", .type = CONFIG_TYPE_UINT, .uintValue = &configFramerateMode}, {.name = "frame_limit", .type = CONFIG_TYPE_UINT, .uintValue = &configFrameLimit}, {.name = "interpolation_mode", .type = CONFIG_TYPE_UINT, .uintValue = &configInterpolationMode}, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index a63d374c8..d537970e4 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -50,6 +50,7 @@ extern ConfigWindow configWindow; extern ConfigStick configStick; extern unsigned int configFiltering; extern bool configShowFPS; +extern bool configShowPing; extern enum RefreshRateMode configFramerateMode; extern unsigned int configFrameLimit; extern unsigned int configInterpolationMode; diff --git a/src/pc/djui/djui_panel_display.c b/src/pc/djui/djui_panel_display.c index f0aecfe74..a052af65d 100644 --- a/src/pc/djui/djui_panel_display.c +++ b/src/pc/djui/djui_panel_display.c @@ -63,6 +63,7 @@ void djui_panel_display_create(struct DjuiBase* caller) { djui_checkbox_create(body, DLANG(DISPLAY, FULLSCREEN), &configWindow.fullscreen, djui_panel_display_apply); djui_checkbox_create(body, DLANG(DISPLAY, FORCE_4BY3), &configForce4By3, djui_panel_display_apply); djui_checkbox_create(body, DLANG(DISPLAY, SHOW_FPS), &configShowFPS, NULL); + djui_checkbox_create(body, DLANG(DISPLAY, SHOW_PING), &configShowPing, NULL); djui_checkbox_create(body, DLANG(DISPLAY, VSYNC), &configWindow.vsync, djui_panel_display_apply); char* framerateModeChoices[3] = { DLANG(DISPLAY, AUTO), DLANG(DISPLAY, MANUAL), DLANG(DISPLAY, UNCAPPED) }; diff --git a/src/pc/djui/djui_panel_playerlist.c b/src/pc/djui/djui_panel_playerlist.c index 21aeaaf25..8b48fdbb9 100644 --- a/src/pc/djui/djui_panel_playerlist.c +++ b/src/pc/djui/djui_panel_playerlist.c @@ -10,11 +10,21 @@ #include "pc/network/network.h" #include "pc/utils/misc.h" +extern ALIGNED8 const u8 texture_hud_char_mario_head[]; + +extern ALIGNED8 const Texture texture_ping_empty[]; +extern ALIGNED8 const Texture texture_ping_one[]; +extern ALIGNED8 const Texture texture_ping_two[]; +extern ALIGNED8 const Texture texture_ping_three[]; +extern ALIGNED8 const Texture texture_ping_four[]; +extern ALIGNED8 const Texture texture_ping_full[]; + struct DjuiThreePanel* gDjuiPlayerList = NULL; bool gAttemptingToOpenPlayerlist = false; static struct DjuiFlowLayout* djuiRow[MAX_PLAYERS] = { 0 }; -static struct DjuiImage* djuiImages[MAX_PLAYERS] = { 0 }; +static struct DjuiImage* djuiHeadIconImages[MAX_PLAYERS] = { 0 }; +static struct DjuiImage* djuiPingImages[MAX_PLAYERS] = { 0 }; static struct DjuiText* djuiTextNames[MAX_PLAYERS] = { 0 }; static struct DjuiText* djuiTextDescriptions[MAX_PLAYERS] = { 0 }; static struct DjuiText* djuiTextLocations[MAX_PLAYERS] = { 0 }; @@ -35,7 +45,17 @@ static void playerlist_update_row(u8 i, struct NetworkPlayer *np) { snprintf(sActNum, 7, "Done"); } if (charIndex >= CT_MAX) { charIndex = 0; } - djuiImages[i]->texture = gCharacters[charIndex].hudHeadTexture.texture; + djuiHeadIconImages[i]->texture = gCharacters[charIndex].hudHeadTexture.texture; + + s16 pingValue = np->ping / 150; + switch (pingValue) { + case 0: djuiPingImages[i]->texture = texture_ping_full; break; + case 1: djuiPingImages[i]->texture = texture_ping_four; break; + case 2: djuiPingImages[i]->texture = texture_ping_three; break; + case 3: djuiPingImages[i]->texture = texture_ping_two; break; + case 4: djuiPingImages[i]->texture = texture_ping_one; break; + default: djuiPingImages[i]->texture = texture_ping_empty; break; + } u8 visible = np->connected; if (np == gNetworkPlayerServer && gServerSettings.headlessServer) { @@ -46,6 +66,7 @@ static void playerlist_update_row(u8 i, struct NetworkPlayer *np) { } djui_base_set_visible(&djuiRow[i]->base, visible); + djui_base_set_visible(&djuiPingImages[i]->base, configShowPing); u8* rgb = network_get_player_text_color(np->localIndex); djui_base_set_color(&djuiTextNames[i]->base, rgb[0], rgb[1], rgb[2], 255); @@ -60,6 +81,7 @@ static void playerlist_update_row(u8 i, struct NetworkPlayer *np) { : np->overrideLocation ); djui_text_set_text(djuiTextAct[i], sActNum); + djui_base_set_size(&djuiTextAct[i]->base, configShowPing ? 65 : 100, 32.0f); } void djui_panel_playerlist_on_render_pre(UNUSED struct DjuiBase* base, UNUSED bool* skipRender) { @@ -94,7 +116,7 @@ void djui_panel_playerlist_create(UNUSED struct DjuiBase* caller) { // delete old player list if (gDjuiPlayerList != NULL) { djui_base_destroy(&gDjuiPlayerList->base); - gDjuiPlayerList= NULL; + gDjuiPlayerList = NULL; } struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(PLAYER_LIST, PLAYERS), false); @@ -119,10 +141,13 @@ void djui_panel_playerlist_create(UNUSED struct DjuiBase* caller) { djui_base_set_visible(&row->base, false); djuiRow[i] = row; - extern ALIGNED8 const u8 texture_hud_char_mario_head[]; - struct DjuiImage* i1 = djui_image_create(&row->base, texture_hud_char_mario_head, 16, 16, 8); + struct DjuiImage* i1 = djui_image_create(&row->base, texture_ping_empty, 16, 16, 8); djui_base_set_size(&i1->base, 32, 32); - djuiImages[i] = i1; + djuiPingImages[i] = i1; + + struct DjuiImage* i2 = djui_image_create(&row->base, texture_hud_char_mario_head, 16, 16, 8); + djui_base_set_size(&i2->base, 32, 32); + djuiHeadIconImages[i] = i2; int t = 220; struct DjuiText* t2 = djui_text_create(&row->base, DLANG(PLAYER_LIST, NAME)); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 8a9cfe646..885815bc9 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -33082,6 +33082,21 @@ int smlua_func_djui_menu_get_theme(UNUSED lua_State* L) { return 1; } +int smlua_func_djui_is_playerlist_ping_visible(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_is_playerlist_ping_visible", 0, top); + return 0; + } + + + lua_pushboolean(L, djui_is_playerlist_ping_visible()); + + return 1; +} + int smlua_func_get_dialog_box_state(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -38236,6 +38251,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_get_playerlist_page_index", smlua_func_djui_get_playerlist_page_index); smlua_bind_function(L, "djui_menu_get_font", smlua_func_djui_menu_get_font); smlua_bind_function(L, "djui_menu_get_theme", smlua_func_djui_menu_get_theme); + smlua_bind_function(L, "djui_is_playerlist_ping_visible", smlua_func_djui_is_playerlist_ping_visible); 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); smlua_bind_function(L, "get_last_star_or_key", smlua_func_get_last_star_or_key); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 58a9af095..c57c06d3f 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -118,6 +118,10 @@ struct DjuiTheme* djui_menu_get_theme(void) { return gDjuiThemes[configDjuiTheme]; } +bool djui_is_playerlist_ping_visible(void) { + return configShowPing; +} + /// extern s8 gDialogBoxState; diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 9c65320d7..0469da92a 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -79,6 +79,8 @@ u8 djui_get_playerlist_page_index(void); enum DjuiFontType djui_menu_get_font(void); /* |description|Gets the DJUI menu theme|descriptionEnd| */ struct DjuiTheme* djui_menu_get_theme(void); +/* |description|Checks if the DJUI playerlist ping icon is visible|descriptionEnd| */ +bool djui_is_playerlist_ping_visible(void); /* |description|Gets the current state of the dialog box|descriptionEnd| */ s8 get_dialog_box_state(void); diff --git a/textures/segment2/custom_ping_empty.rgba16.png b/textures/segment2/custom_ping_empty.rgba16.png new file mode 100644 index 000000000..2867d6345 Binary files /dev/null and b/textures/segment2/custom_ping_empty.rgba16.png differ diff --git a/textures/segment2/custom_ping_four.rgba16.png b/textures/segment2/custom_ping_four.rgba16.png new file mode 100644 index 000000000..f8c6eb0fb Binary files /dev/null and b/textures/segment2/custom_ping_four.rgba16.png differ diff --git a/textures/segment2/custom_ping_full.rgba16.png b/textures/segment2/custom_ping_full.rgba16.png new file mode 100644 index 000000000..959e75124 Binary files /dev/null and b/textures/segment2/custom_ping_full.rgba16.png differ diff --git a/textures/segment2/custom_ping_one.rgba16.png b/textures/segment2/custom_ping_one.rgba16.png new file mode 100644 index 000000000..eae2ba817 Binary files /dev/null and b/textures/segment2/custom_ping_one.rgba16.png differ diff --git a/textures/segment2/custom_ping_three.rgba16.png b/textures/segment2/custom_ping_three.rgba16.png new file mode 100644 index 000000000..0bfc3474c Binary files /dev/null and b/textures/segment2/custom_ping_three.rgba16.png differ diff --git a/textures/segment2/custom_ping_two.rgba16.png b/textures/segment2/custom_ping_two.rgba16.png new file mode 100644 index 000000000..c48c0c110 Binary files /dev/null and b/textures/segment2/custom_ping_two.rgba16.png differ