summaryrefslogtreecommitdiff
path: root/tools/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/editor_node.cpp')
-rw-r--r--tools/editor/editor_node.cpp125
1 files changed, 99 insertions, 26 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 02b0e9447a..316485f42a 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -1571,15 +1571,27 @@ void EditorNode::_imported(Node *p_node) {
}
+void EditorNode::_hide_top_editors() {
+ _display_top_editors(false);
-void EditorNode::_hide_top_editors() {
+ editor_plugins_over->clear();
+}
+
+void EditorNode::_display_top_editors(bool p_display) {
+ editor_plugins_over->make_visible(p_display);
+}
+
+void EditorNode::_set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over) {
+ editor_plugins_over->set_plugins_list(p_editor_plugins_over);
+}
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
- editor_plugin_over=NULL;
+void EditorNode::_set_editing_top_editors(Object* p_current_object) {
+ editor_plugins_over->edit(p_current_object);
}
+
+
void EditorNode::_edit_current() {
uint32_t current = editor_history.get_current();
@@ -1598,8 +1610,7 @@ void EditorNode::_edit_current() {
property_editor->edit( NULL );
object_menu->set_disabled(true);
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
+ _display_top_editors(false);
return;
}
@@ -1679,20 +1690,18 @@ void EditorNode::_edit_current() {
}
- EditorPlugin *sub_plugin = editor_data.get_subeditor(current_obj);
+ Vector<EditorPlugin*> sub_plugins = editor_data.get_subeditors(current_obj);
- if (sub_plugin) {
+ if (!sub_plugins.empty()) {
+ _display_top_editors(false);
+ _set_top_editors(sub_plugins);
+ _set_editing_top_editors(current_obj);
+ _display_top_editors(true);
+
+ } else if (!editor_plugins_over->get_plugins_list().empty()) {
- if (editor_plugin_over)
- editor_plugin_over->make_visible(false);
- editor_plugin_over=sub_plugin;
- editor_plugin_over->edit(current_obj);
- editor_plugin_over->make_visible(true);
- } else if (editor_plugin_over) {
-
- editor_plugin_over->make_visible(false);
- editor_plugin_over=NULL;
+ _hide_top_editors();
}
/*
@@ -2076,8 +2085,12 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
Node *scene = editor_data.get_edited_scene_root();
if (scene && scene->get_filename()!="") {
- //_save_scene(scene->get_filename());
- _save_scene_with_preview(scene->get_filename());
+ // save in background if in the script editor
+ if (_get_current_main_editor() == EDITOR_SCRIPT) {
+ _save_scene(scene->get_filename());
+ } else {
+ _save_scene_with_preview(scene->get_filename());
+ }
return;
};
// fallthrough to save_as
@@ -2579,10 +2592,9 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
}
editor_data.get_undo_redo().clear_history();
- if (editor_plugin_over) { //reload editor plugin
- editor_plugin_over->edit(NULL);
- editor_plugin_over->edit(current);
- }
+
+ _set_editing_top_editors(NULL);
+ _set_editing_top_editors(current);
} break;
case OBJECT_CALL_METHOD: {
@@ -2660,6 +2672,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
break;
}
+ _menu_option_confirm(RUN_STOP,true);
get_tree()->quit();
String exec = OS::get_singleton()->get_executable_path();
@@ -6134,7 +6147,7 @@ EditorNode::EditorNode() {
_rebuild_import_menu();
editor_plugin_screen=NULL;
- editor_plugin_over=NULL;
+ editor_plugins_over = memnew(EditorPluginList);
// force_top_viewport(true);
_edit_current();
@@ -6266,12 +6279,72 @@ EditorNode::EditorNode() {
EditorNode::~EditorNode() {
-
-
+
memdelete( EditorHelp::get_doc_data() );
memdelete(editor_selection);
+ memdelete(editor_plugins_over);
memdelete(file_server);
EditorSettings::destroy();
}
+/*
+ * EDITOR PLUGIN LIST
+ */
+
+
+void EditorPluginList::make_visible(bool p_visible) {
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ plugins_list[i]->make_visible(p_visible);
+ }
+ }
+}
+
+void EditorPluginList::edit(Object* p_object) {
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ plugins_list[i]->edit(p_object);
+ }
+ }
+}
+
+bool EditorPluginList::forward_input_event(const InputEvent& p_event) {
+ bool discard = false;
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ if (plugins_list[i]->forward_input_event(p_event)) {
+ discard = true;
+ }
+ }
+ }
+ return discard;
+}
+
+bool EditorPluginList::forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event) {
+ bool discard = false;
+ if (!plugins_list.empty()) {
+ for (int i = 0; i < plugins_list.size(); i++) {
+ if (plugins_list[i]->forward_spatial_input_event(p_camera, p_event)) {
+ discard = true;
+ }
+ }
+ }
+ return discard;
+}
+
+bool EditorPluginList::empty() {
+ return plugins_list.empty();
+}
+
+void EditorPluginList::clear() {
+ plugins_list.clear();
+}
+
+EditorPluginList::EditorPluginList() {
+}
+
+EditorPluginList::~EditorPluginList() {
+}
+
+