mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
(Ozone) Horizontal list - put on stack - it's already on heap-allocated
struct as is
This commit is contained in:
parent
93fa9a0194
commit
7a6b9fd1b2
@ -72,6 +72,8 @@ void file_list_free(file_list_t *list);
|
||||
|
||||
bool file_list_deinitialize(file_list_t *list);
|
||||
|
||||
bool file_list_initialize(file_list_t *list);
|
||||
|
||||
/**
|
||||
* @brief makes the list big enough to contain at least nitems
|
||||
*
|
||||
|
@ -55,6 +55,18 @@ static bool file_list_deinitialize_internal(file_list_t *list)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool file_list_initialize(file_list_t *list)
|
||||
{
|
||||
if (!list)
|
||||
return false;
|
||||
|
||||
list->list = NULL;
|
||||
list->capacity = 0;
|
||||
list->size = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool file_list_reserve(file_list_t *list, size_t nitems)
|
||||
{
|
||||
const size_t item_size = sizeof(struct item_file);
|
||||
|
@ -280,8 +280,7 @@ static enum menu_action ozone_parse_menu_entry_action(
|
||||
}
|
||||
}
|
||||
|
||||
if (ozone->horizontal_list)
|
||||
horizontal_list_size = (unsigned)ozone->horizontal_list->size;
|
||||
horizontal_list_size = (unsigned)ozone->horizontal_list.size;
|
||||
|
||||
ozone->messagebox_state = false || menu_input_dialog_get_display_kb();
|
||||
selection_buf = menu_entries_get_selection_buf_ptr(0);
|
||||
@ -669,14 +668,9 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
|
||||
|
||||
gfx_display_allocate_white_texture();
|
||||
|
||||
ozone->horizontal_list = (file_list_t*)malloc(sizeof(file_list_t));
|
||||
file_list_initialize(&ozone->horizontal_list);
|
||||
|
||||
ozone->horizontal_list->list = NULL;
|
||||
ozone->horizontal_list->capacity = 0;
|
||||
ozone->horizontal_list->size = 0;
|
||||
|
||||
if (ozone->horizontal_list)
|
||||
ozone_init_horizontal_list(ozone);
|
||||
ozone_init_horizontal_list(ozone);
|
||||
|
||||
/* Theme */
|
||||
if (settings->bools.menu_use_preferred_system_color_theme)
|
||||
@ -753,11 +747,8 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
|
||||
error:
|
||||
if (ozone)
|
||||
{
|
||||
if (ozone->horizontal_list)
|
||||
{
|
||||
ozone_free_list_nodes(ozone->horizontal_list, false);
|
||||
file_list_free(ozone->horizontal_list);
|
||||
}
|
||||
ozone_free_list_nodes(&ozone->horizontal_list, false);
|
||||
file_list_deinitialize(&ozone->horizontal_list);
|
||||
|
||||
if (ozone->selection_buf_old)
|
||||
{
|
||||
@ -766,7 +757,6 @@ error:
|
||||
}
|
||||
|
||||
ozone->selection_buf_old = NULL;
|
||||
ozone->horizontal_list = NULL;
|
||||
}
|
||||
|
||||
if (menu)
|
||||
@ -797,13 +787,9 @@ static void ozone_free(void *data)
|
||||
file_list_free(ozone->selection_buf_old);
|
||||
}
|
||||
|
||||
if (ozone->horizontal_list)
|
||||
{
|
||||
ozone_free_list_nodes(ozone->horizontal_list, false);
|
||||
file_list_free(ozone->horizontal_list);
|
||||
}
|
||||
ozone_free_list_nodes(&ozone->horizontal_list, false);
|
||||
file_list_deinitialize(&ozone->horizontal_list);
|
||||
|
||||
ozone->horizontal_list = NULL;
|
||||
ozone->selection_buf_old = NULL;
|
||||
|
||||
if (!string_is_empty(ozone->pending_message))
|
||||
@ -1323,10 +1309,9 @@ static void *ozone_list_get_entry(void *data,
|
||||
}
|
||||
break;
|
||||
case MENU_LIST_HORIZONTAL:
|
||||
if (ozone && ozone->horizontal_list)
|
||||
list_size = file_list_get_size(ozone->horizontal_list);
|
||||
list_size = file_list_get_size(&ozone->horizontal_list);
|
||||
if (i < list_size)
|
||||
return (void*)&ozone->horizontal_list->list[i];
|
||||
return (void*)&ozone->horizontal_list.list[i];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1689,8 +1674,7 @@ static void ozone_render(void *data,
|
||||
bool first_entry_found = false;
|
||||
bool last_entry_found = false;
|
||||
|
||||
unsigned horizontal_list_size = ozone->horizontal_list ?
|
||||
(unsigned)ozone->horizontal_list->size : 0;
|
||||
unsigned horizontal_list_size = (unsigned)ozone->horizontal_list.size;
|
||||
float category_height = ozone->dimensions.sidebar_entry_height +
|
||||
ozone->dimensions.sidebar_entry_padding_vertical;
|
||||
bool first_category_found = false;
|
||||
@ -2880,12 +2864,10 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
static void ozone_set_header(ozone_handle_t *ozone)
|
||||
{
|
||||
if (ozone->categories_selection_ptr <= ozone->system_tab_end)
|
||||
{
|
||||
menu_entries_get_title(ozone->title, sizeof(ozone->title));
|
||||
}
|
||||
else if (ozone->horizontal_list)
|
||||
else
|
||||
{
|
||||
ozone_node_t *node = (ozone_node_t*) file_list_get_userdata_at_offset(ozone->horizontal_list, ozone->categories_selection_ptr - ozone->system_tab_end-1);
|
||||
ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(&ozone->horizontal_list, ozone->categories_selection_ptr - ozone->system_tab_end-1);
|
||||
|
||||
if (node && node->console_name)
|
||||
{
|
||||
@ -3494,8 +3476,7 @@ static int ozone_pointer_up(void *userdata,
|
||||
/* Otherwise, select current category */
|
||||
else if (ozone->pointer_categories_selection != ozone->categories_selection_ptr)
|
||||
{
|
||||
unsigned horizontal_list_size = (ozone->horizontal_list) ?
|
||||
(unsigned)ozone->horizontal_list->size : 0;
|
||||
unsigned horizontal_list_size = (unsigned)ozone->horizontal_list.size;
|
||||
|
||||
/* Ensure that current category is valid */
|
||||
if (ozone->pointer_categories_selection <= ozone->system_tab_end + horizontal_list_size)
|
||||
@ -3568,9 +3549,7 @@ size_t ozone_list_get_size(void *data, enum menu_list_type type)
|
||||
case MENU_LIST_PLAIN:
|
||||
return menu_entries_get_stack_size(0);
|
||||
case MENU_LIST_HORIZONTAL:
|
||||
if (ozone && ozone->horizontal_list)
|
||||
return file_list_get_size(ozone->horizontal_list);
|
||||
break;
|
||||
return file_list_get_size(&ozone->horizontal_list);
|
||||
case MENU_LIST_TABS:
|
||||
return ozone->system_tab_end;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ struct ozone_handle
|
||||
|
||||
unsigned old_list_offset_y;
|
||||
|
||||
file_list_t *horizontal_list; /* console tabs */
|
||||
file_list_t horizontal_list; /* console tabs */ /* ptr alignment */
|
||||
|
||||
struct {
|
||||
int header_height;
|
||||
|
@ -721,9 +721,9 @@ border_iterate:
|
||||
uintptr_t texture = tex;
|
||||
|
||||
/* Console specific icons */
|
||||
if (entry.type == FILE_TYPE_RPL_ENTRY && ozone->horizontal_list && ozone->categories_selection_ptr > ozone->system_tab_end)
|
||||
if (entry.type == FILE_TYPE_RPL_ENTRY && ozone->categories_selection_ptr > ozone->system_tab_end)
|
||||
{
|
||||
ozone_node_t *sidebar_node = (ozone_node_t*) file_list_get_userdata_at_offset(ozone->horizontal_list, ozone->categories_selection_ptr - ozone->system_tab_end-1);
|
||||
ozone_node_t *sidebar_node = (ozone_node_t*) file_list_get_userdata_at_offset(&ozone->horizontal_list, ozone->categories_selection_ptr - ozone->system_tab_end-1);
|
||||
|
||||
if (!sidebar_node || !sidebar_node->content_icon)
|
||||
texture = tex;
|
||||
@ -736,13 +736,9 @@ border_iterate:
|
||||
(entry.type >= MENU_SETTINGS_CHEEVOS_START) &&
|
||||
(entry.type < MENU_SETTINGS_NETPLAY_ROOMS_START)
|
||||
))
|
||||
{
|
||||
icon_color = ozone->theme_dynamic.entries_icon;
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_color = ozone_pure_white;
|
||||
}
|
||||
|
||||
gfx_display_set_alpha(icon_color, alpha);
|
||||
|
||||
|
@ -207,8 +207,7 @@ void ozone_draw_sidebar(
|
||||
ticker.spacer = ticker_spacer;
|
||||
}
|
||||
|
||||
if (ozone->horizontal_list)
|
||||
horizontal_list_size = (unsigned)ozone->horizontal_list->size;
|
||||
horizontal_list_size = (unsigned)ozone->horizontal_list.size;
|
||||
|
||||
gfx_display_scissor_begin(userdata,
|
||||
video_width, video_height,
|
||||
@ -374,7 +373,7 @@ void ozone_draw_sidebar(
|
||||
|
||||
uint32_t text_color = COLOR_TEXT_ALPHA((selected ? ozone->theme->text_selected_rgba : ozone->theme->text_rgba), text_alpha);
|
||||
|
||||
ozone_node_t *node = (ozone_node_t*) file_list_get_userdata_at_offset(ozone->horizontal_list, i);
|
||||
ozone_node_t *node = (ozone_node_t*) file_list_get_userdata_at_offset(&ozone->horizontal_list, i);
|
||||
|
||||
if (!node)
|
||||
goto console_iterate;
|
||||
@ -504,9 +503,9 @@ unsigned ozone_get_selected_sidebar_y_position(ozone_handle_t *ozone)
|
||||
|
||||
unsigned ozone_get_sidebar_height(ozone_handle_t *ozone)
|
||||
{
|
||||
int entries = (int)(ozone->system_tab_end + 1 + (ozone->horizontal_list ? ozone->horizontal_list->size : 0));
|
||||
int entries = (int)(ozone->system_tab_end + 1 + (ozone->horizontal_list.size ));
|
||||
return entries * ozone->dimensions.sidebar_entry_height + (entries - 1) * ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.sidebar_padding_vertical +
|
||||
(ozone->horizontal_list && ozone->horizontal_list->size > 0 ? ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px : 0);
|
||||
(ozone->horizontal_list.size > 0 ? ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px : 0);
|
||||
}
|
||||
|
||||
void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation)
|
||||
@ -746,7 +745,7 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone)
|
||||
|
||||
menu_displaylist_info_init(&info);
|
||||
|
||||
info.list = ozone->horizontal_list;
|
||||
info.list = &ozone->horizontal_list;
|
||||
info.path = strdup(dir_playlist);
|
||||
info.label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLISTS_TAB));
|
||||
@ -774,12 +773,12 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone)
|
||||
playlist_file_noext[0] = '\0';
|
||||
|
||||
/* Get playlist file name */
|
||||
file_list_get_at_offset(ozone->horizontal_list, i,
|
||||
file_list_get_at_offset(&ozone->horizontal_list, i,
|
||||
&playlist_file, NULL, NULL, NULL);
|
||||
|
||||
if (!playlist_file)
|
||||
{
|
||||
file_list_set_alt_at_offset(ozone->horizontal_list, i, NULL);
|
||||
file_list_set_alt_at_offset(&ozone->horizontal_list, i, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -818,7 +817,7 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone)
|
||||
}
|
||||
|
||||
/* Assign console name to list */
|
||||
file_list_set_alt_at_offset(ozone->horizontal_list, i, console_name);
|
||||
file_list_set_alt_at_offset(&ozone->horizontal_list, i, console_name);
|
||||
}
|
||||
|
||||
/* If playlist names were truncated and option is
|
||||
@ -826,30 +825,19 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone)
|
||||
if (ozone_truncate_playlist_name &&
|
||||
ozone_sort_after_truncate &&
|
||||
(list_size > 0))
|
||||
file_list_sort_on_alt(ozone->horizontal_list);
|
||||
file_list_sort_on_alt(&ozone->horizontal_list);
|
||||
}
|
||||
|
||||
void ozone_refresh_horizontal_list(ozone_handle_t *ozone)
|
||||
{
|
||||
ozone_context_destroy_horizontal_list(ozone);
|
||||
if (ozone->horizontal_list)
|
||||
{
|
||||
ozone_free_list_nodes(ozone->horizontal_list, false);
|
||||
file_list_free(ozone->horizontal_list);
|
||||
}
|
||||
ozone->horizontal_list = NULL;
|
||||
ozone_free_list_nodes(&ozone->horizontal_list, false);
|
||||
file_list_deinitialize(&ozone->horizontal_list);
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
|
||||
|
||||
ozone->horizontal_list = (file_list_t*)
|
||||
malloc(sizeof(file_list_t));
|
||||
|
||||
ozone->horizontal_list->list = NULL;
|
||||
ozone->horizontal_list->capacity = 0;
|
||||
ozone->horizontal_list->size = 0;
|
||||
|
||||
if (ozone->horizontal_list)
|
||||
ozone_init_horizontal_list(ozone);
|
||||
file_list_initialize(&ozone->horizontal_list);
|
||||
ozone_init_horizontal_list(ozone);
|
||||
|
||||
ozone_context_reset_horizontal_list(ozone);
|
||||
}
|
||||
@ -863,7 +851,7 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
|
||||
{
|
||||
const char *path = NULL;
|
||||
const char *console_name = NULL;
|
||||
ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(ozone->horizontal_list, i);
|
||||
ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(&ozone->horizontal_list, i);
|
||||
|
||||
if (!node)
|
||||
{
|
||||
@ -872,7 +860,7 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
|
||||
continue;
|
||||
}
|
||||
|
||||
file_list_get_at_offset(ozone->horizontal_list, i,
|
||||
file_list_get_at_offset(&ozone->horizontal_list, i,
|
||||
&path, NULL, NULL, NULL);
|
||||
|
||||
if (!path)
|
||||
@ -950,7 +938,7 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone)
|
||||
|
||||
/* Console name */
|
||||
menu_entries_get_at_offset(
|
||||
ozone->horizontal_list, i,
|
||||
&ozone->horizontal_list, i,
|
||||
NULL, NULL, NULL, NULL, &console_name);
|
||||
|
||||
if (node->console_name)
|
||||
@ -973,12 +961,12 @@ void ozone_context_destroy_horizontal_list(ozone_handle_t *ozone)
|
||||
for (i = 0; i < list_size; i++)
|
||||
{
|
||||
const char *path = NULL;
|
||||
ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(ozone->horizontal_list, i);
|
||||
ozone_node_t *node = (ozone_node_t*)file_list_get_userdata_at_offset(&ozone->horizontal_list, i);
|
||||
|
||||
if (!node)
|
||||
continue;
|
||||
|
||||
file_list_get_at_offset(ozone->horizontal_list, i,
|
||||
file_list_get_at_offset(&ozone->horizontal_list, i,
|
||||
&path, NULL, NULL, NULL);
|
||||
|
||||
if (!path || !string_ends_with_size(path, ".lpl",
|
||||
|
Loading…
Reference in New Issue
Block a user