From 80595ba92b089de6c22ef0ca17b11054a252587c Mon Sep 17 00:00:00 2001 From: Will Nations Date: Fri, 12 Jan 2018 15:43:29 -0600 Subject: [PATCH] Added EditorPlugin 'resource_saved' signal --- editor/editor_data.cpp | 8 ++++++++ editor/editor_data.h | 1 + editor/editor_node.cpp | 1 + editor/editor_plugin.cpp | 5 +++++ editor/editor_plugin.h | 1 + 5 files changed, 16 insertions(+) diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 374688f2dbb..dc052564d79 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -364,6 +364,14 @@ void EditorData::notify_edited_scene_changed() { } } +void EditorData::notify_resource_saved(const Ref &p_resource) { + + for (int i = 0; i < editor_plugins.size(); i++) { + + editor_plugins[i]->notify_resource_saved(p_resource); + } +} + void EditorData::clear_editor_states() { for (int i = 0; i < editor_plugins.size(); i++) { diff --git a/editor/editor_data.h b/editor/editor_data.h index 844145853df..2d2247c4cbe 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -203,6 +203,7 @@ public: void save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom); Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history); void notify_edited_scene_changed(); + void notify_resource_saved(const Ref &p_resource); EditorData(); }; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2b62faf2180..833ae3e9547 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -596,6 +596,7 @@ void EditorNode::save_resource_in_path(const Ref &p_resource, const St ((Resource *)p_resource.ptr())->set_path(path); emit_signal("resource_saved", p_resource); + editor_data.notify_resource_saved(p_resource); } void EditorNode::save_resource(const Ref &p_resource) { diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 9dd8a7232f3..df1e37a0d6e 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -410,6 +410,10 @@ void EditorPlugin::notify_scene_closed(const String &scene_filepath) { emit_signal("scene_closed", scene_filepath); } +void EditorPlugin::notify_resource_saved(const Ref &p_resource) { + emit_signal("resource_saved", p_resource); +} + Ref EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) { //?? if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) { @@ -690,6 +694,7 @@ void EditorPlugin::_bind_methods() { ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath"))); ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name"))); + ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR); BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 8ed14ab847f..cac6f7f7283 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -163,6 +163,7 @@ public: void notify_main_screen_changed(const String &screen_name); void notify_scene_changed(const Node *scn_root); void notify_scene_closed(const String &scene_filepath); + void notify_resource_saved(const Ref &p_resource); virtual Ref create_spatial_gizmo(Spatial *p_spatial); virtual bool forward_canvas_gui_input(const Ref &p_event);