From d6d76a53b9e6980567e6ddb9eff2bc5af834fe57 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 21 Dec 2019 19:56:33 +0100 Subject: [PATCH] (Menu) Selectively hide Relay Server Location --- menu/menu_displaylist.c | 52 +++++++++++++++++++++++++++-------------- menu/menu_setting.c | 3 +++ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 4a9b71931b..2476000891 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5189,28 +5189,44 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct break; case DISPLAYLIST_NETWORK_SETTINGS_LIST: { - menu_displaylist_build_info_t build_list[] = { - {MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE, PARSE_ONLY_BOOL }, - {MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER, PARSE_ONLY_BOOL }, - {MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, PARSE_ONLY_STRING}, - {MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, PARSE_ONLY_STRING}, - {MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT, PARSE_ONLY_UINT }, - {MENU_ENUM_LABEL_NETPLAY_PASSWORD, PARSE_ONLY_STRING}, - {MENU_ENUM_LABEL_NETPLAY_SPECTATE_PASSWORD, PARSE_ONLY_STRING}, - {MENU_ENUM_LABEL_NETPLAY_START_AS_SPECTATOR, PARSE_ONLY_BOOL }, - {MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES, PARSE_ONLY_BOOL }, - {MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES, PARSE_ONLY_BOOL }, - {MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE, PARSE_ONLY_BOOL }, - {MENU_ENUM_LABEL_NETPLAY_CHECK_FRAMES, PARSE_ONLY_INT }, - {MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_MIN, PARSE_ONLY_INT }, - {MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_RANGE, PARSE_ONLY_INT }, - {MENU_ENUM_LABEL_NETPLAY_NAT_TRAVERSAL, PARSE_ONLY_BOOL }, - {MENU_ENUM_LABEL_NETPLAY_SHARE_DIGITAL, PARSE_ONLY_UINT }, - {MENU_ENUM_LABEL_NETPLAY_SHARE_ANALOG, PARSE_ONLY_UINT }, + settings_t *settings = config_get_ptr(); + menu_displaylist_build_info_selective_t build_list[] = { + {MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE, PARSE_ONLY_BOOL, true }, + {MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER, PARSE_ONLY_BOOL, true }, + {MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, PARSE_ONLY_STRING, false}, + {MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, PARSE_ONLY_STRING, true}, + {MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT, PARSE_ONLY_UINT, true}, + {MENU_ENUM_LABEL_NETPLAY_PASSWORD, PARSE_ONLY_STRING, true}, + {MENU_ENUM_LABEL_NETPLAY_SPECTATE_PASSWORD, PARSE_ONLY_STRING, true}, + {MENU_ENUM_LABEL_NETPLAY_START_AS_SPECTATOR, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_CHECK_FRAMES, PARSE_ONLY_INT, true}, + {MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_MIN, PARSE_ONLY_INT, true}, + {MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_RANGE, PARSE_ONLY_INT, true}, + {MENU_ENUM_LABEL_NETPLAY_NAT_TRAVERSAL, PARSE_ONLY_BOOL, true}, + {MENU_ENUM_LABEL_NETPLAY_SHARE_DIGITAL, PARSE_ONLY_UINT, true}, + {MENU_ENUM_LABEL_NETPLAY_SHARE_ANALOG, PARSE_ONLY_UINT, true}, }; for (i = 0; i < ARRAY_SIZE(build_list); i++) { + switch (build_list[i].enum_idx) + { + case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER: + if (settings->bools.netplay_use_mitm_server) + build_list[i].checked = true; + break; + default: + break; + } + } + + for (i = 0; i < ARRAY_SIZE(build_list); i++) + { + if (!build_list[i].checked && !include_everything) + continue; if (menu_displaylist_parse_settings_enum(list, build_list[i].enum_idx, build_list[i].parse_type, false) == 0) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6fbf0f83cf..f113287710 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -15428,6 +15428,9 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_NONE); + (*list)[list_info->index - 1].action_ok = &setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_left = &setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_right = &setting_bool_action_right_with_refresh; CONFIG_STRING( list, list_info,