mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 18:40:49 +00:00
Refactor cbs->action_get_representation
This commit is contained in:
parent
4d27d888f5
commit
fc5fe960a5
@ -386,19 +386,21 @@ static void glui_frame(void)
|
||||
unsigned type = 0, w = 0;
|
||||
bool selected = false;
|
||||
rarch_setting_t *setting = NULL;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
|
||||
&entry_label, &type);
|
||||
setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
driver.menu->list_settings,
|
||||
driver.menu->menu_list->selection_buf->list[i].label);
|
||||
|
||||
(void)setting;
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
|
||||
i);
|
||||
|
||||
disp_set_label(driver.menu->menu_list->selection_buf, &w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
if (cbs && cbs->action_get_representation)
|
||||
cbs->action_get_representation(driver.menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
selected = (i == driver.menu->selection_ptr);
|
||||
|
||||
|
@ -440,18 +440,21 @@ static void rgui_render(void)
|
||||
unsigned type = 0, w = 0;
|
||||
bool selected = false;
|
||||
rarch_setting_t *setting = NULL;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
|
||||
&entry_label, &type);
|
||||
setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
driver.menu->list_settings,
|
||||
driver.menu->menu_list->selection_buf->list[i].label);
|
||||
(void)setting;
|
||||
|
||||
disp_set_label(driver.menu->menu_list->selection_buf, &w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
|
||||
i);
|
||||
|
||||
if (cbs && cbs->action_get_representation)
|
||||
cbs->action_get_representation(driver.menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
selected = (i == driver.menu->selection_ptr);
|
||||
|
||||
|
@ -230,20 +230,21 @@ static void rmenu_render(void)
|
||||
const char *path = NULL, *entry_label = NULL;
|
||||
unsigned type = 0, w = 0;
|
||||
bool selected = false;
|
||||
rarch_setting_t *setting = NULL;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
menu_list_get_at_offset(menu->menu_list->selection_buf, i,
|
||||
&path, &entry_label, &type);
|
||||
|
||||
setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
driver.menu->list_settings,
|
||||
driver.menu->menu_list->selection_buf->list[i].label);
|
||||
(void)setting;
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
|
||||
i);
|
||||
|
||||
disp_set_label(menu->menu_list->selection_buf, &w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
if (cbs && cbs->action_get_representation)
|
||||
cbs->action_get_representation(driver.menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
selected = (i == driver.menu->selection_ptr);
|
||||
|
||||
|
@ -582,21 +582,21 @@ static void rmenu_xui_render(void)
|
||||
char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
|
||||
const char *path = NULL, *entry_label = NULL;
|
||||
unsigned type = 0, w = 0;
|
||||
rarch_setting_t *setting = NULL;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
|
||||
&entry_label, &type);
|
||||
|
||||
setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
driver.menu->list_settings,
|
||||
driver.menu->menu_list->selection_buf->list[i].label);
|
||||
(void)setting;
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
|
||||
i);
|
||||
|
||||
disp_set_label(driver.menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
if (cbs && cbs->action_get_representation)
|
||||
cbs->action_get_representation(driver.menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
mbstowcs(msg_left, path_buf, sizeof(msg_left) / sizeof(wchar_t));
|
||||
mbstowcs(msg_right, type_str, sizeof(msg_right) / sizeof(wchar_t));
|
||||
|
@ -366,98 +366,4 @@ static INLINE void disp_timedate_set_label(char *label, size_t label_size,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void disp_set_label(file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *type_str, size_t type_str_size,
|
||||
const char *entry_label,
|
||||
const char *path,
|
||||
char *path_buf, size_t path_buf_size)
|
||||
{
|
||||
*type_str = '\0';
|
||||
*w = 19;
|
||||
|
||||
if (!strcmp(label, "performance_counters"))
|
||||
*w = strlen(label);
|
||||
|
||||
if (!strcmp(label, "history_list"))
|
||||
*w = strlen(label);
|
||||
|
||||
if (type == MENU_FILE_CORE)
|
||||
{
|
||||
strlcpy(type_str, "(CORE)", type_str_size);
|
||||
menu_list_get_alt_at_offset(list, i, &path);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_PLAIN)
|
||||
{
|
||||
strlcpy(type_str, "(FILE)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_USE_DIRECTORY)
|
||||
{
|
||||
*type_str = '\0';
|
||||
*w = 0;
|
||||
}
|
||||
else if (type == MENU_FILE_DIRECTORY)
|
||||
{
|
||||
strlcpy(type_str, "(DIR)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(COMP)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_IN_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(CFILE)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_FONT)
|
||||
{
|
||||
strlcpy(type_str, "(FONT)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_SHADER_PRESET)
|
||||
{
|
||||
strlcpy(type_str, "(PRESET)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_SHADER)
|
||||
{
|
||||
strlcpy(type_str, "(SHADER)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (
|
||||
type == MENU_FILE_VIDEOFILTER ||
|
||||
type == MENU_FILE_AUDIOFILTER)
|
||||
{
|
||||
strlcpy(type_str, "(FILTER)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_CONFIG)
|
||||
{
|
||||
strlcpy(type_str, "(CONFIG)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_OVERLAY)
|
||||
{
|
||||
strlcpy(type_str, "(OVERLAY)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type >= MENU_SETTINGS_CORE_OPTION_START)
|
||||
strlcpy(
|
||||
type_str,
|
||||
core_option_get_val(g_extern.system.core_options,
|
||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||
type_str_size);
|
||||
else
|
||||
setting_data_get_label(list, type_str,
|
||||
type_str_size, w, type, label, entry_label, i);
|
||||
|
||||
strlcpy(path_buf, path, path_buf_size);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -872,25 +872,26 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack,
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
char val_buf[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
|
||||
char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
|
||||
char name[256], value[256];
|
||||
const char *path = NULL, *entry_label = NULL;
|
||||
unsigned type = 0, w = 0;
|
||||
xmb_node_t *node = NULL;
|
||||
rarch_setting_t *setting = NULL;
|
||||
menu_file_list_cbs_t *cbs = NULL;
|
||||
|
||||
menu_list_get_at_offset(list, i, &path, &entry_label, &type);
|
||||
node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i);
|
||||
|
||||
setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
driver.menu->list_settings,
|
||||
driver.menu->menu_list->selection_buf->list[i].label);
|
||||
(void)setting;
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
|
||||
i);
|
||||
|
||||
disp_set_label(list, &w, type, i, label,
|
||||
val_buf, sizeof(val_buf),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
if (cbs && cbs->action_get_representation)
|
||||
cbs->action_get_representation(driver.menu->menu_list->selection_buf,
|
||||
&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
if (type == MENU_FILE_CONTENTLIST_ENTRY)
|
||||
strlcpy(path_buf, path_basename(path_buf), sizeof(path_buf));
|
||||
@ -961,19 +962,19 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack,
|
||||
node->label_alpha,
|
||||
0);
|
||||
|
||||
menu_ticker_line(value, 35, g_extern.frame_count / 20, val_buf,
|
||||
menu_ticker_line(value, 35, g_extern.frame_count / 20, type_str,
|
||||
(i == current));
|
||||
|
||||
if(( strcmp(val_buf, "...")
|
||||
&& strcmp(val_buf, "(CORE)")
|
||||
&& strcmp(val_buf, "(FILE)")
|
||||
&& strcmp(val_buf, "(DIR)")
|
||||
&& strcmp(val_buf, "(COMP)")
|
||||
&& strcmp(val_buf, "ON")
|
||||
&& strcmp(val_buf, "OFF"))
|
||||
|| ((!strcmp(val_buf, "ON")
|
||||
if(( strcmp(type_str, "...")
|
||||
&& strcmp(type_str, "(CORE)")
|
||||
&& strcmp(type_str, "(FILE)")
|
||||
&& strcmp(type_str, "(DIR)")
|
||||
&& strcmp(type_str, "(COMP)")
|
||||
&& strcmp(type_str, "ON")
|
||||
&& strcmp(type_str, "OFF"))
|
||||
|| ((!strcmp(type_str, "ON")
|
||||
&& !xmb->textures[XMB_TEXTURE_SWITCH_ON].id)
|
||||
|| (!strcmp(val_buf, "OFF")
|
||||
|| (!strcmp(type_str, "OFF")
|
||||
&& !xmb->textures[XMB_TEXTURE_SWITCH_OFF].id)))
|
||||
xmb_draw_text(value,
|
||||
node->x + xmb->margin_left + xmb->hspacing +
|
||||
@ -983,7 +984,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack,
|
||||
node->label_alpha,
|
||||
0);
|
||||
|
||||
if (!strcmp(val_buf, "ON") && xmb->textures[XMB_TEXTURE_SWITCH_ON].id)
|
||||
if (!strcmp(type_str, "ON") && xmb->textures[XMB_TEXTURE_SWITCH_ON].id)
|
||||
xmb_draw_icon(xmb->textures[XMB_TEXTURE_SWITCH_ON].id,
|
||||
node->x + xmb->margin_left + xmb->hspacing
|
||||
+ xmb->icon_size/2.0 + xmb->setting_margin_left,
|
||||
@ -992,7 +993,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack,
|
||||
0,
|
||||
1);
|
||||
|
||||
if (!strcmp(val_buf, "OFF") && xmb->textures[XMB_TEXTURE_SWITCH_OFF].id)
|
||||
if (!strcmp(type_str, "OFF") && xmb->textures[XMB_TEXTURE_SWITCH_OFF].id)
|
||||
xmb_draw_icon(xmb->textures[XMB_TEXTURE_SWITCH_OFF].id,
|
||||
node->x + xmb->margin_left + xmb->hspacing
|
||||
+ xmb->icon_size/2.0 + xmb->setting_margin_left,
|
||||
|
@ -157,7 +157,13 @@ typedef struct menu_file_list_cbs
|
||||
int (*action_toggle)(unsigned type, const char *label, unsigned action);
|
||||
int (*action_refresh)(file_list_t *list, file_list_t *menu_list);
|
||||
int (*action_up_or_down)(unsigned type, const char *label, unsigned action);
|
||||
void (*action_get_representation)(rarch_setting_t *setting, char *type_str, size_t type_str_size);
|
||||
void (*action_get_representation)(file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *type_str, size_t type_str_size,
|
||||
const char *entry_label,
|
||||
const char *path,
|
||||
char *path_buf, size_t path_buf_size);
|
||||
} menu_file_list_cbs_t;
|
||||
|
||||
typedef struct menu_ctx_driver
|
||||
|
@ -4023,6 +4023,99 @@ static int action_start_lookup_setting(unsigned type, const char *label,
|
||||
return menu_action_setting_set(type, label, MENU_ACTION_START);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label(file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *type_str, size_t type_str_size,
|
||||
const char *entry_label,
|
||||
const char *path,
|
||||
char *path_buf, size_t path_buf_size)
|
||||
{
|
||||
*type_str = '\0';
|
||||
*w = 19;
|
||||
|
||||
if (!strcmp(label, "performance_counters"))
|
||||
*w = strlen(label);
|
||||
|
||||
if (!strcmp(label, "history_list"))
|
||||
*w = strlen(label);
|
||||
|
||||
if (type == MENU_FILE_CORE)
|
||||
{
|
||||
strlcpy(type_str, "(CORE)", type_str_size);
|
||||
menu_list_get_alt_at_offset(list, i, &path);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_PLAIN)
|
||||
{
|
||||
strlcpy(type_str, "(FILE)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_USE_DIRECTORY)
|
||||
{
|
||||
*type_str = '\0';
|
||||
*w = 0;
|
||||
}
|
||||
else if (type == MENU_FILE_DIRECTORY)
|
||||
{
|
||||
strlcpy(type_str, "(DIR)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(COMP)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_IN_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(CFILE)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_FONT)
|
||||
{
|
||||
strlcpy(type_str, "(FONT)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_SHADER_PRESET)
|
||||
{
|
||||
strlcpy(type_str, "(PRESET)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_SHADER)
|
||||
{
|
||||
strlcpy(type_str, "(SHADER)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (
|
||||
type == MENU_FILE_VIDEOFILTER ||
|
||||
type == MENU_FILE_AUDIOFILTER)
|
||||
{
|
||||
strlcpy(type_str, "(FILTER)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_CONFIG)
|
||||
{
|
||||
strlcpy(type_str, "(CONFIG)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type == MENU_FILE_OVERLAY)
|
||||
{
|
||||
strlcpy(type_str, "(OVERLAY)", type_str_size);
|
||||
*w = strlen(type_str);
|
||||
}
|
||||
else if (type >= MENU_SETTINGS_CORE_OPTION_START)
|
||||
strlcpy(
|
||||
type_str,
|
||||
core_option_get_val(g_extern.system.core_options,
|
||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||
type_str_size);
|
||||
else
|
||||
setting_data_get_label(list, type_str,
|
||||
type_str_size, w, type, label, entry_label, i);
|
||||
|
||||
strlcpy(path_buf, path, path_buf_size);
|
||||
}
|
||||
|
||||
static void menu_entries_cbs_init_bind_select(menu_file_list_cbs_t *cbs,
|
||||
const char *path, const char *label, unsigned type, size_t idx)
|
||||
{
|
||||
@ -4516,7 +4609,7 @@ static void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_
|
||||
if (!cbs || !driver.menu)
|
||||
return;
|
||||
|
||||
cbs->action_get_representation = menu_action_setting_get_representation;
|
||||
cbs->action_get_representation = menu_action_setting_disp_set_label;
|
||||
}
|
||||
|
||||
static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
|
||||
|
Loading…
x
Reference in New Issue
Block a user