(Menu) Cut down on code duplication

This commit is contained in:
twinaphex 2018-01-12 04:18:53 +01:00
parent af12858953
commit 3407cd665d

View File

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