From 3407cd665d568ebfbe0741d64c8f9ed460e1d209 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 12 Jan 2018 04:18:53 +0100 Subject: [PATCH] (Menu) Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 127 ++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 83 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index a563ce1042..6119a2c951 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -117,6 +117,49 @@ static char *lakka_get_project(void) #endif #endif +#define action_ok_dl_lbl(a, b) \ + info.directory_ptr = idx; \ + info.type = type; \ + info_path = path; \ + info_label = msg_hash_to_str(a); \ + info.enum_idx = a; \ + dl_type = b; + +static unsigned action_ok_dl_to_enum(unsigned lbl) +{ + switch (lbl) + { + case ACTION_OK_DL_ACCOUNTS_LIST: + return MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST; + case ACTION_OK_DL_INPUT_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_INPUT_SETTINGS_LIST; + case ACTION_OK_DL_DRIVER_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST; + case ACTION_OK_DL_CORE_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST; + case ACTION_OK_DL_VIDEO_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST; + case ACTION_OK_DL_CONFIGURATION_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST; + case ACTION_OK_DL_SAVING_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST; + case ACTION_OK_DL_LOGGING_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST; + case ACTION_OK_DL_FRAME_THROTTLE_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST; + case ACTION_OK_DL_REWIND_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST; + case ACTION_OK_DL_ONSCREEN_DISPLAY_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST; + case ACTION_OK_DL_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST: + return MENU_ENUM_LABEL_DEFERRED_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST; + default: + break; + } + + return 0; +} + int generic_action_ok_displaylist_push(const char *path, const char *new_path, const char *label, unsigned type, size_t idx, size_t entry_idx, @@ -604,100 +647,18 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_ACCOUNTS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_ACCOUNTS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_INPUT_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_INPUT_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_INPUT_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_DRIVER_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DRIVER_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_CORE_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_VIDEO_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_VIDEO_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_CONFIGURATION_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_CONFIGURATION_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_SAVING_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_LOGGING_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_LOGGING_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_FRAME_THROTTLE_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_FRAME_THROTTLE_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_REWIND_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_REWIND_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_ONSCREEN_DISPLAY_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_ONSCREEN_DISPLAY_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; - break; case ACTION_OK_DL_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST: - info.directory_ptr = idx; - info.type = type; - info_path = path; - info_label = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST); - info.enum_idx = MENU_ENUM_LABEL_DEFERRED_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST; - dl_type = DISPLAYLIST_GENERIC; + action_ok_dl_lbl(action_ok_dl_to_enum(action_type), DISPLAYLIST_GENERIC); break; case ACTION_OK_DL_ONSCREEN_OVERLAY_SETTINGS_LIST: info.directory_ptr = idx;