aboutsummaryrefslogtreecommitdiff
path: root/tools/editor/editor_settings.cpp
diff options
context:
space:
mode:
authorAdham Zahran2016-10-12 22:23:48 +0200
committerAdham Zahran2016-10-20 23:53:15 +0200
commita84a46176729ffab82703bdff62fcde73dd6477d (patch)
treef9dc4ed104d69aa0b6478fc49e44c68abe9af576 /tools/editor/editor_settings.cpp
parent78d97b060a6873a454e710380cb9ef1bde5e4c65 (diff)
downloadgodot-a84a46176729ffab82703bdff62fcde73dd6477d.tar.gz
godot-a84a46176729ffab82703bdff62fcde73dd6477d.tar.zst
godot-a84a46176729ffab82703bdff62fcde73dd6477d.zip
fix #6031 when creating a script the language will be what you selected last time
Diffstat (limited to 'tools/editor/editor_settings.cpp')
-rw-r--r--tools/editor/editor_settings.cpp28
1 files changed, 28 insertions, 0 deletions
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<ConfigFile> 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<String>(last_selected_language);
+}
+
+void EditorSettings::set_last_selected_language(String p_language)
+{
+ Ref<ConfigFile> 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);