From a84a46176729ffab82703bdff62fcde73dd6477d Mon Sep 17 00:00:00 2001 From: Adham Zahran Date: Wed, 12 Oct 2016 22:23:48 +0200 Subject: fix #6031 when creating a script the language will be what you selected last time --- tools/editor/editor_settings.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tools/editor/editor_settings.cpp') diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 4778a7ce9..7e450fb4a 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -1022,6 +1022,34 @@ void EditorSettings::set_optimize_save(bool p_optimize) { optimize_save=p_optimize; } +String EditorSettings::get_last_selected_language() +{ + Ref cf = memnew( ConfigFile ); + String path = get_project_settings_path().plus_file("project_metadata.cfg"); + Error err = cf->load(path); + if (err != OK) { + WARN_PRINTS("Can't load config file: " + path); + return ""; + } + Variant last_selected_language = cf->get_value("script_setup", "last_selected_language"); + if (last_selected_language.get_type() != Variant::STRING) + return ""; + return static_cast(last_selected_language); +} + +void EditorSettings::set_last_selected_language(String p_language) +{ + Ref cf = memnew( ConfigFile ); + String path = get_project_settings_path().plus_file("project_metadata.cfg"); + Error err = cf->load(path); + if (err != OK) { + WARN_PRINTS("Can't load config file: " + path); + return; + } + cf->set_value("script_setup", "last_selected_language", p_language); + cf->save(path); +} + void EditorSettings::_bind_methods() { ObjectTypeDB::bind_method(_MD("erase","property"),&EditorSettings::erase); -- cgit v1.2.3-70-g09d2