(Menu) Cleanups / split up duplicate entries_refresh code into

separate static function
This commit is contained in:
twinaphex 2014-09-01 02:11:51 +02:00
parent 140db3d689
commit c0b100002c
2 changed files with 70 additions and 41 deletions

View File

@ -33,13 +33,15 @@ void menu_update_system_info(menu_handle_t *menu, bool *load_no_content)
if (core_info_list_get_info(menu->core_info,
menu->core_info_current, g_settings.libretro))
{
const core_info_t *info = (const core_info_t*)menu->core_info_current;
const core_info_t *info = (const core_info_t*)
menu->core_info_current;
RARCH_LOG("[Core Info]:\n");
if (info->display_name)
RARCH_LOG(" Display Name: %s\n", info->display_name);
if (info->supported_extensions)
RARCH_LOG(" Supported Extensions: %s\n", info->supported_extensions);
RARCH_LOG(" Supported Extensions: %s\n",
info->supported_extensions);
if (info->authors)
RARCH_LOG(" Authors: %s\n", info->authors);
if (info->permissions)
@ -129,7 +131,8 @@ static void load_menu_content_prepare(void)
content_playlist_push(g_extern.history,
*g_extern.fullpath ? g_extern.fullpath : NULL,
g_settings.libretro,
driver.menu->info.library_name ? driver.menu->info.library_name : "");
driver.menu->info.library_name ?
driver.menu->info.library_name : "");
}
/* redraw menu frame */
@ -137,17 +140,21 @@ static void load_menu_content_prepare(void)
driver.menu->do_held = false;
driver.menu->msg_force = true;
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->iterate)
if (driver.menu_ctx && driver.menu_ctx->backend &&
driver.menu_ctx->backend->iterate)
driver.menu_ctx->backend->iterate(MENU_ACTION_NOOP);
/* Draw frame for loading message */
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data, driver.menu->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
if (driver.video_data && driver.video_poke &&
driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data,
driver.menu->frame_buf_show, MENU_TEXTURE_FULLSCREEN);
if (driver.video)
rarch_render_cached_frame();
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
if (driver.video_data && driver.video_poke &&
driver.video_poke->set_texture_enable)
driver.video_poke->set_texture_enable(driver.video_data, false,
MENU_TEXTURE_FULLSCREEN);
}
@ -189,7 +196,8 @@ static void menu_update_libretro_info(menu_handle_t *menu)
menu_update_system_info(menu, NULL);
}
static void menu_environment_get(int *argc, char *argv[], void *args, void *params_data)
static void menu_environment_get(int *argc, char *argv[],
void *args, void *params_data)
{
struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*)params_data;
@ -582,9 +590,11 @@ bool menu_save_new_config(void)
for (i = 0; i < 16; i++)
{
char tmp[64];
fill_pathname_base(config_name, g_settings.libretro, sizeof(config_name));
fill_pathname_base(config_name, g_settings.libretro,
sizeof(config_name));
path_remove_extension(config_name);
fill_pathname_join(config_path, config_dir, config_name, sizeof(config_path));
fill_pathname_join(config_path, config_dir, config_name,
sizeof(config_path));
*tmp = '\0';
@ -614,8 +624,10 @@ bool menu_save_new_config(void)
if (config_save_file(config_path))
{
strlcpy(g_extern.config_path, config_path, sizeof(g_extern.config_path));
snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", config_path);
strlcpy(g_extern.config_path, config_path,
sizeof(g_extern.config_path));
snprintf(msg, sizeof(msg), "Saved new config to \"%s\".",
config_path);
RARCH_LOG("%s\n", msg);
ret = true;
}
@ -631,7 +643,8 @@ bool menu_save_new_config(void)
return ret;
}
static inline int menu_list_get_first_char(file_list_t *buf, unsigned offset)
static inline int menu_list_get_first_char(file_list_t *buf,
unsigned offset)
{
int ret;
const char *path = NULL;
@ -691,7 +704,8 @@ void menu_build_scroll_indices(file_list_t *buf)
current_is_dir = is_dir;
}
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = buf->size - 1;
driver.menu->scroll_indices[driver.menu->scroll_indices_size++] =
buf->size - 1;
}
void menu_push_info_screen(void)

View File

@ -19,25 +19,40 @@
#include "../../settings_data.h"
#include "../../file_ext.h"
static inline struct gfx_shader *shader_manager_get_current_shader(menu_handle_t *menu, unsigned type)
static void entries_refresh(void)
{
/* Before a refresh, we could have deleted a file on disk, causing
* selection_ptr to suddendly be out of range.
* Ensure it doesn't overflow. */
if (driver.menu->selection_ptr >= file_list_get_size(
driver.menu->selection_buf) &&
file_list_get_size(driver.menu->selection_buf))
menu_set_navigation(driver.menu, file_list_get_size(driver.menu->selection_buf) - 1);
else if (!file_list_get_size(driver.menu->selection_buf))
menu_clear_navigation(driver.menu);
}
static inline struct gfx_shader *shader_manager_get_current_shader(
menu_handle_t *menu, unsigned type)
{
if (type == MENU_SETTINGS_SHADER_PRESET_PARAMETERS)
return menu->shader;
else if (driver.video_poke && driver.video_data && driver.video_poke->get_current_shader)
else if (driver.video_poke && driver.video_data &&
driver.video_poke->get_current_shader)
return driver.video_poke->get_current_shader(driver.video_data);
return NULL;
}
static void add_setting_entry(menu_handle_t *menu, const char *label, unsigned id,
static void add_setting_entry(menu_handle_t *menu,
const char *label, unsigned id,
rarch_setting_t *settings)
{
rarch_setting_t *setting = (rarch_setting_t*)
setting_data_find_setting(settings, label);
if (setting)
file_list_push(menu->selection_buf, setting->short_description, setting->name,
id, 0);
file_list_push(menu->selection_buf, setting->short_description,
setting->name, id, 0);
}
int menu_entries_push(menu_handle_t *menu,
@ -47,7 +62,8 @@ int menu_entries_push(menu_handle_t *menu,
unsigned i;
char tmp[256];
size_t list_size = 0;
rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list();
rarch_setting_t *setting_data = (rarch_setting_t *)
setting_data_get_list();
bool do_action = false;
#if 0
@ -123,7 +139,8 @@ int menu_entries_push(menu_handle_t *menu,
if (path)
{
char path_short[PATH_MAX];
fill_pathname(path_short, path_basename(path), "", sizeof(path_short));
fill_pathname(path_short, path_basename(path), "",
sizeof(path_short));
snprintf(fill_buf, sizeof(fill_buf), "%s (%s)",
path_short, core_name);
@ -139,12 +156,14 @@ int menu_entries_push(menu_handle_t *menu,
{
const core_info_t *info = NULL;
file_list_clear(driver.menu->selection_buf);
core_info_list_get_supported_cores(driver.menu->core_info, driver.menu->deferred_path, &info, &list_size);
core_info_list_get_supported_cores(driver.menu->core_info,
driver.menu->deferred_path, &info, &list_size);
for (i = 0; i < list_size; i++)
{
file_list_push(driver.menu->selection_buf, info[i].path, "",
MENU_FILE_PLAIN, 0);
file_list_set_alt_at_offset(driver.menu->selection_buf, i, info[i].display_name);
file_list_set_alt_at_offset(driver.menu->selection_buf, i,
info[i].display_name);
}
file_list_sort_on_alt(driver.menu->selection_buf);
@ -535,12 +554,7 @@ int menu_entries_push(menu_handle_t *menu,
if (menu_type != MENU_SETTINGS_OPEN_HISTORY)
menu_build_scroll_indices(driver.menu->selection_buf);
// Before a refresh, we could have deleted a file on disk, causing
// selection_ptr to suddendly be out of range. Ensure it doesn't overflow.
if (driver.menu->selection_ptr >= file_list_get_size(driver.menu->selection_buf) && file_list_get_size(driver.menu->selection_buf))
menu_set_navigation(driver.menu, file_list_get_size(driver.menu->selection_buf) - 1);
else if (!file_list_get_size(driver.menu->selection_buf))
menu_clear_navigation(driver.menu);
entries_refresh();
}
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
@ -549,6 +563,7 @@ int menu_entries_push(menu_handle_t *menu,
return 0;
}
int menu_parse_and_resolve(void)
{
size_t i, list_size;
@ -663,7 +678,8 @@ int menu_parse_and_resolve(void)
LWP_MutexLock(gx_device_mutex);
int dev = gx_get_device_from_path(dir);
if (dev != -1 && !gx_devices[dev].mounted && gx_devices[dev].interface->isInserted())
if (dev != -1 && !gx_devices[dev].mounted &&
gx_devices[dev].interface->isInserted())
fatMountSimple(gx_devices[dev].name, gx_devices[dev].interface);
LWP_MutexUnlock(gx_device_mutex);
@ -690,12 +706,14 @@ int menu_parse_and_resolve(void)
else if (menu_common_type_is(menu_type) == MENU_FILE_DIRECTORY)
exts = ""; // we ignore files anyway
else if (driver.menu->defer_core)
exts = driver.menu->core_info ? core_info_list_get_all_extensions(driver.menu->core_info) : "";
exts = driver.menu->core_info ? core_info_list_get_all_extensions(
driver.menu->core_info) : "";
else if (driver.menu->info.valid_extensions)
{
exts = ext_buf;
if (*driver.menu->info.valid_extensions)
snprintf(ext_buf, sizeof(ext_buf), "%s|zip", driver.menu->info.valid_extensions);
snprintf(ext_buf, sizeof(ext_buf), "%s|zip",
driver.menu->info.valid_extensions);
else
*ext_buf = '\0';
}
@ -726,7 +744,8 @@ int menu_parse_and_resolve(void)
path = path_basename(path);
#ifdef HAVE_LIBRETRO_MANAGEMENT
if (menu_type == MENU_SETTINGS_CORE && (is_dir || strcasecmp(path, SALAMANDER_FILE) == 0))
if (menu_type == MENU_SETTINGS_CORE && (is_dir ||
strcasecmp(path, SALAMANDER_FILE) == 0))
continue;
#endif
@ -744,7 +763,8 @@ int menu_parse_and_resolve(void)
case MENU_SETTINGS_CORE:
{
file_list_t *list = (file_list_t*)driver.menu->selection_buf;
file_list_get_last(driver.menu->menu_stack, &dir, NULL, &menu_type);
file_list_get_last(driver.menu->menu_stack, &dir, NULL,
&menu_type);
list_size = file_list_get_size(list);
for (i = 0; i < list_size; i++)
@ -773,12 +793,7 @@ int menu_parse_and_resolve(void)
if (menu_type != MENU_SETTINGS_OPEN_HISTORY)
menu_build_scroll_indices(driver.menu->selection_buf);
// Before a refresh, we could have deleted a file on disk, causing
// selection_ptr to suddendly be out of range. Ensure it doesn't overflow.
if (driver.menu->selection_ptr >= file_list_get_size(driver.menu->selection_buf) && file_list_get_size(driver.menu->selection_buf))
menu_set_navigation(driver.menu, file_list_get_size(driver.menu->selection_buf) - 1);
else if (!file_list_get_size(driver.menu->selection_buf))
menu_clear_navigation(driver.menu);
entries_refresh();
return 0;
}