mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +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);
|
||||
}
|
||||
|
||||
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(
|
||||
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);
|
||||
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)
|
||||
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
|
||||
else if (!strcmp(label, "video_shader_preset_save_as"))
|
||||
{
|
||||
menu_key_start_line(driver.menu, "Preset Filename: ",
|
||||
"shader_preset_save", preset_filename_callback);
|
||||
return 0;
|
||||
if (action == MENU_ACTION_OK)
|
||||
menu_key_start_line(driver.menu, "Preset Filename",
|
||||
label, st_string_callback);
|
||||
}
|
||||
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];
|
||||
unsigned d, type = RARCH_SHADER_NONE;
|
||||
config_file_t *conf = NULL;
|
||||
const char *conf_path = NULL;
|
||||
bool ret = false;
|
||||
|
||||
if (!driver.menu)
|
||||
@ -210,8 +209,6 @@ static void menu_common_shader_manager_save_preset(
|
||||
if (type == RARCH_SHADER_NONE)
|
||||
return;
|
||||
|
||||
conf_path = (type == RARCH_SHADER_GLSL) ?
|
||||
driver.menu->default_glslp : driver.menu->default_cgp;
|
||||
*config_directory = '\0';
|
||||
|
||||
if (basename)
|
||||
@ -227,6 +224,12 @@ static void menu_common_shader_manager_save_preset(
|
||||
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)
|
||||
fill_pathname_basedir(config_directory,
|
||||
@ -247,7 +250,7 @@ static void menu_common_shader_manager_save_preset(
|
||||
if (!*dirs[d])
|
||||
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))
|
||||
{
|
||||
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,
|
||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||
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));
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend &&
|
||||
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,
|
||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||
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));
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend
|
||||
&& 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,
|
||||
type - MENU_SETTINGS_CORE_OPTION_START),
|
||||
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));
|
||||
else if (driver.menu_ctx && driver.menu_ctx->backend
|
||||
&& driver.menu_ctx->backend->setting_set_label)
|
||||
|
@ -61,6 +61,7 @@ typedef enum
|
||||
MENU_FILE_DIRECTORY,
|
||||
MENU_FILE_DEVICE,
|
||||
MENU_FILE_LINEFEED,
|
||||
MENU_FILE_LINEFEED_SWITCH,
|
||||
MENU_FILE_CORE,
|
||||
MENU_FILE_PLAYLIST_ENTRY,
|
||||
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",
|
||||
MENU_FILE_SWITCH, 0);
|
||||
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)",
|
||||
"video_shader_parameters", MENU_FILE_SWITCH, 0);
|
||||
file_list_push(list, "Parameters (Menu)",
|
||||
|
@ -32,6 +32,8 @@
|
||||
/* forward decls */
|
||||
void menu_common_setting_set_current_string(rarch_setting_t *setting,
|
||||
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,
|
||||
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, menu->keyboard.label_setting)))
|
||||
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);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
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 preset_filename_callback(void *userdata, const char *str);
|
||||
|
||||
void menu_poll_bind_get_rested_axes(struct menu_bind_state *state);
|
||||
|
||||
void menu_poll_bind_state(struct menu_bind_state *state);
|
||||
|
Loading…
x
Reference in New Issue
Block a user