mirror of
https://github.com/libretro/RetroArch
synced 2025-04-15 23:42:30 +00:00
(Menu) Fix Shader Preset Save As option
This commit is contained in:
parent
780688ec92
commit
7e6aa11c5b
@ -612,6 +612,19 @@ static void menu_common_setting_set_current_string_path(
|
|||||||
setting->change_handler(setting);
|
setting->change_handler(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void menu_common_set_current_string_based_on_label(
|
||||||
|
const char *label, const char *str)
|
||||||
|
{
|
||||||
|
if (!strcmp(label, "video_shader_preset_save_as"))
|
||||||
|
{
|
||||||
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
|
if (driver.menu_ctx && driver.menu_ctx->backend
|
||||||
|
&& driver.menu_ctx->backend->shader_manager_save_preset)
|
||||||
|
driver.menu_ctx->backend->shader_manager_save_preset(str, false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void menu_common_setting_set_current_string(
|
void menu_common_setting_set_current_string(
|
||||||
rarch_setting_t *setting, const char *str)
|
rarch_setting_t *setting, const char *str)
|
||||||
{
|
{
|
||||||
@ -659,7 +672,7 @@ static void handle_setting(rarch_setting_t *setting,
|
|||||||
setting->default_value.string, setting->name, id, action);
|
setting->default_value.string, setting->name, id, action);
|
||||||
else if (setting->type == ST_STRING)
|
else if (setting->type == ST_STRING)
|
||||||
{
|
{
|
||||||
if (id == MENU_FILE_LINEFEED)
|
if (id == MENU_FILE_LINEFEED || id == MENU_FILE_LINEFEED_SWITCH)
|
||||||
{
|
{
|
||||||
if (action == MENU_ACTION_OK)
|
if (action == MENU_ACTION_OK)
|
||||||
menu_key_start_line(driver.menu, setting->short_description,
|
menu_key_start_line(driver.menu, setting->short_description,
|
||||||
@ -1028,9 +1041,9 @@ static int menu_setting_ok_toggle(unsigned type,
|
|||||||
#ifdef HAVE_SHADER_MANAGER
|
#ifdef HAVE_SHADER_MANAGER
|
||||||
else if (!strcmp(label, "video_shader_preset_save_as"))
|
else if (!strcmp(label, "video_shader_preset_save_as"))
|
||||||
{
|
{
|
||||||
menu_key_start_line(driver.menu, "Preset Filename: ",
|
if (action == MENU_ACTION_OK)
|
||||||
"shader_preset_save", preset_filename_callback);
|
menu_key_start_line(driver.menu, "Preset Filename",
|
||||||
return 0;
|
label, st_string_callback);
|
||||||
}
|
}
|
||||||
else if (!strcmp(label, "shader_apply_changes"))
|
else if (!strcmp(label, "shader_apply_changes"))
|
||||||
{
|
{
|
||||||
|
@ -193,7 +193,6 @@ static void menu_common_shader_manager_save_preset(
|
|||||||
char buffer[PATH_MAX], config_directory[PATH_MAX], cgp_path[PATH_MAX];
|
char buffer[PATH_MAX], config_directory[PATH_MAX], cgp_path[PATH_MAX];
|
||||||
unsigned d, type = RARCH_SHADER_NONE;
|
unsigned d, type = RARCH_SHADER_NONE;
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
const char *conf_path = NULL;
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if (!driver.menu)
|
if (!driver.menu)
|
||||||
@ -210,8 +209,6 @@ static void menu_common_shader_manager_save_preset(
|
|||||||
if (type == RARCH_SHADER_NONE)
|
if (type == RARCH_SHADER_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conf_path = (type == RARCH_SHADER_GLSL) ?
|
|
||||||
driver.menu->default_glslp : driver.menu->default_cgp;
|
|
||||||
*config_directory = '\0';
|
*config_directory = '\0';
|
||||||
|
|
||||||
if (basename)
|
if (basename)
|
||||||
@ -227,6 +224,12 @@ static void menu_common_shader_manager_save_preset(
|
|||||||
strlcat(buffer, ".cgp", sizeof(buffer));
|
strlcat(buffer, ".cgp", sizeof(buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char *conf_path = (type == RARCH_SHADER_GLSL) ?
|
||||||
|
driver.menu->default_glslp : driver.menu->default_cgp;
|
||||||
|
strlcpy(buffer, conf_path, sizeof(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
if (*g_extern.config_path)
|
if (*g_extern.config_path)
|
||||||
fill_pathname_basedir(config_directory,
|
fill_pathname_basedir(config_directory,
|
||||||
@ -247,7 +250,7 @@ static void menu_common_shader_manager_save_preset(
|
|||||||
if (!*dirs[d])
|
if (!*dirs[d])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fill_pathname_join(cgp_path, dirs[d], conf_path, sizeof(cgp_path));
|
fill_pathname_join(cgp_path, dirs[d], buffer, sizeof(cgp_path));
|
||||||
if (config_file_write(conf, cgp_path))
|
if (config_file_write(conf, cgp_path))
|
||||||
{
|
{
|
||||||
RARCH_LOG("Saved shader preset to %s.\n", cgp_path);
|
RARCH_LOG("Saved shader preset to %s.\n", cgp_path);
|
||||||
|
@ -386,7 +386,7 @@ static void rgui_render(void)
|
|||||||
core_option_get_val(g_extern.system.core_options,
|
core_option_get_val(g_extern.system.core_options,
|
||||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||||
sizeof(type_str));
|
sizeof(type_str));
|
||||||
else if (type == MENU_FILE_SWITCH)
|
else if (type == MENU_FILE_SWITCH || type == MENU_FILE_LINEFEED_SWITCH)
|
||||||
strlcpy(type_str, "...", sizeof(type_str));
|
strlcpy(type_str, "...", sizeof(type_str));
|
||||||
else if (driver.menu_ctx && driver.menu_ctx->backend &&
|
else if (driver.menu_ctx && driver.menu_ctx->backend &&
|
||||||
driver.menu_ctx->backend->setting_set_label)
|
driver.menu_ctx->backend->setting_set_label)
|
||||||
|
@ -254,7 +254,7 @@ static void rmenu_render(void)
|
|||||||
core_option_get_val(g_extern.system.core_options,
|
core_option_get_val(g_extern.system.core_options,
|
||||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||||
sizeof(type_str));
|
sizeof(type_str));
|
||||||
else if (type == MENU_FILE_SWITCH)
|
else if (type == MENU_FILE_SWITCH || type == MENU_FILE_LINEFEED_SWITCH)
|
||||||
strlcpy(type_str, "...", sizeof(type_str));
|
strlcpy(type_str, "...", sizeof(type_str));
|
||||||
else if (driver.menu_ctx && driver.menu_ctx->backend
|
else if (driver.menu_ctx && driver.menu_ctx->backend
|
||||||
&& driver.menu_ctx->backend->setting_set_label)
|
&& driver.menu_ctx->backend->setting_set_label)
|
||||||
|
@ -466,7 +466,7 @@ static void rmenu_xui_render(void)
|
|||||||
core_option_get_val(g_extern.system.core_options,
|
core_option_get_val(g_extern.system.core_options,
|
||||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||||
sizeof(type_str));
|
sizeof(type_str));
|
||||||
else if (type == MENU_FILE_SWITCH)
|
else if (type == MENU_FILE_SWITCH || type == MENU_FILE_LINEFEED_SWITCH)
|
||||||
strlcpy(type_str, "...", sizeof(type_str));
|
strlcpy(type_str, "...", sizeof(type_str));
|
||||||
else if (driver.menu_ctx && driver.menu_ctx->backend
|
else if (driver.menu_ctx && driver.menu_ctx->backend
|
||||||
&& driver.menu_ctx->backend->setting_set_label)
|
&& driver.menu_ctx->backend->setting_set_label)
|
||||||
|
@ -61,6 +61,7 @@ typedef enum
|
|||||||
MENU_FILE_DIRECTORY,
|
MENU_FILE_DIRECTORY,
|
||||||
MENU_FILE_DEVICE,
|
MENU_FILE_DEVICE,
|
||||||
MENU_FILE_LINEFEED,
|
MENU_FILE_LINEFEED,
|
||||||
|
MENU_FILE_LINEFEED_SWITCH,
|
||||||
MENU_FILE_CORE,
|
MENU_FILE_CORE,
|
||||||
MENU_FILE_PLAYLIST_ENTRY,
|
MENU_FILE_PLAYLIST_ENTRY,
|
||||||
MENU_FILE_USE_DIRECTORY,
|
MENU_FILE_USE_DIRECTORY,
|
||||||
|
@ -495,7 +495,7 @@ int menu_entries_push_list(menu_handle_t *menu,
|
|||||||
file_list_push(list, "Load Shader Preset", "video_shader_preset",
|
file_list_push(list, "Load Shader Preset", "video_shader_preset",
|
||||||
MENU_FILE_SWITCH, 0);
|
MENU_FILE_SWITCH, 0);
|
||||||
file_list_push(list, "Shader Preset Save As",
|
file_list_push(list, "Shader Preset Save As",
|
||||||
"video_shader_preset_save_as", MENU_FILE_SWITCH, 0);
|
"video_shader_preset_save_as", MENU_FILE_LINEFEED_SWITCH, 0);
|
||||||
file_list_push(list, "Parameters (Current)",
|
file_list_push(list, "Parameters (Current)",
|
||||||
"video_shader_parameters", MENU_FILE_SWITCH, 0);
|
"video_shader_parameters", MENU_FILE_SWITCH, 0);
|
||||||
file_list_push(list, "Parameters (Menu)",
|
file_list_push(list, "Parameters (Menu)",
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
/* forward decls */
|
/* forward decls */
|
||||||
void menu_common_setting_set_current_string(rarch_setting_t *setting,
|
void menu_common_setting_set_current_string(rarch_setting_t *setting,
|
||||||
const char *str);
|
const char *str);
|
||||||
|
void menu_common_set_current_string_based_on_label(
|
||||||
|
const char *label, const char *str);
|
||||||
|
|
||||||
void menu_key_start_line(void *data, const char *label,
|
void menu_key_start_line(void *data, const char *label,
|
||||||
const char *label_setting, input_keyboard_line_complete_t cb)
|
const char *label_setting, input_keyboard_line_complete_t cb)
|
||||||
@ -99,23 +101,12 @@ void st_string_callback(void *userdata, const char *str)
|
|||||||
setting_data_find_setting(
|
setting_data_find_setting(
|
||||||
setting_data, menu->keyboard.label_setting)))
|
setting_data, menu->keyboard.label_setting)))
|
||||||
menu_common_setting_set_current_string(current_setting, str);
|
menu_common_setting_set_current_string(current_setting, str);
|
||||||
|
else
|
||||||
|
menu_common_set_current_string_based_on_label(menu->keyboard.label_setting, str);
|
||||||
}
|
}
|
||||||
menu_key_end_line(menu);
|
menu_key_end_line(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SHADER_MANAGER
|
|
||||||
void preset_filename_callback(void *userdata, const char *str)
|
|
||||||
{
|
|
||||||
menu_handle_t *menu = (menu_handle_t*)userdata;
|
|
||||||
|
|
||||||
if (driver.menu_ctx && driver.menu_ctx->backend
|
|
||||||
&& driver.menu_ctx->backend->shader_manager_save_preset)
|
|
||||||
driver.menu_ctx->backend->shader_manager_save_preset(
|
|
||||||
str && *str ? str : NULL, false);
|
|
||||||
menu_key_end_line(menu);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod)
|
void menu_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod)
|
||||||
{
|
{
|
||||||
if (!driver.menu)
|
if (!driver.menu)
|
||||||
|
@ -29,8 +29,6 @@ void st_uint_callback(void *userdata, const char *str);
|
|||||||
|
|
||||||
void st_string_callback(void *userdata, const char *str);
|
void st_string_callback(void *userdata, const char *str);
|
||||||
|
|
||||||
void preset_filename_callback(void *userdata, const char *str);
|
|
||||||
|
|
||||||
void menu_poll_bind_get_rested_axes(struct menu_bind_state *state);
|
void menu_poll_bind_get_rested_axes(struct menu_bind_state *state);
|
||||||
|
|
||||||
void menu_poll_bind_state(struct menu_bind_state *state);
|
void menu_poll_bind_state(struct menu_bind_state *state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user