From f186583728d1c0f71331fa8f2d2b3591fd034ca8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Dec 2016 09:07:03 +0100 Subject: [PATCH] Move filebrowser-dependent code to menu_filebrowser.c --- deps/SPIRV-Cross | 2 +- deps/glslang/glslang | 2 +- menu/cbs/menu_cbs_ok.c | 38 +++++++++++++------------ menu/menu_displaylist.c | 40 +++++++++++++-------------- menu/menu_displaylist.h | 10 ------- menu/widgets/menu_filebrowser.c | 49 +++++++++++++++++++++++---------- menu/widgets/menu_filebrowser.h | 16 +++++++++-- 7 files changed, 88 insertions(+), 69 deletions(-) diff --git a/deps/SPIRV-Cross b/deps/SPIRV-Cross index 5c24d99ff2..875c32fd39 160000 --- a/deps/SPIRV-Cross +++ b/deps/SPIRV-Cross @@ -1 +1 @@ -Subproject commit 5c24d99ff22a25ef38e9e39985f80cf57a1e7418 +Subproject commit 875c32fd39a06f624814effe5eab691b078429f5 diff --git a/deps/glslang/glslang b/deps/glslang/glslang index a4a4d5e22c..be8462149a 160000 --- a/deps/glslang/glslang +++ b/deps/glslang/glslang @@ -1 +1 @@ -Subproject commit a4a4d5e22c375d37bd286106904ef819eafff29b +Subproject commit be8462149a3c150fc89db84e57ef06de3ab90d47 diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index d3dc17ffc7..aaf198a5e4 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -33,6 +33,7 @@ #include "../menu_shader.h" #include "../menu_navigation.h" #include "../widgets/menu_dialog.h" +#include "../widgets/menu_filebrowser.h" #include "../widgets/menu_input_dialog.h" #include "../menu_content.h" @@ -295,7 +296,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_AUDIO_DSP_PLUGIN: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.directory_ptr = idx; info_path = settings->directory.audio_filter; info_label = msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN); @@ -303,7 +304,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; break; case ACTION_OK_DL_SHADER_PASS: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.type = type; info.directory_ptr = idx; info_path = settings->directory.video_shader; @@ -327,7 +328,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_FILE_BROWSER_SELECT_DIR: - filebrowser_types = FILEBROWSER_SELECT_DIR; + filebrowser_set_type(FILEBROWSER_SELECT_DIR); if (path) strlcpy(menu->deferred_path, path, sizeof(menu->deferred_path)); @@ -345,7 +346,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_SHADER_PRESET: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.type = type; info.directory_ptr = idx; info_path = settings->directory.video_shader; @@ -360,7 +361,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_SCAN_DIR_LIST: - filebrowser_types = FILEBROWSER_SCAN_DIR; + filebrowser_set_type(FILEBROWSER_SCAN_DIR); info.type = FILE_TYPE_DIRECTORY; info.directory_ptr = idx; info_path = new_path; @@ -368,7 +369,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SCAN_DIR; break; case ACTION_OK_DL_REMAP_FILE: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.type = type; info.directory_ptr = idx; info_path = settings->directory.input_remapping; @@ -376,9 +377,9 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; break; case ACTION_OK_DL_RECORD_CONFIGFILE: + filebrowser_clear_type(); { global_t *global = global_get_ptr(); - filebrowser_types = FILEBROWSER_NONE; info.type = type; info.directory_ptr = idx; info_path = global->record.config_dir; @@ -387,7 +388,7 @@ int generic_action_ok_displaylist_push(const char *path, } break; case ACTION_OK_DL_DISK_IMAGE_APPEND_LIST: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.type = type; info.directory_ptr = idx; info_path = settings->directory.menu_content; @@ -395,7 +396,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; break; case ACTION_OK_DL_PLAYLIST_COLLECTION: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.type = type; info.directory_ptr = idx; info_path = path; @@ -403,7 +404,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_CHEAT_FILE: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.type = type; info.directory_ptr = idx; info_path = settings->path.cheat_database; @@ -411,7 +412,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; break; case ACTION_OK_DL_CORE_LIST: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info.type = type; info.directory_ptr = idx; info_path = settings->directory.libretro; @@ -419,7 +420,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_CORE; break; case ACTION_OK_DL_CONTENT_COLLECTION_LIST: - filebrowser_types = FILEBROWSER_SELECT_COLLECTION; + filebrowser_set_type(FILEBROWSER_SELECT_COLLECTION); info.type = type; info.directory_ptr = idx; info_path = settings->directory.playlist; @@ -427,7 +428,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_COLLECTION; break; case ACTION_OK_DL_RDB_ENTRY: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); fill_pathname_join_delim(tmp, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RDB_ENTRY_DETAIL), path, '|', sizeof(tmp)); @@ -501,7 +502,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_DATABASE_MANAGER_LIST: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); fill_pathname_join(tmp, settings->path.content_database, path, sizeof(tmp)); @@ -514,7 +515,7 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_GENERIC; break; case ACTION_OK_DL_CURSOR_MANAGER_LIST: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); fill_pathname_join(tmp, settings->directory.cursor, path, sizeof(tmp)); @@ -1838,7 +1839,7 @@ static int action_ok_remap_file_save_game(const char *path, int action_ok_path_use_directory(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); return generic_action_ok(NULL, label, type, idx, entry_idx, ACTION_OK_SET_DIRECTORY, MSG_UNKNOWN); } @@ -3183,7 +3184,8 @@ static int action_ok_push_downloads_dir(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { settings_t *settings = config_get_ptr(); - filebrowser_types = FILEBROWSER_NONE; + + filebrowser_clear_type(); return generic_action_ok_displaylist_push(path, settings->directory.core_assets, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), type, idx, @@ -3215,7 +3217,7 @@ int action_ok_push_filebrowser_list_dir_select(const char *path, static int action_ok_push_default(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); return generic_action_ok_displaylist_push(path, NULL, label, type, idx, entry_idx, ACTION_OK_DL_PUSH_DEFAULT); } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index d97d1581b9..3e0ec54569 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3207,8 +3207,6 @@ static int menu_displaylist_parse_options_remappings( return 0; } -unsigned filebrowser_types = 0; - static int menu_displaylist_parse_playlists( menu_displaylist_info_t *info, bool horizontal) { @@ -3685,7 +3683,7 @@ static bool menu_displaylist_push_internal( } else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_MUSIC_TAB))) { - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type = 42; strlcpy(info->exts, file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT), @@ -3700,7 +3698,7 @@ static bool menu_displaylist_push_internal( } else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_TAB))) { - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type = 42; strlcpy(info->exts, file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT), @@ -3716,7 +3714,7 @@ static bool menu_displaylist_push_internal( else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_IMAGES_TAB))) { - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type = 42; strlcpy(info->exts, file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT), @@ -3751,7 +3749,7 @@ static bool menu_displaylist_push_internal( { settings_t *settings = config_get_ptr(); - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type = 42; strlcpy(info->exts, file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT), @@ -5814,7 +5812,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) info->need_push = true; break; case DISPLAYLIST_DATABASES: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_RDB; strlcpy(info->exts, file_path_str(FILE_PATH_RDB_EXTENSION), @@ -5853,7 +5851,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) info->need_push = true; break; case DISPLAYLIST_DATABASE_CURSORS: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_CURSOR; strlcpy(info->exts, "dbc", sizeof(info->exts)); strlcpy(info->path, settings->directory.cursor, sizeof(info->path)); @@ -5864,14 +5862,14 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) ext_name[0] = '\0'; - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_PLAIN; if (frontend_driver_get_core_extension(ext_name, sizeof(ext_name))) strlcpy(info->exts, ext_name, sizeof(info->exts)); } break; case DISPLAYLIST_CONFIG_FILES: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_CONFIG; strlcpy(info->exts, "cfg", sizeof(info->exts)); break; @@ -5882,7 +5880,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) (void)attr; - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_SHADER_PRESET; #ifdef HAVE_CG @@ -5903,7 +5901,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) union string_list_elem_attr attr = {0}; struct string_list *str_list = string_list_new(); - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_SHADER; (void)attr; @@ -5922,12 +5920,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) } break; case DISPLAYLIST_VIDEO_FILTERS: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_VIDEOFILTER; strlcpy(info->exts, "filt", sizeof(info->exts)); break; case DISPLAYLIST_IMAGES: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_IMAGE; { union string_list_elem_attr attr = {0}; @@ -5951,37 +5949,37 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) } break; case DISPLAYLIST_AUDIO_FILTERS: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_AUDIOFILTER; strlcpy(info->exts, "dsp", sizeof(info->exts)); break; case DISPLAYLIST_CHEAT_FILES: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_CHEAT; strlcpy(info->exts, "cht", sizeof(info->exts)); break; case DISPLAYLIST_CONTENT_HISTORY: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_PLAIN; strlcpy(info->exts, "lpl", sizeof(info->exts)); break; case DISPLAYLIST_FONTS: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_FONT; strlcpy(info->exts, "ttf", sizeof(info->exts)); break; case DISPLAYLIST_OVERLAYS: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_OVERLAY; strlcpy(info->exts, "cfg", sizeof(info->exts)); break; case DISPLAYLIST_RECORD_CONFIG_FILES: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_RECORD_CONFIG; strlcpy(info->exts, "cfg", sizeof(info->exts)); break; case DISPLAYLIST_REMAP_FILES: - filebrowser_types = FILEBROWSER_NONE; + filebrowser_clear_type(); info->type_default = FILE_TYPE_REMAP; strlcpy(info->exts, "rmp", sizeof(info->exts)); break; diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index dfd2de0d26..d03324acea 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -159,14 +159,6 @@ enum menu_displaylist_ctl_state DISPLAYLIST_PENDING_CLEAR }; -enum filebrowser_enums -{ - FILEBROWSER_NONE = 0, - FILEBROWSER_SELECT_DIR, - FILEBROWSER_SCAN_DIR, - FILEBROWSER_SELECT_COLLECTION -}; - typedef struct menu_displaylist_info { bool need_sort; @@ -213,8 +205,6 @@ void menu_displaylist_reset_filebrowser(void); bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data); -extern unsigned filebrowser_types; - RETRO_END_DECLS #endif diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index 3b53984b03..5f05b10836 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -27,28 +27,45 @@ #include "../../config.h" #endif +#include "menu_filebrowser.h" #include "menu_input_dialog.h" +#include "../menu_driver.h" +#include "../menu_displaylist.h" +#include "../menu_navigation.h" + #include "../../configuration.h" #include "../../frontend/frontend_driver.h" #include "../../paths.h" -#include "../menu_driver.h" -#include "../menu_navigation.h" + +static enum filebrowser_enums filebrowser_types = FILEBROWSER_NONE; + +void filebrowser_clear_type(void) +{ + filebrowser_types = FILEBROWSER_NONE; +} + +void filebrowser_set_type(enum filebrowser_enums type) +{ + filebrowser_types = type; +} int filebrowser_parse(void *data, void *data2, - enum menu_displaylist_ctl_state type, + unsigned type_data, bool extensions_honored) { size_t i, list_size; - unsigned files_count = 0; - unsigned dirs_count = 0; - bool path_is_compressed = false; - bool filter_ext = false; - struct string_list *str_list = NULL; - unsigned items_found = 0; - settings_t *settings = config_get_ptr(); - menu_handle_t *menu = (menu_handle_t*)data; - menu_displaylist_info_t *info= (menu_displaylist_info_t*)data2; + bool path_is_compressed = false; + bool filter_ext = false; + struct string_list *str_list = NULL; + unsigned items_found = 0; + unsigned files_count = 0; + unsigned dirs_count = 0; + settings_t *settings = config_get_ptr(); + menu_handle_t *menu = (menu_handle_t*)data; + menu_displaylist_info_t *info = (menu_displaylist_info_t*)data2; + enum menu_displaylist_ctl_state type = (enum menu_displaylist_ctl_state) + type_data; if (string_is_empty(info->path)) { @@ -62,7 +79,8 @@ int filebrowser_parse(void *data, void *data2, filter_ext = settings->menu.navigation.browser.filter.supported_extensions_enable; - if (string_is_equal(info->label, msg_hash_to_str(MENU_ENUM_LABEL_SCAN_FILE))) + if (string_is_equal(info->label, + msg_hash_to_str(MENU_ENUM_LABEL_SCAN_FILE))) filter_ext = false; if (extensions_honored) @@ -176,8 +194,9 @@ int filebrowser_parse(void *data, void *data2, file_type = FILE_TYPE_PLAYLIST_COLLECTION; } - if (!is_dir && (settings->multimedia.builtin_mediaplayer_enable || - settings->multimedia.builtin_imageviewer_enable)) + if (!is_dir && + (settings->multimedia.builtin_mediaplayer_enable || + settings->multimedia.builtin_imageviewer_enable)) { switch (path_is_media_type(path)) { diff --git a/menu/widgets/menu_filebrowser.h b/menu/widgets/menu_filebrowser.h index afa3e11db8..ed0f11f8d8 100644 --- a/menu/widgets/menu_filebrowser.h +++ b/menu/widgets/menu_filebrowser.h @@ -24,12 +24,22 @@ #include -#include "../menu_displaylist.h" - RETRO_BEGIN_DECLS +enum filebrowser_enums +{ + FILEBROWSER_NONE = 0, + FILEBROWSER_SELECT_DIR, + FILEBROWSER_SCAN_DIR, + FILEBROWSER_SELECT_COLLECTION +}; + +void filebrowser_clear_type(void); + +void filebrowser_set_type(enum filebrowser_enums type); + int filebrowser_parse(void *data, void *data2, - enum menu_displaylist_ctl_state type, + unsigned type, bool extensions_honored); RETRO_END_DECLS