Merge pull request #6710 from lordadamson/master

fix #6031 when creating a script the default language will be what yo…
This commit is contained in:
Rémi Verschelde 2016-10-22 12:48:59 +02:00 committed by GitHub
commit ac765fd518
4 changed files with 46 additions and 1 deletions

View file

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