mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-24 11:45:16 +00:00
(Menu) Refactor common code in disp/rgui | rmenu | rmenu_xui
This commit is contained in:
parent
05f32cdcfc
commit
0eea8307a5
@ -1522,7 +1522,7 @@ static int menu_action_ok(const char *menu_path,
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
case MENU_FILE_DIRECTORY:
|
||||
case MENU_FILE_CARCHIVE:
|
||||
|
||||
|
@ -348,66 +348,23 @@ static void rgui_render(void)
|
||||
const char *path = NULL;
|
||||
const char *entry_label = NULL;
|
||||
unsigned type = 0;
|
||||
unsigned w = 0;
|
||||
char entry_title_buf[256];
|
||||
char type_str_buf[64];
|
||||
bool selected = false;
|
||||
|
||||
file_list_get_at_offset(driver.menu->selection_buf, i, &path,
|
||||
&entry_label, &type);
|
||||
rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
setting_data_get_list(),
|
||||
driver.menu->selection_buf->list[i].label);
|
||||
|
||||
unsigned w = 19;
|
||||
(void)setting;
|
||||
|
||||
if (!strcmp(label, "performance_counters"))
|
||||
w = 28;
|
||||
disp_set_label(&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path);
|
||||
|
||||
if (type == MENU_FILE_CORE)
|
||||
{
|
||||
strlcpy(type_str, "(CORE)", sizeof(type_str));
|
||||
file_list_get_alt_at_offset(driver.menu->selection_buf, i, &path);
|
||||
w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_PLAIN)
|
||||
{
|
||||
strlcpy(type_str, "(FILE)", sizeof(type_str));
|
||||
w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_USE_DIRECTORY)
|
||||
{
|
||||
*type_str = '\0';
|
||||
w = 0;
|
||||
}
|
||||
else if (type == MENU_FILE_DIRECTORY)
|
||||
{
|
||||
strlcpy(type_str, "(DIR)", sizeof(type_str));
|
||||
type = MENU_FILE_DIRECTORY;
|
||||
w = 5;
|
||||
}
|
||||
else if (type == MENU_FILE_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(COMP)", sizeof(type_str));
|
||||
w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_IN_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(CFILE)", sizeof(type_str));
|
||||
w = 7;
|
||||
}
|
||||
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),
|
||||
sizeof(type_str));
|
||||
else if (type == MENU_FILE_SWITCH || type == MENU_FILE_LINEFEED_SWITCH)
|
||||
strlcpy(type_str, "...", sizeof(type_str));
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend &&
|
||||
driver.menu_ctx->backend->setting_set_label)
|
||||
driver.menu_ctx->backend->setting_set_label(type_str,
|
||||
sizeof(type_str), &w, type, label, entry_label, i);
|
||||
|
||||
char entry_title_buf[256];
|
||||
char type_str_buf[64];
|
||||
bool selected = i == driver.menu->selection_ptr;
|
||||
selected = (i == driver.menu->selection_ptr);
|
||||
|
||||
menu_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2),
|
||||
g_extern.frame_count / RGUI_TERM_START_X, path, selected);
|
||||
|
@ -224,46 +224,16 @@ static void rmenu_render(void)
|
||||
&path, &entry_label, &type);
|
||||
char message[256];
|
||||
char type_str[256];
|
||||
|
||||
unsigned w = 19;
|
||||
|
||||
if (type == MENU_FILE_CORE)
|
||||
{
|
||||
strlcpy(type_str, "(CORE)", sizeof(type_str));
|
||||
file_list_get_alt_at_offset(driver.menu->selection_buf, i, &path);
|
||||
w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_PLAIN)
|
||||
{
|
||||
strlcpy(type_str, "(FILE)", sizeof(type_str));
|
||||
w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_USE_DIRECTORY)
|
||||
{
|
||||
*type_str = '\0';
|
||||
w = 0;
|
||||
}
|
||||
else if (type == MENU_FILE_DIRECTORY)
|
||||
{
|
||||
strlcpy(type_str, "(DIR)", sizeof(type_str));
|
||||
type = MENU_FILE_DIRECTORY;
|
||||
w = 5;
|
||||
}
|
||||
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),
|
||||
sizeof(type_str));
|
||||
else if (type == MENU_FILE_SWITCH || type == MENU_FILE_LINEFEED_SWITCH)
|
||||
strlcpy(type_str, "...", sizeof(type_str));
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend
|
||||
&& driver.menu_ctx->backend->setting_set_label)
|
||||
driver.menu_ctx->backend->setting_set_label(type_str,
|
||||
sizeof(type_str), &w, type, label, entry_label, i);
|
||||
|
||||
unsigned w = 0;
|
||||
char entry_title_buf[256];
|
||||
char type_str_buf[64];
|
||||
bool selected = i == menu->selection_ptr;
|
||||
bool selected = false;
|
||||
|
||||
disp_set_label(&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path);
|
||||
|
||||
selected = (i == driver.menu->selection_ptr);
|
||||
|
||||
menu_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2),
|
||||
g_extern.frame_count / 15, path, selected);
|
||||
|
@ -436,46 +436,16 @@ static void rmenu_xui_render(void)
|
||||
&path, &entry_label, &type);
|
||||
char message[256];
|
||||
char type_str[256];
|
||||
|
||||
unsigned w = 19;
|
||||
|
||||
if (type == MENU_FILE_CORE)
|
||||
{
|
||||
strlcpy(type_str, "(CORE)", sizeof(type_str));
|
||||
file_list_get_alt_at_offset(driver.menu->selection_buf, i, &path);
|
||||
w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_PLAIN)
|
||||
{
|
||||
strlcpy(type_str, "(FILE)", sizeof(type_str));
|
||||
w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_USE_DIRECTORY)
|
||||
{
|
||||
*type_str = '\0';
|
||||
w = 0;
|
||||
}
|
||||
else if (type == MENU_FILE_DIRECTORY)
|
||||
{
|
||||
strlcpy(type_str, "(DIR)", sizeof(type_str));
|
||||
type = MENU_FILE_DIRECTORY;
|
||||
w = 5;
|
||||
}
|
||||
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),
|
||||
sizeof(type_str));
|
||||
else if (type == MENU_FILE_SWITCH || type == MENU_FILE_LINEFEED_SWITCH)
|
||||
strlcpy(type_str, "...", sizeof(type_str));
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend
|
||||
&& driver.menu_ctx->backend->setting_set_label)
|
||||
driver.menu_ctx->backend->setting_set_label(type_str,
|
||||
sizeof(type_str), &w, type, label, entry_label, i);
|
||||
|
||||
char entry_title_buf[256];
|
||||
char type_str_buf[64];
|
||||
bool selected = i == driver.menu->selection_ptr;
|
||||
bool selected = false;
|
||||
unsigned w = 0;
|
||||
|
||||
disp_set_label(&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path);
|
||||
|
||||
selected = (i == driver.menu->selection_ptr);
|
||||
|
||||
#if 0
|
||||
if ((type == MENU_FILE_PLAIN || type == MENU_FILE_DIRECTORY))
|
||||
|
@ -124,4 +124,61 @@ static void get_title(const char *label, const char *dir,
|
||||
}
|
||||
}
|
||||
|
||||
static void disp_set_label(unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *type_str, size_t type_str_size,
|
||||
const char *entry_label,
|
||||
const char *path)
|
||||
{
|
||||
*w = 19;
|
||||
|
||||
if (!strcmp(label, "performance_counters"))
|
||||
*w = 28;
|
||||
|
||||
if (type == MENU_FILE_CORE)
|
||||
{
|
||||
strlcpy(type_str, "(CORE)", type_str_size);
|
||||
file_list_get_alt_at_offset(driver.menu->selection_buf, i, &path);
|
||||
*w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_PLAIN)
|
||||
{
|
||||
strlcpy(type_str, "(FILE)", type_str_size);
|
||||
*w = 6;
|
||||
}
|
||||
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);
|
||||
type = MENU_FILE_DIRECTORY;
|
||||
*w = 5;
|
||||
}
|
||||
else if (type == MENU_FILE_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(COMP)", type_str_size);
|
||||
*w = 6;
|
||||
}
|
||||
else if (type == MENU_FILE_IN_CARCHIVE)
|
||||
{
|
||||
strlcpy(type_str, "(CFILE)", type_str_size);
|
||||
*w = 7;
|
||||
}
|
||||
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 if (type == MENU_FILE_SWITCH || type == MENU_FILE_LINEFEED_SWITCH)
|
||||
strlcpy(type_str, "...", type_str_size);
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend &&
|
||||
driver.menu_ctx->backend->setting_set_label)
|
||||
driver.menu_ctx->backend->setting_set_label(type_str,
|
||||
type_str_size, w, type, label, entry_label, i);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -553,10 +553,12 @@ int menu_parse_check(const char *label, unsigned menu_type)
|
||||
int menu_parse_and_resolve(file_list_t *list, file_list_t *menu_list)
|
||||
{
|
||||
size_t i, list_size;
|
||||
unsigned menu_type = 0;
|
||||
unsigned menu_type = 0, default_type_plain = MENU_FILE_PLAIN;
|
||||
|
||||
const char *dir = NULL;
|
||||
const char *label = NULL;
|
||||
const char *exts = NULL;
|
||||
char ext_buf[PATH_MAX];
|
||||
|
||||
file_list_get_last(menu_list, &dir, &label, &menu_type);
|
||||
|
||||
@ -664,9 +666,6 @@ int menu_parse_and_resolve(file_list_t *list, file_list_t *menu_list)
|
||||
LWP_MutexUnlock(gx_device_mutex);
|
||||
#endif
|
||||
|
||||
const char *exts;
|
||||
char ext_buf[1024];
|
||||
|
||||
//RARCH_LOG("LABEL: %s\n", label);
|
||||
if (!strcmp(label, "core_list"))
|
||||
exts = EXT_EXECUTABLES;
|
||||
@ -738,7 +737,7 @@ int menu_parse_and_resolve(file_list_t *list, file_list_t *menu_list)
|
||||
break;
|
||||
case RARCH_PLAIN_FILE:
|
||||
default:
|
||||
file_type = MENU_FILE_PLAIN;
|
||||
file_type = default_type_plain;
|
||||
break;
|
||||
}
|
||||
bool is_dir = (file_type == MENU_FILE_DIRECTORY);
|
||||
|
Loading…
Reference in New Issue
Block a user