mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-26 04:36:56 +00:00
(Menu) Cleanups for drivers
This commit is contained in:
parent
d9948c00e1
commit
69d251ff6d
@ -2303,10 +2303,8 @@ static void materialui_refresh_playlist_icon_list(materialui_handle_t *mui,
|
||||
* necessary (if 'invalid' playlist files
|
||||
* are included in the list), but this
|
||||
* reduces code complexity */
|
||||
mui->textures.playlist.icons = (materialui_playlist_icon_t*)
|
||||
malloc(file_list->size * sizeof(materialui_playlist_icon_t));
|
||||
|
||||
if (!mui->textures.playlist.icons)
|
||||
if (!(mui->textures.playlist.icons = (materialui_playlist_icon_t*)
|
||||
malloc(file_list->size * sizeof(materialui_playlist_icon_t))))
|
||||
goto end;
|
||||
|
||||
mui->textures.playlist.size = file_list->size;
|
||||
@ -2369,24 +2367,8 @@ static void materialui_set_node_playlist_icon(
|
||||
materialui_handle_t *mui, materialui_node_t* node,
|
||||
const char *playlist_path)
|
||||
{
|
||||
const char *playlist_file = NULL;
|
||||
size_t i;
|
||||
|
||||
/* Set defaults */
|
||||
node->icon_texture_index = MUI_TEXTURE_PLAYLIST;
|
||||
node->icon_type = MUI_ICON_TYPE_INTERNAL;
|
||||
|
||||
if (mui->textures.playlist.size < 1)
|
||||
return;
|
||||
|
||||
/* Get playlist file name */
|
||||
if (string_is_empty(playlist_path))
|
||||
return;
|
||||
|
||||
playlist_file = path_basename_nocompression(playlist_path);
|
||||
|
||||
if (string_is_empty(playlist_path))
|
||||
return;
|
||||
const char *playlist_file = path_basename_nocompression(playlist_path);
|
||||
|
||||
/* Search icon list for specified file */
|
||||
for (i = 0; i < mui->textures.playlist.size; i++)
|
||||
@ -2410,15 +2392,13 @@ static uintptr_t materialui_get_playlist_icon(
|
||||
materialui_handle_t *mui, unsigned texture_index)
|
||||
{
|
||||
uintptr_t playlist_icon;
|
||||
|
||||
/* Always use MUI_TEXTURE_PLAYLIST as
|
||||
* a fallback */
|
||||
if (texture_index >= mui->textures.playlist.size)
|
||||
return mui->textures.list[MUI_TEXTURE_PLAYLIST];
|
||||
|
||||
playlist_icon = mui->textures.playlist.icons[texture_index].image;
|
||||
|
||||
return playlist_icon ? playlist_icon : mui->textures.list[MUI_TEXTURE_PLAYLIST];
|
||||
if ((playlist_icon = mui->textures.playlist.icons[texture_index].image))
|
||||
return playlist_icon;
|
||||
return mui->textures.list[MUI_TEXTURE_PLAYLIST];
|
||||
}
|
||||
|
||||
/* ==============================
|
||||
@ -2516,21 +2496,12 @@ static void materialui_draw_thumbnail(
|
||||
float scale_factor,
|
||||
math_matrix_4x4 *mymat)
|
||||
{
|
||||
float bg_x;
|
||||
float bg_y;
|
||||
float bg_width;
|
||||
float bg_height;
|
||||
|
||||
/* Sanity check */
|
||||
if (scale_factor <= 0)
|
||||
return;
|
||||
|
||||
/* Get background draw position + dimensions,
|
||||
* accounting for scale factor */
|
||||
bg_width = (float)mui->thumbnail_width_max * scale_factor;
|
||||
bg_height = (float)mui->thumbnail_height_max * scale_factor;
|
||||
bg_x = x - (bg_width - (float)mui->thumbnail_width_max) / 2.0f;
|
||||
bg_y = y - (bg_height - (float)mui->thumbnail_height_max) / 2.0f;
|
||||
float bg_width = (float)mui->thumbnail_width_max * scale_factor;
|
||||
float bg_height = (float)mui->thumbnail_height_max * scale_factor;
|
||||
float bg_x = x - (bg_width - (float)mui->thumbnail_width_max) / 2.0f;
|
||||
float bg_y = y - (bg_height - (float)mui->thumbnail_height_max) / 2.0f;
|
||||
|
||||
/* If thumbnail is missing, draw fallback image... */
|
||||
switch (thumbnail->status)
|
||||
@ -10236,7 +10207,12 @@ static void materialui_list_insert(
|
||||
node->icon_type = MUI_ICON_TYPE_INTERNAL;
|
||||
break;
|
||||
case FILE_TYPE_PLAYLIST_COLLECTION:
|
||||
materialui_set_node_playlist_icon(mui, node, path);
|
||||
/* Set defaults */
|
||||
node->icon_texture_index = MUI_TEXTURE_PLAYLIST;
|
||||
node->icon_type = MUI_ICON_TYPE_INTERNAL;
|
||||
if (mui->textures.playlist.size >= 1)
|
||||
if (!string_is_empty(path))
|
||||
materialui_set_node_playlist_icon(mui, node, path);
|
||||
break;
|
||||
case FILE_TYPE_RDB:
|
||||
node->icon_texture_index = MUI_TEXTURE_DATABASE;
|
||||
|
@ -2564,16 +2564,14 @@ static float ozone_sidebar_get_scroll_y(
|
||||
return scroll_y;
|
||||
}
|
||||
|
||||
/* Flushing is slow - only do it if font
|
||||
* has actually been used */
|
||||
static void ozone_font_flush(
|
||||
unsigned video_width, unsigned video_height,
|
||||
ozone_font_data_t *font_data)
|
||||
{
|
||||
/* Flushing is slow - only do it if font
|
||||
* has actually been used */
|
||||
if (!font_data ||
|
||||
(font_data->raster_block.carr.coords.vertices == 0))
|
||||
if (font_data->raster_block.carr.coords.vertices == 0)
|
||||
return;
|
||||
|
||||
font_driver_flush(video_width, video_height, font_data->font);
|
||||
font_data->raster_block.carr.coords.vertices = 0;
|
||||
}
|
||||
@ -9485,8 +9483,7 @@ static void ozone_messagebox_fadeout_cb(void *userdata)
|
||||
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
|
||||
|
||||
free(ozone->pending_message);
|
||||
ozone->pending_message = NULL;
|
||||
|
||||
ozone->pending_message = NULL;
|
||||
ozone->should_draw_messagebox = false;
|
||||
}
|
||||
|
||||
@ -9503,8 +9500,9 @@ static void INLINE ozone_font_unbind(ozone_font_data_t *font_data)
|
||||
|
||||
static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
{
|
||||
math_matrix_4x4 mymat;
|
||||
gfx_animation_ctx_entry_t entry;
|
||||
ozone_handle_t* ozone = (ozone_handle_t*) data;
|
||||
ozone_handle_t* ozone = (ozone_handle_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned color_theme = settings->uints.menu_ozone_color_theme;
|
||||
bool use_preferred_system_color_theme = settings->bools.menu_use_preferred_system_color_theme;
|
||||
@ -9526,7 +9524,6 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
|
||||
gfx_animation_t *p_anim = anim_get_ptr();
|
||||
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
||||
math_matrix_4x4 mymat;
|
||||
|
||||
#if 0
|
||||
static bool reset = false;
|
||||
@ -9538,7 +9535,6 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (!ozone)
|
||||
return;
|
||||
|
||||
@ -9763,37 +9759,37 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
/* Fade in animation */
|
||||
if (ozone->messagebox_state_old != ozone->messagebox_state && ozone->messagebox_state)
|
||||
{
|
||||
ozone->messagebox_state_old = ozone->messagebox_state;
|
||||
ozone->messagebox_state_old = ozone->messagebox_state;
|
||||
|
||||
gfx_animation_kill_by_tag(&messagebox_tag);
|
||||
ozone->animations.messagebox_alpha = 0.0f;
|
||||
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.messagebox_alpha;
|
||||
entry.tag = messagebox_tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.messagebox_alpha;
|
||||
entry.tag = messagebox_tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
|
||||
gfx_animation_push(&entry);
|
||||
}
|
||||
/* Fade out animation */
|
||||
else if (ozone->messagebox_state_old != ozone->messagebox_state && !ozone->messagebox_state)
|
||||
{
|
||||
ozone->messagebox_state_old = ozone->messagebox_state;
|
||||
ozone->messagebox_state = false;
|
||||
ozone->messagebox_state_old = ozone->messagebox_state;
|
||||
ozone->messagebox_state = false;
|
||||
|
||||
gfx_animation_kill_by_tag(&messagebox_tag);
|
||||
ozone->animations.messagebox_alpha = 1.0f;
|
||||
|
||||
entry.cb = ozone_messagebox_fadeout_cb;
|
||||
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.messagebox_alpha;
|
||||
entry.tag = messagebox_tag;
|
||||
entry.target_value = 0.0f;
|
||||
entry.userdata = ozone;
|
||||
entry.cb = ozone_messagebox_fadeout_cb;
|
||||
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.messagebox_alpha;
|
||||
entry.tag = messagebox_tag;
|
||||
entry.target_value = 0.0f;
|
||||
entry.userdata = ozone;
|
||||
|
||||
gfx_animation_push(&entry);
|
||||
}
|
||||
@ -9888,7 +9884,7 @@ static void ozone_set_header(ozone_handle_t *ozone)
|
||||
|
||||
static void ozone_animation_end(void *userdata)
|
||||
{
|
||||
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
|
||||
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
|
||||
ozone->draw_old_list = false;
|
||||
ozone->animations.cursor_alpha = 1.0f;
|
||||
}
|
||||
@ -10007,11 +10003,9 @@ static void ozone_populate_entries(void *data,
|
||||
bool goto_sidebar = false;
|
||||
|
||||
if (!list || (list->size < 1))
|
||||
goto_sidebar = true;
|
||||
|
||||
if (!goto_sidebar &&
|
||||
(list->list[0].type != FILE_TYPE_RPL_ENTRY))
|
||||
goto_sidebar = true;
|
||||
goto_sidebar = true;
|
||||
else if ((list->list[0].type != FILE_TYPE_RPL_ENTRY))
|
||||
goto_sidebar = true;
|
||||
|
||||
if (goto_sidebar)
|
||||
{
|
||||
@ -10096,17 +10090,14 @@ static void ozone_toggle(void *userdata, bool menu_on)
|
||||
return;
|
||||
|
||||
settings = config_get_ptr();
|
||||
tmp = !menu_entries_ctl(
|
||||
MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL);
|
||||
|
||||
if (tmp)
|
||||
if ((tmp = !menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL)))
|
||||
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
|
||||
else
|
||||
menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL);
|
||||
|
||||
if (ozone->depth == 1)
|
||||
{
|
||||
ozone->draw_sidebar = true;
|
||||
ozone->draw_sidebar = true;
|
||||
ozone->sidebar_offset = 0.0f;
|
||||
}
|
||||
|
||||
@ -10134,7 +10125,7 @@ static bool ozone_menu_init_list(void *data)
|
||||
MENU_ENUM_LABEL_MAIN_MENU,
|
||||
info.type, info.flags, 0);
|
||||
|
||||
info.list = selection_buf;
|
||||
info.list = selection_buf;
|
||||
|
||||
if (!menu_displaylist_ctl(DISPLAYLIST_MAIN_MENU, &info, settings))
|
||||
goto error;
|
||||
@ -10161,23 +10152,21 @@ static void ozone_list_insert(void *userdata,
|
||||
unsigned type)
|
||||
{
|
||||
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
|
||||
ozone_node_t *node = NULL;
|
||||
int i = (int)list_size;
|
||||
ozone_node_t *node = NULL;
|
||||
int i = (int)list_size;
|
||||
|
||||
if (!ozone || !list)
|
||||
return;
|
||||
|
||||
ozone->need_compute = true;
|
||||
|
||||
node = (ozone_node_t*)list->list[i].userdata;
|
||||
|
||||
if (!node)
|
||||
node = ozone_alloc_node();
|
||||
|
||||
if (!node)
|
||||
if (!(node = (ozone_node_t*)list->list[i].userdata))
|
||||
{
|
||||
RARCH_ERR("ozone node could not be allocated.\n");
|
||||
return;
|
||||
if (!(node = ozone_alloc_node()))
|
||||
{
|
||||
RARCH_ERR("ozone node could not be allocated.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string_is_empty(fullpath))
|
||||
@ -10185,7 +10174,7 @@ static void ozone_list_insert(void *userdata,
|
||||
if (node->fullpath)
|
||||
free(node->fullpath);
|
||||
|
||||
node->fullpath = strdup(fullpath);
|
||||
node->fullpath = strdup(fullpath);
|
||||
}
|
||||
|
||||
list->list[i].userdata = node;
|
||||
@ -10209,10 +10198,7 @@ static int ozone_environ_cb(enum menu_environ_cb type, void *data, void *userdat
|
||||
case MENU_ENVIRON_RESET_HORIZONTAL_LIST:
|
||||
if (!ozone)
|
||||
return -1;
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
ozone_refresh_horizontal_list(ozone, settings);
|
||||
}
|
||||
ozone_refresh_horizontal_list(ozone, config_get_ptr());
|
||||
break;
|
||||
case MENU_ENVIRON_ENABLE_SCREENSAVER:
|
||||
ozone->show_screensaver = true;
|
||||
@ -10237,7 +10223,7 @@ static void ozone_messagebox(void *data, const char *message)
|
||||
if (ozone->pending_message)
|
||||
{
|
||||
free(ozone->pending_message);
|
||||
ozone->pending_message = NULL;
|
||||
ozone->pending_message = NULL;
|
||||
}
|
||||
|
||||
ozone->pending_message = strdup(message);
|
||||
|
@ -452,7 +452,7 @@ static float xmb_coord_white[] = {
|
||||
1, 1, 1, 1
|
||||
};
|
||||
|
||||
static float item_color[] = {
|
||||
static float xmb_item_color[] = {
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
@ -5310,7 +5310,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
/**************************/
|
||||
|
||||
/* Clock image */
|
||||
gfx_display_set_alpha(item_color, MIN(xmb->alpha, 1.00f));
|
||||
gfx_display_set_alpha(xmb_item_color, MIN(xmb->alpha, 1.00f));
|
||||
|
||||
if (battery_level_enable)
|
||||
{
|
||||
@ -5357,7 +5357,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
&item_color[0],
|
||||
&xmb_item_color[0],
|
||||
xmb->shadow_offset,
|
||||
&mymat);
|
||||
if (dispctx && dispctx->blend_end)
|
||||
@ -5406,7 +5406,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
&item_color[0],
|
||||
&xmb_item_color[0],
|
||||
xmb->shadow_offset,
|
||||
&mymat);
|
||||
if (dispctx && dispctx->blend_end)
|
||||
@ -5429,7 +5429,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
}
|
||||
|
||||
/* Arrow image */
|
||||
gfx_display_set_alpha(item_color,
|
||||
gfx_display_set_alpha(xmb_item_color,
|
||||
MIN(xmb->textures_arrow_alpha, xmb->alpha));
|
||||
|
||||
if (!xmb->assets_missing)
|
||||
@ -5456,7 +5456,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
xmb->textures_arrow_alpha,
|
||||
0,
|
||||
1,
|
||||
&item_color[0],
|
||||
&xmb_item_color[0],
|
||||
xmb->shadow_offset,
|
||||
&mymat);
|
||||
if (dispctx && dispctx->blend_end)
|
||||
@ -5478,9 +5478,9 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
if (!node)
|
||||
continue;
|
||||
|
||||
gfx_display_set_alpha(item_color, MIN(node->alpha, xmb->alpha));
|
||||
gfx_display_set_alpha(xmb_item_color, MIN(node->alpha, xmb->alpha));
|
||||
|
||||
if (item_color[3] != 0)
|
||||
if (xmb_item_color[3] != 0)
|
||||
{
|
||||
gfx_display_ctx_rotate_draw_t rotate_draw;
|
||||
math_matrix_4x4 mymat_tmp;
|
||||
@ -5501,7 +5501,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
|
||||
if (x > x_threshold)
|
||||
{
|
||||
float fade_alpha = item_color[3];
|
||||
float fade_alpha = xmb_item_color[3];
|
||||
float fade_offset = (x - x_threshold) * 2.0f;
|
||||
|
||||
fade_offset = (fade_offset > xmb->icon_size) ? xmb->icon_size : fade_offset;
|
||||
@ -5510,7 +5510,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
if (fade_alpha <= 0.0f)
|
||||
continue;
|
||||
|
||||
gfx_display_set_alpha(item_color, fade_alpha);
|
||||
gfx_display_set_alpha(xmb_item_color, fade_alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5539,7 +5539,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
1.0,
|
||||
0, /* rotation */
|
||||
scale_factor,
|
||||
&item_color[0],
|
||||
&xmb_item_color[0],
|
||||
xmb->shadow_offset,
|
||||
&mymat_tmp);
|
||||
}
|
||||
@ -5562,7 +5562,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
(xmb_list_get_size(xmb, MENU_LIST_PLAIN) > 1)
|
||||
? xmb->categories_selection_ptr :
|
||||
xmb->categories_selection_ptr_old,
|
||||
&item_color[0],
|
||||
&xmb_item_color[0],
|
||||
video_width,
|
||||
video_height,
|
||||
&mymat);
|
||||
@ -5581,7 +5581,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
||||
selection_buf,
|
||||
selection,
|
||||
xmb->categories_selection_ptr,
|
||||
&item_color[0],
|
||||
&xmb_item_color[0],
|
||||
video_width,
|
||||
video_height,
|
||||
&mymat);
|
||||
@ -6498,7 +6498,7 @@ static void xmb_context_reset_textures(
|
||||
(settings->uints.menu_xmb_theme == XMB_ICON_THEME_MONOCHROME_INVERTED) ||
|
||||
(settings->uints.menu_xmb_theme == XMB_ICON_THEME_AUTOMATIC_INVERTED)
|
||||
)
|
||||
memcpy(item_color, xmb_coord_black, sizeof(item_color));
|
||||
memcpy(xmb_item_color, xmb_coord_black, sizeof(xmb_item_color));
|
||||
else
|
||||
{
|
||||
if (
|
||||
@ -6510,14 +6510,14 @@ static void xmb_context_reset_textures(
|
||||
{
|
||||
if ((i==3) || (i==7) || (i==11) || (i==15))
|
||||
{
|
||||
item_color[i] = 1;
|
||||
xmb_item_color[i] = 1;
|
||||
continue;
|
||||
}
|
||||
item_color[i] = 0.95;
|
||||
xmb_item_color[i] = 0.95;
|
||||
}
|
||||
}
|
||||
else
|
||||
memcpy(item_color, xmb_coord_white, sizeof(item_color));
|
||||
memcpy(xmb_item_color, xmb_coord_white, sizeof(xmb_item_color));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -6708,15 +6708,13 @@ static void xmb_list_insert(void *userdata,
|
||||
if (!xmb || !list)
|
||||
return;
|
||||
|
||||
node = (xmb_node_t*)list->list[i].userdata;
|
||||
|
||||
if (!node)
|
||||
node = xmb_alloc_node();
|
||||
|
||||
if (!node)
|
||||
if (!(node = (xmb_node_t*)list->list[i].userdata))
|
||||
{
|
||||
RARCH_ERR("XMB node could not be allocated.\n");
|
||||
return;
|
||||
if (!(node = xmb_alloc_node()))
|
||||
{
|
||||
RARCH_ERR("XMB node could not be allocated.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
current = (int)selection;
|
||||
|
Loading…
x
Reference in New Issue
Block a user