aboutsummaryrefslogtreecommitdiff
path: root/tools/editor/editor_settings.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2016-10-22 12:48:59 +0200
committerGitHub2016-10-22 12:48:59 +0200
commitac765fd5182d0aec4c68da41a23cef2322ea92b6 (patch)
treeeddb375c0b4bf62d5515d413e5e605394e376a68 /tools/editor/editor_settings.cpp
parentcf3ba3379f6888aa9520ce20b8121216cf5ba09b (diff)
parenta84a46176729ffab82703bdff62fcde73dd6477d (diff)
downloadgodot-ac765fd5182d0aec4c68da41a23cef2322ea92b6.tar.gz
godot-ac765fd5182d0aec4c68da41a23cef2322ea92b6.tar.zst
godot-ac765fd5182d0aec4c68da41a23cef2322ea92b6.zip
Merge pull request #6710 from lordadamson/master
fix #6031 when creating a script the default language will be what yo…
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 bdbf20e34..f5741c4a9 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -1026,6 +1026,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);