diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-04-21 13:01:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-21 13:01:43 +0200 |
commit | 71bbe6eb01d1664340ea624aca36aa47c693981d (patch) | |
tree | 7fab2ac8f65a8d3190d4255d1ba22cbb52a8697f /editor/plugins/script_editor_plugin.cpp | |
parent | 7879968136828a6b98daab9ee4e8897eb8c26048 (diff) | |
parent | 6ea253aa776e03dc7174b289c6747cd8d0410245 (diff) | |
download | redot-engine-71bbe6eb01d1664340ea624aca36aa47c693981d.tar.gz |
Merge pull request #27979 from Paulb23/remember_script_state
Restore script editor state between sessions
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 31 |
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)); |