From 631a1fc8bf4492d2ffb28cb7dbc9479ed5858497 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 24 Jul 2014 21:29:53 +0200 Subject: [PATCH] (Menu) Add Content History Path --- frontend/menu/backend/menu_common_backend.c | 26 +++++++++++++++++++++ frontend/menu/backend/menu_common_backend.h | 1 + frontend/menu/menu_common.c | 16 ++----------- settings.c | 1 + settings_data.c | 2 +- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index c28b6de2bf..1a0bf70ff4 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -530,6 +530,7 @@ static void menu_common_entries_init(void *data, unsigned menu_type) #endif file_list_push(menu->selection_buf, "Core Directory", MENU_LIBRETRO_DIR_PATH, 0); file_list_push(menu->selection_buf, "Core Info Directory", MENU_LIBRETRO_INFO_DIR_PATH, 0); + file_list_push(menu->selection_buf, "Content History Path", MENU_SETTINGS_CONTENT_HISTORY_PATH, 0); #ifdef HAVE_DYLIB file_list_push(menu->selection_buf, "Software Filter Directory", MENU_FILTER_DIR_PATH, 0); #endif @@ -2563,6 +2564,7 @@ static int menu_common_iterate(unsigned action) type == MENU_SETTINGS_OVERLAY_PRESET || type == MENU_SETTINGS_VIDEO_SOFTFILTER || type == MENU_SETTINGS_AUDIO_DSP_FILTER || + type == MENU_SETTINGS_CONTENT_HISTORY_PATH || type == MENU_SETTINGS_CORE || type == MENU_SETTINGS_CONFIG || type == MENU_SETTINGS_DISK_APPEND || @@ -2690,6 +2692,11 @@ static int menu_common_iterate(unsigned action) menu_flush_stack_type(MENU_SETTINGS); ret = -1; } + else if (menu_type == MENU_SETTINGS_CONTENT_HISTORY_PATH) + { + fill_pathname_join(g_settings.game_history_path, dir, path, sizeof(g_settings.input.overlay)); + menu_flush_stack_type(MENU_SETTINGS_PATH_OPTIONS); + } else if (menu_type == MENU_BROWSER_DIR_PATH) { strlcpy(g_settings.menu_content_directory, dir, sizeof(g_settings.menu_content_directory)); @@ -2847,6 +2854,7 @@ static int menu_common_iterate(unsigned action) menu_common_type_is(menu_type) == MENU_SETTINGS_SHADER_OPTIONS || menu_common_type_is(menu_type) == MENU_FILE_DIRECTORY || menu_type == MENU_SETTINGS_OVERLAY_PRESET || + menu_type == MENU_SETTINGS_CONTENT_HISTORY_PATH || menu_type == MENU_SETTINGS_VIDEO_SOFTFILTER || menu_type == MENU_SETTINGS_AUDIO_DSP_FILTER || menu_type == MENU_SETTINGS_DEFERRED_CORE || @@ -3965,6 +3973,21 @@ static int menu_common_setting_set(unsigned setting, unsigned action) } break; #endif + case MENU_SETTINGS_CONTENT_HISTORY_PATH: + switch (action) + { + case MENU_ACTION_OK: + file_list_push(driver.menu->menu_stack, g_settings.game_history_path, setting, driver.menu->selection_ptr); + menu_clear_navigation(driver.menu); + driver.menu->need_refresh = true; + break; + case MENU_ACTION_START: + *g_settings.game_history_path = '\0'; + break; + default: + break; + } + break; case MENU_SETTINGS_VIDEO_SOFTFILTER: switch (action) { @@ -5191,6 +5214,9 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size, snprintf(type_str, type_str_size, "%.2f", g_settings.input.overlay_scale); break; #endif + case MENU_SETTINGS_CONTENT_HISTORY_PATH: + strlcpy(type_str, g_settings.game_history_path ? g_settings.game_history_path : "", type_str_size); + break; case MENU_SETTINGS_BIND_PLAYER: snprintf(type_str, type_str_size, "#%d", driver.menu->current_pad + 1); break; diff --git a/frontend/menu/backend/menu_common_backend.h b/frontend/menu/backend/menu_common_backend.h index c839c579b8..0c7dd0e097 100644 --- a/frontend/menu/backend/menu_common_backend.h +++ b/frontend/menu/backend/menu_common_backend.h @@ -131,6 +131,7 @@ typedef enum MENU_SETTINGS_WINDOW_COMPOSITING_ENABLE, MENU_SETTINGS_PAUSE_IF_WINDOW_FOCUS_LOST, MENU_CONTENT_HISTORY_SIZE, + MENU_SETTINGS_CONTENT_HISTORY_PATH, MENU_SCREENSHOT_DIR_PATH, MENU_BROWSER_DIR_PATH, MENU_CONTENT_DIR_PATH, diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 1c5dceec51..26bb6afaf2 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -176,20 +176,8 @@ static void menu_init_history(menu_handle_t *menu) { menu_free_history(menu); - if (*g_extern.config_path) - { - char history_path[PATH_MAX]; - if (*g_settings.game_history_path) - strlcpy(history_path, g_settings.game_history_path, sizeof(history_path)); - else - { - fill_pathname_resolve_relative(history_path, g_extern.config_path, - ".retroarch-game-history.txt", sizeof(history_path)); - } - - RARCH_LOG("[Menu]: Opening history: %s.\n", history_path); - menu->history = content_history_init(history_path, g_settings.game_history_size); - } + RARCH_LOG("[Menu]: Opening history: %s.\n", g_settings.game_history_path); + menu->history = content_history_init(g_settings.game_history_path, g_settings.game_history_size); } static void menu_update_libretro_info(menu_handle_t *menu) diff --git a/settings.c b/settings.c index a6b12f80cd..7a8baf1207 100644 --- a/settings.c +++ b/settings.c @@ -1090,6 +1090,7 @@ bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_INT(network_cmd_port, "network_cmd_port"); CONFIG_GET_BOOL(stdin_cmd_enable, "stdin_cmd_enable"); + fill_pathname_resolve_relative(g_settings.game_history_path, g_extern.config_path, ".retroarch-game-history.txt", sizeof(g_settings.game_history_path)); CONFIG_GET_PATH(game_history_path, "game_history_path"); CONFIG_GET_INT(game_history_size, "game_history_size"); diff --git a/settings_data.c b/settings_data.c index bd19ada2cf..d3a4cc9e93 100644 --- a/settings_data.c +++ b/settings_data.c @@ -670,7 +670,7 @@ static void general_change_handler(const void *data) else if (!strcmp(setting->name, "cheat_settings_path")) strlcpy(g_settings.cheat_settings_path, setting->value.string, sizeof(g_settings.cheat_settings_path)); else if (!strcmp(setting->name, "game_history_path")) - strlcpy(g_settings.cheat_settings_path, setting->value.string, sizeof(g_settings.cheat_settings_path)); + strlcpy(g_settings.game_history_path, setting->value.string, sizeof(g_settings.game_history_path)); else if (!strcmp(setting->name, "video_shader_dir")) strlcpy(g_settings.video.filter_dir, setting->value.string, sizeof(g_settings.video.filter_dir)); else if (!strcmp(setting->name, "video_aspect_ratio_auto"))