(Menu) Simplify menu_display_setting_label

This commit is contained in:
twinaphex 2015-05-07 04:28:57 +02:00
parent dcd203b44d
commit bcab96bb77
7 changed files with 78 additions and 102 deletions

View File

@ -300,30 +300,20 @@ static void glui_render_menu_list(runloop_t *runloop,
for (i = 0; i < menu_list_get_size(menu->menu_list); i++)
{
unsigned y;
char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH],
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH],
path_buf[PATH_MAX_LENGTH];
const char *entry_label = NULL;
unsigned type = 0;
unsigned w = 0;
menu_entry_t entry;
char message[PATH_MAX_LENGTH],
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH];
bool selected = false;
menu_file_list_cbs_t *cbs = NULL;
menu_display_setting_label(cbs, i,
&w, &type,
label,
type_str, sizeof(type_str),
path_buf, sizeof(path_buf),
NULL, 0,
entry_label,
NULL);
menu_display_setting_label(cbs, &entry, i, label, NULL);
selected = (i == menu->navigation.selection_ptr);
menu_animation_ticker_line(entry_title_buf, glui->ticker_limit,
runloop->frames.video.count / 100, path_buf, selected);
runloop->frames.video.count / 100, entry.path, selected);
menu_animation_ticker_line(type_str_buf, glui->ticker_limit,
runloop->frames.video.count / 100, type_str, selected);
runloop->frames.video.count / 100, entry.value, selected);
strlcpy(message, entry_title_buf, sizeof(message));

View File

@ -488,43 +488,31 @@ static void rgui_render(void)
for (i = menu->begin; i < end; i++, y += FONT_HEIGHT_STRIDE)
{
char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH],
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH],
path_buf[PATH_MAX_LENGTH];
const char *entry_label = NULL;
unsigned type = 0;
unsigned w = 0;
menu_entry_t entry;
char message[PATH_MAX_LENGTH],
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH];
bool selected = false;
menu_file_list_cbs_t *cbs = NULL;
menu_display_setting_label(
cbs,
i,
&w, &type,
label,
type_str, sizeof(type_str),
path_buf, sizeof(path_buf),
NULL, 0,
entry_label,
NULL);
menu_display_setting_label(cbs, &entry, i, label, NULL);
selected = (i == menu->navigation.selection_ptr);
if (i > (menu->navigation.selection_ptr + 100))
continue;
menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2),
runloop->frames.video.count / RGUI_TERM_START_X, path_buf, selected);
menu_animation_ticker_line(type_str_buf, w,
menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (entry.spacing + 1 + 2),
runloop->frames.video.count / RGUI_TERM_START_X, entry.path, selected);
menu_animation_ticker_line(type_str_buf, entry.spacing,
runloop->frames.video.count / RGUI_TERM_START_X,
type_str, selected);
entry.value, selected);
snprintf(message, sizeof(message), "%c %-*.*s %-*s",
selected ? '>' : ' ',
RGUI_TERM_WIDTH - (w + 1 + 2),
RGUI_TERM_WIDTH - (w + 1 + 2),
RGUI_TERM_WIDTH - (entry.spacing + 1 + 2),
RGUI_TERM_WIDTH - (entry.spacing + 1 + 2),
entry_title_buf,
w,
entry.spacing,
type_str_buf);
blit_line(menu, x, y, message, selected ? hover_color : normal_color);

View File

@ -997,14 +997,10 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
for (i = 0; i < end; i++)
{
GLuint texture_switch = 0;
menu_entry_t entry;
float icon_x, icon_y;
char entry_label_buf[PATH_MAX_LENGTH];
char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
GLuint texture_switch = 0;
char name[PATH_MAX_LENGTH], value[PATH_MAX_LENGTH];
const char *entry_label = NULL;
unsigned type = 0;
unsigned w = 0;
GLuint icon = 0;
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i);
runloop_t *runloop = rarch_main_get_ptr();
@ -1025,44 +1021,37 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
icon_y > global->video_data.height + xmb->icon.size)
continue;
menu_display_setting_label(cbs, i,
&w, &type,
label,
type_str, sizeof(type_str),
path_buf, sizeof(path_buf),
entry_label_buf, sizeof(entry_label_buf),
entry_label,
list);
menu_display_setting_label(cbs, &entry, i, label, list);
if (type == MENU_FILE_CONTENTLIST_ENTRY)
strlcpy(path_buf, path_basename(path_buf), sizeof(path_buf));
if (entry.type == MENU_FILE_CONTENTLIST_ENTRY)
strlcpy(entry.path, path_basename(entry.path), sizeof(entry.path));
icon = xmb_icon_get_type(xmb, core_node, type);
icon = xmb_icon_get_type(xmb, core_node, entry.type);
if (!strcmp(entry_label_buf, "core_options"))
if (!strcmp(entry.label, "core_options"))
icon = xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].id;
else if (!strcmp(entry_label_buf, "core_information"))
else if (!strcmp(entry.label, "core_information"))
icon = xmb->textures.list[XMB_TEXTURE_CORE_INFO].id;
else if (!strcmp(entry_label_buf, "core_input_remapping_options"))
else if (!strcmp(entry.label, "core_input_remapping_options"))
icon = xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].id;
else if (!strcmp(entry_label_buf, "core_cheat_options"))
else if (!strcmp(entry.label, "core_cheat_options"))
icon = xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].id;
else if (!strcmp(entry_label_buf, "core_disk_options"))
else if (!strcmp(entry.label, "core_disk_options"))
icon = xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].id;
else if (!strcmp(entry_label_buf, "savestate"))
else if (!strcmp(entry.label, "savestate"))
icon = xmb->textures.list[XMB_TEXTURE_SAVESTATE].id;
else if (!strcmp(entry_label_buf, "loadstate"))
else if (!strcmp(entry.label, "loadstate"))
icon = xmb->textures.list[XMB_TEXTURE_LOADSTATE].id;
else if (!strcmp(entry_label_buf, "take_screenshot"))
else if (!strcmp(entry.label, "take_screenshot"))
icon = xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id;
else if (!strcmp(entry_label_buf, "restart_content"))
else if (!strcmp(entry.label, "restart_content"))
icon = xmb->textures.list[XMB_TEXTURE_RELOAD].id;
else if (!strcmp(entry_label_buf, "resume_content"))
else if (!strcmp(entry.label, "resume_content"))
icon = xmb->textures.list[XMB_TEXTURE_RESUME].id;
menu_animation_ticker_line(name, 35,
runloop->frames.video.count / 20, path_buf,
runloop->frames.video.count / 20, entry.path,
(i == current));
xmb_draw_text(menu, xmb, name,
@ -1072,21 +1061,21 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
1, node->label_alpha, TEXT_ALIGN_LEFT);
menu_animation_ticker_line(value, 35,
runloop->frames.video.count / 20, type_str,
runloop->frames.video.count / 20, entry.value,
(i == current));
if(( strcmp(type_str, "...")
&& strcmp(type_str, "(CORE)")
&& strcmp(type_str, "(RDB)")
&& strcmp(type_str, "(CURSOR)")
&& strcmp(type_str, "(FILE)")
&& strcmp(type_str, "(DIR)")
&& strcmp(type_str, "(COMP)")
&& strcmp(type_str, "ON")
&& strcmp(type_str, "OFF"))
|| ((!strcmp(type_str, "ON")
if(( strcmp(entry.value, "...")
&& strcmp(entry.value, "(CORE)")
&& strcmp(entry.value, "(RDB)")
&& strcmp(entry.value, "(CURSOR)")
&& strcmp(entry.value, "(FILE)")
&& strcmp(entry.value, "(DIR)")
&& strcmp(entry.value, "(COMP)")
&& strcmp(entry.value, "ON")
&& strcmp(entry.value, "OFF"))
|| ((!strcmp(entry.value, "ON")
&& !xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id)
|| (!strcmp(type_str, "OFF")
|| (!strcmp(entry.value, "OFF")
&& !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id)))
xmb_draw_text(menu, xmb, value,
node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal +
@ -1101,10 +1090,10 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
xmb_draw_icon(gl, xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom);
if (!strcmp(type_str, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id)
if (!strcmp(entry.value, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id)
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id;
if (!strcmp(type_str, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id)
if (!strcmp(entry.value, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id)
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id;
if (texture_switch != 0)

View File

@ -208,23 +208,23 @@ void menu_display_unset_viewport(menu_handle_t *menu)
global->video_data.height, false, true);
}
void menu_display_setting_label(
bool menu_display_setting_label(
menu_file_list_cbs_t *cbs,
menu_entry_t *entry,
unsigned i,
unsigned *w, unsigned *type,
const char *label,
char *type_str, size_t sizeof_type_str,
char *path_buf, size_t sizeof_path_buf,
char *entry_label_buf, size_t sizeof_entry_label_buf,
const char *entry_label,
void *userdata)
{
const char *path = NULL;
const char *entry_label = NULL;
const char *path = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
file_list_t *list = userdata ? (file_list_t*)userdata
: menu->menu_list->selection_buf;
menu_list_get_at_offset(list, i, &path, &entry_label, type);
if (!entry)
return false;
menu_list_get_at_offset(list, i, &path, &entry_label, &entry->type);
cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(list,
@ -232,11 +232,13 @@ void menu_display_setting_label(
if (cbs && cbs->action_get_representation)
cbs->action_get_representation(list,
w, *type, i, label,
type_str, sizeof_type_str,
&entry->spacing, entry->type, i, label,
entry->value, sizeof(entry->value),
entry_label, path,
path_buf, sizeof_path_buf);
entry->path, sizeof(entry->path));
if (entry_label && entry_label_buf != NULL)
strlcpy(entry_label_buf, entry_label, sizeof_entry_label_buf);
if (entry_label)
strlcpy(entry->label, entry_label, sizeof(entry->label));
return true;
}

View File

@ -17,6 +17,7 @@
#define __MENU_DISPLAY_H__
#include "menu_driver.h"
#include "menu_list.h"
#include "../gfx/video_thread_wrapper.h"
#include "../gfx/font_renderer_driver.h"
@ -53,15 +54,11 @@ void menu_display_set_viewport(menu_handle_t *menu);
void menu_display_unset_viewport(menu_handle_t *menu);
void menu_display_setting_label(
bool menu_display_setting_label(
menu_file_list_cbs_t *cbs,
menu_entry_t *entry,
unsigned i,
unsigned *w, unsigned *type,
const char *label,
char *type_str, size_t sizeof_type_str,
char *path_buf, size_t sizeof_path_buf,
char *entry_label_buf, size_t sizeof_entry_label_buf,
const char *entry_label,
void *userdata);
#ifdef __cplusplus

View File

@ -167,7 +167,7 @@ void menu_list_free(menu_list_t *menu_list)
menu_list_destroy(menu_list->selection_buf);
}
void *menu_list_new(void)
menu_list_t *menu_list_new(void)
{
menu_list_t *list = (menu_list_t*)calloc(1, sizeof(*list));

View File

@ -30,9 +30,19 @@ typedef struct menu_list
file_list_t *selection_buf;
} menu_list_t;
typedef struct menu_entry
{
char path[PATH_MAX_LENGTH];
char label[PATH_MAX_LENGTH];
char value[PATH_MAX_LENGTH];
unsigned id;
unsigned type;
unsigned spacing;
} menu_entry_t;
void menu_list_free(menu_list_t *menu_list);
void *menu_list_new(void);
menu_list_t *menu_list_new(void);
void menu_list_flush_stack(menu_list_t *list,
unsigned final_type);