(Menu) Get rid of hardcoded MENU_SETTINGS_PERFORMANCE_COUNTERS enum

This commit is contained in:
twinaphex 2014-09-03 22:04:46 +02:00
parent 836124c217
commit a88198a12e
9 changed files with 26 additions and 26 deletions

View File

@ -140,7 +140,7 @@ typedef struct menu_ctx_driver_backend
void (*shader_manager_save_preset)(const char *, bool); void (*shader_manager_save_preset)(const char *, bool);
unsigned (*shader_manager_get_type)(const struct gfx_shader *); unsigned (*shader_manager_get_type)(const struct gfx_shader *);
int (*shader_manager_setting_toggle)(unsigned, const char *, unsigned); int (*shader_manager_setting_toggle)(unsigned, const char *, unsigned);
unsigned (*type_is)(unsigned); unsigned (*type_is)(const char *, unsigned);
void (*setting_set_label)(char *, size_t, unsigned *, unsigned,unsigned); void (*setting_set_label)(char *, size_t, unsigned *, unsigned,unsigned);
const char *ident; const char *ident;
} menu_ctx_driver_backend_t; } menu_ctx_driver_backend_t;

View File

@ -1278,14 +1278,14 @@ static int menu_setting_ok_toggle(unsigned type,
"", label, type, driver.menu->selection_ptr); "", label, type, driver.menu->selection_ptr);
return 0; return 0;
} }
else if (menu_common_type_is(type) == MENU_FILE_DIRECTORY) else if (menu_common_type_is(label, type) == MENU_FILE_DIRECTORY)
{ {
menu_entries_push(driver.menu->menu_stack, menu_entries_push(driver.menu->menu_stack,
"", label, type, driver.menu->selection_ptr); "", label, type, driver.menu->selection_ptr);
return 0; return 0;
} }
else if ( else if (
menu_common_type_is(type) == MENU_SETTINGS || menu_common_type_is(label, type) == MENU_SETTINGS ||
type == MENU_SETTINGS_CORE || type == MENU_SETTINGS_CORE ||
type == MENU_SETTINGS_CONFIG || type == MENU_SETTINGS_CONFIG ||
type == MENU_SETTINGS_DISK_APPEND type == MENU_SETTINGS_DISK_APPEND
@ -1989,7 +1989,7 @@ static int menu_common_iterate(unsigned action)
return menu_start_screen_iterate(action); return menu_start_screen_iterate(action);
else if (!strcmp(menu_label, "info_screen")) else if (!strcmp(menu_label, "info_screen"))
return menu_info_screen_iterate(action); return menu_info_screen_iterate(action);
else if (menu_common_type_is(menu_type) == MENU_SETTINGS) else if (menu_common_type_is(menu_label, menu_type) == MENU_SETTINGS)
return menu_settings_iterate(action); return menu_settings_iterate(action);
else if ( else if (
menu_type == MENU_SETTINGS_CUSTOM_VIEWPORT || menu_type == MENU_SETTINGS_CUSTOM_VIEWPORT ||

View File

@ -302,7 +302,7 @@ static void rgui_render(void)
if (driver.menu_ctx && driver.menu_ctx->backend && if (driver.menu_ctx && driver.menu_ctx->backend &&
driver.menu_ctx->backend->type_is) driver.menu_ctx->backend->type_is)
menu_type_is = driver.menu_ctx->backend->type_is(menu_type); menu_type_is = driver.menu_ctx->backend->type_is(label, menu_type);
#if 0 #if 0
RARCH_LOG("Dir is: %s\n", label); RARCH_LOG("Dir is: %s\n", label);
@ -354,7 +354,7 @@ static void rgui_render(void)
unsigned w = 19; unsigned w = 19;
(void)setting; (void)setting;
if (menu_type == MENU_SETTINGS_PERFORMANCE_COUNTERS) if (!strcmp(label, "performance_counters"))
w = 28; w = 28;
else if (menu_type == MENU_SETTINGS_INPUT_OPTIONS || else if (menu_type == MENU_SETTINGS_INPUT_OPTIONS ||
menu_type == MENU_SETTINGS_CUSTOM_BIND || menu_type == MENU_SETTINGS_CUSTOM_BIND ||

View File

@ -165,7 +165,7 @@ static void rmenu_render(void)
if (driver.menu_ctx && driver.menu_ctx->backend if (driver.menu_ctx && driver.menu_ctx->backend
&& driver.menu_ctx->backend->type_is) && driver.menu_ctx->backend->type_is)
menu_type_is = driver.menu_ctx->backend->type_is(menu_type); menu_type_is = driver.menu_ctx->backend->type_is(label, menu_type);
get_title(label, dir, menu_type, menu_type_is, get_title(label, dir, menu_type, menu_type_is,
title, sizeof(title)); title, sizeof(title));

View File

@ -389,7 +389,7 @@ static void rmenu_xui_render(void)
if (driver.menu_ctx && driver.menu_ctx->backend if (driver.menu_ctx && driver.menu_ctx->backend
&& driver.menu_ctx->backend->type_is) && driver.menu_ctx->backend->type_is)
menu_type_is = driver.menu_ctx->backend->type_is(menu_type); menu_type_is = driver.menu_ctx->backend->type_is(label, menu_type);
get_title(label, dir, menu_type, menu_type_is, get_title(label, dir, menu_type, menu_type_is,
title, sizeof(title)); title, sizeof(title));

View File

@ -31,7 +31,7 @@ static void get_title(const char *label, const char *dir,
strlcpy(title, "SETTINGS", sizeof_title); strlcpy(title, "SETTINGS", sizeof_title);
else if (menu_type == MENU_SETTINGS_DRIVERS) else if (menu_type == MENU_SETTINGS_DRIVERS)
strlcpy(title, "DRIVER OPTIONS", sizeof_title); strlcpy(title, "DRIVER OPTIONS", sizeof_title);
else if (menu_type == MENU_SETTINGS_PERFORMANCE_COUNTERS) else if (!strcmp(label, "performance_counters"))
strlcpy(title, "PERFORMANCE COUNTERS", sizeof_title); strlcpy(title, "PERFORMANCE COUNTERS", sizeof_title);
else if (menu_type == MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO) else if (menu_type == MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO)
strlcpy(title, "CORE PERFORMANCE COUNTERS", sizeof_title); strlcpy(title, "CORE PERFORMANCE COUNTERS", sizeof_title);

View File

@ -640,7 +640,7 @@ void menu_build_scroll_indices(file_list_t *buf)
buf->size - 1; buf->size - 1;
} }
unsigned menu_common_type_is(unsigned type) unsigned menu_common_type_is(const char *label, unsigned type)
{ {
if ( if (
type == MENU_SETTINGS || type == MENU_SETTINGS ||
@ -661,7 +661,7 @@ unsigned menu_common_type_is(unsigned type)
type == MENU_SETTINGS_NETPLAY_OPTIONS || type == MENU_SETTINGS_NETPLAY_OPTIONS ||
type == MENU_SETTINGS_OPTIONS || type == MENU_SETTINGS_OPTIONS ||
type == MENU_SETTINGS_DRIVERS || type == MENU_SETTINGS_DRIVERS ||
type == MENU_SETTINGS_PERFORMANCE_COUNTERS || !strcmp(label, "performance_counters") ||
type == MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO || type == MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO ||
type == MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND || type == MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND ||
type == MENU_SETTINGS_INPUT_OPTIONS type == MENU_SETTINGS_INPUT_OPTIONS

View File

@ -119,7 +119,6 @@ typedef enum
MENU_SETTINGS_PRIVACY_OPTIONS, MENU_SETTINGS_PRIVACY_OPTIONS,
MENU_SETTINGS_OPTIONS, MENU_SETTINGS_OPTIONS,
MENU_SETTINGS_DRIVERS, MENU_SETTINGS_DRIVERS,
MENU_SETTINGS_PERFORMANCE_COUNTERS,
MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO, MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO,
MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND, MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND,
MENU_SETTINGS_DISK_OPTIONS, MENU_SETTINGS_DISK_OPTIONS,
@ -188,7 +187,7 @@ void menu_update_system_info(menu_handle_t *menu, bool *load_no_content);
void menu_build_scroll_indices(file_list_t *buf); void menu_build_scroll_indices(file_list_t *buf);
unsigned menu_common_type_is(unsigned type); unsigned menu_common_type_is(const char *label, unsigned type);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -109,7 +109,7 @@ int menu_entries_push_list(menu_handle_t *menu,
add_setting_entry(menu,list,"core_options", MENU_SETTINGS_CORE_OPTIONS, setting_data); add_setting_entry(menu,list,"core_options", MENU_SETTINGS_CORE_OPTIONS, setting_data);
add_setting_entry(menu,list,"core_information", MENU_SETTINGS_CORE_INFO, setting_data); add_setting_entry(menu,list,"core_information", MENU_SETTINGS_CORE_INFO, setting_data);
add_setting_entry(menu,list,"settings", MENU_SETTINGS_OPTIONS, setting_data); add_setting_entry(menu,list,"settings", MENU_SETTINGS_OPTIONS, setting_data);
add_setting_entry(menu,list,"performance_counters", MENU_SETTINGS_PERFORMANCE_COUNTERS, setting_data); add_setting_entry(menu,list,"performance_counters", MENU_FILE_SWITCH, setting_data);
add_setting_entry(menu,list,"savestate", 0, setting_data); add_setting_entry(menu,list,"savestate", 0, setting_data);
add_setting_entry(menu,list,"loadstate", 0, setting_data); add_setting_entry(menu,list,"loadstate", 0, setting_data);
add_setting_entry(menu,list,"take_screenshot", 0, setting_data); add_setting_entry(menu,list,"take_screenshot", 0, setting_data);
@ -175,6 +175,14 @@ int menu_entries_push_list(menu_handle_t *menu,
do_action = true; do_action = true;
} }
} }
else if (!strcmp(label, "performance_counters"))
{
file_list_clear(list);
file_list_push(list, "Frontend Counters", "",
MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND, 0);
file_list_push(list, "Core Counters", "",
MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO, 0);
}
else else
{ {
switch (menu_type) switch (menu_type)
@ -535,13 +543,6 @@ int menu_entries_push_list(menu_handle_t *menu,
add_setting_entry(menu,list,"location_driver", 0, setting_data); add_setting_entry(menu,list,"location_driver", 0, setting_data);
add_setting_entry(menu,list,"menu_driver", 0, setting_data); add_setting_entry(menu,list,"menu_driver", 0, setting_data);
break; break;
case MENU_SETTINGS_PERFORMANCE_COUNTERS:
file_list_clear(list);
file_list_push(list, "Frontend Counters", "",
MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND, 0);
file_list_push(list, "Core Counters", "",
MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO, 0);
break;
case MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO: case MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO:
file_list_clear(list); file_list_clear(list);
menu_entries_push_perfcounter(menu, list, perf_counters_libretro, menu_entries_push_perfcounter(menu, list, perf_counters_libretro,
@ -576,8 +577,8 @@ int menu_parse_check(const char *label, unsigned menu_type)
RARCH_LOG("label is menu_parse_check: %s\n", label); RARCH_LOG("label is menu_parse_check: %s\n", label);
#endif #endif
if (!((menu_type == MENU_FILE_DIRECTORY || if (!((menu_type == MENU_FILE_DIRECTORY ||
menu_common_type_is(menu_type) == MENU_SETTINGS_SHADER_OPTIONS || menu_common_type_is(label, menu_type) == MENU_SETTINGS_SHADER_OPTIONS ||
menu_common_type_is(menu_type) == MENU_FILE_DIRECTORY || menu_common_type_is(label, menu_type) == MENU_FILE_DIRECTORY ||
menu_type == MENU_SETTINGS_OVERLAY_PRESET || menu_type == MENU_SETTINGS_OVERLAY_PRESET ||
menu_type == MENU_CONTENT_HISTORY_PATH || menu_type == MENU_CONTENT_HISTORY_PATH ||
!strcmp(label, "video_filter") || !strcmp(label, "video_filter") ||
@ -723,7 +724,7 @@ int menu_parse_and_resolve(file_list_t *list, file_list_t *menu_list)
exts = "cfg"; exts = "cfg";
else if (menu_type == MENU_CONTENT_HISTORY_PATH) else if (menu_type == MENU_CONTENT_HISTORY_PATH)
exts = "cfg"; exts = "cfg";
else if (menu_common_type_is(menu_type) == MENU_FILE_DIRECTORY) else if (menu_common_type_is(label, menu_type) == MENU_FILE_DIRECTORY)
exts = ""; /* we ignore files anyway */ exts = ""; /* we ignore files anyway */
else if (driver.menu->defer_core) else if (driver.menu->defer_core)
exts = g_extern.core_info ? core_info_list_get_all_extensions( exts = g_extern.core_info ? core_info_list_get_all_extensions(
@ -746,7 +747,7 @@ int menu_parse_and_resolve(file_list_t *list, file_list_t *menu_list)
dir_list_sort(str_list, true); dir_list_sort(str_list, true);
if (menu_common_type_is(menu_type) == MENU_FILE_DIRECTORY) if (menu_common_type_is(label, menu_type) == MENU_FILE_DIRECTORY)
file_list_push(list, "<Use this directory>", "", file_list_push(list, "<Use this directory>", "",
MENU_FILE_USE_DIRECTORY, 0); MENU_FILE_USE_DIRECTORY, 0);
@ -755,7 +756,7 @@ int menu_parse_and_resolve(file_list_t *list, file_list_t *menu_list)
{ {
bool is_dir = str_list->elems[i].attr.b; bool is_dir = str_list->elems[i].attr.b;
if ((menu_common_type_is(menu_type) == MENU_FILE_DIRECTORY) && !is_dir) if ((menu_common_type_is(label, menu_type) == MENU_FILE_DIRECTORY) && !is_dir)
continue; continue;
/* Need to preserve slash first time. */ /* Need to preserve slash first time. */