mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
(menu_animation) Create menu_animation_ticker_generic
This commit is contained in:
parent
06838d044f
commit
b217bbad24
@ -317,8 +317,8 @@ static void glui_render_label_value(glui_handle_t *glui, int y, unsigned width,
|
||||
label_str[0] = '\0';
|
||||
value_str[0] = '\0';
|
||||
|
||||
menu_animation_ticker_line(label_str, glui->ticker_limit, index, label, selected);
|
||||
menu_animation_ticker_line(value_str, glui->ticker_limit, index, value, selected);
|
||||
menu_animation_ticker_str(label_str, glui->ticker_limit, index, label, selected);
|
||||
menu_animation_ticker_str(value_str, glui->ticker_limit, index, value, selected);
|
||||
|
||||
glui_blit_line(glui->margin, y, label_str, color, TEXT_ALIGN_LEFT);
|
||||
glui_blit_line(width - glui->margin, y, value_str, color, TEXT_ALIGN_RIGHT);
|
||||
@ -430,7 +430,7 @@ static void glui_frame(void)
|
||||
glui_render_quad(gl, 0, 0, width,
|
||||
disp->header_height, 0.2, 0.2, 0.2, 1);
|
||||
|
||||
menu_animation_ticker_line(title_buf, glui->ticker_limit,
|
||||
menu_animation_ticker_str(title_buf, glui->ticker_limit,
|
||||
frame_count / 100, title, true);
|
||||
glui_blit_line(width / 2, 0, title_buf,
|
||||
title_color, TEXT_ALIGN_CENTER);
|
||||
|
@ -466,7 +466,7 @@ static void rgui_render(void)
|
||||
|
||||
menu_entries_get_title(title, sizeof(title));
|
||||
|
||||
menu_animation_ticker_line(title_buf, RGUI_TERM_WIDTH - 10,
|
||||
menu_animation_ticker_str(title_buf, RGUI_TERM_WIDTH - 10,
|
||||
frame_count / RGUI_TERM_START_X, title, true);
|
||||
|
||||
hover_color = HOVER_COLOR(settings);
|
||||
@ -527,9 +527,9 @@ static void rgui_render(void)
|
||||
menu_entry_get_value(i, entry_value, sizeof(entry_value));
|
||||
menu_entry_get_path(i, entry_path, sizeof(entry_path));
|
||||
|
||||
menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (entry_spacing + 1 + 2),
|
||||
menu_animation_ticker_str(entry_title_buf, RGUI_TERM_WIDTH - (entry_spacing + 1 + 2),
|
||||
frame_count / RGUI_TERM_START_X, entry_path, entry_selected);
|
||||
menu_animation_ticker_line(type_str_buf, entry_spacing,
|
||||
menu_animation_ticker_str(type_str_buf, entry_spacing,
|
||||
frame_count / RGUI_TERM_START_X,
|
||||
entry_value, entry_selected);
|
||||
|
||||
|
@ -171,7 +171,7 @@ static void rmenu_render(void)
|
||||
|
||||
menu_entries_get_title(title, sizeof(title));
|
||||
|
||||
menu_animation_ticker_line(title_buf, RMENU_TERM_WIDTH,
|
||||
menu_animation_ticker_str(title_buf, RMENU_TERM_WIDTH,
|
||||
frame_count / 15, title, true);
|
||||
|
||||
font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
|
||||
@ -206,9 +206,9 @@ static void rmenu_render(void)
|
||||
menu_entry_get_value(i, entry_value, sizeof(entry_value));
|
||||
menu_entry_get_path(i, entry_path, sizeof(entry_path));
|
||||
|
||||
menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (entry_spacing + 1 + 2),
|
||||
menu_animation_ticker_str(entry_title_buf, RMENU_TERM_WIDTH - (entry_spacing + 1 + 2),
|
||||
frame_count / 15, entry_path, entry_selected);
|
||||
menu_animation_ticker_line(type_str_buf, entry_spacing,
|
||||
menu_animation_ticker_str(type_str_buf, entry_spacing,
|
||||
frame_count / 15, entry_value, entry_selected);
|
||||
|
||||
snprintf(message, sizeof(message), "%c %s",
|
||||
|
@ -560,7 +560,7 @@ static void rmenu_xui_render(void)
|
||||
menu_entries_get_title(title, sizeof(title));
|
||||
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
|
||||
XuiTextElementSetText(m_menutitle, strw_buffer);
|
||||
menu_animation_ticker_line(title, RXUI_TERM_WIDTH - 3, (unsigned int)frame_count / 15, title, true);
|
||||
menu_animation_ticker_str(title, RXUI_TERM_WIDTH - 3, (unsigned int)frame_count / 15, title, true);
|
||||
}
|
||||
|
||||
if (XuiHandleIsValid(m_menutitle))
|
||||
|
@ -1388,7 +1388,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
|
||||
ticker_limit = 70;
|
||||
}
|
||||
|
||||
menu_animation_ticker_line(name, ticker_limit,
|
||||
menu_animation_ticker_str(name, ticker_limit,
|
||||
frame_count / 20, entry.path,
|
||||
(i == current));
|
||||
|
||||
@ -1398,7 +1398,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
|
||||
xmb->margins.screen.top + node->y + xmb->margins.label.top,
|
||||
1, node->label_alpha, TEXT_ALIGN_LEFT);
|
||||
|
||||
menu_animation_ticker_line(value, 35,
|
||||
menu_animation_ticker_str(value, 35,
|
||||
frame_count / 20, entry.value,
|
||||
(i == current));
|
||||
|
||||
|
@ -545,8 +545,42 @@ bool menu_animation_update(menu_animation_t *anim, float dt)
|
||||
return true;
|
||||
}
|
||||
|
||||
void menu_animation_ticker_generic(uint64_t idx, int max_width,
|
||||
int *offset, int *width)
|
||||
{
|
||||
int ticker_period, phase, phase_left_stop;
|
||||
int phase_left_moving, phase_right_stop;
|
||||
int left_offset, right_offset;
|
||||
|
||||
*offset = 0;
|
||||
|
||||
if (*width <= max_width)
|
||||
return;
|
||||
|
||||
ticker_period = 2 * (*width - max_width) + 4;
|
||||
phase = idx % ticker_period;
|
||||
|
||||
phase_left_stop = 2;
|
||||
phase_left_moving = phase_left_stop + (*width - max_width);
|
||||
phase_right_stop = phase_left_moving + 2;
|
||||
|
||||
left_offset = phase - phase_left_stop;
|
||||
right_offset = (*width - max_width) - (phase - phase_right_stop);
|
||||
|
||||
if (phase < phase_left_stop)
|
||||
*offset = 0;
|
||||
else if (phase < phase_left_moving)
|
||||
*offset = -left_offset;
|
||||
else if (phase < phase_right_stop)
|
||||
*offset = -(*width - max_width);
|
||||
else
|
||||
*offset = -right_offset;
|
||||
|
||||
*width = max_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu_animation_ticker_line:
|
||||
* menu_animation_ticker_str:
|
||||
* @s : buffer to write new message line to.
|
||||
* @len : length of buffer @input.
|
||||
* @idx : Index. Will be used for ticker logic.
|
||||
@ -556,14 +590,12 @@ bool menu_animation_update(menu_animation_t *anim, float dt)
|
||||
* Take the contents of @str and apply a ticker effect to it,
|
||||
* and write the results in @s.
|
||||
**/
|
||||
void menu_animation_ticker_line(char *s, size_t len, uint64_t idx,
|
||||
void menu_animation_ticker_str(char *s, size_t len, uint64_t idx,
|
||||
const char *str, bool selected)
|
||||
{
|
||||
unsigned ticker_period, phase, phase_left_stop;
|
||||
unsigned phase_left_moving, phase_right_stop;
|
||||
unsigned left_offset, right_offset;
|
||||
size_t str_len = strlen(str);
|
||||
menu_animation_t *anim = menu_animation_get_ptr();
|
||||
int str_len = strlen(str);
|
||||
int offset = 0;
|
||||
|
||||
if (str_len <= len)
|
||||
{
|
||||
@ -578,31 +610,9 @@ void menu_animation_ticker_line(char *s, size_t len, uint64_t idx,
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wrap long strings in options with some kind of ticker line. */
|
||||
ticker_period = 2 * (str_len - len) + 4;
|
||||
phase = idx % ticker_period;
|
||||
menu_animation_ticker_generic(idx, len, &offset, &str_len);
|
||||
|
||||
phase_left_stop = 2;
|
||||
phase_left_moving = phase_left_stop + (str_len - len);
|
||||
phase_right_stop = phase_left_moving + 2;
|
||||
|
||||
left_offset = phase - phase_left_stop;
|
||||
right_offset = (str_len - len) - (phase - phase_right_stop);
|
||||
|
||||
/* Ticker period:
|
||||
* [Wait at left (2 ticks),
|
||||
* Progress to right(type_len - w),
|
||||
* Wait at right (2 ticks),
|
||||
* Progress to left].
|
||||
*/
|
||||
if (phase < phase_left_stop)
|
||||
strlcpy(s, str, len + 1);
|
||||
else if (phase < phase_left_moving)
|
||||
strlcpy(s, str + left_offset, len + 1);
|
||||
else if (phase < phase_right_stop)
|
||||
strlcpy(s, str + str_len - len, len + 1);
|
||||
else
|
||||
strlcpy(s, str + right_offset, len + 1);
|
||||
strlcpy(s, str - offset, str_len + 1);
|
||||
|
||||
anim->is_active = true;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ bool menu_animation_update(
|
||||
float dt);
|
||||
|
||||
/**
|
||||
* menu_animation_ticker_line:
|
||||
* menu_animation_ticker_str:
|
||||
* @s : buffer to write new message line to.
|
||||
* @len : length of buffer @input.
|
||||
* @idx : Index. Will be used for ticker logic.
|
||||
@ -145,9 +145,12 @@ bool menu_animation_update(
|
||||
* Take the contents of @str and apply a ticker effect to it,
|
||||
* and write the results in @s.
|
||||
**/
|
||||
void menu_animation_ticker_line(char *s, size_t len, uint64_t tick,
|
||||
void menu_animation_ticker_str(char *s, size_t len, uint64_t tick,
|
||||
const char *str, bool selected);
|
||||
|
||||
void menu_animation_ticker_generic(uint64_t idx, int max_width,
|
||||
int *offset, int *width);
|
||||
|
||||
menu_animation_t *menu_animation_get_ptr(void);
|
||||
|
||||
void menu_animation_update_time(menu_animation_t *anim);
|
||||
|
Loading…
x
Reference in New Issue
Block a user