(Netplay/Lobby) Add setting for filtering out rooms with non-installed cores (#14124)

This commit is contained in:
Cthulhu-throwaway 2022-07-01 19:24:33 -03:00 committed by GitHub
parent e7b9ff1ff6
commit 78bc42de68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 58 additions and 10 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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"

View File

@ -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"

View File

@ -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)

View File

@ -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,

View File

@ -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),