summaryrefslogtreecommitdiff
path: root/editor/plugins/script_editor_plugin.cpp
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2019-04-13 12:43:35 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2019-04-13 13:07:12 +0100
commit6ea253aa776e03dc7174b289c6747cd8d0410245 (patch)
tree3e73d0955615133c8994c1150639583007f31b4a /editor/plugins/script_editor_plugin.cpp
parentb7cf4c2050dfd51521522c874676e96d2e5c4762 (diff)
Restore script editor state between sessions
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r--editor/plugins/script_editor_plugin.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index d7d4cec07d..8fdeb1cd39 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -2482,22 +2482,33 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
for (int i = 0; i < scripts.size(); i++) {
String path = scripts[i];
+
+ Dictionary script_info = scripts[i];
+ if (!script_info.empty()) {
+ path = script_info["path"];
+ }
+
if (!FileAccess::exists(path))
continue;
if (extensions.find(path.get_extension())) {
Ref<Script> scr = ResourceLoader::load(path);
- if (scr.is_valid()) {
- edit(scr);
+ if (!scr.is_valid()) {
continue;
}
+ edit(scr);
+ } else {
+ Error error;
+ Ref<TextFile> text_file = _load_text_file(path, &error);
+ if (error != OK || !text_file.is_valid()) {
+ continue;
+ }
+ edit(text_file);
}
- Error error;
- Ref<TextFile> text_file = _load_text_file(path, &error);
- if (error == OK && text_file.is_valid()) {
- edit(text_file);
- continue;
+ if (!script_info.empty()) {
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
+ se->set_edit_state(script_info["state"]);
}
}
@@ -2537,7 +2548,11 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
if (!path.is_resource_file())
continue;
- scripts.push_back(path);
+ Dictionary script_info;
+ script_info["path"] = path;
+ script_info["state"] = se->get_edit_state();
+
+ scripts.push_back(script_info);
}
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));