diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 4778a7ce90f..7e450fb4ad1 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); diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h index 2a7d3bb4f02..a9766023046 100644 --- a/tools/editor/editor_settings.h +++ b/tools/editor/editor_settings.h @@ -160,6 +160,9 @@ public: void set_optimize_save(bool p_optimize); + String get_last_selected_language(); + void set_last_selected_language(String p_language); + EditorSettings(); ~EditorSettings(); diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index 749198314a5..62d5c7cd84e 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -121,6 +121,8 @@ void ScriptCreateDialog::ok_pressed() { Ref