(RGUI) Cut down on ifdef party

This commit is contained in:
twinaphex 2013-03-11 04:57:17 +01:00
parent 2a1bfde771
commit 91d35e2e41
2 changed files with 12 additions and 44 deletions

View File

@ -222,14 +222,12 @@ static void init_font(rgui_handle_t *rgui, const uint8_t *font_bmp_buf)
rgui_handle_t *rgui_init(const char *base_path, rgui_handle_t *rgui_init(const char *base_path,
uint16_t *framebuf, size_t framebuf_pitch, uint16_t *framebuf, size_t framebuf_pitch,
const uint8_t *font_bmp_buf, const uint8_t *font_bin_buf, const uint8_t *font_bmp_buf, const uint8_t *font_bin_buf)
void *userdata)
{ {
rgui_handle_t *rgui = (rgui_handle_t*)calloc(1, sizeof(*rgui)); rgui_handle_t *rgui = (rgui_handle_t*)calloc(1, sizeof(*rgui));
rgui->frame_buf = framebuf; rgui->frame_buf = framebuf;
rgui->frame_buf_pitch = framebuf_pitch; rgui->frame_buf_pitch = framebuf_pitch;
rgui->userdata = userdata;
strlcpy(rgui->base_path, base_path, sizeof(rgui->base_path)); strlcpy(rgui->base_path, base_path, sizeof(rgui->base_path));
rgui->menu_stack = (rgui_list_t*)calloc(1, sizeof(rgui_list_t)); rgui->menu_stack = (rgui_list_t*)calloc(1, sizeof(rgui_list_t));
@ -399,11 +397,9 @@ static void render_text(rgui_handle_t *rgui)
unsigned menu_type = 0; unsigned menu_type = 0;
rgui_list_get_last(rgui->menu_stack, &dir, &menu_type, NULL); rgui_list_get_last(rgui->menu_stack, &dir, &menu_type, NULL);
#ifdef HAVE_LIBRETRO_MANAGEMENT
if (menu_type == RGUI_SETTINGS_CORE) if (menu_type == RGUI_SETTINGS_CORE)
snprintf(title, sizeof(title), "CORE SELECTION"); snprintf(title, sizeof(title), "CORE SELECTION");
else else
#endif
if (rgui_is_controller_menu(menu_type) || rgui_is_viewport_menu(menu_type) || menu_type == RGUI_SETTINGS) if (rgui_is_controller_menu(menu_type) || rgui_is_viewport_menu(menu_type) || menu_type == RGUI_SETTINGS)
snprintf(title, sizeof(title), "SETTINGS: %s", dir); snprintf(title, sizeof(title), "SETTINGS: %s", dir);
else else
@ -455,11 +451,9 @@ static void render_text(rgui_handle_t *rgui)
case RGUI_SETTINGS_VIDEO_FILTER: case RGUI_SETTINGS_VIDEO_FILTER:
snprintf(type_str, sizeof(type_str), g_settings.video.smooth ? "Bilinear filtering" : "Point filtering"); snprintf(type_str, sizeof(type_str), g_settings.video.smooth ? "Bilinear filtering" : "Point filtering");
break; break;
#ifdef HW_RVL
case RGUI_SETTINGS_VIDEO_SOFT_FILTER: case RGUI_SETTINGS_VIDEO_SOFT_FILTER:
snprintf(type_str, sizeof(type_str), (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE)) ? "ON" : "OFF"); snprintf(type_str, sizeof(type_str), (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE)) ? "ON" : "OFF");
break; break;
#endif
#ifdef GEKKO #ifdef GEKKO
case RGUI_SETTINGS_VIDEO_RESOLUTION: case RGUI_SETTINGS_VIDEO_RESOLUTION:
snprintf(type_str, sizeof(type_str), "%s", gx_get_video_mode()); snprintf(type_str, sizeof(type_str), "%s", gx_get_video_mode());
@ -488,11 +482,9 @@ static void render_text(rgui_handle_t *rgui)
snprintf(type_str, sizeof(type_str), "%.3f", g_settings.audio.rate_control_delta); snprintf(type_str, sizeof(type_str), "%.3f", g_settings.audio.rate_control_delta);
break; break;
case RGUI_SETTINGS_RESAMPLER_TYPE: case RGUI_SETTINGS_RESAMPLER_TYPE:
#ifdef HAVE_SINC
if (strstr(g_settings.audio.resampler, "sinc")) if (strstr(g_settings.audio.resampler, "sinc"))
snprintf(type_str, sizeof(type_str), "Sinc"); snprintf(type_str, sizeof(type_str), "Sinc");
else else
#endif
snprintf(type_str, sizeof(type_str), "Hermite"); snprintf(type_str, sizeof(type_str), "Hermite");
break; break;
case RGUI_SETTINGS_SRAM_DIR: case RGUI_SETTINGS_SRAM_DIR:
@ -506,9 +498,7 @@ static void render_text(rgui_handle_t *rgui)
break; break;
case RGUI_SETTINGS_OPEN_FILEBROWSER: case RGUI_SETTINGS_OPEN_FILEBROWSER:
case RGUI_SETTINGS_CUSTOM_VIEWPORT: case RGUI_SETTINGS_CUSTOM_VIEWPORT:
#ifdef HAVE_LIBRETRO_MANAGEMENT
case RGUI_SETTINGS_CORE: case RGUI_SETTINGS_CORE:
#endif
case RGUI_SETTINGS_CONTROLLER_1: case RGUI_SETTINGS_CONTROLLER_1:
case RGUI_SETTINGS_CONTROLLER_2: case RGUI_SETTINGS_CONTROLLER_2:
case RGUI_SETTINGS_CONTROLLER_3: case RGUI_SETTINGS_CONTROLLER_3:
@ -668,7 +658,6 @@ static int rgui_settings_toggle_setting(unsigned setting, rgui_action_t action,
} }
break; break;
#endif #endif
#ifndef HAVE_DYNAMIC
case RGUI_SETTINGS_RESTART_GAME: case RGUI_SETTINGS_RESTART_GAME:
if (action == RGUI_ACTION_OK) if (action == RGUI_ACTION_OK)
{ {
@ -677,7 +666,6 @@ static int rgui_settings_toggle_setting(unsigned setting, rgui_action_t action,
return -1; return -1;
} }
break; break;
#endif
case RGUI_SETTINGS_VIDEO_FILTER: case RGUI_SETTINGS_VIDEO_FILTER:
if (action == RGUI_ACTION_START) if (action == RGUI_ACTION_START)
menu_settings_set_default(S_DEF_HW_TEXTURE_FILTER); menu_settings_set_default(S_DEF_HW_TEXTURE_FILTER);
@ -866,7 +854,6 @@ static int rgui_settings_toggle_setting(unsigned setting, rgui_action_t action,
else if (action == RGUI_ACTION_RIGHT) else if (action == RGUI_ACTION_RIGHT)
g_extern.lifecycle_mode_state |= (1ULL << MODE_FPS_DRAW); g_extern.lifecycle_mode_state |= (1ULL << MODE_FPS_DRAW);
break; break;
#ifndef HAVE_DYNAMIC
case RGUI_SETTINGS_RESTART_EMULATOR: case RGUI_SETTINGS_RESTART_EMULATOR:
if (action == RGUI_ACTION_OK) if (action == RGUI_ACTION_OK)
{ {
@ -879,7 +866,6 @@ static int rgui_settings_toggle_setting(unsigned setting, rgui_action_t action,
return -1; return -1;
} }
break; break;
#endif
case RGUI_SETTINGS_QUIT_EMULATOR: case RGUI_SETTINGS_QUIT_EMULATOR:
if (action == RGUI_ACTION_OK) if (action == RGUI_ACTION_OK)
{ {
@ -1208,11 +1194,7 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
case RGUI_ACTION_RIGHT: case RGUI_ACTION_RIGHT:
case RGUI_ACTION_OK: case RGUI_ACTION_OK:
case RGUI_ACTION_START: case RGUI_ACTION_START:
if ((rgui_is_controller_menu(type) if ((rgui_is_controller_menu(type) || type == RGUI_SETTINGS_CORE)
#ifdef HAVE_LIBRETRO_MANAGEMENT
|| type == RGUI_SETTINGS_CORE
#endif
)
&& action == RGUI_ACTION_OK) && action == RGUI_ACTION_OK)
{ {
rgui_list_push(rgui->menu_stack, label, type, rgui->selection_ptr); rgui_list_push(rgui->menu_stack, label, type, rgui->selection_ptr);
@ -1256,11 +1238,8 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
rgui_list_get_last(rgui->menu_stack, &dir, &menu_type, &directory_ptr); rgui_list_get_last(rgui->menu_stack, &dir, &menu_type, &directory_ptr);
if (rgui->need_refresh && !(menu_type == RGUI_FILE_DIRECTORY || menu_type == RGUI_FILE_DEVICE if (rgui->need_refresh && !(menu_type == RGUI_FILE_DIRECTORY ||
#ifdef HAVE_LIBRETRO_MANAGEMENT menu_type == RGUI_FILE_DEVICE || menu_type == RGUI_SETTINGS_CORE))
|| menu_type == RGUI_SETTINGS_CORE
#endif
))
{ {
rgui->need_refresh = false; rgui->need_refresh = false;
if (rgui_is_controller_menu(menu_type)) if (rgui_is_controller_menu(menu_type))
@ -1276,11 +1255,7 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
static bool directory_parse(const char *directory, void *userdata, void *ctx) static bool directory_parse(const char *directory, void *userdata, void *ctx)
{ {
#ifdef HAVE_LIBRETRO_MANAGEMENT
bool core_chooser = (userdata) ? *(unsigned*)userdata == RGUI_SETTINGS_CORE : false; bool core_chooser = (userdata) ? *(unsigned*)userdata == RGUI_SETTINGS_CORE : false;
#else
bool core_chooser = false;
#endif
if (!*directory) if (!*directory)
{ {
@ -1332,11 +1307,12 @@ static bool directory_parse(const char *directory, void *userdata, void *ctx)
for (size_t i = 0; i < list->size; i++) for (size_t i = 0; i < list->size; i++)
{ {
bool is_dir = list->elems[i].attr.b; bool is_dir = list->elems[i].attr.b;
if (core_chooser && (is_dir
#ifdef HAVE_LIBRETRO_MANAGEMENT #ifdef HAVE_LIBRETRO_MANAGEMENT
if (core_chooser && (is_dir || || strcasecmp(list->elems[i].data, default_paths.salamander_file) == 0
strcasecmp(list->elems[i].data, default_paths.salamander_file) == 0))
continue;
#endif #endif
))
continue;
rgui_list_push(ctx, path_basename(list->elems[i].data), rgui_list_push(ctx, path_basename(list->elems[i].data),
is_dir ? RGUI_FILE_DIRECTORY : RGUI_FILE_PLAIN, 0); is_dir ? RGUI_FILE_DIRECTORY : RGUI_FILE_PLAIN, 0);
@ -1497,11 +1473,8 @@ int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
// refresh values in case the stack changed // refresh values in case the stack changed
rgui_list_get_last(rgui->menu_stack, &dir, &menu_type, &directory_ptr); rgui_list_get_last(rgui->menu_stack, &dir, &menu_type, &directory_ptr);
if (rgui->need_refresh && (menu_type == RGUI_FILE_DIRECTORY || menu_type == RGUI_FILE_DEVICE if (rgui->need_refresh && (menu_type == RGUI_FILE_DIRECTORY ||
#ifdef HAVE_LIBRETRO_MANAGEMENT menu_type == RGUI_FILE_DEVICE || menu_type == RGUI_SETTINGS_CORE))
|| menu_type == RGUI_SETTINGS_CORE
#endif
))
{ {
rgui->need_refresh = false; rgui->need_refresh = false;
rgui_list_clear(rgui->selection_buf); rgui_list_clear(rgui->selection_buf);
@ -1581,7 +1554,7 @@ void menu_init(void)
{ {
rgui = rgui_init("", rgui = rgui_init("",
menu_framebuf, RGUI_WIDTH * sizeof(uint16_t), menu_framebuf, RGUI_WIDTH * sizeof(uint16_t),
NULL, bitmap_bin, NULL); NULL, bitmap_bin);
rgui_iterate(rgui, RGUI_ACTION_REFRESH); rgui_iterate(rgui, RGUI_ACTION_REFRESH);
} }

View File

@ -43,9 +43,7 @@ typedef enum
#endif #endif
RGUI_SETTINGS_RESTART_GAME, RGUI_SETTINGS_RESTART_GAME,
RGUI_SETTINGS_VIDEO_FILTER, RGUI_SETTINGS_VIDEO_FILTER,
#ifdef HW_RVL
RGUI_SETTINGS_VIDEO_SOFT_FILTER, RGUI_SETTINGS_VIDEO_SOFT_FILTER,
#endif
#ifdef GEKKO #ifdef GEKKO
RGUI_SETTINGS_VIDEO_RESOLUTION, RGUI_SETTINGS_VIDEO_RESOLUTION,
#endif #endif
@ -61,9 +59,7 @@ typedef enum
RGUI_SETTINGS_ZIP_EXTRACT, RGUI_SETTINGS_ZIP_EXTRACT,
RGUI_SETTINGS_SRAM_DIR, RGUI_SETTINGS_SRAM_DIR,
RGUI_SETTINGS_STATE_DIR, RGUI_SETTINGS_STATE_DIR,
#ifdef HAVE_LIBRETRO_MANAGEMENT
RGUI_SETTINGS_CORE, RGUI_SETTINGS_CORE,
#endif
RGUI_SETTINGS_CONTROLLER_1, RGUI_SETTINGS_CONTROLLER_1,
RGUI_SETTINGS_CONTROLLER_2, RGUI_SETTINGS_CONTROLLER_2,
RGUI_SETTINGS_CONTROLLER_3, RGUI_SETTINGS_CONTROLLER_3,
@ -119,8 +115,7 @@ extern unsigned RGUI_HEIGHT;
rgui_handle_t *rgui_init(const char *base_path, rgui_handle_t *rgui_init(const char *base_path,
uint16_t *framebuf, size_t framebuf_pitch, uint16_t *framebuf, size_t framebuf_pitch,
const uint8_t *font_bmp_buf, const uint8_t *font_bin_buf, const uint8_t *font_bmp_buf, const uint8_t *font_bin_buf);
void *userdata);
int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action); int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action);