Create content_push_to_history_playlist

This commit is contained in:
twinaphex 2016-02-15 03:56:10 +01:00
parent f621165adf
commit b4b50d1972
4 changed files with 55 additions and 71 deletions

View File

@ -123,6 +123,29 @@ static void check_defaults_dirs(void)
check_defaults_dir_create_dir(g_defaults.dir.cheats);
}
void content_push_to_history_playlist(bool do_push,
const char *path, void *data)
{
settings_t *settings = config_get_ptr();
struct retro_system_info *info = (struct retro_system_info*)data;
/* If the history list is not enabled, early return. */
if (!settings->history_list_enable)
return;
if (!g_defaults.history)
return;
if (!do_push)
return;
content_playlist_push(g_defaults.history,
path,
NULL,
settings->libretro,
info->library_name,
NULL,
NULL);
}
/**
* content_load_init_wrap:
* @args : Input arguments.

View File

@ -86,6 +86,9 @@ typedef struct ram_type
bool content_load(int argc, char **argv,
void *args, environment_get_t environ_get);
void content_push_to_history_playlist(bool do_push,
const char *path, void *data);
bool content_ctl(enum content_ctl_state state, void *data);
#ifdef __cplusplus

View File

@ -88,36 +88,6 @@ void main_exit(void *args)
frontend_driver_free();
}
static void history_playlist_push(content_playlist_t *playlist,
const char *path, const char *core_path,
struct retro_system_info *info)
{
char tmp[PATH_MAX_LENGTH];
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (!playlist || rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL) || !info)
return;
/* Path can be relative here.
* Ensure we're pushing absolute path. */
strlcpy(tmp, path, sizeof(tmp));
if (*tmp)
path_resolve_realpath(tmp, sizeof(tmp));
if (system->no_content || *tmp)
content_playlist_push(playlist,
*tmp ? tmp : NULL,
NULL,
core_path,
info->library_name,
NULL,
NULL);
}
/**
* main_entry:
*
@ -131,9 +101,10 @@ static void history_playlist_push(content_playlist_t *playlist,
**/
int rarch_main(int argc, char *argv[], void *data)
{
char *fullpath = NULL;
rarch_system_info_t *system = NULL;
void *args = (void*)data;
int ret = 0;
settings_t *settings = NULL;
rarch_ctl(RARCH_CTL_PREINIT, NULL);
@ -155,22 +126,29 @@ int rarch_main(int argc, char *argv[], void *data)
event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL);
settings = config_get_ptr();
if (settings->history_list_enable)
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
if (content_ctl(CONTENT_CTL_IS_INITED, NULL) || system->no_content)
{
char *fullpath = NULL;
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
char tmp[PATH_MAX_LENGTH];
struct retro_system_info *info = system ? &system->info : NULL;
if (content_ctl(CONTENT_CTL_IS_INITED, NULL) || system->no_content)
history_playlist_push(
g_defaults.history,
fullpath,
settings->libretro,
system ? &system->info : NULL);
strlcpy(tmp, fullpath, sizeof(tmp));
if (*tmp)
{
/* Path can be relative here.
* Ensure we're pushing absolute path. */
path_resolve_realpath(tmp, sizeof(tmp));
}
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL) || !info)
content_push_to_history_playlist(
system->no_content || *tmp,
*tmp ? tmp : NULL,
info);
}
ui_companion_driver_init_first();

View File

@ -35,32 +35,6 @@
#include "../runloop.h"
#include "../verbosity.h"
static void menu_content_push_to_history_playlist(void)
{
struct retro_system_info *system = NULL;
settings_t *settings = config_get_ptr();
char *fullpath = NULL;
/* If the history list is not enabled, early return. */
if (!settings->history_list_enable)
return;
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET,
&system);
content_playlist_push(g_defaults.history,
fullpath,
NULL,
settings->libretro,
system->library_name,
NULL,
NULL);
content_playlist_write_file(g_defaults.history);
}
static void menu_content_environment_get(int *argc, char *argv[],
void *args, void *params_data)
{
@ -142,7 +116,13 @@ static bool menu_content_load(void)
event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL);
if (*fullpath || menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL))
menu_content_push_to_history_playlist();
{
struct retro_system_info *info = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET,
&info);
content_push_to_history_playlist(true, fullpath, info);
content_playlist_write_file(g_defaults.history);
}
event_cmd_ctl(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL);