Create content_get_status

This commit is contained in:
twinaphex 2017-01-25 15:44:21 +01:00
parent 41a647945b
commit 361bd471de
5 changed files with 74 additions and 32 deletions

View File

@ -1325,6 +1325,10 @@ static void command_event_set_savestate_auto_index(void)
static bool event_init_content(void)
{
bool contentless = false;
content_get_status(&contentless);
rarch_ctl(RARCH_CTL_SET_SRAM_ENABLE, NULL);
/* No content to be loaded for dummy core,
@ -1332,13 +1336,15 @@ static bool event_init_content(void)
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
return true;
if (!content_does_not_need_content())
if (!contentless)
path_fill_names();
if (!content_init())
return false;
if (content_does_not_need_content())
content_get_status(&contentless);
if (contentless)
{
#ifdef HAVE_NETWORKING
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
@ -1442,18 +1448,23 @@ static void command_event_restore_default_shader_preset(void)
static bool command_event_save_auto_state(void)
{
bool ret;
char savestate_name_auto[PATH_MAX_LENGTH] = {0};
bool ret = false;;
bool contentless = false;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if (!settings || !settings->savestate_auto_save)
return false;
if (!global)
return false;
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
return false;
if (content_does_not_need_content())
content_get_status(&contentless);
if (contentless)
return false;
#ifdef HAVE_CHEEVOS
@ -1504,15 +1515,18 @@ static bool command_event_save_config(const char *config_path,
**/
static bool command_event_save_core_config(void)
{
char config_dir[PATH_MAX_LENGTH] = {0};
char config_name[PATH_MAX_LENGTH] = {0};
char config_path[PATH_MAX_LENGTH] = {0};
char msg[128] = {0};
char config_dir[PATH_MAX_LENGTH];
char config_name[PATH_MAX_LENGTH];
char config_path[PATH_MAX_LENGTH];
char msg[128];
bool ret = false;
bool found_path = false;
bool overrides_active = false;
settings_t *settings = config_get_ptr();
config_dir[0] = config_name[0] =
config_path[0] = msg[0] = '\0';
if (!string_is_empty(settings->directory.menu_config))
strlcpy(config_dir, settings->directory.menu_config,
sizeof(config_dir));
@ -1603,7 +1617,9 @@ static bool command_event_save_core_config(void)
**/
static void command_event_save_current_config(enum override_type type)
{
char msg[128] = {0};
char msg[128];
msg[0] = '\0';
switch (type)
{
@ -1678,20 +1694,26 @@ static void command_event_undo_load_state(char *s, size_t len)
static void command_event_main_state(unsigned cmd)
{
retro_ctx_size_info_t info;
char path[PATH_MAX_LENGTH] = {0};
char msg[128] = {0};
char path[PATH_MAX_LENGTH];
char msg[128];
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
bool push_msg = true;
if (settings->state_slot > 0)
snprintf(path, sizeof(path), "%s%d",
global->name.savestate, settings->state_slot);
else if (settings->state_slot < 0)
fill_pathname_join_delim(path,
global->name.savestate, "auto", '.', sizeof(path));
else
strlcpy(path, global->name.savestate, sizeof(path));
path[0] = msg[0] = '\0';
if (global)
{
settings_t *settings = config_get_ptr();
if (settings->state_slot > 0)
snprintf(path, sizeof(path), "%s%d",
global->name.savestate, settings->state_slot);
else if (settings->state_slot < 0)
fill_pathname_join_delim(path,
global->name.savestate, "auto", '.', sizeof(path));
else
strlcpy(path, global->name.savestate, sizeof(path));
}
core_serialize_size(&info);

View File

@ -59,7 +59,7 @@ bool content_undo_load_state(void);
/* Restores the last savestate file which was overwritten */
bool content_undo_save_state(void);
bool content_does_not_need_content(void);
void content_get_status(bool *contentless);
void content_set_does_not_need_content(void);

View File

@ -281,12 +281,16 @@ bool core_get_memory(retro_ctx_memory_info_t *info)
bool core_load_game(retro_ctx_load_content_info_t *load_info)
{
bool contentless = false;
content_get_status(&contentless);
if (load_info && load_info->special)
core_game_loaded = core.retro_load_game_special(
load_info->special->id, load_info->info, load_info->content->size);
else if (load_info && !string_is_empty(load_info->content->elems[0].data))
core_game_loaded = core.retro_load_game(load_info->info);
else if (content_does_not_need_content())
else if (contentless)
core_game_loaded = core.retro_load_game(NULL);
else
core_game_loaded = false;

View File

@ -1261,9 +1261,14 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_INIT, NULL);
break;
case RARCH_CTL_SET_PATHS_REDIRECT:
if (content_does_not_need_content())
return false;
path_set_redirect();
{
bool contentless = false;
content_get_status(&contentless);
if (contentless)
return false;
path_set_redirect();
}
break;
case RARCH_CTL_IS_SRAM_LOAD_DISABLED:
return rarch_is_sram_load_disabled;
@ -1284,8 +1289,12 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
case RARCH_CTL_IS_SRAM_USED:
return rarch_use_sram;
case RARCH_CTL_SET_SRAM_ENABLE:
rarch_use_sram = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL)
&& !content_does_not_need_content();
{
bool contentless = false;
content_get_status(&contentless);
rarch_use_sram = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL)
&& !contentless;
}
break;
case RARCH_CTL_SET_SRAM_ENABLE_FORCE:
rarch_use_sram = true;

View File

@ -691,12 +691,16 @@ static bool content_file_init_set_attribs(
}
else
{
bool contentless = false;
content_get_status(&contentless);
attr.i = content_ctx->block_extract;
attr.i |= content_ctx->need_fullpath << 1;
attr.i |= (!content_does_not_need_content()) << 2;
attr.i |= (!contentless) << 2;
if (path_is_empty(RARCH_PATH_CONTENT)
&& content_does_not_need_content()
&& contentless
&& content_ctx->set_supports_no_game_enable)
string_list_append(content, "", attr);
else
@ -817,14 +821,17 @@ static bool task_load_content(content_ctx_info_t *content_info,
{
char name[255];
char msg[255];
bool contentless = false;
name[0] = msg[0] = '\0';
content_get_status(&contentless);
if (!content_load(content_info))
goto error;
/* Push entry to top of history playlist */
if (_content_is_inited || content_does_not_need_content())
if (_content_is_inited || contentless)
{
char tmp[PATH_MAX_LENGTH];
struct retro_system_info *info = NULL;
@ -1321,9 +1328,9 @@ cleanup:
#endif
}
bool content_does_not_need_content(void)
void content_get_status(bool *contentless)
{
return core_does_not_need_content;
*contentless = core_does_not_need_content;
}
void content_set_does_not_need_content(void)