From 6bc6b8fcf24bdfcae4a990054c9077e1bc5a87e5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 9 Dec 2015 09:08:41 -0300 Subject: -ability to change scripts in external editor and still have properties reloaded in godot UI, fixes #3003 --- tools/editor/editor_data.cpp | 8 ++ tools/editor/editor_data.h | 1 + tools/editor/editor_node.cpp | 2 + tools/editor/editor_plugin.h | 1 + tools/editor/plugins/script_editor_plugin.cpp | 116 ++++++++++++++++++++++---- tools/editor/plugins/script_editor_plugin.h | 6 +- 6 files changed, 115 insertions(+), 19 deletions(-) (limited to 'tools') diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 673ee30ad..a6aedf270 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -338,6 +338,14 @@ void EditorData::set_editor_states(const Dictionary& p_states) { } +void EditorData::notify_edited_scene_changed() { + + for(int i=0;iedited_scene_changed(); + } +} + void EditorData::clear_editor_states() { for(int i=0;iget_debugger()->update_live_edit_root(); ScriptEditor::get_singleton()->set_scene_root_script( editor_data.get_scene_root_script(editor_data.get_edited_scene()) ); + editor_data.notify_edited_scene_changed(); + //changing_scene=false; } diff --git a/tools/editor/editor_plugin.h b/tools/editor/editor_plugin.h index 0f3a1e2e3..6850be2ea 100644 --- a/tools/editor/editor_plugin.h +++ b/tools/editor/editor_plugin.h @@ -92,6 +92,7 @@ public: virtual bool get_remove_list(List *p_list); virtual void set_window_layout(Ref p_layout); virtual void get_window_layout(Ref p_layout); + virtual void edited_scene_changed(){}; // if changes are pending in editor, apply them virtual void restore_global_state(); virtual void save_global_state(); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 4e394f9e3..37f4076a0 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -379,6 +379,8 @@ void ScriptTextEditor::reload_text() { te->set_h_scroll(h); te->set_v_scroll(v); + te->tag_saved_version(); + _line_col_changed(); } @@ -391,6 +393,12 @@ void ScriptTextEditor::_notification(int p_what) { } } + +bool ScriptTextEditor::is_unsaved() { + + return get_text_edit()->get_version()!=get_text_edit()->get_saved_version(); +} + String ScriptTextEditor::get_name() { String name; @@ -492,6 +500,59 @@ static Node* _find_node_for_script(Node* p_base, Node*p_current, const Ref > &r_scripts) { + + if (p_current->get_owner()!=p_base && p_base!=p_current) + return; + Ref