From 10c29cd31728df935e0dd17830aa3b80e84c19b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 13 Sep 2016 22:43:20 +0200 Subject: [PATCH] Add default 'no settings' entry if no settings could be added for network settings --- menu/menu_displaylist.c | 102 ++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 40 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e21adb4846..7a876f2f1d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4655,53 +4655,75 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) info->need_push = true; break; case DISPLAYLIST_NETWORK_SETTINGS_LIST: - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_CLIENT_SWAP_INPUT, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, - PARSE_ONLY_STRING, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_MODE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_DELAY_FRAMES, - PARSE_ONLY_UINT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT, - PARSE_ONLY_UINT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_CMD_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_CMD_PORT, - PARSE_ONLY_UINT, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_REMOTE_ENABLE, - PARSE_ONLY_BOOL, false); - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_NETWORK_REMOTE_PORT, - PARSE_ONLY_UINT, false); - { unsigned user; + unsigned count = 0; + + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_CLIENT_SWAP_INPUT, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, + PARSE_ONLY_STRING, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_MODE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_DELAY_FRAMES, + PARSE_ONLY_UINT, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT, + PARSE_ONLY_UINT, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_CMD_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_CMD_PORT, + PARSE_ONLY_UINT, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_REMOTE_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETWORK_REMOTE_PORT, + PARSE_ONLY_UINT, false) != -1) + count++; + for(user = 0; user < settings->input.max_users; user++) { - menu_displaylist_parse_settings_enum(menu, info, + if (menu_displaylist_parse_settings_enum(menu, info, (enum msg_hash_enums)(MENU_ENUM_LABEL_NETWORK_REMOTE_USER_1_ENABLE + user), - PARSE_ONLY_BOOL, false); + PARSE_ONLY_BOOL, false) != -1) + count++; } - } - menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_STDIN_CMD_ENABLE, - PARSE_ONLY_BOOL, false); + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_STDIN_CMD_ENABLE, + PARSE_ONLY_BOOL, false) != -1) + count++; + + if (count == 0) + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND), + msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND), + MENU_ENUM_LABEL_NO_SETTINGS_FOUND, + 0, 0, 0); + } info->need_refresh = true; info->need_push = true;