diff options
Diffstat (limited to 'tools/editor/editor_node.cpp')
| -rw-r--r-- | tools/editor/editor_node.cpp | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index b30c87586..4438123df 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -584,59 +584,66 @@ void EditorNode::_dialog_display_file_error(String p_file,Error p_error) { } -void EditorNode::_get_scene_metadata() { +void EditorNode::_get_scene_metadata(const String& p_file) { Node *scene = editor_data.get_edited_scene_root(); if (!scene) return; + String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg"); - if (scene->has_meta("__editor_plugin_states__")) { + Ref<ConfigFile> cf; + cf.instance(); - Dictionary md = scene->get_meta("__editor_plugin_states__"); - editor_data.set_editor_states(md); + Error err = cf->load(path); + if (err!=OK) + return; //must not exist - } + List<String> esl; + cf->get_section_keys("editor_states",&esl); - if (scene->has_meta("__editor_run_settings__")) { + Dictionary md; + for (List<String>::Element *E=esl.front();E;E=E->next()) { - Dictionary md = scene->get_meta("__editor_run_settings__"); - if (md.has("run_mode")) - run_settings_dialog->set_run_mode(md["run_mode"]); - if (md.has("custom_args")) - run_settings_dialog->set_custom_arguments(md["custom_args"]); + Variant st=cf->get_value("editor_states",E->get()); + if (st.get_type()) { + md[E->get()]=st; + } } + + editor_data.set_editor_states(md); + } -void EditorNode::_set_scene_metadata() { +void EditorNode::_set_scene_metadata(const String& p_file) { Node *scene = editor_data.get_edited_scene_root(); if (!scene) return; - { /* Editor States */ - Dictionary md = editor_data.get_editor_states(); + scene->set_meta("__editor_run_settings__",Variant()); //clear it (no point in keeping it) + scene->set_meta("__editor_plugin_states__",Variant()); - if (!md.empty()) { - scene->set_meta("__editor_plugin_states__",md); - } - } + String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file()+"-editstate-"+p_file.md5_text()+".cfg"); - { /* Run Settings */ + Ref<ConfigFile> cf; + cf.instance(); + Dictionary md = editor_data.get_editor_states(); + List<Variant> keys; + md.get_key_list(&keys); - Dictionary md; - md["run_mode"]=run_settings_dialog->get_run_mode(); - md["custom_args"]=run_settings_dialog->get_custom_arguments(); - scene->set_meta("__editor_run_settings__",md); - } - + for(List<Variant>::Element *E=keys.front();E;E=E->next()) { + cf->set_value("editor_states",E->get(),md[E->get()]); + } + Error err = cf->save(path); + ERR_FAIL_COND(err!=OK); } @@ -954,7 +961,7 @@ void EditorNode::_save_scene(String p_file) { } - _set_scene_metadata(); + _set_scene_metadata(p_file); Ref<PackedScene> sdata; @@ -3652,7 +3659,7 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo new_scene->set_scene_instance_state(Ref<SceneState>()); set_edited_scene(new_scene); - _get_scene_metadata(); + _get_scene_metadata(p_scene); /* editor_data.set_edited_scene_root(new_scene); |
