summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-12-31 00:31:00 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-12-31 00:31:00 -0300
commitfd836cad270f7eb9645356cd583c8f11bf737b0f (patch)
treecf3c430537b27cf0dc902e6a1c12906b93771611 /tools/editor
parent9bf7adfc1fcf1e57b5279f3d56983bc222366562 (diff)
-Ensure .tscn and .tres always save in a deterministic way, fixes #2495
-Scene edit state is saved outside the scene now, to avoid changes .tscn files when nothing really changed -Created a VariantWriter helper to unify all variant to text writing -Moved SceneFormatText writing to VariantWriter -Moved ConfigFile to use VariantWriter and VariantParser, added compatibility mode for old .cfg files that use engine.cfg format
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/editor_node.cpp61
-rw-r--r--tools/editor/editor_node.h4
2 files changed, 36 insertions, 29 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index b30c875866..4438123dff 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);
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 0a087eb1ed..36f23490d8 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -420,8 +420,8 @@ class EditorNode : public Node {
void _node_renamed();
void _editor_select(int p_which);
- void _set_scene_metadata();
- void _get_scene_metadata();
+ void _set_scene_metadata(const String &p_file);
+ void _get_scene_metadata(const String& p_file);
void _update_title();
void _update_scene_tabs();
void _close_messages();