mirror of
https://github.com/libretro/RetroArch.git
synced 2025-04-02 10:51:52 -04:00
Replace more instances of string_split
This commit is contained in:
parent
fe5307c4ac
commit
662e37f670
11 changed files with 155 additions and 131 deletions
|
@ -3313,11 +3313,14 @@ static bool gl2_resolve_extensions(gl_t *gl, const char *context_ident, const vi
|
|||
if (ext)
|
||||
{
|
||||
size_t i;
|
||||
struct string_list *list = string_split(ext, " ");
|
||||
struct string_list list = {0};
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
RARCH_LOG("\t%s\n", list->elems[i].data);
|
||||
string_list_free(list);
|
||||
string_list_initialize(&list);
|
||||
string_split_noalloc(&list, ext, " ");
|
||||
|
||||
for (i = 0; i < list.size; i++)
|
||||
RARCH_LOG("\t%s\n", list.elems[i].data);
|
||||
string_list_deinitialize(&list);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -101,7 +101,7 @@ static void gdi_render_msg(
|
|||
unsigned width = gdi->video_width;
|
||||
unsigned height = gdi->video_height;
|
||||
SIZE textSize = {0};
|
||||
struct string_list *msg_list = NULL;
|
||||
struct string_list msg_list = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_msg_pos_x = settings->floats.video_msg_pos_x;
|
||||
float video_msg_pos_y = settings->floats.video_msg_pos_y;
|
||||
|
@ -173,7 +173,8 @@ static void gdi_render_msg(
|
|||
|
||||
SetBkMode(font->gdi->memDC, TRANSPARENT);
|
||||
|
||||
msg_list = string_split(msg, "\n");
|
||||
string_list_initialize(&msg_list);
|
||||
string_split_noalloc(&msg_list, msg, "\n");
|
||||
|
||||
if (drop_x || drop_y)
|
||||
{
|
||||
|
@ -184,22 +185,20 @@ static void gdi_render_msg(
|
|||
|
||||
SetTextColor(font->gdi->memDC, RGB(drop_red, drop_green, drop_blue));
|
||||
|
||||
if (msg_list)
|
||||
{
|
||||
for (i = 0; i < msg_list->size; i++)
|
||||
TextOut(font->gdi->memDC, newDropX, newDropY + (textSize.cy * i), msg_list->elems[i].data, utf8len(msg_list->elems[i].data));
|
||||
}
|
||||
for (i = 0; i < msg_list.size; i++)
|
||||
TextOut(font->gdi->memDC, newDropX, newDropY + (textSize.cy * i),
|
||||
msg_list.elems[i].data,
|
||||
utf8len(msg_list.elems[i].data));
|
||||
}
|
||||
|
||||
SetTextColor(font->gdi->memDC, RGB(red, green, blue));
|
||||
|
||||
if (msg_list)
|
||||
{
|
||||
for (i = 0; i < msg_list->size; i++)
|
||||
TextOut(font->gdi->memDC, newX, newY + (textSize.cy * i), msg_list->elems[i].data, utf8len(msg_list->elems[i].data));
|
||||
for (i = 0; i < msg_list.size; i++)
|
||||
TextOut(font->gdi->memDC, newX, newY + (textSize.cy * i),
|
||||
msg_list.elems[i].data,
|
||||
utf8len(msg_list.elems[i].data));
|
||||
|
||||
string_list_free(msg_list);
|
||||
}
|
||||
string_list_deinitialize(&msg_list);
|
||||
|
||||
SelectObject(font->gdi->memDC, font->gdi->bmp_old);
|
||||
}
|
||||
|
|
|
@ -1395,11 +1395,13 @@ struct string_list* cdrom_get_available_drives(void)
|
|||
if (filestream_read_file("/proc/modules", (void**)&buf, &len))
|
||||
{
|
||||
#ifdef CDROM_DEBUG
|
||||
bool found = false;
|
||||
bool found = false;
|
||||
#endif
|
||||
struct string_list *mods = string_split(buf, "\n");
|
||||
struct string_list mods = {0};
|
||||
|
||||
if (mods)
|
||||
string_list_initialize(&mods);
|
||||
|
||||
if (string_split_noalloc(&mods, buf, "\n"))
|
||||
{
|
||||
for (i = 0; i < mods->size; i++)
|
||||
{
|
||||
|
@ -1411,9 +1413,8 @@ struct string_list* cdrom_get_available_drives(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string_list_free(mods);
|
||||
}
|
||||
string_list_deinitialize(&mods);
|
||||
|
||||
#ifdef CDROM_DEBUG
|
||||
if (found)
|
||||
|
|
|
@ -58,37 +58,34 @@ static int file_archive_get_file_list_cb(
|
|||
size_t path_len = strlen(path);
|
||||
/* Checks if this entry is a directory or a file. */
|
||||
char last_char = path[path_len - 1];
|
||||
struct string_list *ext_list = NULL;
|
||||
struct string_list ext_list = {0};
|
||||
|
||||
/* Skip if directory. */
|
||||
if (last_char == '/' || last_char == '\\' )
|
||||
{
|
||||
string_list_free(ext_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ext_list = string_split(valid_exts, "|");
|
||||
|
||||
if (ext_list)
|
||||
string_list_initialize(&ext_list);
|
||||
if (string_split_noalloc(&ext_list, valid_exts, "|"))
|
||||
{
|
||||
const char *file_ext = path_get_extension(path);
|
||||
|
||||
if (!file_ext)
|
||||
{
|
||||
string_list_free(ext_list);
|
||||
string_list_deinitialize(&ext_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!string_list_find_elem_prefix(ext_list, ".", file_ext))
|
||||
if (!string_list_find_elem_prefix(&ext_list, ".", file_ext))
|
||||
{
|
||||
/* keep iterating */
|
||||
string_list_free(ext_list);
|
||||
string_list_deinitialize(&ext_list);
|
||||
return -1;
|
||||
}
|
||||
|
||||
attr.i = RARCH_COMPRESSED_FILE_IN_ARCHIVE;
|
||||
string_list_free(ext_list);
|
||||
}
|
||||
|
||||
string_list_deinitialize(&ext_list);
|
||||
}
|
||||
|
||||
return string_list_append(userdata->list, path, attr);
|
||||
|
|
|
@ -76,12 +76,14 @@ int config_userdata_get_float_array(void *userdata, const char *key_str,
|
|||
config_get_string(usr->conf, key[1], &str))
|
||||
{
|
||||
unsigned i;
|
||||
struct string_list *list = string_split(str, " ");
|
||||
*values = (float*)calloc(list->size, sizeof(float));
|
||||
for (i = 0; i < list->size; i++)
|
||||
(*values)[i] = (float)strtod(list->elems[i].data, NULL);
|
||||
*out_num_values = (unsigned)list->size;
|
||||
string_list_free(list);
|
||||
struct string_list list = {0};
|
||||
string_list_initialize(&list);
|
||||
string_split_noalloc(&list, str, " ");
|
||||
*values = (float*)calloc(list.size, sizeof(float));
|
||||
for (i = 0; i < list.size; i++)
|
||||
(*values)[i] = (float)strtod(list.elems[i].data, NULL);
|
||||
*out_num_values = (unsigned)list.size;
|
||||
string_list_deinitialize(&list);
|
||||
free(str);
|
||||
return true;
|
||||
}
|
||||
|
@ -106,12 +108,14 @@ int config_userdata_get_int_array(void *userdata, const char *key_str,
|
|||
config_get_string(usr->conf, key[1], &str))
|
||||
{
|
||||
unsigned i;
|
||||
struct string_list *list = string_split(str, " ");
|
||||
*values = (int*)calloc(list->size, sizeof(int));
|
||||
for (i = 0; i < list->size; i++)
|
||||
(*values)[i] = (int)strtod(list->elems[i].data, NULL);
|
||||
*out_num_values = (unsigned)list->size;
|
||||
string_list_free(list);
|
||||
struct string_list list = {0};
|
||||
string_list_initialize(&list);
|
||||
string_split_noalloc(&list, str, " ");
|
||||
*values = (int*)calloc(list.size, sizeof(int));
|
||||
for (i = 0; i < list.size; i++)
|
||||
(*values)[i] = (int)strtod(list.elems[i].data, NULL);
|
||||
*out_num_values = (unsigned)list.size;
|
||||
string_list_deinitialize(&list);
|
||||
free(str);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -214,12 +214,19 @@ bool dir_list_append(struct string_list *list,
|
|||
bool include_hidden, bool include_compressed,
|
||||
bool recursive)
|
||||
{
|
||||
struct string_list *ext_list = ext ? string_split(ext, "|") : NULL;
|
||||
bool ret = dir_list_read(dir, list, ext_list,
|
||||
bool ret = false;
|
||||
struct string_list ext_list = {0};
|
||||
struct string_list *ext_list_ptr = NULL;
|
||||
|
||||
if (ext)
|
||||
{
|
||||
string_list_initialize(&ext_list);
|
||||
string_split_noalloc(&ext_list, ext, "|");
|
||||
ext_list_ptr = &ext_list;
|
||||
}
|
||||
ret = dir_list_read(dir, list, ext_list_ptr,
|
||||
include_dirs, include_hidden, include_compressed, recursive) != -1;
|
||||
|
||||
string_list_free(ext_list);
|
||||
|
||||
string_list_deinitialize(&ext_list);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -2504,7 +2504,7 @@ static void materialui_render_messagebox(materialui_handle_t *mui,
|
|||
int y = 0;
|
||||
int usable_width = 0;
|
||||
int longest_width = 0;
|
||||
struct string_list *list = NULL;
|
||||
struct string_list list = {0};
|
||||
char wrapped_message[MENU_SUBLABEL_MAX_LENGTH];
|
||||
|
||||
wrapped_message[0] = '\0';
|
||||
|
@ -2513,12 +2513,12 @@ static void materialui_render_messagebox(materialui_handle_t *mui,
|
|||
if (string_is_empty(message) ||
|
||||
!mui ||
|
||||
!mui->font_data.list.font)
|
||||
goto end;
|
||||
return;
|
||||
|
||||
usable_width = (int)video_width - (mui->margin * 4.0);
|
||||
|
||||
if (usable_width < 1)
|
||||
goto end;
|
||||
return;
|
||||
|
||||
/* Split message into lines */
|
||||
word_wrap(
|
||||
|
@ -2526,22 +2526,26 @@ static void materialui_render_messagebox(materialui_handle_t *mui,
|
|||
usable_width / (int)mui->font_data.list.glyph_width,
|
||||
true, 0);
|
||||
|
||||
list = string_split(wrapped_message, "\n");
|
||||
|
||||
if (!list || list->elems == 0)
|
||||
goto end;
|
||||
string_list_initialize(&list);
|
||||
if (
|
||||
!string_split_noalloc(&list, wrapped_message, "\n")
|
||||
|| list.elems == 0)
|
||||
{
|
||||
string_list_deinitialize(&list);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get coordinates of message box centre */
|
||||
x = video_width / 2;
|
||||
y = (int)(y_centre - (list->size * mui->font_data.list.line_height) / 2);
|
||||
y = (int)(y_centre - (list.size * mui->font_data.list.line_height) / 2);
|
||||
|
||||
/* TODO/FIXME: Reduce text scale if width or height
|
||||
* are too large to fit on screen */
|
||||
|
||||
/* Find the longest line width */
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *line = list->elems[i].data;
|
||||
const char *line = list.elems[i].data;
|
||||
|
||||
if (!string_is_empty(line))
|
||||
{
|
||||
|
@ -2564,15 +2568,15 @@ static void materialui_render_messagebox(materialui_handle_t *mui,
|
|||
x - longest_width / 2.0 - mui->margin * 2.0,
|
||||
y - mui->margin * 2.0,
|
||||
longest_width + mui->margin * 4.0,
|
||||
mui->font_data.list.line_height * list->size + mui->margin * 4.0,
|
||||
mui->font_data.list.line_height * list.size + mui->margin * 4.0,
|
||||
video_width,
|
||||
video_height,
|
||||
mui->colors.surface_background);
|
||||
|
||||
/* Print each line of the message */
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *line = list->elems[i].data;
|
||||
const char *line = list.elems[i].data;
|
||||
|
||||
if (!string_is_empty(line))
|
||||
gfx_display_draw_text(
|
||||
|
@ -2583,9 +2587,7 @@ static void materialui_render_messagebox(materialui_handle_t *mui,
|
|||
TEXT_ALIGN_LEFT, 1.0f, false, 0.0f, true);
|
||||
}
|
||||
|
||||
end:
|
||||
if (list)
|
||||
string_list_free(list);
|
||||
string_list_deinitialize(&list);
|
||||
}
|
||||
|
||||
/* Initialises scrollbar parameters (width/height) */
|
||||
|
|
|
@ -367,7 +367,7 @@ void ozone_draw_osk(ozone_handle_t *ozone,
|
|||
char message[2048];
|
||||
unsigned text_color;
|
||||
static retro_time_t last_time = 0;
|
||||
struct string_list *list = NULL;
|
||||
struct string_list list = {0};
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
unsigned margin = 75 * scale_factor;
|
||||
unsigned padding = 10 * scale_factor;
|
||||
|
@ -463,11 +463,12 @@ void ozone_draw_osk(ozone_handle_t *ozone,
|
|||
|
||||
word_wrap(message, text, (video_width - margin*2 - padding*2) / ozone->fonts.entries_label.glyph_width, true, 0);
|
||||
|
||||
list = string_split(message, "\n");
|
||||
string_list_initialize(&list);
|
||||
string_split_noalloc(&list, message, "\n");
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
const char *msg = list.elems[i].data;
|
||||
|
||||
ozone_draw_text(ozone, msg,
|
||||
margin + padding * 2,
|
||||
|
@ -475,7 +476,7 @@ void ozone_draw_osk(ozone_handle_t *ozone,
|
|||
TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.entries_label, text_color, false);
|
||||
|
||||
/* Cursor */
|
||||
if (i == list->size - 1)
|
||||
if (i == list.size - 1)
|
||||
{
|
||||
if (ozone->osk_cursor)
|
||||
{
|
||||
|
@ -520,7 +521,7 @@ void ozone_draw_osk(ozone_handle_t *ozone,
|
|||
input_event_get_osk_ptr(),
|
||||
ozone->theme->text_rgba);
|
||||
|
||||
string_list_free(list);
|
||||
string_list_deinitialize(&list);
|
||||
}
|
||||
|
||||
void ozone_draw_messagebox(
|
||||
|
@ -534,7 +535,7 @@ void ozone_draw_messagebox(
|
|||
char wrapped_message[MENU_SUBLABEL_MAX_LENGTH];
|
||||
int x, y, longest_width = 0;
|
||||
int usable_width = 0;
|
||||
struct string_list *list = NULL;
|
||||
struct string_list list = {0};
|
||||
float scale_factor = 0.0f;
|
||||
unsigned width = video_width;
|
||||
unsigned height = video_height;
|
||||
|
@ -551,7 +552,7 @@ void ozone_draw_messagebox(
|
|||
usable_width = (int)width - (48 * 8 * scale_factor);
|
||||
|
||||
if (usable_width < 1)
|
||||
goto end;
|
||||
return;
|
||||
|
||||
/* Split message into lines */
|
||||
word_wrap(
|
||||
|
@ -559,22 +560,27 @@ void ozone_draw_messagebox(
|
|||
usable_width / (int)ozone->fonts.footer.glyph_width,
|
||||
true, 0);
|
||||
|
||||
list = string_split(wrapped_message, "\n");
|
||||
|
||||
if (!list || list->elems == 0)
|
||||
goto end;
|
||||
string_list_initialize(&list);
|
||||
if (
|
||||
!string_split_noalloc(&list, wrapped_message, "\n")
|
||||
|| list.elems == 0)
|
||||
{
|
||||
string_list_deinitialize(&list);
|
||||
return;
|
||||
}
|
||||
|
||||
y_position = height / 2;
|
||||
if (menu_input_dialog_get_display_kb())
|
||||
y_position = height / 4;
|
||||
|
||||
x = width / 2;
|
||||
y = y_position - (list->size * ozone->fonts.footer.line_height) / 2;
|
||||
y = y_position - (list.size
|
||||
* ozone->fonts.footer.line_height) / 2;
|
||||
|
||||
/* find the longest line width */
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
const char *msg = list.elems[i].data;
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
{
|
||||
|
@ -599,10 +605,12 @@ void ozone_draw_messagebox(
|
|||
* is quite 'loose', and depends upon source image
|
||||
* size, draw size and scale factor... */
|
||||
unsigned slice_new_w = longest_width + 48 * 2 * scale_factor;
|
||||
unsigned slice_new_h = ozone->fonts.footer.line_height * (list->size + 2);
|
||||
unsigned slice_new_h = ozone->fonts.footer.line_height * (list.size + 2);
|
||||
int slice_x = x - longest_width/2 - 48 * scale_factor;
|
||||
int slice_y = y - ozone->fonts.footer.line_height +
|
||||
((slice_new_h >= 256) ? (16.0f * scale_factor) : (16.0f * ((float)slice_new_h / 256.0f)));
|
||||
((slice_new_h >= 256)
|
||||
? (16.0f * scale_factor)
|
||||
: (16.0f * ((float)slice_new_h / 256.0f)));
|
||||
|
||||
gfx_display_draw_texture_slice(
|
||||
userdata,
|
||||
|
@ -620,9 +628,9 @@ void ozone_draw_messagebox(
|
|||
);
|
||||
}
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
const char *msg = list.elems[i].data;
|
||||
|
||||
if (msg)
|
||||
ozone_draw_text(ozone,
|
||||
|
@ -637,9 +645,7 @@ void ozone_draw_messagebox(
|
|||
);
|
||||
}
|
||||
|
||||
end:
|
||||
if (list)
|
||||
string_list_free(list);
|
||||
string_list_deinitialize(&list);
|
||||
}
|
||||
|
||||
void ozone_draw_fullscreen_thumbnails(
|
||||
|
|
|
@ -2890,7 +2890,7 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message)
|
|||
unsigned width = 0;
|
||||
unsigned glyphs_width = 0;
|
||||
unsigned height = 0;
|
||||
struct string_list *list = NULL;
|
||||
struct string_list list = {0};
|
||||
char wrapped_message[MENU_SUBLABEL_MAX_LENGTH];
|
||||
|
||||
wrapped_message[0] = '\0';
|
||||
|
@ -2904,18 +2904,21 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message)
|
|||
rgui_term_layout.width,
|
||||
false, 0);
|
||||
|
||||
list = string_split(wrapped_message, "\n");
|
||||
|
||||
if (!list || list->elems == 0)
|
||||
goto end;
|
||||
string_list_initialize(&list);
|
||||
if ( !string_split_noalloc(&list, wrapped_message, "\n")
|
||||
|| list.elems == 0)
|
||||
{
|
||||
string_list_deinitialize(&list);
|
||||
return;
|
||||
}
|
||||
|
||||
gfx_display_get_fb_size(&fb_width, &fb_height,
|
||||
&fb_pitch);
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
unsigned line_width;
|
||||
char *msg = list->elems[i].data;
|
||||
char *msg = list.elems[i].data;
|
||||
unsigned msglen = (unsigned)utf8len(msg);
|
||||
|
||||
line_width = msglen * FONT_WIDTH_STRIDE - 1 + 6 + 10;
|
||||
|
@ -2923,7 +2926,7 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message)
|
|||
glyphs_width = MAX(glyphs_width, msglen);
|
||||
}
|
||||
|
||||
height = (unsigned)(FONT_HEIGHT_STRIDE * list->size + 6 + 10);
|
||||
height = (unsigned)(FONT_HEIGHT_STRIDE * list.size + 6 + 10);
|
||||
x = ((int)fb_width - (int)width) / 2;
|
||||
y = ((int)fb_height - (int)height) / 2;
|
||||
|
||||
|
@ -2973,14 +2976,11 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message)
|
|||
rgui_fill_rect(rgui_frame_buf.data, fb_width, fb_height,
|
||||
x, y + 5, 5, height - 5,
|
||||
border_dark_color, border_light_color, border_thickness);
|
||||
}
|
||||
|
||||
/* Draw text */
|
||||
if (rgui_frame_buf.data)
|
||||
{
|
||||
for (i = 0; i < list->size; i++)
|
||||
/* Draw text */
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
const char *msg = list.elems[i].data;
|
||||
int offset_x = (int)(FONT_WIDTH_STRIDE * (glyphs_width - utf8len(msg)) / 2);
|
||||
int offset_y = (int)(FONT_HEIGHT_STRIDE * i);
|
||||
int text_x = x + 8 + offset_x;
|
||||
|
@ -2996,9 +2996,7 @@ static void rgui_render_messagebox(rgui_t *rgui, const char *message)
|
|||
}
|
||||
}
|
||||
|
||||
end:
|
||||
if (list)
|
||||
string_list_free(list);
|
||||
string_list_deinitialize(&list);
|
||||
}
|
||||
|
||||
static void rgui_blit_cursor(rgui_t *rgui)
|
||||
|
@ -5119,13 +5117,16 @@ static void rgui_update_menu_sublabel(rgui_t *rgui)
|
|||
/* Sanitise sublabel
|
||||
* > Replace newline characters with standard delimiter
|
||||
* > Remove whitespace surrounding each sublabel line */
|
||||
struct string_list *list = string_split(entry.sublabel, "\n");
|
||||
|
||||
if (list)
|
||||
struct string_list list = {0};
|
||||
|
||||
string_list_initialize(&list);
|
||||
|
||||
if (string_split_noalloc(&list, entry.sublabel, "\n"))
|
||||
{
|
||||
for (line_index = 0; line_index < list->size; line_index++)
|
||||
for (line_index = 0; line_index < list.size; line_index++)
|
||||
{
|
||||
const char *line = string_trim_whitespace(list->elems[line_index].data);
|
||||
const char *line = string_trim_whitespace(
|
||||
list.elems[line_index].data);
|
||||
if (!string_is_empty(line))
|
||||
{
|
||||
if (!prev_line_empty)
|
||||
|
@ -5136,9 +5137,9 @@ static void rgui_update_menu_sublabel(rgui_t *rgui)
|
|||
prev_line_empty = false;
|
||||
}
|
||||
}
|
||||
|
||||
string_list_free(list);
|
||||
}
|
||||
|
||||
string_list_deinitialize(&list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -938,24 +938,24 @@ static void xmb_render_messagebox_internal(
|
|||
xmb_handle_t *xmb, const char *message)
|
||||
{
|
||||
unsigned i, y_position;
|
||||
int x, y, longest_width = 0;
|
||||
char wrapped_message[MENU_SUBLABEL_MAX_LENGTH];
|
||||
int x, y, longest_width = 0;
|
||||
float line_height = 0;
|
||||
int usable_width = 0;
|
||||
struct string_list *list = NULL;
|
||||
char wrapped_message[MENU_SUBLABEL_MAX_LENGTH];
|
||||
struct string_list list = {0};
|
||||
|
||||
wrapped_message[0] = '\0';
|
||||
wrapped_message[0] = '\0';
|
||||
|
||||
/* Sanity check */
|
||||
if (string_is_empty(message) ||
|
||||
!xmb ||
|
||||
!xmb->font)
|
||||
goto end;
|
||||
return;
|
||||
|
||||
usable_width = (int)video_width - (xmb->margins_dialog * 8);
|
||||
|
||||
if (usable_width < 1)
|
||||
goto end;
|
||||
return;
|
||||
|
||||
/* Split message into lines */
|
||||
word_wrap(
|
||||
|
@ -963,10 +963,16 @@ static void xmb_render_messagebox_internal(
|
|||
usable_width / (xmb->font_size * 0.6f),
|
||||
true, 0);
|
||||
|
||||
list = string_split(wrapped_message, "\n");
|
||||
string_list_initialize(&list);
|
||||
|
||||
if (!list || list->elems == 0)
|
||||
goto end;
|
||||
if (
|
||||
!string_split_noalloc(&list, wrapped_message, "\n")
|
||||
|| list.elems == 0
|
||||
)
|
||||
{
|
||||
string_list_deinitialize(&list);
|
||||
return;
|
||||
}
|
||||
|
||||
line_height = xmb->font->size * 1.2;
|
||||
|
||||
|
@ -975,12 +981,12 @@ static void xmb_render_messagebox_internal(
|
|||
y_position = video_height / 4;
|
||||
|
||||
x = video_width / 2;
|
||||
y = y_position - (list->size-1) * line_height / 2;
|
||||
y = y_position - (list.size-1) * line_height / 2;
|
||||
|
||||
/* find the longest line width */
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
const char *msg = list.elems[i].data;
|
||||
|
||||
if (!string_is_empty(msg))
|
||||
{
|
||||
|
@ -1002,15 +1008,15 @@ static void xmb_render_messagebox_internal(
|
|||
y + xmb->margins_slice - xmb->margins_dialog,
|
||||
256, 256,
|
||||
longest_width + xmb->margins_dialog * 2,
|
||||
line_height * list->size + xmb->margins_dialog * 2,
|
||||
line_height * list.size + xmb->margins_dialog * 2,
|
||||
video_width, video_height,
|
||||
NULL,
|
||||
xmb->margins_slice, xmb->last_scale_factor,
|
||||
xmb->textures.list[XMB_TEXTURE_DIALOG_SLICE]);
|
||||
|
||||
for (i = 0; i < list->size; i++)
|
||||
for (i = 0; i < list.size; i++)
|
||||
{
|
||||
const char *msg = list->elems[i].data;
|
||||
const char *msg = list.elems[i].data;
|
||||
|
||||
if (msg)
|
||||
gfx_display_draw_text(xmb->font, msg,
|
||||
|
@ -1031,9 +1037,7 @@ static void xmb_render_messagebox_internal(
|
|||
input_event_get_osk_ptr(),
|
||||
0xffffffff);
|
||||
|
||||
end:
|
||||
if (list)
|
||||
string_list_free(list);
|
||||
string_list_deinitialize(&list);
|
||||
}
|
||||
|
||||
static void xmb_update_savestate_thumbnail_path(void *data, unsigned i)
|
||||
|
|
|
@ -798,7 +798,7 @@ extern "C" {
|
|||
string_list_initialize(&split);
|
||||
string_split_noalloc(&split, lang_bcp, "-");
|
||||
|
||||
strlcat(lang_iso, split.elems[0].data, sizeof(lang_iso));
|
||||
strlcpy(lang_iso, split.elems[0].data, sizeof(lang_iso));
|
||||
|
||||
if (split.size >= 2)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue