From 9b4636ff623e3af161262e833c6c281855273ac5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 15 Oct 2021 14:32:07 +0200 Subject: [PATCH] Fixes --disable-menu --- core_option_manager.c | 1 + core_option_manager.h | 4 +- gfx/video_shader_parse.c | 65 +++++++++++++++++++++++++++++++ menu/menu_driver.c | 62 ----------------------------- menu/menu_shader.h | 7 ---- retroarch.c | 22 +++++++++-- retroarch.h | 2 - runloop.h | 2 + tasks/task_audio_mixer.h | 2 +- tasks/task_content.c | 37 +++++++++++++++--- tasks/task_content.h | 7 ++-- tasks/task_netplay_find_content.c | 6 +-- 12 files changed, 128 insertions(+), 89 deletions(-) diff --git a/core_option_manager.c b/core_option_manager.c index f6e314e4ef..9f6b311007 100644 --- a/core_option_manager.c +++ b/core_option_manager.c @@ -25,6 +25,7 @@ #endif #include "core_option_manager.h" +#include "msg_hash.h" #define CORE_OPTION_MANAGER_MAP_TAG "#" #define CORE_OPTION_MANAGER_MAP_DELIM ":" diff --git a/core_option_manager.h b/core_option_manager.h index d2816699f5..157621b27c 100644 --- a/core_option_manager.h +++ b/core_option_manager.h @@ -23,8 +23,10 @@ #include #include #include +#include +#include -#include "retroarch.h" +#include RETRO_BEGIN_DECLS diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index b77bc0e045..e8ace368f2 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -41,6 +41,7 @@ #include "../verbosity.h" #include "../frontend/frontend_driver.h" #include "../command.h" +#include "../list_special.h" #include "../file_path_special.h" #include "../paths.h" #include "../retroarch.h" @@ -1997,6 +1998,67 @@ void dir_free_shader( dir_list->remember_last_preset_dir = shader_remember_last_dir; } +static bool dir_init_shader_internal( + bool shader_remember_last_dir, + struct rarch_dir_shader_list *dir_list, + const char *shader_dir, + const char *shader_file_name, + bool show_hidden_files) +{ + size_t i; + struct string_list *new_list = dir_list_new_special( + shader_dir, DIR_LIST_SHADERS, NULL, show_hidden_files); + bool search_file_name = shader_remember_last_dir && + !string_is_empty(shader_file_name); + + if (!new_list) + return false; + + if (new_list->size < 1) + { + dir_list_free(new_list); + return false; + } + + dir_list_sort(new_list, false); + + dir_list->shader_list = new_list; + dir_list->directory = strdup(shader_dir); + dir_list->selection = 0; + dir_list->shader_loaded = false; + dir_list->remember_last_preset_dir = shader_remember_last_dir; + + if (search_file_name) + { + for (i = 0; i < new_list->size; i++) + { + const char *file_name = NULL; + const char *file_path = new_list->elems[i].data; + + if (string_is_empty(file_path)) + continue; + + /* If a shader file name has been provided, + * search the list for a match and set 'selection' + * index if found */ + file_name = path_basename(file_path); + + if (!string_is_empty(file_name) && + string_is_equal(file_name, shader_file_name)) + { + RARCH_LOG("[Shaders]: %s \"%s\"\n", + msg_hash_to_str(MSG_FOUND_SHADER), + file_path); + + dir_list->selection = i; + break; + } + } + } + + return true; +} + void dir_init_shader( void *menu_driver_data_, settings_t *settings, @@ -2157,6 +2219,7 @@ void dir_check_shader( } } +#ifdef HAVE_MENU /* Check whether the shader referenced by the * current selection index is already loaded */ if (!dir_list->shader_loaded) @@ -2176,6 +2239,7 @@ void dir_check_shader( dir_list->shader_loaded = true; } } +#endif } /* Select next shader in list */ @@ -2337,3 +2401,4 @@ success: strlcpy(s, shader_path, len); return true; } + diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 99679cc31a..58a40dc409 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -39,7 +39,6 @@ #include "menu_driver.h" #include "menu_cbs.h" #include "../driver.h" -#include "../list_special.h" #include "../paths.h" #include "../tasks/task_powerstate.h" #include "../tasks/tasks_internal.h" @@ -4061,67 +4060,6 @@ void menu_driver_set_last_shader_path_int( if (!string_is_empty(file_name)) strlcpy(shader_file, file_name, file_len); } - -bool dir_init_shader_internal( - bool shader_remember_last_dir, - struct rarch_dir_shader_list *dir_list, - const char *shader_dir, - const char *shader_file_name, - bool show_hidden_files) -{ - size_t i; - struct string_list *new_list = dir_list_new_special( - shader_dir, DIR_LIST_SHADERS, NULL, show_hidden_files); - bool search_file_name = shader_remember_last_dir && - !string_is_empty(shader_file_name); - - if (!new_list) - return false; - - if (new_list->size < 1) - { - dir_list_free(new_list); - return false; - } - - dir_list_sort(new_list, false); - - dir_list->shader_list = new_list; - dir_list->directory = strdup(shader_dir); - dir_list->selection = 0; - dir_list->shader_loaded = false; - dir_list->remember_last_preset_dir = shader_remember_last_dir; - - if (search_file_name) - { - for (i = 0; i < new_list->size; i++) - { - const char *file_name = NULL; - const char *file_path = new_list->elems[i].data; - - if (string_is_empty(file_path)) - continue; - - /* If a shader file name has been provided, - * search the list for a match and set 'selection' - * index if found */ - file_name = path_basename(file_path); - - if (!string_is_empty(file_name) && - string_is_equal(file_name, shader_file_name)) - { - RARCH_LOG("[Shaders]: %s \"%s\"\n", - msg_hash_to_str(MSG_FOUND_SHADER), - file_path); - - dir_list->selection = i; - break; - } - } - } - - return true; -} #endif void get_current_menu_value(struct menu_state *menu_st, diff --git a/menu/menu_shader.h b/menu/menu_shader.h index 8208600c00..72672a08c2 100644 --- a/menu/menu_shader.h +++ b/menu/menu_shader.h @@ -173,13 +173,6 @@ void menu_driver_set_last_shader_path_int( char *shader_dir, size_t dir_len, char *shader_file, size_t file_len); -bool dir_init_shader_internal( - bool shader_remember_last_dir, - struct rarch_dir_shader_list *dir_list, - const char *shader_dir, - const char *shader_file_name, - bool show_hidden_files); - RETRO_END_DECLS #endif diff --git a/retroarch.c b/retroarch.c index 7ccc966782..0d7d8942a7 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1549,6 +1549,7 @@ static const void *find_driver_nonempty( return NULL; } +#ifdef HAVE_MENU #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) struct video_shader *menu_shader_get(void) { @@ -1700,6 +1701,7 @@ clear: return ret; } #endif +#endif #ifdef HAVE_DISCORD bool discord_is_ready(void) @@ -6920,14 +6922,24 @@ bool command_event(enum event_command cmd, void *data) break; case CMD_EVENT_SHADER_NEXT: #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) +#ifdef HAVE_MENU dir_check_shader(menu_st->driver_data, settings, &video_st->dir_shader_list, true, false); +#else + dir_check_shader(NULL, settings, + &video_st->dir_shader_list, true, false); +#endif #endif break; case CMD_EVENT_SHADER_PREV: #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) +#ifdef HAVE_MENU dir_check_shader(menu_st->driver_data, settings, &video_st->dir_shader_list, false, true); +#else + dir_check_shader(NULL, settings, + &video_st->dir_shader_list, false, true); +#endif #endif break; case CMD_EVENT_BSV_RECORDING_TOGGLE: @@ -7843,7 +7855,9 @@ bool command_event(enum event_command cmd, void *data) #endif break; case CMD_EVENT_RESUME: +#ifdef HAVE_MENU retroarch_menu_running_finished(false); +#endif if (p_rarch->main_ui_companion_is_on_foreground) { #ifdef HAVE_QT @@ -19147,7 +19161,9 @@ bool retroarch_main_quit(void) } runloop_state.shutdown_initiated = true; +#ifdef HAVE_MENU retroarch_menu_running_finished(true); +#endif return true; } @@ -19343,6 +19359,7 @@ static enum runloop_state_enum runloop_check_state( #endif input_driver_state_t *input_st = input_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr(); + gfx_display_t *p_disp = disp_get_ptr(); runloop_state_t *runloop_st = &runloop_state; static bool old_focus = true; struct retro_callbacks *cbs = &runloop_st->retro_ctx; @@ -19353,12 +19370,11 @@ static enum runloop_state_enum runloop_check_state( bool rarch_is_initialized = p_rarch->rarch_is_inited; bool runloop_paused = runloop_st->paused; bool pause_nonactive = settings->bools.pause_nonactive; + unsigned quit_gamepad_combo = settings->uints.input_quit_gamepad_combo; #ifdef HAVE_MENU struct menu_state *menu_st = menu_state_get_ptr(); menu_handle_t *menu = menu_st->driver_data; unsigned menu_toggle_gamepad_combo = settings->uints.input_menu_toggle_gamepad_combo; - unsigned quit_gamepad_combo = settings->uints.input_quit_gamepad_combo; - gfx_display_t *p_disp = disp_get_ptr(); bool menu_driver_binding_state = menu_st->is_binding; bool menu_is_alive = menu_st->alive; bool display_kb = menu_input_dialog_get_display_kb(); @@ -20098,9 +20114,7 @@ static enum runloop_state_enum runloop_check_state( retroarch_menu_running_finished(false); } else - { retroarch_menu_running(); - } } else menu_st->kb_key_state[RETROK_F1] = diff --git a/retroarch.h b/retroarch.h index 26905afd30..424acc98de 100644 --- a/retroarch.h +++ b/retroarch.h @@ -279,8 +279,6 @@ typedef enum apple_view_type bool retroarch_get_current_savestate_path(char *path, size_t len); -runloop_state_t *runloop_state_get_ptr(void); - struct recording { const record_driver_t *driver; diff --git a/runloop.h b/runloop.h index b87e96be32..b35fc7c41c 100644 --- a/runloop.h +++ b/runloop.h @@ -202,6 +202,8 @@ typedef struct runloop runloop_state_t; RETRO_BEGIN_DECLS +runloop_state_t *runloop_state_get_ptr(void); + RETRO_END_DECLS #endif diff --git a/tasks/task_audio_mixer.h b/tasks/task_audio_mixer.h index 9f27c81384..902c3645ba 100644 --- a/tasks/task_audio_mixer.h +++ b/tasks/task_audio_mixer.h @@ -28,7 +28,7 @@ #include "../config.h" #endif -#include "../retroarch.h" +#include "../audio/audio_defines.h" RETRO_BEGIN_DECLS diff --git a/tasks/task_content.c b/tasks/task_content.c index 73aded7d68..9a941ad677 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1505,8 +1505,10 @@ static bool content_load(content_ctx_info_t *info, #endif #endif +#ifdef HAVE_MENU #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) menu_shader_manager_init(); +#endif #endif command_event(CMD_EVENT_HISTORY_INIT, NULL); @@ -1855,7 +1857,6 @@ bool task_push_start_dummy_core(content_ctx_info_t *content_info) } #ifdef HAVE_MENU - bool task_push_load_content_from_playlist_from_menu( const char *core_path, const char *fullpath, @@ -2077,7 +2078,9 @@ bool task_push_start_current_core(content_ctx_info_t *content_info) free(error_string); } +#ifdef HAVE_MENU retroarch_menu_running(); +#endif goto end; } @@ -2154,7 +2157,7 @@ bool task_push_load_content_with_new_core_from_menu( if (!force_core_reload && (type == CORE_TYPE_PLAIN) && retroarch_ctl(RARCH_CTL_IS_CORE_LOADED, (void*)core_path)) - return task_push_load_content_with_core_from_menu( + return task_push_load_content_with_core( fullpath, content_info, type, cb, user_data); #endif @@ -2453,7 +2456,9 @@ bool task_push_start_builtin_core( /* Load content */ if (!task_load_content_internal(content_info, true, false, false)) { +#ifdef HAVE_MENU retroarch_menu_running(); +#endif return false; } @@ -2465,7 +2470,7 @@ bool task_push_start_builtin_core( return true; } -bool task_push_load_content_with_core_from_menu( +bool task_push_load_content_with_core( const char *fullpath, content_ctx_info_t *content_info, enum rarch_core_type type, @@ -2477,7 +2482,9 @@ bool task_push_load_content_with_core_from_menu( /* Load content */ if (!task_load_content_internal(content_info, true, false, false)) { +#ifdef HAVE_MENU retroarch_menu_running(); +#endif return false; } @@ -2508,12 +2515,28 @@ bool task_push_load_content_with_current_core_from_companion_ui( * > TODO/FIXME: Set loading_from_companion_ui 'false' for * now, until someone can implement the required higher * level functionality in 'win32_common.c' and 'ui_cocoa.m' */ - return task_push_load_content_with_core_from_menu(fullpath, - content_info, type, cb, user_data); + path_set(RARCH_PATH_CONTENT, fullpath); + + /* Load content */ + if (!task_load_content_internal(content_info, true, false, false)) + { +#ifdef HAVE_MENU + retroarch_menu_running(); +#endif + return false; + } + +#ifdef HAVE_MENU + /* Push quick menu onto menu stack */ + if (type != CORE_TYPE_DUMMY) + menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); +#endif + + return true; } -bool task_push_load_subsystem_with_core_from_menu( +bool task_push_load_subsystem_with_core( const char *fullpath, content_ctx_info_t *content_info, enum rarch_core_type type, @@ -2527,7 +2550,9 @@ bool task_push_load_subsystem_with_core_from_menu( /* Load content */ if (!task_load_content_internal(content_info, true, false, false)) { +#ifdef HAVE_MENU retroarch_menu_running(); +#endif return false; } diff --git a/tasks/task_content.h b/tasks/task_content.h index 6f0f64a424..34289e24dc 100644 --- a/tasks/task_content.h +++ b/tasks/task_content.h @@ -84,7 +84,6 @@ bool task_push_load_content_with_new_core_from_companion_ui( void *user_data); #ifdef HAVE_MENU - bool task_push_load_content_with_new_core_from_menu( const char *core_path, const char *fullpath, @@ -102,19 +101,21 @@ bool task_push_load_content_from_playlist_from_menu( void *user_data); #endif -bool task_push_load_content_with_core_from_menu( +bool task_push_load_content_with_core( const char *fullpath, content_ctx_info_t *content_info, enum rarch_core_type type, retro_task_callback_t cb, void *user_data); -bool task_push_load_subsystem_with_core_from_menu( + +bool task_push_load_subsystem_with_core( const char *fullpath, content_ctx_info_t *content_info, enum rarch_core_type type, retro_task_callback_t cb, void *user_data); + RETRO_END_DECLS #endif diff --git a/tasks/task_netplay_find_content.c b/tasks/task_netplay_find_content.c index 6626322a72..975c1d1a2a 100644 --- a/tasks/task_netplay_find_content.c +++ b/tasks/task_netplay_find_content.c @@ -81,7 +81,7 @@ static void netplay_crc_scan_callback(retro_task_t *task, for (i = 0; i < game_list->size; i++) content_add_subsystem(game_list->elems[i].data); - task_push_load_subsystem_with_core_from_menu( + task_push_load_subsystem_with_core( NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL); string_list_free(game_list); @@ -100,14 +100,14 @@ static void netplay_crc_scan_callback(retro_task_t *task, command_event(CMD_EVENT_NETPLAY_INIT_DIRECT_DEFERRED, state->hostname); if (system && string_is_equal(system->library_name, state->core_name)) - task_push_load_content_with_core_from_menu( + task_push_load_content_with_core( state->content_path, &content_info, CORE_TYPE_PLAIN, NULL, NULL); else { task_push_load_new_core(state->core_path, NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL); - task_push_load_content_with_core_from_menu( + task_push_load_content_with_core( state->content_path, &content_info, CORE_TYPE_PLAIN, NULL, NULL); }