From d037546a13e95890f41d6879cbbc3ad9afcc04e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 12 Aug 2017 17:10:14 +0200 Subject: [PATCH] (XMB) Display favorites tab, part 2 --- command.c | 7 +++++++ configuration.c | 22 ++++++++++++++++++++++ configuration.h | 2 ++ defaults.h | 1 + file_path_special.h | 1 + file_path_str.c | 3 +++ menu/cbs/menu_cbs_left.c | 4 ++++ menu/cbs/menu_cbs_right.c | 4 ++++ menu/menu_displaylist.c | 24 ++++++++++++++++++++++++ menu/menu_displaylist.h | 1 + 10 files changed, 69 insertions(+) diff --git a/command.c b/command.c index 878a24f211..19b2de761e 100644 --- a/command.c +++ b/command.c @@ -2034,6 +2034,13 @@ bool command_event(enum event_command cmd, void *data) settings->paths.path_content_history, content_history_size); + RARCH_LOG("%s: [%s].\n", + msg_hash_to_str(MSG_LOADING_HISTORY_FILE), + settings->paths.path_content_favorites); + g_defaults.content_favorites = playlist_init( + settings->paths.path_content_favorites, + content_history_size); + RARCH_LOG("%s: [%s].\n", msg_hash_to_str(MSG_LOADING_HISTORY_FILE), settings->paths.path_content_music_history); diff --git a/configuration.c b/configuration.c index 62bb385401..05461d6c4b 100644 --- a/configuration.c +++ b/configuration.c @@ -1020,6 +1020,8 @@ static struct config_path_setting *populate_settings_path(settings_t *settings, #endif SETTING_PATH("content_history_path", settings->paths.path_content_history, false, NULL, true); + SETTING_PATH("content_favorites_path", + settings->paths.path_content_favorites, false, NULL, true); SETTING_PATH("content_music_history_path", settings->paths.path_content_music_history, false, NULL, true); SETTING_PATH("content_video_history_path", @@ -1655,6 +1657,7 @@ static void config_set_defaults(void) *settings->paths.path_core_options = '\0'; *settings->paths.path_content_history = '\0'; + *settings->paths.path_content_favorites = '\0'; *settings->paths.path_content_music_history = '\0'; *settings->paths.path_content_image_history = '\0'; *settings->paths.path_content_video_history = '\0'; @@ -2482,6 +2485,25 @@ static bool config_load_file(const char *path, bool set_defaults, } } + if (string_is_empty(settings->paths.path_content_favorites)) + { + if (string_is_empty(settings->paths.directory_content_history)) + { + fill_pathname_resolve_relative( + settings->paths.path_content_favorites, + path_get(RARCH_PATH_CONFIG), + file_path_str(FILE_PATH_CONTENT_FAVORITES), + sizeof(settings->paths.path_content_favorites)); + } + else + { + fill_pathname_join(settings->paths.path_content_favorites, + settings->paths.directory_content_history, + file_path_str(FILE_PATH_CONTENT_FAVORITES), + sizeof(settings->paths.path_content_favorites)); + } + } + if (string_is_empty(settings->paths.path_content_music_history)) { if (string_is_empty(settings->paths.directory_content_history)) diff --git a/configuration.h b/configuration.h index 9018d965dd..85a68bbea2 100644 --- a/configuration.h +++ b/configuration.h @@ -382,6 +382,7 @@ typedef struct settings char path_softfilter_plugin[PATH_MAX_LENGTH]; char path_core_options[PATH_MAX_LENGTH]; char path_content_history[PATH_MAX_LENGTH]; + char path_content_favorites[PATH_MAX_LENGTH]; char path_content_music_history[PATH_MAX_LENGTH]; char path_content_image_history[PATH_MAX_LENGTH]; char path_content_video_history[PATH_MAX_LENGTH]; @@ -398,6 +399,7 @@ typedef struct settings char directory_video_filter[PATH_MAX_LENGTH]; char directory_video_shader[PATH_MAX_LENGTH]; char directory_content_history[PATH_MAX_LENGTH]; + char directory_content_favorites[PATH_MAX_LENGTH]; char directory_libretro[PATH_MAX_LENGTH]; char directory_cursor[PATH_MAX_LENGTH]; char directory_input_remapping[PATH_MAX_LENGTH]; diff --git a/defaults.h b/defaults.h index 80306a797c..66940f307e 100644 --- a/defaults.h +++ b/defaults.h @@ -102,6 +102,7 @@ struct defaults #ifndef IS_SALAMANDER playlist_t *content_history; + playlist_t *content_favorites; #ifdef HAVE_IMAGEVIEWER playlist_t *image_history; #endif diff --git a/file_path_special.h b/file_path_special.h index 8e0576da6f..e763f78a7f 100644 --- a/file_path_special.h +++ b/file_path_special.h @@ -34,6 +34,7 @@ enum file_path_enum FILE_PATH_LOG_ERROR, FILE_PATH_LOG_INFO, FILE_PATH_CONTENT_HISTORY, + FILE_PATH_CONTENT_FAVORITES, FILE_PATH_CONTENT_MUSIC_HISTORY, FILE_PATH_CONTENT_VIDEO_HISTORY, FILE_PATH_CONTENT_IMAGE_HISTORY, diff --git a/file_path_str.c b/file_path_str.c index 4f6ae0bc30..ce976bf261 100644 --- a/file_path_str.c +++ b/file_path_str.c @@ -194,6 +194,9 @@ const char *file_path_str(enum file_path_enum enum_idx) case FILE_PATH_CONTENT_HISTORY: str = "content_history.lpl"; break; + case FILE_PATH_CONTENT_FAVORITES: + str = "content_favorites.lpl"; + break; case FILE_PATH_CONTENT_MUSIC_HISTORY: str = "content_music_history.lpl"; break; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 488e103e46..ef585ae524 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -464,6 +464,7 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_NO_PLAYLIST_ENTRIES_AVAILABLE: if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_MUSIC_TAB)) || @@ -483,6 +484,7 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_TAKE_SCREENSHOT: if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB)) || @@ -584,6 +586,7 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs, case MENU_SETTING_GROUP: case MENU_SETTINGS_CORE_INFO_NONE: if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB)) || @@ -624,6 +627,7 @@ int menu_cbs_init_bind_left(menu_file_list_cbs_t *cbs, if (type == MENU_SETTING_NO_ITEM) { if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB)) || diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 665d2d7aef..22e2b83c7c 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -458,6 +458,7 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, case MENU_SETTING_GROUP: case MENU_SETTINGS_CORE_INFO_NONE: if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB)) || @@ -564,6 +565,7 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_NO_PLAYLIST_ENTRIES_AVAILABLE: if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_MUSIC_TAB)) || @@ -582,6 +584,7 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_START_VIDEO_PROCESSOR: case MENU_ENUM_LABEL_TAKE_SCREENSHOT: if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB)) || @@ -621,6 +624,7 @@ int menu_cbs_init_bind_right(menu_file_list_cbs_t *cbs, if (type == MENU_SETTING_NO_ITEM) { if ( string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)) || + string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB)) || string_is_equal(menu_label, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB)) || diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index dfbda6ee74..21fa7845a4 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3838,6 +3838,11 @@ static bool menu_displaylist_push_internal( if (menu_displaylist_ctl(DISPLAYLIST_HISTORY, info)) return true; } + else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB))) + { + if (menu_displaylist_ctl(DISPLAYLIST_FAVORITES, info)) + return true; + } else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_SETTINGS_TAB))) { if (menu_displaylist_ctl(DISPLAYLIST_SETTINGS_ALL, info)) @@ -4365,6 +4370,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) return menu_displaylist_process(info); return false; } + else if (string_is_equal(info->path, file_path_str(FILE_PATH_CONTENT_FAVORITES))) + { + if (menu_displaylist_ctl(DISPLAYLIST_FAVORITES, info)) + return menu_displaylist_process(info); + return false; + } else { char path_playlist[PATH_MAX_LENGTH]; @@ -4428,6 +4439,19 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) info->need_push = true; } break; + case DISPLAYLIST_FAVORITES: + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); + menu_displaylist_parse_playlist_history(menu, info, + g_defaults.content_favorites, + "favorites", + settings->paths.path_content_favorites, + &ret); + if (ret == 0) + { + info->need_refresh = true; + info->need_push = true; + } + break; case DISPLAYLIST_MUSIC_HISTORY: if (settings->bools.history_list_enable) menu_displaylist_parse_playlist_history(menu, info, diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index bde192651a..3a6d4d0664 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -61,6 +61,7 @@ enum menu_displaylist_ctl_state DISPLAYLIST_HORIZONTAL, DISPLAYLIST_HORIZONTAL_CONTENT_ACTIONS, DISPLAYLIST_HISTORY, + DISPLAYLIST_FAVORITES, DISPLAYLIST_VIDEO_HISTORY, DISPLAYLIST_MUSIC_HISTORY, DISPLAYLIST_IMAGES_HISTORY,