mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
Cleanups - menu_entries_get_title returns results of strlcpy
This commit is contained in:
parent
de8f979cb7
commit
67b0147a59
@ -183,8 +183,6 @@ typedef struct gfx_display_ctx_datetime
|
|||||||
|
|
||||||
typedef struct gfx_display_ctx_powerstate
|
typedef struct gfx_display_ctx_powerstate
|
||||||
{
|
{
|
||||||
char *s;
|
|
||||||
size_t len;
|
|
||||||
unsigned percent;
|
unsigned percent;
|
||||||
bool battery_enabled;
|
bool battery_enabled;
|
||||||
bool charging;
|
bool charging;
|
||||||
|
@ -5763,13 +5763,8 @@ static void materialui_render_header(
|
|||||||
{
|
{
|
||||||
gfx_display_ctx_powerstate_t powerstate;
|
gfx_display_ctx_powerstate_t powerstate;
|
||||||
char percent_str[MUI_BATTERY_PERCENT_MAX_LENGTH];
|
char percent_str[MUI_BATTERY_PERCENT_MAX_LENGTH];
|
||||||
|
|
||||||
percent_str[0] = '\0';
|
percent_str[0] = '\0';
|
||||||
|
menu_display_powerstate(&powerstate, percent_str, sizeof(percent_str));
|
||||||
powerstate.s = percent_str;
|
|
||||||
powerstate.len = sizeof(percent_str);
|
|
||||||
|
|
||||||
menu_display_powerstate(&powerstate);
|
|
||||||
|
|
||||||
if (powerstate.battery_enabled)
|
if (powerstate.battery_enabled)
|
||||||
{
|
{
|
||||||
|
@ -10512,11 +10512,7 @@ static void ozone_draw_header(
|
|||||||
char msg[12];
|
char msg[12];
|
||||||
|
|
||||||
msg[0] = '\0';
|
msg[0] = '\0';
|
||||||
|
menu_display_powerstate(&powerstate, msg, sizeof(msg));
|
||||||
powerstate.s = msg;
|
|
||||||
powerstate.len = sizeof(msg);
|
|
||||||
|
|
||||||
menu_display_powerstate(&powerstate);
|
|
||||||
|
|
||||||
if (powerstate.battery_enabled)
|
if (powerstate.battery_enabled)
|
||||||
{
|
{
|
||||||
|
@ -5332,10 +5332,7 @@ static void rgui_render(
|
|||||||
|
|
||||||
percent_str[0] = '\0';
|
percent_str[0] = '\0';
|
||||||
|
|
||||||
powerstate.s = percent_str;
|
menu_display_powerstate(&powerstate, percent_str, sizeof(percent_str));
|
||||||
powerstate.len = sizeof(percent_str);
|
|
||||||
|
|
||||||
menu_display_powerstate(&powerstate);
|
|
||||||
|
|
||||||
if (powerstate.battery_enabled)
|
if (powerstate.battery_enabled)
|
||||||
{
|
{
|
||||||
|
@ -6896,13 +6896,9 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
|||||||
{
|
{
|
||||||
gfx_display_ctx_powerstate_t powerstate;
|
gfx_display_ctx_powerstate_t powerstate;
|
||||||
char msg[12];
|
char msg[12];
|
||||||
|
|
||||||
msg[0] = '\0';
|
msg[0] = '\0';
|
||||||
|
|
||||||
powerstate.s = msg;
|
menu_display_powerstate(&powerstate, msg, sizeof(msg));
|
||||||
powerstate.len = sizeof(msg);
|
|
||||||
|
|
||||||
menu_display_powerstate(&powerstate);
|
|
||||||
|
|
||||||
if (powerstate.battery_enabled)
|
if (powerstate.battery_enabled)
|
||||||
{
|
{
|
||||||
|
@ -1014,7 +1014,7 @@ size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, char *s, size
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Display current (battery) power state */
|
/* Display current (battery) power state */
|
||||||
void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate)
|
size_t menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate, char *s, size_t len)
|
||||||
{
|
{
|
||||||
int percent = 0;
|
int percent = 0;
|
||||||
struct menu_state *menu_st = &menu_driver_state;
|
struct menu_state *menu_st = &menu_driver_state;
|
||||||
@ -1043,64 +1043,55 @@ void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate)
|
|||||||
powerstate->charging = true;
|
powerstate->charging = true;
|
||||||
if (percent > 0)
|
if (percent > 0)
|
||||||
powerstate->percent = (unsigned)percent;
|
powerstate->percent = (unsigned)percent;
|
||||||
snprintf(powerstate->s, powerstate->len, "%u%%", powerstate->percent);
|
return snprintf(s, len, "%u%%", powerstate->percent);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Sets title to what the name of the current menu should be. */
|
/* Sets title to what the name of the current menu should be. */
|
||||||
int menu_entries_get_title(char *s, size_t len)
|
size_t menu_entries_get_title(char *s, size_t len)
|
||||||
{
|
{
|
||||||
unsigned menu_type = 0;
|
struct menu_state *menu_st = &menu_driver_state;
|
||||||
const char *path = NULL;
|
menu_handle_t *menu = menu_st->driver_data;
|
||||||
const char *label = NULL;
|
const file_list_t *list = menu_st->entries.list
|
||||||
struct menu_state *menu_st = &menu_driver_state;
|
? MENU_LIST_GET(menu_st->entries.list, 0)
|
||||||
menu_handle_t *menu = menu_st->driver_data;
|
: NULL;
|
||||||
const file_list_t *list = menu_st->entries.list ?
|
menu_file_list_cbs_t *cbs = list
|
||||||
MENU_LIST_GET(menu_st->entries.list, 0) : NULL;
|
|
||||||
menu_file_list_cbs_t *cbs = list
|
|
||||||
? (menu_file_list_cbs_t*)list->list[list->size - 1].actiondata
|
? (menu_file_list_cbs_t*)list->list[list->size - 1].actiondata
|
||||||
: NULL;
|
: NULL;
|
||||||
|
if (cbs && cbs->action_get_title)
|
||||||
if (!cbs)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (cbs->action_get_title)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
const char *label = (list->size) ? list->list[list->size - 1].label : NULL;
|
||||||
if (!string_is_empty(cbs->action_title_cache))
|
if (!string_is_empty(cbs->action_title_cache))
|
||||||
{
|
return strlcpy(s, cbs->action_title_cache, len);
|
||||||
strlcpy(s, cbs->action_title_cache, len);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list->size)
|
|
||||||
{
|
|
||||||
path = list->list[list->size - 1].path;
|
|
||||||
label = list->list[list->size - 1].label;
|
|
||||||
menu_type = list->list[list->size - 1].type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Show playlist entry instead of "Quick Menu" */
|
/* Show playlist entry instead of "Quick Menu" */
|
||||||
if (string_is_equal(label, "deferred_rpl_entry_actions"))
|
if (string_is_equal(label, "deferred_rpl_entry_actions"))
|
||||||
{
|
{
|
||||||
playlist_t *playlist = playlist_get_cached();
|
playlist_t *playlist = playlist_get_cached();
|
||||||
if (playlist)
|
if (playlist)
|
||||||
{
|
{
|
||||||
const struct playlist_entry *entry = NULL;
|
const struct playlist_entry *entry = NULL;
|
||||||
playlist_get_index(playlist, menu->rpl_entry_selection_ptr, &entry);
|
playlist_get_index(playlist, menu->rpl_entry_selection_ptr, &entry);
|
||||||
if (entry)
|
if (entry)
|
||||||
strlcpy(s,
|
return strlcpy(s,
|
||||||
!string_is_empty(entry->label) ? entry->label : entry->path,
|
!string_is_empty(entry->label) ? entry->label : entry->path,
|
||||||
len);
|
len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = cbs->action_get_title(path, label, menu_type, s, len);
|
{
|
||||||
|
const char *path = NULL;
|
||||||
if (ret == 1)
|
unsigned menu_type = 0;
|
||||||
strlcpy(cbs->action_title_cache, s, sizeof(cbs->action_title_cache));
|
if (list->size)
|
||||||
return ret;
|
{
|
||||||
|
path = list->list[list->size - 1].path;
|
||||||
|
menu_type = list->list[list->size - 1].type;
|
||||||
|
}
|
||||||
|
if (cbs->action_get_title(path, label, menu_type, s, len) == 1)
|
||||||
|
return strlcpy(cbs->action_title_cache, s, sizeof(cbs->action_title_cache));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -7740,14 +7731,11 @@ int generic_menu_entry_action(
|
|||||||
access_st->enabled)
|
access_st->enabled)
|
||||||
&& !menu_input_dialog_get_display_kb())
|
&& !menu_input_dialog_get_display_kb())
|
||||||
{
|
{
|
||||||
char current_label[128];
|
|
||||||
char current_value[128];
|
char current_value[128];
|
||||||
char title_name[NAME_MAX_LENGTH];
|
char title_name[NAME_MAX_LENGTH];
|
||||||
char speak_string[512];
|
char speak_string[512];
|
||||||
|
|
||||||
speak_string[0] = '\0';
|
|
||||||
title_name [0] = '\0';
|
title_name [0] = '\0';
|
||||||
current_label[0] = '\0';
|
|
||||||
|
|
||||||
get_current_menu_value(menu_st,
|
get_current_menu_value(menu_st,
|
||||||
current_value, sizeof(current_value));
|
current_value, sizeof(current_value));
|
||||||
@ -7776,7 +7764,6 @@ int generic_menu_entry_action(
|
|||||||
case MENU_ACTION_SELECT:
|
case MENU_ACTION_SELECT:
|
||||||
case MENU_ACTION_SEARCH:
|
case MENU_ACTION_SEARCH:
|
||||||
case MENU_ACTION_ACCESSIBILITY_SPEAK_LABEL:
|
case MENU_ACTION_ACCESSIBILITY_SPEAK_LABEL:
|
||||||
menu_driver_get_current_menu_label(menu_st, current_label, sizeof(current_label));
|
|
||||||
break;
|
break;
|
||||||
case MENU_ACTION_SCAN:
|
case MENU_ACTION_SCAN:
|
||||||
case MENU_ACTION_INFO:
|
case MENU_ACTION_INFO:
|
||||||
@ -7790,9 +7777,10 @@ int generic_menu_entry_action(
|
|||||||
title_name, sizeof(speak_string));
|
title_name, sizeof(speak_string));
|
||||||
speak_string[ _len] = ' ';
|
speak_string[ _len] = ' ';
|
||||||
speak_string[++_len] = '\0';
|
speak_string[++_len] = '\0';
|
||||||
_len += strlcpy(speak_string + _len,
|
_len += menu_driver_get_current_menu_label(
|
||||||
current_label,
|
menu_st,
|
||||||
sizeof(speak_string) - _len);
|
speak_string + _len,
|
||||||
|
sizeof(speak_string) - _len);
|
||||||
if (!string_is_equal(current_value, "..."))
|
if (!string_is_equal(current_value, "..."))
|
||||||
{
|
{
|
||||||
speak_string[ _len] = ' ';
|
speak_string[ _len] = ' ';
|
||||||
@ -7804,8 +7792,10 @@ int generic_menu_entry_action(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t _len = strlcpy(speak_string,
|
size_t _len = menu_driver_get_current_menu_label(
|
||||||
current_label, sizeof(speak_string));
|
menu_st,
|
||||||
|
speak_string,
|
||||||
|
sizeof(speak_string));
|
||||||
if (!string_is_equal(current_value, "..."))
|
if (!string_is_equal(current_value, "..."))
|
||||||
{
|
{
|
||||||
speak_string[ _len] = ' ';
|
speak_string[ _len] = ' ';
|
||||||
|
@ -630,7 +630,7 @@ retro_time_t menu_driver_get_current_time(void);
|
|||||||
|
|
||||||
size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, char *s, size_t len);
|
size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime, char *s, size_t len);
|
||||||
|
|
||||||
void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate);
|
size_t menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate, char *s, size_t len);
|
||||||
|
|
||||||
void menu_display_handle_wallpaper_upload(retro_task_t *task,
|
void menu_display_handle_wallpaper_upload(retro_task_t *task,
|
||||||
void *task_data,
|
void *task_data,
|
||||||
|
@ -161,7 +161,7 @@ typedef struct menu_file_list_cbs
|
|||||||
bool checked;
|
bool checked;
|
||||||
} menu_file_list_cbs_t;
|
} menu_file_list_cbs_t;
|
||||||
|
|
||||||
int menu_entries_get_title(char *title, size_t title_len);
|
size_t menu_entries_get_title(char *s, size_t len);
|
||||||
|
|
||||||
void menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
|
void menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user