Create MENU_ENTRIES_CTL_SET_REFRESH/MENU_ENTRIES_CTL_UNSET_REFRESH

This commit is contained in:
twinaphex 2015-12-12 02:14:50 +01:00
parent 36ce2f1001
commit 1004537e8d
11 changed files with 53 additions and 40 deletions

View File

@ -298,6 +298,7 @@ size_t core_len;
void cb_net_generic(void *task_data, void *user_data, const char *err)
{
bool refresh = false;
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
if (core_buf)
@ -319,7 +320,7 @@ void cb_net_generic(void *task_data, void *user_data, const char *err)
core_len = data->len;
finish:
menu_entries_unset_refresh(true);
menu_entries_ctl(MENU_ENTRIES_CTL_UNSET_REFRESH, &refresh);
if (err)
RARCH_ERR("Download failed: %s\n", err);

View File

@ -242,11 +242,12 @@ static int action_left_shader_filter_default(unsigned type, const char *label,
static int action_left_cheat_num_passes(unsigned type, const char *label,
bool wraparound)
{
bool refresh = false;
unsigned new_size = 0;
if (cheat_manager_get_size())
new_size = cheat_manager_get_size() - 1;
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
cheat_manager_realloc(new_size);
@ -257,6 +258,7 @@ static int action_left_shader_num_passes(unsigned type, const char *label,
bool wraparound)
{
#ifdef HAVE_SHADER_MANAGER
bool refresh = false;
struct video_shader *shader = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SHADER_GET,
@ -266,7 +268,7 @@ static int action_left_shader_num_passes(unsigned type, const char *label,
if (shader->passes)
shader->passes--;
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
video_shader_resolve_parameters(NULL, shader);

View File

@ -1417,8 +1417,9 @@ static int generic_action_ok_network(const char *path,
unsigned type_id2 = 0;
const char *url_label = NULL;
rarch_task_callback_t callback = NULL;
bool refresh = true;
menu_entries_set_refresh(true);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
if (settings->network.buildbot_url[0] == '\0')
return -1;

View File

@ -261,10 +261,11 @@ static int action_right_shader_filter_default(unsigned type, const char *label,
static int action_right_cheat_num_passes(unsigned type, const char *label,
bool wraparound)
{
bool refresh = false;
unsigned new_size = 0;
new_size = cheat_manager_get_size() + 1;
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
cheat_manager_realloc(new_size);
@ -275,6 +276,7 @@ static int action_right_shader_num_passes(unsigned type, const char *label,
bool wraparound)
{
#ifdef HAVE_SHADER_MANAGER
bool refresh = false;
struct video_shader *shader = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SHADER_GET,
@ -284,7 +286,7 @@ static int action_right_shader_num_passes(unsigned type, const char *label,
if ((shader->passes < GFX_MAX_SHADERS))
shader->passes++;
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
video_shader_resolve_parameters(NULL, shader);

View File

@ -218,6 +218,7 @@ static int action_start_shader_filter_pass(unsigned type, const char *label)
static int action_start_shader_num_passes(unsigned type, const char *label)
{
#ifdef HAVE_SHADER_MANAGER
bool refresh = false;
struct video_shader *shader = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SHADER_GET,
@ -228,7 +229,7 @@ static int action_start_shader_num_passes(unsigned type, const char *label)
if (shader->passes)
shader->passes = 0;
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
video_shader_resolve_parameters(NULL, shader);
#endif
return 0;
@ -238,7 +239,8 @@ static int action_start_cheat_num_passes(unsigned type, const char *label)
{
if (cheat_manager_get_size())
{
menu_entries_set_refresh(false);
bool refresh = false;
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
cheat_manager_realloc(0);
}

View File

@ -2508,12 +2508,14 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
break;
case DISPLAYLIST_GENERIC:
{
bool refresh = false;
bool pending_push = true;
menu_driver_list_cache(MENU_LIST_PLAIN, 0);
menu_entries_push(info->list, info->path, info->label, info->type, info->directory_ptr, 0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
}
break;
case DISPLAYLIST_USER_BINDS_LIST:

View File

@ -296,7 +296,8 @@ static void menu_driver_toggle(bool latch)
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
{
menu_entries_set_refresh(false);
bool refresh = false;
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
/* Menu should always run with vsync on. */
event_command(EVENT_CMD_VIDEO_SET_BLOCKING_STATE);

View File

@ -169,6 +169,7 @@ static int menu_entries_flush_stack_type(const char *needle, const char *label,
static bool menu_list_pop_stack(menu_list_t *list, size_t idx, size_t *directory_ptr)
{
bool refresh = false;
file_list_t *menu_list = NULL;
if (!list)
return false;
@ -186,7 +187,7 @@ static bool menu_list_pop_stack(menu_list_t *list, size_t idx, size_t *directory
file_list_pop(menu_list, directory_ptr);
menu_driver_list_set_selection(menu_list);
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
return true;
}
@ -194,6 +195,7 @@ static bool menu_list_pop_stack(menu_list_t *list, size_t idx, size_t *directory
static void menu_list_flush_stack(menu_list_t *list,
size_t idx, const char *needle, unsigned final_type)
{
bool refresh = false;
const char *path = NULL;
const char *label = NULL;
unsigned type = 0;
@ -201,7 +203,7 @@ static void menu_list_flush_stack(menu_list_t *list,
if (!list)
return;
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_entries_get_last(list->menu_stack[idx],
&path, &label, &type, &entry_idx);
@ -482,28 +484,6 @@ file_list_t *menu_entries_get_selection_buf_ptr(size_t idx)
return menu_list->selection_buf[idx];
}
void menu_entries_set_refresh(bool nonblocking)
{
if (menu_entries_data)
{
if (nonblocking)
menu_entries_data->nonblocking_refresh = true;
else
menu_entries_data->need_refresh = true;
}
}
void menu_entries_unset_refresh(bool nonblocking)
{
if (menu_entries_data)
{
if (nonblocking)
menu_entries_data->nonblocking_refresh = false;
else
menu_entries_data->need_refresh = false;
}
}
static bool menu_entries_init(void)
{
menu_entries_t *entries = (menu_entries_t*)calloc(1, sizeof(*entries));
@ -717,6 +697,28 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data)
*settings = menu_entries_data->list_settings;
}
return true;
case MENU_ENTRIES_CTL_SET_REFRESH:
if (menu_entries_data)
{
bool *nonblocking = (bool*)data;
if (*nonblocking)
menu_entries_data->nonblocking_refresh = true;
else
menu_entries_data->need_refresh = true;
}
return true;
case MENU_ENTRIES_CTL_UNSET_REFRESH:
if (menu_entries_data)
{
bool *nonblocking = (bool*)data;
if (*nonblocking)
menu_entries_data->nonblocking_refresh = false;
else
menu_entries_data->need_refresh = false;
}
return true;
case MENU_ENTRIES_CTL_INIT:
return menu_entries_init();
case MENU_ENTRIES_CTL_SHOW_BACK:

View File

@ -108,6 +108,8 @@ enum menu_entries_ctl_state
MENU_ENTRIES_CTL_INIT,
MENU_ENTRIES_CTL_LIST_GET,
MENU_ENTRIES_CTL_SETTINGS_GET,
MENU_ENTRIES_CTL_SET_REFRESH,
MENU_ENTRIES_CTL_UNSET_REFRESH,
MENU_ENTRIES_CTL_NEEDS_REFRESH,
MENU_ENTRIES_CTL_SHOW_BACK
};
@ -126,10 +128,6 @@ int menu_entries_get_title(char *title, size_t title_len);
int menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
void menu_entries_set_refresh(bool nonblocking);
void menu_entries_unset_refresh(bool nonblocking);
file_list_t *menu_entries_get_selection_buf_ptr(size_t idx);
file_list_t *menu_entries_get_menu_stack_ptr(size_t idx);

View File

@ -420,10 +420,11 @@ int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
{
if (cbs && cbs->action_refresh)
{
bool refresh = false;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
cbs->action_refresh(selection_buf, menu_stack);
menu_entries_unset_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_UNSET_REFRESH, &refresh);
}
}

View File

@ -141,6 +141,7 @@ void menu_shader_manager_set_preset(struct video_shader *shader,
{
#ifdef HAVE_SHADER_MANAGER
config_file_t *conf = NULL;
bool refresh = false;
settings_t *settings = config_get_ptr();
settings->video.shader_enable = false;
@ -177,7 +178,7 @@ void menu_shader_manager_set_preset(struct video_shader *shader,
}
config_file_free(conf);
menu_entries_set_refresh(false);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
#endif
}