1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

fix #6031 when creating a script the language will be what you selected last time

This commit is contained in:
Adham Zahran
2016-10-12 22:23:48 +02:00
parent 78d97b060a
commit a84a461767
4 changed files with 46 additions and 1 deletions

View File

@@ -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);