Filter out non-connectable rooms (#13429)

Add an option for filtering out non-connectable netplay rooms.
This commit is contained in:
Cthulhu-throwaway 2021-12-30 04:33:54 -03:00 committed by GitHub
parent e161af4826
commit d017ce7b03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 0 deletions

View File

@ -1159,6 +1159,9 @@ static const bool audio_enable_menu_bgm = false;
#define DEFAULT_AUTOSAVE_INTERVAL 0 #define DEFAULT_AUTOSAVE_INTERVAL 0
#endif #endif
/* Show only connectable rooms */
#define DEFAULT_NETPLAY_SHOW_ONLY_CONNECTABLE true
/* Publicly announce netplay */ /* Publicly announce netplay */
#define DEFAULT_NETPLAY_PUBLIC_ANNOUNCE true #define DEFAULT_NETPLAY_PUBLIC_ANNOUNCE true

View File

@ -1603,6 +1603,7 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("all_users_control_menu", &settings->bools.input_all_users_control_menu, true, DEFAULT_ALL_USERS_CONTROL_MENU, false); SETTING_BOOL("all_users_control_menu", &settings->bools.input_all_users_control_menu, true, DEFAULT_ALL_USERS_CONTROL_MENU, false);
SETTING_BOOL("menu_swap_ok_cancel_buttons", &settings->bools.input_menu_swap_ok_cancel_buttons, true, DEFAULT_MENU_SWAP_OK_CANCEL_BUTTONS, false); 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 #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_public_announce", &settings->bools.netplay_public_announce, true, DEFAULT_NETPLAY_PUBLIC_ANNOUNCE, 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); SETTING_BOOL("netplay_start_as_spectator", &settings->bools.netplay_start_as_spectator, false, netplay_start_as_spectator, false);
SETTING_BOOL("netplay_fade_chat", &settings->bools.netplay_fade_chat, true, netplay_fade_chat, false); SETTING_BOOL("netplay_fade_chat", &settings->bools.netplay_fade_chat, true, netplay_fade_chat, false);

View File

@ -761,6 +761,7 @@ typedef struct settings
bool crt_switch_hires_menu; bool crt_switch_hires_menu;
/* Netplay */ /* Netplay */
bool netplay_show_only_connectable;
bool netplay_public_announce; bool netplay_public_announce;
bool netplay_start_as_spectator; bool netplay_start_as_spectator;
bool netplay_fade_chat; bool netplay_fade_chat;

View File

@ -2848,6 +2848,10 @@ MSG_HASH(
MENU_ENUM_LABEL_SCAN_FILE, MENU_ENUM_LABEL_SCAN_FILE,
"scan_file" "scan_file"
) )
MSG_HASH(
MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_CONNECTABLE,
"netplay_show_only_connectable"
)
MSG_HASH( MSG_HASH(
MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS, MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS,
"refresh_rooms" "refresh_rooms"

View File

@ -6168,6 +6168,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_NETPLAY_DISCONNECT, MENU_ENUM_SUBLABEL_NETPLAY_DISCONNECT,
"Disconnect an active netplay connection." "Disconnect an active netplay connection."
) )
MSG_HASH(
MENU_ENUM_LABEL_VALUE_NETPLAY_SHOW_ONLY_CONNECTABLE,
"Only Connectable Rooms"
)
MSG_HASH( MSG_HASH(
MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS,
"Refresh Netplay Host List" "Refresh Netplay Host List"

View File

@ -9688,6 +9688,7 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
{ {
int i; int i;
unsigned count = 0; unsigned count = 0;
settings_t *settings = config_get_ptr();
net_driver_state_t *net_st = networking_state_get_ptr(); net_driver_state_t *net_st = networking_state_get_ptr();
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, list); menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, list);
@ -9725,6 +9726,11 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
MENU_SETTING_ACTION, 0, 0)) MENU_SETTING_ACTION, 0, 0))
count++; count++;
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_CONNECTABLE,
PARSE_ONLY_BOOL, false) == 0)
count++;
if (menu_entries_append_enum(list, if (menu_entries_append_enum(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS),
msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS), msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_REFRESH_ROOMS),
@ -9753,6 +9759,11 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
if (!room->is_retroarch) if (!room->is_retroarch)
continue; continue;
/* Get rid of any room that is not connectable,
if the user opt-in. */
if (!room->connectable && settings->bools.netplay_show_only_connectable)
continue;
if (room->has_password || room->has_spectate_password) if (room->has_password || room->has_spectate_password)
snprintf(passworded, sizeof(passworded), "[%s] ", snprintf(passworded, sizeof(passworded), "[%s] ",
msg_hash_to_str(MSG_ROOM_PASSWORDED)); msg_hash_to_str(MSG_ROOM_PASSWORDED));

View File

@ -19143,6 +19143,21 @@ static bool setting_append_list(
char dev_req_label[64]; char dev_req_label[64];
char dev_req_value[64]; char dev_req_value[64];
CONFIG_BOOL(
list, list_info,
&settings->bools.netplay_show_only_connectable,
MENU_ENUM_LABEL_NETPLAY_SHOW_ONLY_CONNECTABLE,
MENU_ENUM_LABEL_VALUE_NETPLAY_SHOW_ONLY_CONNECTABLE,
DEFAULT_NETPLAY_SHOW_ONLY_CONNECTABLE,
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( CONFIG_BOOL(
list, list_info, list, list_info,
&settings->bools.netplay_public_announce, &settings->bools.netplay_public_announce,

View File

@ -1645,6 +1645,7 @@ enum msg_hash_enums
MENU_LABEL(SCAN_THIS_DIRECTORY), MENU_LABEL(SCAN_THIS_DIRECTORY),
MENU_LABEL(SCAN_DIRECTORY), MENU_LABEL(SCAN_DIRECTORY),
MENU_LABEL(SCAN_FILE), MENU_LABEL(SCAN_FILE),
MENU_LABEL(NETPLAY_SHOW_ONLY_CONNECTABLE),
MENU_LABEL(NETPLAY_REFRESH_ROOMS), MENU_LABEL(NETPLAY_REFRESH_ROOMS),
MENU_LABEL(NETPLAY_REFRESH_LAN), MENU_LABEL(NETPLAY_REFRESH_LAN),
MENU_LABEL(NETPLAY_ROOM_NICKNAME), MENU_LABEL(NETPLAY_ROOM_NICKNAME),