(menu widgets) Minor variable cleanups; shouldn't affect anything

This commit is contained in:
twinaphex 2020-01-12 21:11:26 +01:00
parent e9adb44c4a
commit 70e472e9e2

View File

@ -857,7 +857,6 @@ static void menu_widgets_hourglass_tick(void *userdata)
void menu_widgets_iterate(unsigned width, unsigned height)
{
size_t i;
settings_t *settings = config_get_ptr();
/* Messages queue */
@ -936,13 +935,16 @@ void menu_widgets_iterate(unsigned width, unsigned height)
if (screenshot_filename[0] != '\0')
{
menu_timer_ctx_entry_t timer;
settings_t *settings = config_get_ptr();
float video_font_size = settings->floats.video_font_size;
video_driver_texture_unload(&screenshot_texture);
menu_display_reset_textures_list(screenshot_filename,
"", &screenshot_texture, TEXTURE_FILTER_MIPMAP_LINEAR,
&screenshot_texture_width, &screenshot_texture_height);
screenshot_height = settings->floats.video_font_size * 4;
screenshot_height = video_font_size * 4;
screenshot_width = width;
screenshot_scale_factor = menu_widgets_get_thumbnail_scale_factor(
@ -973,7 +975,6 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info,
enum msg_hash_enums msg)
{
unsigned width;
settings_t *settings = config_get_ptr();
menu_display_set_alpha(menu_widgets_backdrop_orig, DEFAULT_BACKDROP);
@ -1001,8 +1002,11 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info,
}
else
{
unsigned height = simple_widget_height;
const char *txt = msg_hash_to_str(msg);
unsigned height = simple_widget_height;
const char *txt = msg_hash_to_str(msg);
settings_t *settings = config_get_ptr();
float video_font_size = settings->floats.video_font_size;
width = font_driver_get_message_width(font_regular, txt, (unsigned)strlen(txt), 1) + simple_widget_padding*2;
menu_display_draw_quad(video_info,
@ -1014,7 +1018,7 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info,
menu_display_draw_text(font_regular,
txt,
top_right_x_advance - width + simple_widget_padding, settings->floats.video_font_size + simple_widget_padding/4,
top_right_x_advance - width + simple_widget_padding, video_font_size + simple_widget_padding/4,
video_info->width, video_info->height,
0xFFFFFFFF, TEXT_ALIGN_LEFT,
1.0f,
@ -1042,6 +1046,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
unsigned task_percentage_offset = 0;
char task_percentage[256] = {0};
settings_t *settings = config_get_ptr();
float video_font_size = settings->floats.video_font_size;
if (msg->msg_new)
draw_msg_new = !string_is_equal(msg->msg_new, msg->msg);
@ -1129,7 +1134,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
menu_display_draw_text(font_regular,
msg->msg_new,
msg_queue_task_text_start_x,
video_info->height - msg->offset_y + msg_queue_text_scale_factor * settings->floats.video_font_size + msg_queue_height/4 - settings->floats.video_font_size/2.25f - msg_queue_height/2 + msg->msg_transition_animation,
video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f - msg_queue_height/2 + msg->msg_transition_animation,
video_info->width, video_info->height,
text_color,
TEXT_ALIGN_LEFT,
@ -1143,7 +1148,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
menu_display_draw_text(font_regular,
msg->msg,
msg_queue_task_text_start_x,
video_info->height - msg->offset_y + msg_queue_text_scale_factor * settings->floats.video_font_size + msg_queue_height/4 - settings->floats.video_font_size/2.25f + msg->msg_transition_animation,
video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f + msg->msg_transition_animation,
video_info->width, video_info->height,
text_color,
TEXT_ALIGN_LEFT,
@ -1166,7 +1171,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
menu_display_draw_text(font_regular,
task_percentage,
msg_queue_rect_start_x - msg_queue_icon_size_x + rect_width - msg_queue_glyph_width,
video_info->height - msg->offset_y + msg_queue_text_scale_factor * settings->floats.video_font_size + msg_queue_height/4 - settings->floats.video_font_size/2.25f,
video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f,
video_info->width, video_info->height,
text_color,
TEXT_ALIGN_RIGHT,
@ -1341,9 +1346,9 @@ void menu_widgets_frame(video_frame_info_t *video_info)
{
size_t i;
int top_right_x_advance = video_info->width;
int scissor_me_timbers = 0;
settings_t *settings = config_get_ptr();
int scissor_me_timbers = 0;
settings_t *settings = config_get_ptr();
float video_font_size = settings->floats.video_font_size;
menu_widgets_frame_count++;
@ -1474,7 +1479,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_display_draw_text(font_regular,
msg_hash_to_str(MSG_SCREENSHOT_SAVED),
screenshot_thumbnail_width + simple_widget_padding, settings->floats.video_font_size * 1.9f + screenshot_y,
screenshot_thumbnail_width + simple_widget_padding, video_font_size * 1.9f + screenshot_y,
video_info->width, video_info->height,
text_color_faint,
TEXT_ALIGN_LEFT,
@ -1491,7 +1496,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_display_draw_text(font_regular,
shotname,
screenshot_thumbnail_width + simple_widget_padding, settings->floats.video_font_size * 2.9f + screenshot_y,
screenshot_thumbnail_width + simple_widget_padding, video_font_size * 2.9f + screenshot_y,
video_info->width, video_info->height,
text_color_info,
TEXT_ALIGN_LEFT,
@ -1555,7 +1560,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
/* Title */
menu_display_draw_text(font_regular,
msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED),
cheevo_height + simple_widget_padding - unfold_offet, settings->floats.video_font_size * 1.9f + cheevo_y,
cheevo_height + simple_widget_padding - unfold_offet, video_font_size * 1.9f + cheevo_y,
video_info->width, video_info->height,
text_color_faint,
TEXT_ALIGN_LEFT,
@ -1568,7 +1573,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_display_draw_text(font_regular,
cheevo_title,
cheevo_height + simple_widget_padding - unfold_offet, settings->floats.video_font_size * 2.9f + cheevo_y,
cheevo_height + simple_widget_padding - unfold_offet, video_font_size * 2.9f + cheevo_y,
video_info->width, video_info->height,
text_color_info,
TEXT_ALIGN_LEFT,
@ -1592,24 +1597,22 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_texture_item volume_icon = 0;
unsigned volume_width = video_info->width / 3;
unsigned volume_height = settings->floats.video_font_size * 4;
unsigned volume_height = video_font_size * 4;
unsigned icon_size = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MED] ? volume_height : simple_widget_padding;
unsigned text_color = COLOR_TEXT_ALPHA(0xffffffff, (unsigned)(volume_text_alpha*255.0f));
unsigned text_color_db = COLOR_TEXT_ALPHA(text_color_faint, (unsigned)(volume_text_alpha*255.0f));
unsigned bar_x = icon_size;
unsigned bar_height = settings->floats.video_font_size/2;
unsigned bar_width = volume_width - bar_x - simple_widget_padding;
unsigned bar_y = volume_height / 2 + bar_height/2;
unsigned bar_x = icon_size;
unsigned bar_height = video_font_size / 2;
unsigned bar_width = volume_width - bar_x - simple_widget_padding;
unsigned bar_y = volume_height / 2 + bar_height/2;
float *bar_background = NULL;
float *bar_foreground = NULL;
float bar_percentage = 0.0f;
float *bar_background = NULL;
float *bar_foreground = NULL;
float bar_percentage = 0.0f;
if (volume_mute)
{
volume_icon = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MUTE];
}
else if (volume_percent <= 1.0f)
{
if (volume_percent <= 0.5f)
@ -1676,7 +1679,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
const char *text = msg_hash_to_str(MSG_AUDIO_MUTED);
menu_display_draw_text(font_regular,
text,
volume_width/2, volume_height/2 + settings->floats.video_font_size/3,
volume_width/2, volume_height/2 + video_font_size / 3,
video_info->width, video_info->height,
text_color, TEXT_ALIGN_CENTER,
1, false, 0, false
@ -1712,7 +1715,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_display_draw_text(font_regular,
msg,
volume_width - simple_widget_padding, settings->floats.video_font_size * 2,
volume_width - simple_widget_padding, video_font_size * 2,
video_info->width, video_info->height,
text_color_db,
TEXT_ALIGN_RIGHT,
@ -1721,7 +1724,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_display_draw_text(font_regular,
percentage_msg,
icon_size, settings->floats.video_font_size * 2,
icon_size, video_font_size * 2,
video_info->width, video_info->height,
text_color,
TEXT_ALIGN_LEFT,
@ -1767,7 +1770,7 @@ void menu_widgets_frame(video_frame_info_t *video_info)
menu_display_draw_text(font_regular,
text,
top_right_x_advance - simple_widget_padding - text_width, settings->floats.video_font_size + simple_widget_padding/4,
top_right_x_advance - simple_widget_padding - text_width, video_font_size + simple_widget_padding/4,
video_info->width, video_info->height,
0xFFFFFFFF,
TEXT_ALIGN_LEFT,
@ -1861,7 +1864,8 @@ void menu_widgets_context_reset(bool is_threaded,
char theme_path[PATH_MAX_LENGTH];
char ozone_path[PATH_MAX_LENGTH];
char font_path[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
settings_t *settings = config_get_ptr();
float video_font_size = settings->floats.video_font_size;
/* Textures paths */
fill_pathname_join(
@ -1919,24 +1923,24 @@ void menu_widgets_context_reset(bool is_threaded,
if (settings->paths.path_font[0] == '\0')
{
fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path));
font_regular = menu_display_font_file(font_path, settings->floats.video_font_size, is_threaded);
font_regular = menu_display_font_file(font_path, video_font_size, is_threaded);
fill_pathname_join(font_path, ozone_path, "bold.ttf", sizeof(font_path));
font_bold = menu_display_font_file(font_path, settings->floats.video_font_size, is_threaded);
font_bold = menu_display_font_file(font_path, video_font_size, is_threaded);
}
else
{
font_regular = menu_display_font_file(settings->paths.path_font, settings->floats.video_font_size, is_threaded);
font_bold = menu_display_font_file(settings->paths.path_font, settings->floats.video_font_size, is_threaded);
font_regular = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded);
font_bold = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded);
}
/* Metrics */
simple_widget_padding = settings->floats.video_font_size * 2/3;
simple_widget_height = settings->floats.video_font_size + simple_widget_padding;
glyph_width = font_driver_get_message_width(font_regular, "a", 1, 1);
line_height = font_driver_get_line_height(font_regular, 1);
simple_widget_padding = video_font_size * 2/3;
simple_widget_height = video_font_size + simple_widget_padding;
glyph_width = font_driver_get_message_width(font_regular, "a", 1, 1);
line_height = font_driver_get_line_height(font_regular, 1);
msg_queue_height = settings->floats.video_font_size * 2.5f;
msg_queue_height = video_font_size * 2.5f;
if (msg_queue_has_icons)
{
@ -1973,11 +1977,11 @@ void menu_widgets_context_reset(bool is_threaded,
msg_queue_task_text_start_x -= msg_queue_glyph_width*2;
msg_queue_regular_text_start = msg_queue_rect_start_x + msg_queue_regular_padding_x;
msg_queue_regular_text_base_y = settings->floats.video_font_size * msg_queue_text_scale_factor + msg_queue_height/2;
msg_queue_regular_text_base_y = video_font_size * msg_queue_text_scale_factor + msg_queue_height/2;
msg_queue_task_hourglass_x = msg_queue_rect_start_x - msg_queue_icon_size_x;
generic_message_height = settings->floats.video_font_size * 2;
generic_message_height = video_font_size * 2;
}
void menu_widgets_context_destroy(void)
@ -1988,9 +1992,7 @@ void menu_widgets_context_destroy(void)
/* Textures */
for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++)
{
video_driver_texture_unload(&menu_widgets_icons_textures[i]);
}
video_driver_texture_unload(&msg_queue_icon);
video_driver_texture_unload(&msg_queue_icon_outline);
@ -2112,10 +2114,10 @@ static void menu_widgets_volume_timer_end(void *userdata)
void menu_widgets_volume_update_and_show(void)
{
menu_timer_ctx_entry_t entry;
settings_t *settings = config_get_ptr();
bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE));
float new_volume = settings->floats.audio_volume;
menu_timer_ctx_entry_t entry;
menu_animation_kill_by_tag(&volume_tag);
@ -2389,18 +2391,18 @@ static void menu_widgets_achievement_unfold(void *userdata)
menu_timer_start(&cheevo_timer, &timer);
}
static void menu_widgets_start_achievement_notification()
static void menu_widgets_start_achievement_notification(void)
{
settings_t *settings = config_get_ptr();
menu_animation_ctx_entry_t entry;
cheevo_height = settings->floats.video_font_size * 4;
cheevo_width = MAX(
settings_t *settings = config_get_ptr();
cheevo_height = settings->floats.video_font_size * 4;
cheevo_width = MAX(
font_driver_get_message_width(font_regular, msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED), 0, 1),
font_driver_get_message_width(font_regular, cheevo_title, 0, 1)
);
cheevo_width += simple_widget_padding * 2;
cheevo_y = (float)(-(int)cheevo_height);
cheevo_unfold = 0.0f;
cheevo_width += simple_widget_padding * 2;
cheevo_y = (float)(-(int)cheevo_height);
cheevo_unfold = 0.0f;
/* Slide down animation */
entry.cb = menu_widgets_achievement_unfold;
@ -2449,8 +2451,8 @@ void menu_widgets_push_achievement(const char *title, const char *badge)
static void menu_widgets_generic_message_fadeout(void *userdata)
{
menu_animation_ctx_tag tag = (uintptr_t) &generic_message_timer;
menu_animation_ctx_entry_t entry;
menu_animation_ctx_tag tag = (uintptr_t) &generic_message_timer;
/* Start fade out animation */
entry.cb = NULL;
@ -2466,8 +2468,8 @@ static void menu_widgets_generic_message_fadeout(void *userdata)
void menu_widgets_set_message(char *msg)
{
menu_animation_ctx_tag tag = (uintptr_t) &generic_message_timer;
menu_timer_ctx_entry_t timer;
menu_animation_ctx_tag tag = (uintptr_t) &generic_message_timer;
strlcpy(generic_message, msg, GENERIC_MESSAGE_SIZE);
@ -2486,8 +2488,8 @@ void menu_widgets_set_message(char *msg)
static void menu_widgets_libretro_message_fadeout(void *userdata)
{
menu_animation_ctx_tag tag = (uintptr_t) &libretro_message_timer;
menu_animation_ctx_entry_t entry;
menu_animation_ctx_tag tag = (uintptr_t) &libretro_message_timer;
/* Start fade out animation */
entry.cb = NULL;
@ -2503,8 +2505,8 @@ static void menu_widgets_libretro_message_fadeout(void *userdata)
void menu_widgets_set_libretro_message(const char *msg, unsigned duration)
{
menu_animation_ctx_tag tag = (uintptr_t) &libretro_message_timer;
menu_timer_ctx_entry_t timer;
menu_animation_ctx_tag tag = (uintptr_t) &libretro_message_timer;
strlcpy(libretro_message, msg, LIBRETRO_MESSAGE_SIZE);