Add CONTENT_CT_LOAD

This commit is contained in:
twinaphex 2016-02-16 05:34:33 +01:00
parent bebf9abfb2
commit 46cc21029b
4 changed files with 35 additions and 30 deletions

View File

@ -828,10 +828,6 @@ static void content_load_init_wrap(
/** /**
* content_load: * content_load:
* @argc : Argument count.
* @argv : Argument variable list.
* @args : Arguments passed from callee.
* @environ_get : Function passed for environment_get function.
* *
* Loads content file and starts up RetroArch. * Loads content file and starts up RetroArch.
* If no content file can be loaded, will start up RetroArch * If no content file can be loaded, will start up RetroArch
@ -839,16 +835,15 @@ static void content_load_init_wrap(
* *
* Returns: false (0) if rarch_main_init failed, otherwise true (1). * Returns: false (0) if rarch_main_init failed, otherwise true (1).
**/ **/
bool content_load(int argc, char **argv, void *args, static bool content_load(content_ctx_info_t *info)
environment_get_t environ_get)
{ {
unsigned i; unsigned i;
bool retval = true; bool retval = true;
int rarch_argc = 0; int rarch_argc = 0;
char *rarch_argv[MAX_ARGS] = {NULL}; char *rarch_argv[MAX_ARGS] = {NULL};
char *argv_copy [MAX_ARGS] = {NULL}; char *argv_copy [MAX_ARGS] = {NULL};
char **rarch_argv_ptr = (char**)argv; char **rarch_argv_ptr = (char**)info->argv;
int *rarch_argc_ptr = (int*)&argc; int *rarch_argc_ptr = (int*)&info->argc;
struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*) struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)
calloc(1, sizeof(*wrap_args)); calloc(1, sizeof(*wrap_args));
@ -857,8 +852,9 @@ bool content_load(int argc, char **argv, void *args,
retro_assert(wrap_args); retro_assert(wrap_args);
if (environ_get) if (info->environ_get)
environ_get(rarch_argc_ptr, rarch_argv_ptr, args, wrap_args); info->environ_get(rarch_argc_ptr,
rarch_argv_ptr, info->args, wrap_args);
if (wrap_args->touched) if (wrap_args->touched)
{ {
@ -1761,6 +1757,8 @@ bool content_ctl(enum content_ctl_state state, void *data)
stream->a, stream->b, stream->c); stream->a, stream->b, stream->c);
} }
break; break;
case CONTENT_CTL_LOAD:
return content_load((content_ctx_info_t*)data);
case CONTENT_CTL_NONE: case CONTENT_CTL_NONE:
default: default:
break; break;

View File

@ -46,6 +46,11 @@ enum content_ctl_state
CONTENT_CTL_DEINIT, CONTENT_CTL_DEINIT,
/* Loads content file and starts up RetroArch.
* If no content file can be loaded, will start up RetroArch
* as-is. */
CONTENT_CTL_LOAD,
CONTENT_CTL_GET_CRC, CONTENT_CTL_GET_CRC,
/* Load a RAM state from disk to memory. */ /* Load a RAM state from disk to memory. */
@ -82,21 +87,13 @@ typedef struct content_stream
uint32_t crc; uint32_t crc;
} content_stream_t; } content_stream_t;
/** typedef struct content_ctx_info
* main_load_content: {
* @argc : Argument count. int argc; /* Argument count. */
* @argv : Argument variable list. char **argv; /* Argument variable list. */
* @args : Arguments passed from callee. void *args; /* Arguments passed from callee */
* @environ_get : Function passed for environment_get function. environment_get_t environ_get; /* Function passed for environment_get function */
* } content_ctx_info_t;
* Loads content file and starts up RetroArch.
* If no content file can be loaded, will start up RetroArch
* as-is.
*
* Returns: false (0) if rarch_main_init failed, otherwise true (1).
**/
bool content_load(int argc, char **argv,
void *args, environment_get_t environ_get);
void content_push_to_history_playlist(bool do_push, void content_push_to_history_playlist(bool do_push,
const char *path, void *data); const char *path, void *data);

View File

@ -117,11 +117,15 @@ int rarch_main(int argc, char *argv[], void *data)
if (frontend_driver_is_inited()) if (frontend_driver_is_inited())
{ {
ret = content_load(argc, argv, args, content_ctx_info_t info;
frontend_driver_environment_get_ptr());
if (!ret) info.argc = argc;
return ret; info.argv = argv;
info.args = args;
info.environ_get = frontend_driver_environment_get_ptr();
if (!content_ctl(CONTENT_CTL_LOAD, &info))
return 0;
} }
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);

View File

@ -85,6 +85,7 @@ static void menu_content_environment_get(int *argc, char *argv[],
static bool menu_content_load(void) static bool menu_content_load(void)
{ {
content_ctx_info_t content_info;
char name[PATH_MAX_LENGTH]; char name[PATH_MAX_LENGTH];
char msg[PATH_MAX_LENGTH]; char msg[PATH_MAX_LENGTH];
bool msg_force = true; bool msg_force = true;
@ -98,7 +99,12 @@ static bool menu_content_load(void)
if (*fullpath) if (*fullpath)
fill_pathname_base(name, fullpath, sizeof(name)); fill_pathname_base(name, fullpath, sizeof(name));
if (!(content_load(0, NULL, NULL, menu_content_environment_get))) content_info.argc = 0;
content_info.argv = NULL;
content_info.args = NULL;
content_info.environ_get = menu_content_environment_get;
if (!content_ctl(CONTENT_CTL_LOAD, &content_info))
goto error; goto error;
if (*fullpath) if (*fullpath)