From 78bc42de680fdfda78b9b850f8ab351f1dfa9e90 Mon Sep 17 00:00:00 2001 From: Cthulhu-throwaway <96153783+Cthulhu-throwaway@users.noreply.github.com> Date: Fri, 1 Jul 2022 19:24:33 -0300 Subject: [PATCH] (Netplay/Lobby) Add setting for filtering out rooms with non-installed cores (#14124) --- config.def.h | 5 +++-- configuration.c | 1 + configuration.h | 1 + intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.h | 4 ++++ menu/menu_displaylist.c | 37 +++++++++++++++++++++++++++++-------- menu/menu_setting.c | 15 +++++++++++++++ msg_hash.h | 1 + 8 files changed, 58 insertions(+), 10 deletions(-) diff --git a/config.def.h b/config.def.h index a8455175e9..d0c9959d92 100644 --- a/config.def.h +++ b/config.def.h @@ -1202,8 +1202,9 @@ static const bool audio_enable_menu_bgm = false; #endif /* Netplay lobby filters */ -#define DEFAULT_NETPLAY_SHOW_ONLY_CONNECTABLE true -#define DEFAULT_NETPLAY_SHOW_PASSWORDED true +#define DEFAULT_NETPLAY_SHOW_ONLY_CONNECTABLE true +#define DEFAULT_NETPLAY_SHOW_ONLY_INSTALLED_CORES false +#define DEFAULT_NETPLAY_SHOW_PASSWORDED true /* Publicly announce netplay */ #define DEFAULT_NETPLAY_PUBLIC_ANNOUNCE true diff --git a/configuration.c b/configuration.c index 62a856afe1..8f5e1ae117 100644 --- a/configuration.c +++ b/configuration.c @@ -1608,6 +1608,7 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("menu_swap_ok_cancel_buttons", &settings->bools.input_menu_swap_ok_cancel_buttons, true, DEFAULT_MENU_SWAP_OK_CANCEL_BUTTONS, false); #ifdef HAVE_NETWORKING SETTING_BOOL("netplay_show_only_connectable", &settings->bools.netplay_show_only_connectable, true, DEFAULT_NETPLAY_SHOW_ONLY_CONNECTABLE, false); + SETTING_BOOL("netplay_show_only_installed_cores", &settings->bools.netplay_show_only_installed_cores, true, DEFAULT_NETPLAY_SHOW_ONLY_INSTALLED_CORES, false); SETTING_BOOL("netplay_show_passworded", &settings->bools.netplay_show_passworded, true, DEFAULT_NETPLAY_SHOW_PASSWORDED, false); SETTING_BOOL("netplay_public_announce", &settings->bools.netplay_public_announce, true, DEFAULT_NETPLAY_PUBLIC_ANNOUNCE, false); SETTING_BOOL("netplay_start_as_spectator", &settings->bools.netplay_start_as_spectator, false, netplay_start_as_spectator, false); diff --git a/configuration.h b/configuration.h index 22d52f0a96..fccb382ac9 100644 --- a/configuration.h +++ b/configuration.h @@ -759,6 +759,7 @@ typedef struct settings /* Netplay */ bool netplay_show_only_connectable; + bool netplay_show_only_installed_cores; bool netplay_show_passworded; bool netplay_public_announce; bool netplay_start_as_spectator; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 4b9ef52369..2a8ead97a4 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -3066,6 +3066,10 @@ MSG_HASH( MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_CONNECTABLE, "netplay_show_only_connectable" ) +MSG_HASH( + MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_INSTALLED_CORES, + "netplay_show_only_installed_cores" + ) MSG_HASH( MENU_ENUM_LABEL_NETPLAY_SHOW_PASSWORDED, "netplay_show_passworded" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index d98172da5d..f1f67c0c26 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -6606,6 +6606,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_SHOW_ONLY_CONNECTABLE, "Only Connectable Rooms" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NETPLAY_SHOW_ONLY_INSTALLED_CORES, + "Only Installed Cores" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NETPLAY_SHOW_PASSWORDED, "Passworded Rooms" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 385673fa3a..17a4bb675e 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7953,8 +7953,9 @@ unsigned menu_displaylist_build_list( case DISPLAYLIST_NETPLAY_LOBBY_FILTERS_LIST: { menu_displaylist_build_info_selective_t build_list[] = { - {MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_CONNECTABLE, PARSE_ONLY_BOOL, true}, - {MENU_ENUM_LABEL_NETPLAY_SHOW_PASSWORDED, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_CONNECTABLE, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_INSTALLED_CORES, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_SHOW_PASSWORDED, PARSE_ONLY_BOOL, true}, }; for (i = 0; i < ARRAY_SIZE(build_list); i++) @@ -10412,17 +10413,21 @@ static unsigned menu_displaylist_build_shader_parameter( #ifdef HAVE_NETWORKING unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) { - int i; + int i, j; char buf[256]; char passworded[64]; char country[8]; const char *room_type; struct netplay_room *room; - unsigned count = 0; - settings_t *settings = config_get_ptr(); - net_driver_state_t *net_st = networking_state_get_ptr(); - bool show_only_connectable = settings->bools.netplay_show_only_connectable; - bool show_passworded = settings->bools.netplay_show_passworded; + unsigned count = 0; + core_info_list_t *coreinfos = NULL; + settings_t *settings = config_get_ptr(); + net_driver_state_t *net_st = networking_state_get_ptr(); + bool show_only_connectable = + settings->bools.netplay_show_only_connectable; + bool show_only_installed_cores = + settings->bools.netplay_show_only_installed_cores; + bool show_passworded = settings->bools.netplay_show_passworded; menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, list); @@ -10482,6 +10487,8 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) count++; #endif + core_info_get_list(&coreinfos); + for (i = 0; i < net_st->room_count; i++) { room = &net_st->room_list[i]; @@ -10510,6 +10517,20 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) else room_type = msg_hash_to_str(MSG_INTERNET); + /* Get rid of any room running a core that we don't have installed, + if the user opt-in. */ + if (show_only_installed_cores) + { + for (j = 0; j < coreinfos->count; j++) + { + if (string_is_equal_case_insensitive(coreinfos->list[j].core_name, + room->corename)) + break; + } + if (j >= coreinfos->count) + continue; + } + /* Get rid of any room that is passworded, if the user opt-in. */ if (room->has_password || room->has_spectate_password) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6048bdff31..b6215a221a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -19713,6 +19713,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_BOOL( + list, list_info, + &settings->bools.netplay_show_only_installed_cores, + MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_INSTALLED_CORES, + MENU_ENUM_LABEL_VALUE_NETPLAY_SHOW_ONLY_INSTALLED_CORES, + DEFAULT_NETPLAY_SHOW_ONLY_INSTALLED_CORES, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + CONFIG_BOOL( list, list_info, &settings->bools.netplay_show_passworded, diff --git a/msg_hash.h b/msg_hash.h index 8aae29519a..853d995b94 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1716,6 +1716,7 @@ enum msg_hash_enums MENU_LABEL(SCAN_DIRECTORY), MENU_LABEL(SCAN_FILE), MENU_LABEL(NETPLAY_SHOW_ONLY_CONNECTABLE), + MENU_LABEL(NETPLAY_SHOW_ONLY_INSTALLED_CORES), MENU_LABEL(NETPLAY_SHOW_PASSWORDED), MENU_LABEL(NETPLAY_REFRESH_ROOMS), MENU_LABEL(NETPLAY_REFRESH_LAN),