From 901516d28362764066b12a9faab2f5aca8748e6c Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 28 Apr 2013 00:35:20 +0200 Subject: [PATCH] Load history. --- frontend/menu/menu_common.h | 5 +++++ frontend/menu/rgui.c | 8 +++++++- settings.c | 12 ++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index bcdbdef4ee..99407c0983 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -34,6 +34,8 @@ extern "C" { #include "../../gfx/shader_parse.h" #endif +#include "history.h" + #define RGUI_MAX_SHADERS 8 #if defined(HAVE_RMENU) || defined(HAVE_RMENU_XUI) @@ -118,6 +120,7 @@ typedef enum // settings options are done here too RGUI_SETTINGS_OPEN_FILEBROWSER, + RGUI_SETTINGS_OPEN_HISTORY, RGUI_SETTINGS_CORE, RGUI_SETTINGS_CORE_OPTIONS, RGUI_SETTINGS_REWIND_ENABLE, @@ -227,6 +230,8 @@ typedef struct #ifdef HAVE_SHADER_MANAGER struct gfx_shader shader; #endif + + rom_history_t *history; } rgui_handle_t; extern rgui_handle_t *rgui; diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index 4bef406910..0ff9689a2e 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -225,18 +225,24 @@ rgui_handle_t *rgui_init(void) (float)custom->width / custom->height; } + char history_path[PATH_MAX]; + fill_pathname_resolve_relative(history_path, g_extern.config_path, + ".retroarch-history.txt", sizeof(history_path)); + rgui->history = rom_history_init(history_path, 20); + return rgui; } void rgui_free(rgui_handle_t *rgui) { if (rgui->alloc_font) - free((uint8_t *) rgui->font); + free((uint8_t*)rgui->font); #ifdef HAVE_DYNAMIC libretro_free_system_info(&rgui->info); #endif + rom_history_free(rgui->history); rgui_list_free(rgui->menu_stack); rgui_list_free(rgui->selection_buf); } diff --git a/settings.c b/settings.c index 5a1cd5a8d9..5721d33e2e 100644 --- a/settings.c +++ b/settings.c @@ -309,7 +309,8 @@ static config_file_t *open_default_config_file(void) #if defined(_WIN32) && !defined(_XBOX) // Just do something for now. char conf_path[PATH_MAX]; - conf = config_file_new("retroarch.cfg"); + strlcpy(conf_path, "retroarch.cfg", sizeof(conf_path)); + conf = config_file_new(conf_path); if (!conf) { const char *appdata = getenv("APPDATA"); @@ -347,11 +348,18 @@ static config_file_t *open_default_config_file(void) // Try this as a last chance ... if (!conf) { - conf = config_file_new("/etc/retroarch.cfg"); + strlcpy(conf_path, "/etc/retroarch.cfg", sizeof(conf_path)); + conf = config_file_new(conf_path); RARCH_LOG("Looking for config in: \"/etc/retroarch.cfg\".\n"); } #endif + if (conf) + { + strlcpy(g_extern.config_path, conf_path, + sizeof(g_extern.config_path)); + } + return conf; }