Add environ callback to expose 'Content Directory' path to core -

and refactor g_settings.rgui_browser_directory
This commit is contained in:
twinaphex 2013-12-25 02:31:35 +01:00
parent 84c489d0da
commit 204113e389
7 changed files with 25 additions and 12 deletions

View File

@ -376,7 +376,7 @@ const rarch_setting_t* setting_data_get_list()
CONFIG_UINT(g_settings.game_history_size, "game_history_size", "Content History Size", game_history_size)
#ifdef HAVE_RGUI
CONFIG_PATH(g_settings.rgui_browser_directory, "rgui_browser_directory", "Browser Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR)
CONFIG_PATH(g_settings.content_directory, "rgui_browser_directory", "Content Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR)
#endif
#ifdef HAVE_OVERLAY

View File

@ -914,6 +914,10 @@ bool rarch_environment_cb(unsigned cmd, void *data)
RARCH_LOG("Environ (Private) EXEC.\n");
break;
case RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY:
*(const char **)data = *g_settings.content_directory ? g_settings.content_directory : NULL;
RARCH_LOG("Environ CONTENT_DIRECTORY: \"%s\".\n", g_settings.content_directory);
break;
default:
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);

View File

@ -387,7 +387,7 @@ void menu_init(void)
rarch_fail(1, "menu_init()");
}
strlcpy(rgui->base_path, g_settings.rgui_browser_directory, sizeof(rgui->base_path));
strlcpy(rgui->base_path, g_settings.content_directory, sizeof(rgui->base_path));
rgui->menu_stack = (file_list_t*)calloc(1, sizeof(file_list_t));
rgui->selection_buf = (file_list_t*)calloc(1, sizeof(file_list_t));
file_list_push(rgui->menu_stack, "", RGUI_SETTINGS, 0);
@ -1222,7 +1222,7 @@ static int menu_iterate_func(void *data, unsigned action)
}
else if (menu_type == RGUI_BROWSER_DIR_PATH)
{
strlcpy(g_settings.rgui_browser_directory, dir, sizeof(g_settings.rgui_browser_directory));
strlcpy(g_settings.content_directory, dir, sizeof(g_settings.content_directory));
strlcpy(rgui->base_path, dir, sizeof(rgui->base_path));
menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS);
}
@ -1936,7 +1936,7 @@ void menu_populate_entries(void *data, unsigned menu_type)
break;
case RGUI_SETTINGS_PATH_OPTIONS:
file_list_clear(rgui->selection_buf);
file_list_push(rgui->selection_buf, "Browser Directory", RGUI_BROWSER_DIR_PATH, 0);
file_list_push(rgui->selection_buf, "Content Directory", RGUI_BROWSER_DIR_PATH, 0);
#ifdef HAVE_DYNAMIC
file_list_push(rgui->selection_buf, "Config Directory", RGUI_CONFIG_DIR_PATH, 0);
file_list_push(rgui->selection_buf, "Core Directory", RGUI_LIBRETRO_DIR_PATH, 0);

View File

@ -894,7 +894,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
case RGUI_BROWSER_DIR_PATH:
if (action == RGUI_ACTION_START)
{
*g_settings.rgui_browser_directory = '\0';
*g_settings.content_directory = '\0';
*rgui->base_path = '\0';
}
break;
@ -1720,7 +1720,7 @@ void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w,
snprintf(type_str, type_str_size, (g_settings.fps_show) ? "ON" : "OFF");
break;
case RGUI_BROWSER_DIR_PATH:
strlcpy(type_str, *g_settings.rgui_browser_directory ? g_settings.rgui_browser_directory : "<default>", type_str_size);
strlcpy(type_str, *g_settings.content_directory ? g_settings.content_directory : "<default>", type_str_size);
break;
#ifdef HAVE_SCREENSHOTS
case RGUI_SCREENSHOT_DIR_PATH:

View File

@ -295,8 +295,8 @@ struct settings
uint16_t network_cmd_port;
bool stdin_cmd_enable;
char content_directory[PATH_MAX];
#if defined(HAVE_MENU)
char rgui_browser_directory[PATH_MAX];
char rgui_config_directory[PATH_MAX];
bool rgui_show_start_screen;
#endif

View File

@ -574,6 +574,15 @@ enum retro_mod
// The purpose of this interface is to be able to retrieve location-based information from the host device,
// such as current latitude / longitude.
//
#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30
// const char ** --
// Returns the "content" directory of the frontend.
// This directory can be used to store specific assets that the core relies upon, such as art assets,
// input data, etc etc.
// The returned value can be NULL.
// If so, no such directory is defined,
// and it's up to the implementation to find a suitable directory.
//
enum retro_log_level
{

View File

@ -368,8 +368,8 @@ void config_set_defaults(void)
*g_settings.system_directory = '\0';
*g_settings.input.autoconfig_dir = '\0';
*g_settings.input.overlay = '\0';
*g_settings.content_directory = '\0';
#ifdef HAVE_MENU
*g_settings.rgui_browser_directory = '\0';
*g_settings.rgui_config_directory = '\0';
#endif
@ -819,10 +819,10 @@ bool config_load_file(const char *path)
}
}
CONFIG_GET_PATH(content_directory, "rgui_browser_directory");
if (!strcmp(g_settings.content_directory, "default"))
*g_settings.content_directory = '\0';
#ifdef HAVE_MENU
CONFIG_GET_PATH(rgui_browser_directory, "rgui_browser_directory");
if (!strcmp(g_settings.rgui_browser_directory, "default"))
*g_settings.rgui_browser_directory = '\0';
CONFIG_GET_PATH(rgui_config_directory, "rgui_config_directory");
if (!strcmp(g_settings.rgui_config_directory, "default"))
*g_settings.rgui_config_directory = '\0';
@ -1163,7 +1163,7 @@ bool config_save_file(const char *path)
config_set_path(conf, "video_shader_dir", *g_settings.video.shader_dir ? g_settings.video.shader_dir : "default");
#ifdef HAVE_MENU
config_set_path(conf, "rgui_browser_directory", *g_settings.rgui_browser_directory ? g_settings.rgui_browser_directory : "default");
config_set_path(conf, "rgui_browser_directory", *g_settings.content_directory ? g_settings.content_directory : "default");
config_set_path(conf, "rgui_config_directory", *g_settings.rgui_config_directory ? g_settings.rgui_config_directory : "default");
config_set_bool(conf, "rgui_show_start_screen", g_settings.rgui_show_start_screen);
#endif