(Ozone) Cleanups

This commit is contained in:
twinaphex 2020-09-01 07:26:04 +02:00
parent 1e842c9701
commit eb1ab2e429
3 changed files with 87 additions and 94 deletions

View File

@ -174,12 +174,7 @@ static size_t ozone_get_onscreen_category_selection(
/* Returns true if specified entry is currently
* displayed on screen */
static bool INLINE ozone_entry_onscreen(
ozone_handle_t *ozone, size_t idx)
{
return (idx >= ozone->first_onscreen_entry) &&
(idx <= ozone->last_onscreen_entry);
}
#define OZONE_ENTRY_ONSCREEN(ozone, idx) (((idx) >= (ozone)->first_onscreen_entry) && ((idx) <= (ozone)->last_onscreen_entry))
/* If currently selected entry is off screen,
* moves selection to specified on screen target
@ -192,7 +187,7 @@ static void ozone_auto_select_onscreen_entry(
size_t selection = menu_navigation_get_selection();
/* Check whether selected item is already on screen */
if (ozone_entry_onscreen(ozone, selection))
if (OZONE_ENTRY_ONSCREEN(ozone, selection))
return;
/* Update selection index */
@ -227,13 +222,15 @@ static bool INLINE ozone_metadata_override_available(ozone_handle_t *ozone)
* Short circuiting means that in most cases
* only 'ozone->is_playlist' will be evaluated,
* so this isn't too much of a performance hog... */
return ozone->is_playlist &&
ozone->show_thumbnail_bar &&
!ozone->selection_core_is_viewer &&
(ozone->thumbnails.left.status != GFX_THUMBNAIL_STATUS_MISSING) &&
gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_LEFT) &&
(ozone->thumbnails.right.status != GFX_THUMBNAIL_STATUS_MISSING) &&
gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_RIGHT);
return ozone->is_playlist
&& ozone->show_thumbnail_bar
&& !ozone->selection_core_is_viewer
&& (ozone->thumbnails.left.status != GFX_THUMBNAIL_STATUS_MISSING)
&& gfx_thumbnail_is_enabled(ozone->thumbnail_path_data,
GFX_THUMBNAIL_LEFT)
&& (ozone->thumbnails.right.status != GFX_THUMBNAIL_STATUS_MISSING)
&& gfx_thumbnail_is_enabled(ozone->thumbnail_path_data,
GFX_THUMBNAIL_RIGHT);
}
@ -306,12 +303,14 @@ static enum menu_action ozone_parse_menu_entry_action(
{
/* If cursor is active, ensure we target
* an on screen category */
size_t selection = (ozone->cursor_mode) ?
ozone_get_onscreen_category_selection(ozone) : ozone->categories_selection_ptr;
size_t selection = (ozone->cursor_mode)
? ozone_get_onscreen_category_selection(ozone)
: ozone->categories_selection_ptr;
new_selection = (int)(selection + 1);
if (new_selection >= (int)(ozone->system_tab_end + horizontal_list_size + 1))
if (new_selection >= (int)(ozone->system_tab_end
+ horizontal_list_size + 1))
new_selection = 0;
ozone_sidebar_goto(ozone, new_selection);
@ -333,9 +332,9 @@ static enum menu_action ozone_parse_menu_entry_action(
{
/* If cursor is active, ensure we target
* an on screen category */
size_t selection = (ozone->cursor_mode) ?
ozone_get_onscreen_category_selection(ozone) : ozone->categories_selection_ptr;
size_t selection = (ozone->cursor_mode)
? ozone_get_onscreen_category_selection(ozone)
: ozone->categories_selection_ptr;
new_selection = (int)selection - 1;
if (new_selection < 0)
@ -399,8 +398,8 @@ static enum menu_action ozone_parse_menu_entry_action(
* of a search, if required */
if (ozone->is_playlist)
{
struct string_list *menu_search_terms = menu_driver_search_get_terms();
struct string_list *menu_search_terms =
menu_driver_search_get_terms();
if (menu_search_terms &&
(menu_search_terms->size > 0))
break;
@ -498,17 +497,15 @@ static int ozone_menu_entry_action(
void *userdata, menu_entry_t *entry,
size_t i, enum menu_action action)
{
menu_entry_t new_entry;
ozone_handle_t *ozone = (ozone_handle_t*)userdata;
menu_entry_t *entry_ptr = entry;
size_t selection = i;
size_t new_selection;
menu_entry_t new_entry;
/* Process input action */
enum menu_action new_action = ozone_parse_menu_entry_action(ozone, action);
/* Check whether current selection has changed
* (due to automatic on screen entry selection...) */
new_selection = menu_navigation_get_selection();
size_t new_selection = menu_navigation_get_selection();
if (new_selection != selection)
{
@ -529,7 +526,6 @@ static int ozone_menu_entry_action(
new_selection, new_action);
}
static void ozone_free_node(ozone_node_t *node)
{
if (!node)
@ -632,7 +628,8 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
ozone->system_tab_end = 0;
ozone->tabs[ozone->system_tab_end] = OZONE_SYSTEM_TAB_MAIN;
if (settings->bools.menu_content_show_settings && !settings->bools.kiosk_mode_enable)
if ( settings->bools.menu_content_show_settings
&& !settings->bools.kiosk_mode_enable)
ozone->tabs[++ozone->system_tab_end] = OZONE_SYSTEM_TAB_SETTINGS;
if (settings->bools.menu_content_show_favorites)
ozone->tabs[++ozone->system_tab_end] = OZONE_SYSTEM_TAB_FAVORITES;
@ -653,7 +650,8 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
ozone->tabs[++ozone->system_tab_end] = OZONE_SYSTEM_TAB_NETPLAY;
#endif
if (settings->bools.menu_content_show_add && !settings->bools.kiosk_mode_enable)
if ( settings->bools.menu_content_show_add
&& !settings->bools.kiosk_mode_enable)
ozone->tabs[++ozone->system_tab_end] = OZONE_SYSTEM_TAB_ADD;
#if defined(HAVE_LIBRETRODB)
@ -897,18 +895,15 @@ static bool ozone_init_font(
static void ozone_cache_footer_label(ozone_handle_t *ozone,
ozone_footer_label_t *label, enum msg_hash_enums enum_idx)
{
unsigned length;
const char *str = msg_hash_to_str(enum_idx);
/* Determine pixel width */
unsigned length = (unsigned)strlen(str);
/* Assign string */
label->str = msg_hash_to_str(enum_idx);
/* Determine pixel width */
length = (unsigned)strlen(label->str);
label->str = str;
label->width = font_driver_get_message_width(
ozone->fonts.footer.font,
label->str, length, 1.0f);
/* If font_driver_get_message_width() fails,
* use predetermined glyph_width as a fallback */
if (label->width < 0)
@ -1116,7 +1111,7 @@ static void ozone_context_reset(void *data, bool is_threaded)
#endif
strlcpy(filename, OZONE_TEXTURES_FILES[i], sizeof(filename));
strlcat(filename, ".png", sizeof(filename));
strlcat(filename, FILE_PATH_PNG_EXTENSION, sizeof(filename));
#if 0
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
@ -1133,11 +1128,7 @@ static void ozone_context_reset(void *data, bool is_threaded)
{
#endif
if (!gfx_display_reset_textures_list(filename, ozone->png_path, &ozone->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
{
ozone->has_all_assets = false;
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", ozone->png_path,
PATH_DEFAULT_SLASH(), filename);
}
#if 0
}
#endif
@ -1151,7 +1142,7 @@ static void ozone_context_reset(void *data, bool is_threaded)
filename[0] = '\0';
strlcpy(filename,
OZONE_TAB_TEXTURES_FILES[i], sizeof(filename));
strlcat(filename, ".png", sizeof(filename));
strlcat(filename, FILE_PATH_PNG_EXTENSION, sizeof(filename));
if (!gfx_display_reset_textures_list(filename, ozone->tab_path, &ozone->tab_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
{

View File

@ -120,7 +120,7 @@ unsigned ozone_system_tabs_icons[OZONE_SYSTEM_TAB_LAST] = {
static void ozone_sidebar_collapse_end(void *userdata)
{
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
ozone_handle_t *ozone = (ozone_handle_t*)userdata;
ozone->sidebar_collapsed = true;
}
@ -248,9 +248,13 @@ void ozone_draw_sidebar(
video_width,
video_height,
ozone->sidebar_offset,
video_height - ozone->dimensions.footer_height - ozone->dimensions.sidebar_gradient_height - ozone->dimensions.spacer_1px,
video_height
- ozone->dimensions.footer_height
- ozone->dimensions.sidebar_gradient_height
- ozone->dimensions.spacer_1px,
(unsigned)ozone->dimensions_sidebar_width,
ozone->dimensions.sidebar_gradient_height + ozone->dimensions.spacer_1px,
ozone->dimensions.sidebar_gradient_height
+ ozone->dimensions.spacer_1px,
video_width,
video_height,
ozone->theme->sidebar_bottom_gradient);
@ -575,7 +579,7 @@ void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation)
ozone->animations.sidebar_text_alpha = 0.0f;
ozone->dimensions_sidebar_width =
ozone->dimensions.sidebar_width_collapsed;
ozone_sidebar_collapse_end(ozone);
ozone->sidebar_collapsed = true;
}
}
/* Show it */

View File

@ -27,6 +27,8 @@
#include "../../../cheevos/badges.h"
#endif
#include "../../../file_path_special.h"
#include "../../../verbosity.h"
static const char *OZONE_THEME_TEXTURES_FILES[OZONE_THEME_TEXTURE_LAST] = {
@ -846,16 +848,12 @@ bool ozone_reset_theme_textures(ozone_handle_t *ozone)
char filename[PATH_MAX_LENGTH];
strlcpy(filename, OZONE_THEME_TEXTURES_FILES[i],
sizeof(filename));
strlcat(filename, ".png", sizeof(filename));
strlcat(filename, FILE_PATH_PNG_EXTENSION, sizeof(filename));
if (!gfx_display_reset_textures_list(filename, theme_path, &theme->textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
{
RARCH_WARN("[OZONE] Asset missing: %s%s%s\n", theme_path,
PATH_DEFAULT_SLASH(), filename);
result = false;
}
}
}
return result;
}