mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Move history_list to deferred push callback too
This commit is contained in:
parent
53804dfa16
commit
fbeb79504a
@ -19,7 +19,7 @@
|
||||
#include "../../settings_data.h"
|
||||
#include "../../performance.h"
|
||||
|
||||
static void entries_refresh(file_list_t *list)
|
||||
void entries_refresh(file_list_t *list)
|
||||
{
|
||||
/* Before a refresh, we could have deleted a file on disk, causing
|
||||
* selection_ptr to suddendly be out of range.
|
||||
@ -74,28 +74,28 @@ static inline int menu_list_get_first_char(file_list_t *buf,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void menu_build_scroll_indices(file_list_t *buf)
|
||||
void menu_build_scroll_indices(file_list_t *list)
|
||||
{
|
||||
size_t i;
|
||||
int current;
|
||||
bool current_is_dir;
|
||||
|
||||
if (!driver.menu || !buf)
|
||||
if (!driver.menu || !list)
|
||||
return;
|
||||
|
||||
driver.menu->scroll_indices_size = 0;
|
||||
if (!buf->size)
|
||||
if (!list->size)
|
||||
return;
|
||||
|
||||
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = 0;
|
||||
|
||||
current = menu_list_get_first_char(buf, 0);
|
||||
current_is_dir = menu_list_elem_is_dir(buf, 0);
|
||||
current = menu_list_get_first_char(list, 0);
|
||||
current_is_dir = menu_list_elem_is_dir(list, 0);
|
||||
|
||||
for (i = 1; i < buf->size; i++)
|
||||
for (i = 1; i < list->size; i++)
|
||||
{
|
||||
int first = menu_list_get_first_char(buf, i);
|
||||
bool is_dir = menu_list_elem_is_dir(buf, i);
|
||||
int first = menu_list_get_first_char(list, i);
|
||||
bool is_dir = menu_list_elem_is_dir(list, i);
|
||||
|
||||
if ((current_is_dir && !is_dir) || (first > current))
|
||||
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = i;
|
||||
@ -105,7 +105,7 @@ static void menu_build_scroll_indices(file_list_t *buf)
|
||||
}
|
||||
|
||||
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] =
|
||||
buf->size - 1;
|
||||
list->size - 1;
|
||||
}
|
||||
|
||||
static void add_setting_entry(menu_handle_t *menu,
|
||||
@ -179,7 +179,6 @@ static int push_list(menu_handle_t *menu,
|
||||
unsigned i;
|
||||
size_t list_size = 0;
|
||||
bool do_action = false;
|
||||
bool is_history_list = !strcmp(label, "history_list");
|
||||
|
||||
#if 0
|
||||
RARCH_LOG("Label is: %s\n", label);
|
||||
@ -187,35 +186,7 @@ static int push_list(menu_handle_t *menu,
|
||||
RARCH_LOG("Menu type is: %d\n", menu_type);
|
||||
#endif
|
||||
|
||||
if (!strcmp(label, "history_list"))
|
||||
{
|
||||
file_list_clear(list);
|
||||
list_size = content_playlist_size(g_defaults.history);
|
||||
|
||||
for (i = 0; i < list_size; i++)
|
||||
{
|
||||
char fill_buf[PATH_MAX];
|
||||
const char *core_name = NULL;
|
||||
|
||||
content_playlist_get_index(g_defaults.history, i,
|
||||
&path, NULL, &core_name);
|
||||
strlcpy(fill_buf, core_name, sizeof(fill_buf));
|
||||
|
||||
if (path)
|
||||
{
|
||||
char path_short[PATH_MAX];
|
||||
fill_short_pathname_representation(path_short,path,sizeof(path_short));
|
||||
snprintf(fill_buf,sizeof(fill_buf),"%s (%s)",
|
||||
path_short,core_name);
|
||||
}
|
||||
|
||||
file_list_push(list, fill_buf, "",
|
||||
MENU_FILE_PLAYLIST_ENTRY, 0);
|
||||
|
||||
do_action = true;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(label, "Main Menu"))
|
||||
if (!strcmp(label, "Main Menu"))
|
||||
{
|
||||
settings_list_free(menu->list_mainmenu);
|
||||
menu->list_mainmenu = (rarch_setting_t *)setting_data_new(SL_FLAG_MAIN_MENU);
|
||||
@ -530,9 +501,6 @@ static int push_list(menu_handle_t *menu,
|
||||
if (do_action)
|
||||
{
|
||||
driver.menu->scroll_indices_size = 0;
|
||||
if (is_history_list)
|
||||
menu_build_scroll_indices(list);
|
||||
|
||||
entries_refresh(list);
|
||||
}
|
||||
|
||||
@ -777,7 +745,7 @@ static int menu_parse_check(const char *label, unsigned menu_type)
|
||||
!strcmp(label, "disk_image_append"))));
|
||||
if (check)
|
||||
return -1;
|
||||
check = !strcmp(label, "history_list") || !strcmp(label, "deferred_core_list");
|
||||
check = !strcmp(label, "deferred_core_list");
|
||||
if (check)
|
||||
return -1;
|
||||
return 0;
|
||||
@ -794,7 +762,10 @@ int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list)
|
||||
file_list_get_last(menu_list, &path, &label, &type);
|
||||
|
||||
if (((menu_parse_check(label, type)) == -1))
|
||||
return push_list(driver.menu, list, path, label, type);
|
||||
{
|
||||
if (strcmp(label, "history_list") != 0)
|
||||
return push_list(driver.menu, list, path, label, type);
|
||||
}
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
file_list_get_last_actiondata(menu_list);
|
||||
|
@ -45,6 +45,10 @@ void menu_flush_stack_label(file_list_t *list, const char *needle);
|
||||
|
||||
bool menu_entries_init(menu_handle_t *menu);
|
||||
|
||||
void entries_refresh(file_list_t *list);
|
||||
|
||||
void menu_build_scroll_indices(file_list_t *list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1325,6 +1325,51 @@ static int deferred_push_core_list(void *data, void *userdata,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int deferred_push_history_list(void *data, void *userdata,
|
||||
const char *path, const char *label, unsigned type)
|
||||
{
|
||||
unsigned i;
|
||||
size_t list_size = 0;
|
||||
file_list_t *list = (file_list_t*)data;
|
||||
file_list_t *menu_list = (file_list_t*)userdata;
|
||||
|
||||
if (!list || !menu_list || !driver.menu)
|
||||
return -1;
|
||||
|
||||
file_list_clear(list);
|
||||
list_size = content_playlist_size(g_defaults.history);
|
||||
|
||||
for (i = 0; i < list_size; i++)
|
||||
{
|
||||
char fill_buf[PATH_MAX];
|
||||
const char *core_name = NULL;
|
||||
|
||||
content_playlist_get_index(g_defaults.history, i,
|
||||
&path, NULL, &core_name);
|
||||
strlcpy(fill_buf, core_name, sizeof(fill_buf));
|
||||
|
||||
if (path)
|
||||
{
|
||||
char path_short[PATH_MAX];
|
||||
fill_short_pathname_representation(path_short,path,sizeof(path_short));
|
||||
snprintf(fill_buf,sizeof(fill_buf),"%s (%s)",
|
||||
path_short,core_name);
|
||||
}
|
||||
|
||||
file_list_push(list, fill_buf, "",
|
||||
MENU_FILE_PLAYLIST_ENTRY, 0);
|
||||
}
|
||||
|
||||
driver.menu->scroll_indices_size = 0;
|
||||
menu_build_scroll_indices(list);
|
||||
entries_refresh(list);
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
|
||||
driver.menu_ctx->populate_entries(driver.menu, path, label, type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int deferred_push_configurations(void *data, void *userdata,
|
||||
const char *path, const char *label, unsigned type)
|
||||
{
|
||||
@ -1715,6 +1760,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
|
||||
|
||||
if (!strcmp(label, "core_list"))
|
||||
cbs->action_deferred_push = deferred_push_core_list;
|
||||
if (!strcmp(label, "history_list"))
|
||||
cbs->action_deferred_push = deferred_push_history_list;
|
||||
else if (!strcmp(label, "configurations"))
|
||||
cbs->action_deferred_push = deferred_push_configurations;
|
||||
else if (!strcmp(label, "video_shader_preset"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user