finish up shader menu changes, add 'remove presets' to Qt

This commit is contained in:
LazyBumHorse 2019-08-23 13:45:05 +02:00
parent b6c92d5a66
commit 9b71340959
29 changed files with 291 additions and 116 deletions

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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,

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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.")

View File

@ -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")

View File

@ -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.")

View File

@ -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),

View File

@ -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;

View File

@ -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
}

View File

@ -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)

View File

@ -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

View File

@ -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,

View File

@ -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),

View File

@ -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<QAction*>(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<int>(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;
}
}

View File

@ -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<QVBoxLayout> m_layout;
QPointer<QScrollArea> m_scrollArea;
QAction *removeGlobalPresetAction;
QAction *removeCorePresetAction;
QAction *removeParentPresetAction;
QAction *removeGamePresetAction;
protected:
void closeEvent(QCloseEvent *event);
void resizeEvent(QResizeEvent *event);