mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 13:14:04 +00:00
commit
fcbfaec281
@ -373,14 +373,15 @@ static void mui_get_message(void *data, const char *message)
|
||||
strlcpy(mui->box_message, message, sizeof(mui->box_message));
|
||||
}
|
||||
|
||||
static void mui_render_messagebox(const char *message)
|
||||
static void mui_render_messagebox(mui_handle_t *mui,
|
||||
const char *message, float *body_bg_color, uint32_t font_normal_color)
|
||||
{
|
||||
unsigned i, width, height;
|
||||
uint32_t font_normal_color;
|
||||
int x, y, font_size;
|
||||
int x, y, font_size, longest = 0, longest_width = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct string_list *list = (struct string_list*)
|
||||
string_split(message, "\n");
|
||||
void *fb_buf;
|
||||
|
||||
if (!list)
|
||||
return;
|
||||
@ -392,17 +393,39 @@ static void mui_render_messagebox(const char *message)
|
||||
font_size = menu_display_get_font_size();
|
||||
|
||||
x = width / 2;
|
||||
y = height / 2 - list->size * font_size / 2;
|
||||
y = height / 2 - (list->size-1) * font_size / 2;
|
||||
|
||||
font_normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color);
|
||||
fb_buf = menu_display_get_font_buffer();
|
||||
|
||||
/* find the longest line width */
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
int len = strlen(msg);
|
||||
if (len > longest)
|
||||
{
|
||||
longest = len;
|
||||
longest_width = font_driver_get_message_width(fb_buf, msg, len, 1);
|
||||
}
|
||||
}
|
||||
|
||||
mui_render_quad(mui,
|
||||
x - longest_width/2.0 - mui->margin,
|
||||
y - font_size/2.0 - mui->margin,
|
||||
longest_width + mui->margin*2.0,
|
||||
font_size * list->size + mui->margin*2.0,
|
||||
width,
|
||||
height,
|
||||
&body_bg_color[0]);
|
||||
|
||||
/* print each line */
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
if (msg)
|
||||
mui_draw_text(x, y + i * font_size,
|
||||
mui_draw_text(x - longest_width/2.0, y + i * font_size,
|
||||
width, height,
|
||||
msg, font_normal_color, TEXT_ALIGN_CENTER);
|
||||
msg, font_normal_color, TEXT_ALIGN_LEFT);
|
||||
}
|
||||
|
||||
end:
|
||||
@ -1183,13 +1206,13 @@ static void mui_frame(void *data)
|
||||
str = "";
|
||||
mui_render_quad(mui, 0, 0, width, height, width, height, &black_bg[0]);
|
||||
snprintf(msg, sizeof(msg), "%s\n%s", label, str);
|
||||
mui_render_messagebox(msg);
|
||||
mui_render_messagebox(mui, msg, &body_bg_color[0], font_normal_color);
|
||||
}
|
||||
|
||||
if (!string_is_empty(mui->box_message))
|
||||
{
|
||||
mui_render_quad(mui, 0, 0, width, height, width, height, &black_bg[0]);
|
||||
mui_render_messagebox(mui->box_message);
|
||||
mui_render_messagebox(mui, mui->box_message, &body_bg_color[0], font_normal_color);
|
||||
mui->box_message[0] = '\0';
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user