From 79bd87e12a9c1a2efd0cee6af924c7cb2fde754e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 17 Jun 2016 20:50:36 +0200 Subject: [PATCH] Reduce further dependence on MENU_VALUE_ --- menu/cbs/menu_cbs_left.c | 17 ++++++------ menu/cbs/menu_cbs_right.c | 54 +++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 017761ea8a..5ef6380b15 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -391,9 +391,9 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs, if (cbs->setting) { const char *parent_group = menu_setting_get_parent_group(cbs->setting); - uint32_t parent_group_hash = menu_hash_calculate(parent_group); - if ((parent_group_hash == MENU_VALUE_MAIN_MENU) && (menu_setting_get_type(cbs->setting) == ST_GROUP)) + if (string_is_equal(parent_group, menu_hash_to_str_enum(MENU_ENUM_LABEL_MAIN_MENU)) + && (menu_setting_get_type(cbs->setting) == ST_GROUP)) { BIND_ACTION_LEFT(cbs, action_left_mainmenu); return 0; @@ -606,15 +606,16 @@ int menu_cbs_init_bind_left(menu_file_list_cbs_t *cbs, if (type == MENU_SETTING_NO_ITEM) { - switch (menu_label_hash) + if ( string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_ADD_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_MAIN_MENU)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_HORIZONTAL_MENU)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_SETTINGS_TAB)) + ) { - case MENU_VALUE_HORIZONTAL_MENU: - case MENU_VALUE_MAIN_MENU: - case 153956705: /* TODO/FIXME - dehardcode */ BIND_ACTION_LEFT(cbs, action_left_mainmenu); return 0; - default: - break; } } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 4b76b2342c..0ff73539d2 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -405,7 +405,8 @@ int bind_right_generic(unsigned type, const char *label, } static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, - unsigned type, uint32_t label_hash, uint32_t menu_label_hash) + unsigned type, uint32_t label_hash, const char *menu_label, + uint32_t menu_label_hash) { if (type >= MENU_SETTINGS_CHEAT_BEGIN && type <= MENU_SETTINGS_CHEAT_END) @@ -475,16 +476,18 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, case MENU_FILE_DOWNLOAD_THUMBNAIL_CONTENT: case MENU_FILE_SCAN_DIRECTORY: case MENU_SETTING_GROUP: - switch (menu_label_hash) + if ( string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_ADD_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_HORIZONTAL_MENU)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_SETTINGS_TAB)) + ) { - case MENU_VALUE_HORIZONTAL_MENU: - case MENU_VALUE_MAIN_MENU: - BIND_ACTION_RIGHT(cbs, action_right_mainmenu); - break; - default: - BIND_ACTION_RIGHT(cbs, action_right_scroll); - break; + BIND_ACTION_RIGHT(cbs, action_right_mainmenu); + break; } + BIND_ACTION_RIGHT(cbs, action_right_scroll); + break; case MENU_SETTING_ACTION: case MENU_FILE_CONTENTLIST_ENTRY: BIND_ACTION_RIGHT(cbs, action_right_mainmenu); @@ -506,9 +509,9 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, if (cbs->setting) { const char *parent_group = menu_setting_get_parent_group(cbs->setting); - uint32_t parent_group_hash = menu_hash_calculate(parent_group); - if ((parent_group_hash == MENU_LABEL_SETTINGS) && (menu_setting_get_type(cbs->setting) == ST_GROUP)) + if (string_is_equal(parent_group, menu_hash_to_str_enum(MENU_ENUM_LABEL_MAIN_MENU)) + && (menu_setting_get_type(cbs->setting) == ST_GROUP)) { BIND_ACTION_RIGHT(cbs, action_right_scroll); return 0; @@ -624,25 +627,26 @@ int menu_cbs_init_bind_right(menu_file_list_cbs_t *cbs, BIND_ACTION_RIGHT(cbs, bind_right_generic); - if (type == MENU_SETTING_NO_ITEM) - { - switch (menu_label_hash) - { - case MENU_VALUE_HORIZONTAL_MENU: - case MENU_VALUE_MAIN_MENU: - case 153956705: /* TODO/FIXME - dehardcode */ - BIND_ACTION_RIGHT(cbs, action_right_mainmenu); - return 0; - default: - break; - } - } + if (type == MENU_SETTING_NO_ITEM) + { + if ( string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_ADD_TAB)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_MAIN_MENU)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_HORIZONTAL_MENU)) || + string_is_equal(menu_label, menu_hash_to_str_enum(MENU_ENUM_LABEL_SETTINGS_TAB)) + ) + { + BIND_ACTION_RIGHT(cbs, action_right_mainmenu); + return 0; + } + } if (menu_cbs_init_bind_right_compare_label(cbs, label, label_hash, menu_label, menu_label_hash, elem0) == 0) return 0; - if (menu_cbs_init_bind_right_compare_type(cbs, type, label_hash, menu_label_hash) == 0) + if (menu_cbs_init_bind_right_compare_type(cbs, type, label_hash, menu_label, menu_label_hash) == 0) return 0; return menu_cbs_exit();