From 9b713409592d01f0400962e8105685f617570300 Mon Sep 17 00:00:00 2001 From: LazyBumHorse Date: Fri, 23 Aug 2019 13:45:05 +0200 Subject: [PATCH] finish up shader menu changes, add 'remove presets' to Qt --- intl/msg_hash_ar.h | 2 +- intl/msg_hash_chs.h | 2 +- intl/msg_hash_cht.h | 2 +- intl/msg_hash_de.h | 2 +- intl/msg_hash_el.h | 2 +- intl/msg_hash_eo.h | 2 +- intl/msg_hash_es.h | 2 +- intl/msg_hash_fr.h | 2 +- intl/msg_hash_it.h | 2 +- intl/msg_hash_ja.h | 2 +- intl/msg_hash_ko.h | 2 +- intl/msg_hash_lbl.h | 2 + intl/msg_hash_nl.h | 2 +- intl/msg_hash_pl.h | 2 +- intl/msg_hash_pt_br.h | 2 +- intl/msg_hash_pt_pt.h | 2 +- intl/msg_hash_ru.h | 2 +- intl/msg_hash_tr.h | 2 +- intl/msg_hash_us.h | 16 ++- intl/msg_hash_vn.h | 2 +- menu/cbs/menu_cbs_ok.c | 6 + menu/drivers/materialui.c | 5 +- menu/menu_displaylist.c | 74 ++++++----- menu/menu_shader.c | 65 ++++++++-- menu/menu_shader.h | 2 + msg_hash.h | 2 + retroarch.c | 2 + ui/drivers/qt/shaderparamsdialog.cpp | 181 ++++++++++++++++++++------- ui/drivers/qt/shaderparamsdialog.h | 16 ++- 29 files changed, 291 insertions(+), 116 deletions(-) diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 1c99e0dc87..8898c6a917 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -4084,7 +4084,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index a40c51b62a..85ae24d243 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -5102,7 +5102,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 13ace0a207..ded3a27699 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3860,7 +3860,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 2a6d169b21..895b5f21ed 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3989,7 +3989,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index e02473d8af..82e9618e88 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -8066,7 +8066,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 4c458e103a..bca85d72b0 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3748,7 +3748,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index a6619e3ac1..9dfc8eb454 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -8218,7 +8218,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 00de2ae376..35790af4b9 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -9006,7 +9006,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index d8c4323181..7ae68763a9 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3969,7 +3969,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index e88a9fc418..c17df1477a 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -9381,7 +9381,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 05660d3a57..9a40759ed8 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -9213,7 +9213,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 833641e9d8..f1d04f49bb 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -843,6 +843,8 @@ MSG_HASH(MENU_ENUM_LABEL_NO_PLAYLIST_ENTRIES_AVAILABLE, "no_playlist_entries_available") MSG_HASH(MENU_ENUM_LABEL_NO_SETTINGS_FOUND, "menu_label_no_settings_found") +MSG_HASH(MENU_ENUM_LABEL_NO_PRESETS_FOUND, + "menu_label_no_presets_found") MSG_HASH(MENU_ENUM_LABEL_NO_SHADER_PARAMETERS, "no_shader_parameters.") MSG_HASH(MENU_ENUM_LABEL_ONLINE, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index bcdb9b36cc..bab5900d73 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3742,7 +3742,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index ca2bb58f74..cde0ec5d28 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -4533,7 +4533,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 90443cf109..d59c010633 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -9293,7 +9293,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 0e7a4693ad..386301b74e 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3814,7 +3814,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 76a3323490..5f761ef228 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -4012,7 +4012,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_tr.h b/intl/msg_hash_tr.h index 1029e02e72..66facabd39 100644 --- a/intl/msg_hash_tr.h +++ b/intl/msg_hash_tr.h @@ -9018,7 +9018,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index de704e7557..56ab32ebfb 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2032,6 +2032,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_SETTINGS_FOUND, "No settings found." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_NO_PRESETS_FOUND, + "No automatic shader presets found." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_NO_SHADER_PARAMETERS, "No shader parameters." @@ -3874,7 +3878,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE, - "Save ..." + "Save" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_SAVE_AS, @@ -6594,7 +6598,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE, - "Save shader preset as ..." + "Save the current shader preset." ) MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_SAVE_AS, @@ -8542,6 +8546,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_REMOVE, "Remove" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_QT_REMOVE_PASSES, + "Remove Passes" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_APPLY, "Apply" @@ -9525,10 +9533,10 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, - "Remove shader presets of a specific type.") + "Remove an automatic shader preset.") MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GLOBAL, "Remove Global Preset") diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index d759edaaa0..8941effdaa 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3904,7 +3904,7 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE, - "Remove ...") + "Remove") MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SHADER_PRESET_REMOVE, "Remove shader presets of a specific type.") diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 551052e020..8c0244dba8 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2739,10 +2739,16 @@ static int generic_action_ok_shader_preset_remove(const char *path, } if (menu_shader_manager_remove_auto_preset(preset_type)) + { + bool refresh = false; + runloop_msg_queue_push( msg_hash_to_str(MSG_SHADER_PRESET_REMOVED_SUCCESSFULLY), 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + } else runloop_msg_queue_push( msg_hash_to_str(MSG_ERROR_REMOVING_SHADER_PRESET), diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 9becce72ce..d50286d6ae 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -2495,8 +2495,9 @@ static void materialui_list_insert(void *userdata, string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NO_CORE_INFORMATION_AVAILABLE)) || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NO_ITEMS)) || string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NO_CORE_OPTIONS_AVAILABLE)) || - (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_INFORMATION))) || - string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND)) + string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_INFORMATION)) || + string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NO_SETTINGS_FOUND)) || + string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_NO_PRESETS_FOUND)) ) { node->texture_switch2_index = MUI_TEXTURE_INFO; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index bcf725c829..f4bdef47f9 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6291,13 +6291,6 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (settings->bools.video_shader_enable) { - if (menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_APPLY_CHANGES), - msg_hash_to_str(MENU_ENUM_LABEL_SHADER_APPLY_CHANGES), - MENU_ENUM_LABEL_SHADER_APPLY_CHANGES, - MENU_SETTING_ACTION, 0, 0)) - count++; - if (frontend_driver_can_watch_for_changes()) { if (menu_entries_append_enum(info->list, @@ -6328,12 +6321,20 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, MENU_SETTING_ACTION, 0, 0)) count++; + if (menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_APPLY_CHANGES), + msg_hash_to_str(MENU_ENUM_LABEL_SHADER_APPLY_CHANGES), + MENU_ENUM_LABEL_SHADER_APPLY_CHANGES, + MENU_SETTING_ACTION, 0, 0)) + count++; + if (menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS), msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS), MENU_ENUM_LABEL_VIDEO_SHADER_PARAMETERS, MENU_SETTING_ACTION, 0, 0)) count++; + if (menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_NUM_PASSES), msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_NUM_PASSES), @@ -8214,33 +8215,44 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); { #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) - if (menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GLOBAL), - msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GLOBAL), - MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GLOBAL, - MENU_SETTING_ACTION, 0, 0)) - count++; + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_GLOBAL)) + if (menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GLOBAL), + msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GLOBAL), + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GLOBAL, + MENU_SETTING_ACTION, 0, 0)) + count++; - if (menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_CORE), - msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_CORE), - MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_CORE, - MENU_SETTING_ACTION, 0, 0)) - count++; + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_CORE)) + if (menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_CORE), + msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_CORE), + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_CORE, + MENU_SETTING_ACTION, 0, 0)) + count++; - if (menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_PARENT), - msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_PARENT), - MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_PARENT, - MENU_SETTING_ACTION, 0, 0)) - count++; + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_PARENT)) + if (menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_PARENT), + msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_PARENT), + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_PARENT, + MENU_SETTING_ACTION, 0, 0)) + count++; - if (menu_entries_append_enum(info->list, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GAME), - msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GAME), - MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GAME, - MENU_SETTING_ACTION, 0, 0)) - count++; + if (menu_shader_manager_auto_preset_exists(SHADER_PRESET_GAME)) + if (menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GAME), + msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GAME), + MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_REMOVE_GAME, + MENU_SETTING_ACTION, 0, 0)) + count++; + + if (count == 0) + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_PRESETS_FOUND), + msg_hash_to_str(MENU_ENUM_LABEL_NO_PRESETS_FOUND), + MENU_ENUM_LABEL_NO_PRESETS_FOUND, + 0, 0, 0); #endif } diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 399c9fbde6..8756dd6f17 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -45,6 +45,18 @@ void menu_shader_set_modified(bool modified) menu_driver_shader_modified = modified; } +static enum rarch_shader_type shader_types[] = +{ + RARCH_SHADER_GLSL, RARCH_SHADER_SLANG, RARCH_SHADER_CG +}; + +enum auto_shader_operation +{ + AUTO_SHADER_OP_SAVE = 0, + AUTO_SHADER_OP_REMOVE, + AUTO_SHADER_OP_EXISTS +}; + struct video_shader *menu_shader_get(void) { if (video_shader_any_supported()) @@ -316,8 +328,7 @@ static bool menu_shader_manager_save_preset_internal( return ret; } -/** Saves or deletes an auto-shader, save = false requires no other parameters */ -static bool menu_shader_manager_operate_auto_preset(bool save, +static bool menu_shader_manager_operate_auto_preset(enum auto_shader_operation op, const struct video_shader *shader, enum auto_shader_type type, bool apply) { char tmp[PATH_MAX_LENGTH]; @@ -379,25 +390,20 @@ static bool menu_shader_manager_operate_auto_preset(bool save, return false; } - if (save) + if (op == AUTO_SHADER_OP_SAVE) { if (!path_is_directory(directory)) path_mkdir(directory); return menu_shader_manager_save_preset_internal(shader, file, apply, true); } - else + else if (op == AUTO_SHADER_OP_REMOVE) { + /* remove all supported auto-shaders of given type */ char *end = file + strlen(file); size_t i; bool success = false; - static enum rarch_shader_type shader_types[] = - { - RARCH_SHADER_GLSL, RARCH_SHADER_SLANG, RARCH_SHADER_CG - }; - - /* remove all supported auto-shaders of given type */ for (i = 0; i < ARRAY_SIZE(shader_types); i++) { const char *preset_ext; @@ -414,6 +420,30 @@ static bool menu_shader_manager_operate_auto_preset(bool save, return success; } + else if (op == AUTO_SHADER_OP_EXISTS) + { + /* test if any supported auto-shaders of given type exists */ + char *end = file + strlen(file); + size_t i; + + for (i = 0; i < ARRAY_SIZE(shader_types); i++) + { + const char *preset_ext; + + if (!video_shader_is_supported(shader_types[i])) + continue; + + preset_ext = video_shader_get_preset_extension(shader_types[i]); + strlcpy(end, preset_ext, sizeof(file) - (end-file)); + + if (path_is_valid(file)) + return true; + } + + return false; + } + + return false; } /** @@ -433,7 +463,7 @@ static bool menu_shader_manager_operate_auto_preset(bool save, bool menu_shader_manager_save_auto_preset(const struct video_shader *shader, enum auto_shader_type type, bool apply) { - return menu_shader_manager_operate_auto_preset(true, shader, type, apply); + return menu_shader_manager_operate_auto_preset(AUTO_SHADER_OP_SAVE, shader, type, apply); } /** @@ -459,7 +489,18 @@ bool menu_shader_manager_save_preset(const struct video_shader *shader, **/ bool menu_shader_manager_remove_auto_preset(enum auto_shader_type type) { - return menu_shader_manager_operate_auto_preset(false, NULL, type, false); + return menu_shader_manager_operate_auto_preset(AUTO_SHADER_OP_REMOVE, NULL, type, false); +} + +/** + * menu_shader_manager_auto_preset_exists: + * @type : type of shader preset + * + * Tests if an auto-shader of the given type exists. + **/ +bool menu_shader_manager_auto_preset_exists(enum auto_shader_type type) +{ + return menu_shader_manager_operate_auto_preset(AUTO_SHADER_OP_EXISTS, NULL, type, false); } int menu_shader_manager_clear_num_passes(struct video_shader *shader) diff --git a/menu/menu_shader.h b/menu/menu_shader.h index 5108e3ee53..615433a351 100644 --- a/menu/menu_shader.h +++ b/menu/menu_shader.h @@ -124,6 +124,8 @@ void menu_shader_manager_clear_pass_path(struct video_shader *shader, **/ bool menu_shader_manager_remove_auto_preset(enum auto_shader_type type); +bool menu_shader_manager_auto_preset_exists(enum auto_shader_type type); + void menu_shader_set_modified(bool modified); RETRO_END_DECLS diff --git a/msg_hash.h b/msg_hash.h index ec67ab3b41..e73ee871ce 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1336,6 +1336,7 @@ enum msg_hash_enums MENU_LABEL(LOAD_CONTENT_LIST), MENU_LABEL(LOAD_CONTENT_SPECIAL), MENU_LABEL(NO_SETTINGS_FOUND), + MENU_LABEL(NO_PRESETS_FOUND), MENU_LABEL(NO_NETWORKS_FOUND), MENU_LABEL(NO_PERFORMANCE_COUNTERS), MENU_LABEL(FRAME_THROTTLE_SETTINGS), @@ -2396,6 +2397,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_QT_LOAD, MENU_ENUM_LABEL_VALUE_QT_SAVE, MENU_ENUM_LABEL_VALUE_QT_REMOVE, + MENU_ENUM_LABEL_VALUE_QT_REMOVE_PASSES, MENU_ENUM_LABEL_VALUE_QT_APPLY, MENU_ENUM_LABEL_VALUE_QT_SHADER_ADD_PASS, MENU_ENUM_LABEL_VALUE_QT_SHADER_CLEAR_ALL_PASSES, diff --git a/retroarch.c b/retroarch.c index 91bee7db1e..85afcea502 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2222,10 +2222,12 @@ bool retroarch_apply_shader(enum rarch_shader_type type, const char *preset_path configuration_set_bool(settings, settings->bools.video_shader_enable, true); retroarch_set_runtime_shader_preset(preset_path); +#ifdef HAVE_MENU /* reflect in shader manager */ if (menu_shader_manager_set_preset(menu_shader_get(), type, preset_path, false)) if (!string_is_empty(preset_path)) menu_shader_set_modified(false); +#endif /* Display message */ snprintf(msg, sizeof(msg), diff --git a/ui/drivers/qt/shaderparamsdialog.cpp b/ui/drivers/qt/shaderparamsdialog.cpp index a014b83f60..37c9c31779 100644 --- a/ui/drivers/qt/shaderparamsdialog.cpp +++ b/ui/drivers/qt/shaderparamsdialog.cpp @@ -18,6 +18,7 @@ #include "shaderparamsdialog.h" #include "../ui_qt.h" +#include "../../../menu/menu_entries.h" #ifndef CXX_BUILD extern "C" { @@ -51,11 +52,11 @@ extern "C" { enum { - SHADER_PRESET_SAVE_GLOBAL = 0, - SHADER_PRESET_SAVE_CORE, - SHADER_PRESET_SAVE_PARENT, - SHADER_PRESET_SAVE_GAME, - SHADER_PRESET_SAVE_NORMAL + QT_SHADER_PRESET_GLOBAL = 0, + QT_SHADER_PRESET_CORE, + QT_SHADER_PRESET_PARENT, + QT_SHADER_PRESET_GAME, + QT_SHADER_PRESET_NORMAL }; ShaderPass::ShaderPass(struct video_shader_pass *passToCopy) : @@ -688,76 +689,128 @@ void ShaderParamsDialog::onShaderSavePresetAsClicked() pathArray = path.toUtf8(); pathData = pathArray.constData(); - saveShaderPreset(pathData, SHADER_PRESET_SAVE_NORMAL); + operateShaderPreset(true, pathData, QT_SHADER_PRESET_NORMAL); } -void ShaderParamsDialog::saveShaderPreset(const char *path, unsigned action_type) +/** save or remove shader preset */ +void ShaderParamsDialog::operateShaderPreset(bool save, const char *path, unsigned action_type) { bool ret; enum auto_shader_type preset_type; switch (action_type) { - case SHADER_PRESET_SAVE_GLOBAL: + case QT_SHADER_PRESET_GLOBAL: preset_type = SHADER_PRESET_GLOBAL; break; - case SHADER_PRESET_SAVE_CORE: + case QT_SHADER_PRESET_CORE: + preset_type = SHADER_PRESET_CORE; + break; + case QT_SHADER_PRESET_PARENT: preset_type = SHADER_PRESET_PARENT; break; - case SHADER_PRESET_SAVE_PARENT: - preset_type = SHADER_PRESET_PARENT; - break; - case SHADER_PRESET_SAVE_GAME: + case QT_SHADER_PRESET_GAME: preset_type = SHADER_PRESET_GAME; break; - case SHADER_PRESET_SAVE_NORMAL: + case QT_SHADER_PRESET_NORMAL: break; default: return; } - if (action_type == SHADER_PRESET_SAVE_NORMAL) - ret = menu_shader_manager_save_preset(menu_shader_get(), path, true); - else - ret = menu_shader_manager_save_auto_preset(menu_shader_get(), preset_type, true); + if (save) + { + if (action_type == QT_SHADER_PRESET_NORMAL) + ret = menu_shader_manager_save_preset(menu_shader_get(), path, true); + else + ret = menu_shader_manager_save_auto_preset(menu_shader_get(), preset_type, true); - if (ret) - runloop_msg_queue_push( - msg_hash_to_str(MSG_SHADER_PRESET_SAVED_SUCCESSFULLY), - 1, 100, true, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, - MESSAGE_QUEUE_CATEGORY_INFO - ); + if (ret) + runloop_msg_queue_push( + msg_hash_to_str(MSG_SHADER_PRESET_SAVED_SUCCESSFULLY), + 1, 100, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, + MESSAGE_QUEUE_CATEGORY_INFO + ); + else + runloop_msg_queue_push( + msg_hash_to_str(MSG_ERROR_SAVING_SHADER_PRESET), + 1, 100, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, + MESSAGE_QUEUE_CATEGORY_ERROR + ); + } else - runloop_msg_queue_push( - msg_hash_to_str(MSG_ERROR_SAVING_SHADER_PRESET), - 1, 100, true, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, - MESSAGE_QUEUE_CATEGORY_ERROR - ); + { + if (action_type != QT_SHADER_PRESET_NORMAL && + menu_shader_manager_remove_auto_preset(preset_type)) + { +#ifdef HAVE_MENU + bool refresh = false; +#endif + + runloop_msg_queue_push( + msg_hash_to_str(MSG_SHADER_PRESET_REMOVED_SUCCESSFULLY), + 1, 100, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, + MESSAGE_QUEUE_CATEGORY_INFO + ); + +#ifdef HAVE_MENU + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); +#endif + } + else + runloop_msg_queue_push( + msg_hash_to_str(MSG_ERROR_REMOVING_SHADER_PRESET), + 1, 100, true, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, + MESSAGE_QUEUE_CATEGORY_ERROR + ); + } } void ShaderParamsDialog::onShaderSaveGlobalPresetClicked() { - saveShaderPreset(NULL, SHADER_PRESET_GLOBAL); + operateShaderPreset(true, NULL, QT_SHADER_PRESET_GLOBAL); } void ShaderParamsDialog::onShaderSaveCorePresetClicked() { - saveShaderPreset(NULL, SHADER_PRESET_CORE); + operateShaderPreset(true, NULL, QT_SHADER_PRESET_CORE); } void ShaderParamsDialog::onShaderSaveParentPresetClicked() { - saveShaderPreset(NULL, SHADER_PRESET_PARENT); + operateShaderPreset(true, NULL, QT_SHADER_PRESET_PARENT); } void ShaderParamsDialog::onShaderSaveGamePresetClicked() { - saveShaderPreset(NULL, SHADER_PRESET_GAME); + operateShaderPreset(true, NULL, QT_SHADER_PRESET_GAME); } -void ShaderParamsDialog::onShaderClearAllPassesClicked() +void ShaderParamsDialog::onShaderRemoveGlobalPresetClicked() +{ + operateShaderPreset(false, NULL, QT_SHADER_PRESET_GLOBAL); +} + +void ShaderParamsDialog::onShaderRemoveCorePresetClicked() +{ + operateShaderPreset(false, NULL, QT_SHADER_PRESET_CORE); +} + +void ShaderParamsDialog::onShaderRemoveParentPresetClicked() +{ + operateShaderPreset(false, NULL, QT_SHADER_PRESET_PARENT); +} + +void ShaderParamsDialog::onShaderRemoveGamePresetClicked() +{ + operateShaderPreset(false, NULL, QT_SHADER_PRESET_GAME); +} + +void ShaderParamsDialog::onShaderRemoveAllPassesClicked() { struct video_shader *menu_shader = NULL; struct video_shader *video_shader = NULL; @@ -776,19 +829,13 @@ void ShaderParamsDialog::onShaderClearAllPassesClicked() void ShaderParamsDialog::onShaderRemovePassClicked() { - int i; QVariant passVariant; QAction *action = qobject_cast(sender()); - struct video_shader *menu_shader = NULL; - struct video_shader *video_shader = NULL; int pass = 0; bool ok = false; - getShaders(&menu_shader, &video_shader); - - if (!menu_shader || menu_shader->passes == 0 || !action) + if (!action) return; - passVariant = action->data(); if (!passVariant.isValid()) @@ -799,6 +846,20 @@ void ShaderParamsDialog::onShaderRemovePassClicked() if (!ok) return; + onShaderRemovePass(pass); +} + +void ShaderParamsDialog::onShaderRemovePass(int pass) +{ + int i; + struct video_shader *menu_shader = NULL; + struct video_shader *video_shader = NULL; + + getShaders(&menu_shader, &video_shader); + + if (!menu_shader || menu_shader->passes == 0) + return; + if (pass < 0 || pass > static_cast(menu_shader->passes)) return; @@ -818,6 +879,18 @@ void ShaderParamsDialog::onShaderApplyClicked() command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL); } +void ShaderParamsDialog::updateRemovePresetButtonsState() +{ + if (removeGlobalPresetAction) + removeGlobalPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GLOBAL)); + if (removeCorePresetAction) + removeCorePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_CORE)); + if (removeParentPresetAction) + removeParentPresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_PARENT)); + if (removeGamePresetAction) + removeGamePresetAction->setEnabled(menu_shader_manager_auto_preset_exists(SHADER_PRESET_GAME)); +} + void ShaderParamsDialog::reload() { buildLayout(); @@ -828,11 +901,13 @@ void ShaderParamsDialog::buildLayout() QPushButton *loadButton = NULL; QPushButton *saveButton = NULL; QPushButton *removeButton = NULL; + QPushButton *removePassButton = NULL; QPushButton *applyButton = NULL; QHBoxLayout *topButtonLayout = NULL; QMenu *loadMenu = NULL; QMenu *saveMenu = NULL; QMenu *removeMenu = NULL; + QMenu *removePassMenu = NULL; struct video_shader *menu_shader = NULL; struct video_shader *video_shader = NULL; struct video_shader *avail_shader = NULL; @@ -905,6 +980,7 @@ void ShaderParamsDialog::buildLayout() loadButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_LOAD), this); saveButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SAVE), this); removeButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_REMOVE), this); + removePassButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_REMOVE_PASSES), this); applyButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_APPLY), this); loadMenu = new QMenu(loadButton); @@ -923,6 +999,16 @@ void ShaderParamsDialog::buildLayout() saveButton->setMenu(saveMenu); removeMenu = new QMenu(removeButton); + removeGlobalPresetAction = removeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GLOBAL), this, SLOT(onShaderRemoveGlobalPresetClicked())); + removeCorePresetAction = removeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_CORE), this, SLOT(onShaderRemoveCorePresetClicked())); + removeParentPresetAction = removeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_PARENT), this, SLOT(onShaderRemoveParentPresetClicked())); + removeGamePresetAction = removeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET_REMOVE_GAME), this, SLOT(onShaderRemoveGamePresetClicked())); + + removeButton->setMenu(removeMenu); + + connect(removeMenu, SIGNAL(aboutToShow()), this, SLOT(updateRemovePresetButtonsState())); + + removePassMenu = new QMenu(removeButton); /* When there are no passes, at least on first startup, it seems video_shader erroneously shows 1 pass, with an empty source file. * So we use menu_shader instead for that. @@ -933,15 +1019,15 @@ void ShaderParamsDialog::buildLayout() { QFileInfo fileInfo(menu_shader->pass[i].source.path); QString shaderBasename = fileInfo.completeBaseName(); - QAction *action = removeMenu->addAction(shaderBasename, this, SLOT(onShaderRemovePassClicked())); + QAction *action = removePassMenu->addAction(shaderBasename, this, SLOT(onShaderRemovePassClicked())); action->setData(i); } } - removeMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_CLEAR_ALL_PASSES), this, SLOT(onShaderClearAllPassesClicked())); + removePassMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_CLEAR_ALL_PASSES), this, SLOT(onShaderRemoveAllPassesClicked())); - removeButton->setMenu(removeMenu); + removePassButton->setMenu(removePassMenu); connect(applyButton, SIGNAL(clicked()), this, SLOT(onShaderApplyClicked())); @@ -949,6 +1035,7 @@ void ShaderParamsDialog::buildLayout() topButtonLayout->addWidget(loadButton); topButtonLayout->addWidget(saveButton); topButtonLayout->addWidget(removeButton); + topButtonLayout->addWidget(removePassButton); topButtonLayout->addWidget(applyButton); m_layout->addLayout(topButtonLayout); @@ -1337,6 +1424,7 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int) if (param) { newValue = MainWindow::lerp(0, 100, param->minimum, param->maximum, slider->value()); + newValue = round(newValue / param->step) * param->step; param->current = newValue; } } @@ -1357,6 +1445,7 @@ void ShaderParamsDialog::onShaderParamSliderValueChanged(int) if (param) { newValue = MainWindow::lerp(0, 100, param->minimum, param->maximum, slider->value()); + newValue = round(newValue / param->step) * param->step; param->current = newValue; } } diff --git a/ui/drivers/qt/shaderparamsdialog.h b/ui/drivers/qt/shaderparamsdialog.h index 49ccdf692a..2357db026e 100644 --- a/ui/drivers/qt/shaderparamsdialog.h +++ b/ui/drivers/qt/shaderparamsdialog.h @@ -54,6 +54,9 @@ private slots: void onShaderPassMoveUpClicked(); void onShaderResetPass(int pass); void onShaderResetAllPasses(); + void onShaderRemovePass(int pass); + void onShaderRemoveAllPassesClicked(); + void onShaderRemovePassClicked(); void onShaderResetParameter(QString parameter); void onShaderLoadPresetClicked(); void onShaderAddPassClicked(); @@ -62,19 +65,26 @@ private slots: void onShaderSaveParentPresetClicked(); void onShaderSaveGamePresetClicked(); void onShaderSaveGlobalPresetClicked(); - void onShaderClearAllPassesClicked(); - void onShaderRemovePassClicked(); + void onShaderRemoveCorePresetClicked(); + void onShaderRemoveParentPresetClicked(); + void onShaderRemoveGamePresetClicked(); + void onShaderRemoveGlobalPresetClicked(); void onShaderApplyClicked(); + void updateRemovePresetButtonsState(); void clearLayout(); void buildLayout(); private: QString getFilterLabel(unsigned filter); void addShaderParam(struct video_shader_parameter *param, QFormLayout *form); void getShaders(struct video_shader **menu_shader, struct video_shader **video_shader); - void saveShaderPreset(const char *path, unsigned action_type); + void operateShaderPreset(bool save, const char *path, unsigned action_type); QPointer m_layout; QPointer m_scrollArea; + QAction *removeGlobalPresetAction; + QAction *removeCorePresetAction; + QAction *removeParentPresetAction; + QAction *removeGamePresetAction; protected: void closeEvent(QCloseEvent *event); void resizeEvent(QResizeEvent *event);