mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-18 08:18:07 +00:00
Create two more iteration phases for overlays
This commit is contained in:
parent
b064838da7
commit
7268eab3e8
@ -520,10 +520,93 @@ static bool input_overlay_resolve_targets(struct overlay *ol,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool input_overlay_load_overlays_resolve_iterate(input_overlay_t *ol)
|
||||
{
|
||||
bool not_done = true;
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
if (!ol)
|
||||
return false;
|
||||
conf = config_file_new(ol->overlay_path);
|
||||
|
||||
if (!conf)
|
||||
{
|
||||
RARCH_ERR("Failed to load config file: %s.\n", ol->overlay_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
not_done = ol->pos < ol->size;
|
||||
|
||||
if (!not_done)
|
||||
{
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_DONE;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!input_overlay_resolve_targets(ol->overlays, ol->pos, ol->size))
|
||||
{
|
||||
RARCH_ERR("[Overlay]: Failed to resolve next targets.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ol->pos += 1;
|
||||
|
||||
config_file_free(conf);
|
||||
|
||||
return true;
|
||||
error:
|
||||
config_file_free(conf);
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_ERROR;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_overlay_load_overlays_iterate(input_overlay_t *ol)
|
||||
{
|
||||
bool not_done = true;
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
if (!ol)
|
||||
return false;
|
||||
conf = config_file_new(ol->overlay_path);
|
||||
|
||||
if (!conf)
|
||||
{
|
||||
RARCH_ERR("Failed to load config file: %s.\n", ol->overlay_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
not_done = ol->pos < ol->size;
|
||||
|
||||
if (!not_done)
|
||||
{
|
||||
ol->pos = 0;
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!input_overlay_load_overlay(ol, conf,
|
||||
ol->overlay_path, &ol->overlays[ol->pos], ol->pos))
|
||||
{
|
||||
RARCH_ERR("[Overlay]: Failed to load overlay #%u.\n", (unsigned)ol->pos);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ol->pos += 1;
|
||||
|
||||
config_file_free(conf);
|
||||
|
||||
return true;
|
||||
error:
|
||||
config_file_free(conf);
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_ERROR;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_overlay_load_overlays(input_overlay_t *ol)
|
||||
{
|
||||
size_t i;
|
||||
bool ret = true;
|
||||
unsigned overlays = 0;
|
||||
config_file_t *conf = NULL;
|
||||
|
||||
@ -541,54 +624,29 @@ bool input_overlay_load_overlays(input_overlay_t *ol)
|
||||
if (!config_get_uint(conf, "overlays", &overlays))
|
||||
{
|
||||
RARCH_ERR("overlays variable not defined in config.\n");
|
||||
ret = false;
|
||||
goto end;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!overlays)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
goto error;
|
||||
|
||||
ol->overlays = (struct overlay*)calloc(overlays, sizeof(*ol->overlays));
|
||||
if (!ol->overlays)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
goto error;
|
||||
|
||||
ol->size = overlays;
|
||||
ol->pos = 0;
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_LOADING;
|
||||
|
||||
for (i = 0; i < ol->size; i++)
|
||||
{
|
||||
if (!input_overlay_load_overlay(ol, conf,
|
||||
ol->overlay_path, &ol->overlays[i], i))
|
||||
{
|
||||
RARCH_ERR("[Overlay]: Failed to load overlay #%u.\n", (unsigned)i);
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ol->size; i++)
|
||||
{
|
||||
if (!input_overlay_resolve_targets(ol->overlays, i, ol->size))
|
||||
{
|
||||
RARCH_ERR("[Overlay]: Failed to resolve next targets.\n");
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_DONE;
|
||||
|
||||
end:
|
||||
config_file_free(conf);
|
||||
if (!ret)
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_ERROR;
|
||||
|
||||
return ret;
|
||||
return true;
|
||||
|
||||
error:
|
||||
config_file_free(conf);
|
||||
ol->state = OVERLAY_STATUS_DEFERRED_ERROR;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void input_overlay_load_active(input_overlay_t *ol,
|
||||
|
@ -71,6 +71,8 @@ enum overlay_status
|
||||
{
|
||||
OVERLAY_STATUS_NONE = 0,
|
||||
OVERLAY_STATUS_DEFERRED_LOAD,
|
||||
OVERLAY_STATUS_DEFERRED_LOADING,
|
||||
OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE,
|
||||
OVERLAY_STATUS_DEFERRED_DONE,
|
||||
OVERLAY_STATUS_DEFERRED_ERROR,
|
||||
OVERLAY_STATUS_ALIVE,
|
||||
@ -137,6 +139,7 @@ struct input_overlay
|
||||
const struct overlay *active;
|
||||
size_t index;
|
||||
size_t size;
|
||||
size_t pos;
|
||||
|
||||
unsigned next_index;
|
||||
char *overlay_path;
|
||||
@ -177,6 +180,10 @@ input_overlay_t *input_overlay_new(const char *path, bool enable,
|
||||
|
||||
bool input_overlay_load_overlays(input_overlay_t *ol);
|
||||
|
||||
bool input_overlay_load_overlays_iterate(input_overlay_t *ol);
|
||||
|
||||
bool input_overlay_load_overlays_resolve_iterate(input_overlay_t *ol);
|
||||
|
||||
bool input_overlay_new_done(input_overlay_t *ol);
|
||||
|
||||
/**
|
||||
|
@ -1024,6 +1024,12 @@ void rarch_main_iterate_overlay_state(void)
|
||||
case OVERLAY_STATUS_DEFERRED_LOAD:
|
||||
input_overlay_load_overlays(driver.overlay);
|
||||
break;
|
||||
case OVERLAY_STATUS_DEFERRED_LOADING:
|
||||
input_overlay_load_overlays_iterate(driver.overlay);
|
||||
break;
|
||||
case OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE:
|
||||
input_overlay_load_overlays_resolve_iterate(driver.overlay);
|
||||
break;
|
||||
case OVERLAY_STATUS_DEFERRED_DONE:
|
||||
input_overlay_new_done(driver.overlay);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user