(Menu) Make 'Save as Shader Preset' option available to non-HAVE_OSK targets as

well
This commit is contained in:
twinaphex 2014-03-02 06:44:32 +01:00
parent 5bb7097fbb
commit f9d21c6804
2 changed files with 29 additions and 3 deletions

View File

@ -1806,10 +1806,8 @@ void menu_populate_entries(void *data, unsigned menu_type)
file_list_push(rgui->selection_buf, "Default Filter", RGUI_SETTINGS_SHADER_FILTER, 0);
file_list_push(rgui->selection_buf, "Load Shader Preset",
RGUI_SETTINGS_SHADER_PRESET, 0);
#ifdef HAVE_OSK
file_list_push(rgui->selection_buf, "Save Shader Preset",
file_list_push(rgui->selection_buf, "Save As Shader Preset",
RGUI_SETTINGS_SHADER_PRESET_SAVE, 0);
#endif
file_list_push(rgui->selection_buf, "Shader Passes",
RGUI_SETTINGS_SHADER_PASSES, 0);

View File

@ -405,6 +405,30 @@ static bool osk_callback_enter_filename_init(void *data)
#endif
static void preset_filename_callback(void *userdata, const char *str)
{
rgui_handle_t *rgui = (rgui_handle_t*)userdata;
if (str && *str)
{
char filepath[PATH_MAX];
fill_pathname_join(filepath, g_settings.video.shader_dir, str, sizeof(filepath));
strlcat(filepath, ".cgp", sizeof(filepath));
config_file_t *conf = config_file_new(NULL);
if (conf)
{
gfx_shader_write_conf_cgp(conf, &rgui->shader);
config_file_write(conf, filepath);
config_file_free(conf);
}
}
rgui->keyboard.display = false;
rgui->keyboard.label = NULL;
rgui->old_input_state = -1ULL; // Avoid triggering states on pressing return.
g_extern.system.key_event = menu_key_event;
}
#ifdef HAVE_NETPLAY
static void netplay_port_callback(void *userdata, const char *str)
{
@ -1739,6 +1763,10 @@ int menu_set_settings(void *data, unsigned setting, unsigned action)
else
#endif
{
g_extern.system.key_event = NULL;
rgui->keyboard.display = true;
rgui->keyboard.label = "Preset Filename: ";
rgui->keyboard.buffer = input_keyboard_start_line(rgui, preset_filename_callback);
}
}
break;