mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 18:50:29 +00:00
Rewrite menu_entry_get_rich_label
This commit is contained in:
parent
9c90f97792
commit
efde859e17
@ -997,15 +997,14 @@ static void mui_render_menu_list(
|
||||
for (i = 0; i < entries_end; i++)
|
||||
{
|
||||
menu_entry_t entry;
|
||||
char rich_label[255];
|
||||
char entry_value[255];
|
||||
char *rich_label = NULL;
|
||||
bool entry_selected = false;
|
||||
mui_node_t *node = (mui_node_t*)
|
||||
menu_entries_get_userdata_at_offset(list, i);
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
int y = header_height - mui->scroll_y + sum;
|
||||
rich_label[0] =
|
||||
entry_value[0] = '\0';
|
||||
entry_value[0] = '\0';
|
||||
|
||||
sum += node->line_height;
|
||||
|
||||
@ -1018,7 +1017,7 @@ static void mui_render_menu_list(
|
||||
menu_entry_init(&entry);
|
||||
menu_entry_get(&entry, 0, (unsigned)i, NULL, true);
|
||||
menu_entry_get_value(&entry, entry_value, sizeof(entry_value));
|
||||
menu_entry_get_rich_label(&entry, rich_label, sizeof(rich_label));
|
||||
rich_label = menu_entry_get_rich_label(&entry);
|
||||
|
||||
entry_selected = selection == i;
|
||||
|
||||
@ -1040,6 +1039,9 @@ static void mui_render_menu_list(
|
||||
sublabel_color
|
||||
);
|
||||
|
||||
if (rich_label && !string_is_empty(rich_label))
|
||||
free(rich_label);
|
||||
|
||||
menu_entry_free(&entry);
|
||||
}
|
||||
}
|
||||
|
@ -566,11 +566,11 @@ static void rgui_render(void *data, bool is_idle)
|
||||
{
|
||||
menu_entry_t entry;
|
||||
menu_animation_ctx_ticker_t ticker;
|
||||
char entry_path[255];
|
||||
char entry_value[255];
|
||||
char message[255];
|
||||
char entry_title_buf[255];
|
||||
char type_str_buf[255];
|
||||
char *entry_path = NULL;
|
||||
unsigned entry_spacing = 0;
|
||||
size_t entry_title_buf_utf8len = 0;
|
||||
size_t entry_title_buf_len = 0;
|
||||
@ -580,7 +580,6 @@ static void rgui_render(void *data, bool is_idle)
|
||||
if (i > (selection + 100))
|
||||
continue;
|
||||
|
||||
entry_path[0] = '\0';
|
||||
entry_value[0] = '\0';
|
||||
message[0] = '\0';
|
||||
entry_title_buf[0] = '\0';
|
||||
@ -591,7 +590,7 @@ static void rgui_render(void *data, bool is_idle)
|
||||
|
||||
entry_spacing = menu_entry_get_spacing(&entry);
|
||||
menu_entry_get_value(&entry, entry_value, sizeof(entry_value));
|
||||
menu_entry_get_rich_label(&entry, entry_path, sizeof(entry_path));
|
||||
entry_path = menu_entry_get_rich_label(&entry);
|
||||
|
||||
ticker.s = entry_title_buf;
|
||||
ticker.len = RGUI_TERM_WIDTH(fb_width) - (entry_spacing + 1 + 2);
|
||||
@ -623,6 +622,8 @@ static void rgui_render(void *data, bool is_idle)
|
||||
entry_selected ? hover_color : normal_color);
|
||||
|
||||
menu_entry_free(&entry);
|
||||
if (entry_path && !string_is_empty(entry_path))
|
||||
free(entry_path);
|
||||
}
|
||||
|
||||
if (menu_input_dialog_get_display_kb())
|
||||
@ -650,6 +651,7 @@ static void rgui_render(void *data, bool is_idle)
|
||||
if (settings->bools.menu_mouse_enable && cursor_visible)
|
||||
rgui_blit_cursor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void rgui_framebuffer_free(void)
|
||||
|
@ -2272,8 +2272,8 @@ static int xmb_draw_item(
|
||||
{
|
||||
float icon_x, icon_y, label_offset;
|
||||
menu_animation_ctx_ticker_t ticker;
|
||||
char ticker_str[PATH_MAX_LENGTH];
|
||||
char tmp[255];
|
||||
char *ticker_str = NULL;
|
||||
unsigned entry_type = 0;
|
||||
const float half_size = xmb->icon_size / 2.0f;
|
||||
uintptr_t texture_switch = 0;
|
||||
@ -2285,7 +2285,7 @@ static int xmb_draw_item(
|
||||
if (!node)
|
||||
goto iterate;
|
||||
|
||||
ticker_str[0] = tmp[0] = '\0';
|
||||
tmp[0] = '\0';
|
||||
|
||||
menu_entry_init(entry);
|
||||
|
||||
@ -2364,7 +2364,7 @@ static int xmb_draw_item(
|
||||
ticker_limit = 70;
|
||||
}
|
||||
|
||||
menu_entry_get_rich_label(entry, ticker_str, sizeof(ticker_str));
|
||||
ticker_str = menu_entry_get_rich_label(entry);
|
||||
|
||||
ticker.s = tmp;
|
||||
ticker.len = ticker_limit;
|
||||
@ -2483,9 +2483,13 @@ static int xmb_draw_item(
|
||||
xmb->shadow_offset);
|
||||
|
||||
iterate:
|
||||
if (ticker_str && !string_is_empty(ticker_str))
|
||||
free(ticker_str);
|
||||
return 0;
|
||||
|
||||
end:
|
||||
if (ticker_str && !string_is_empty(ticker_str))
|
||||
free(ticker_str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -514,15 +514,15 @@ static int zarch_zui_render_lay_root_recent(
|
||||
|
||||
for (i = zui->recent_dlist_first; i < size; ++i)
|
||||
{
|
||||
char rich_label[PATH_MAX_LENGTH];
|
||||
char entry_value[PATH_MAX_LENGTH];
|
||||
menu_entry_t entry;
|
||||
char *rich_label = NULL;
|
||||
|
||||
rich_label[0] = entry_value[0] = '\0';
|
||||
entry_value[0] = '\0';
|
||||
|
||||
menu_entry_init(&entry);
|
||||
menu_entry_get(&entry, 0, i, NULL, true);
|
||||
menu_entry_get_rich_label(&entry, rich_label, sizeof(rich_label));
|
||||
rich_label = menu_entry_get_rich_label(&entry);
|
||||
menu_entry_get_value(&entry, entry_value,sizeof(entry_value));
|
||||
|
||||
if (zarch_zui_list_item(
|
||||
@ -534,12 +534,16 @@ static int zarch_zui_render_lay_root_recent(
|
||||
if (menu_entry_action(&entry, i, MENU_ACTION_OK))
|
||||
{
|
||||
menu_entry_free(&entry);
|
||||
if (rich_label && !string_is_empty(rich_label))
|
||||
free(rich_label);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
j++;
|
||||
menu_entry_free(&entry);
|
||||
if (rich_label && !string_is_empty(rich_label))
|
||||
free(rich_label);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,14 +112,13 @@ void menu_entry_get_path(menu_entry_t *entry, char *s, size_t len)
|
||||
strlcpy(s, entry->path, len);
|
||||
}
|
||||
|
||||
void menu_entry_get_rich_label(menu_entry_t *entry, char *s, size_t len)
|
||||
char *menu_entry_get_rich_label(menu_entry_t *entry)
|
||||
{
|
||||
if (!entry)
|
||||
return;
|
||||
return NULL;
|
||||
if (!string_is_empty(entry->rich_label))
|
||||
strlcpy(s, entry->rich_label, len);
|
||||
else
|
||||
strlcpy(s, entry->path, len);
|
||||
return strdup(entry->rich_label);
|
||||
return strdup(entry->path);
|
||||
}
|
||||
|
||||
bool menu_entry_get_sublabel(menu_entry_t *entry, char *s, size_t len)
|
||||
|
@ -91,7 +91,7 @@ void menu_entry_pathdir_extensions(uint32_t i, char *s, size_t len);
|
||||
|
||||
void menu_entry_reset(uint32_t i);
|
||||
|
||||
void menu_entry_get_rich_label(menu_entry_t *entry, char *s, size_t len);
|
||||
char *menu_entry_get_rich_label(menu_entry_t *entry);
|
||||
|
||||
bool menu_entry_get_sublabel(menu_entry_t *entry, char *s, size_t len);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user