diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-01-18 13:06:48 +0100 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-01-22 17:51:12 +0100 |
commit | 97b469c46d8a3225cc26b22952e408451192794e (patch) | |
tree | 4b1ea2c0c53b5de3bd2efff3c25b3f55ee6ad5c2 | |
parent | 0bcc0e92b3f0ac57d4c4650722f347593a258572 (diff) | |
download | redot-engine-97b469c46d8a3225cc26b22952e408451192794e.tar.gz |
[Editor] Add `EditorPlugin::scene_saved` signal
Matches the `EditorNode` one for parity with the exposed
`resource_saved` signal
-rw-r--r-- | doc/classes/EditorPlugin.xml | 10 | ||||
-rw-r--r-- | editor/editor_data.cpp | 6 | ||||
-rw-r--r-- | editor/editor_data.h | 1 | ||||
-rw-r--r-- | editor/editor_node.cpp | 1 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 5 | ||||
-rw-r--r-- | editor/editor_plugin.h | 1 |
6 files changed, 22 insertions, 2 deletions
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index 148a6541a2..407d64e9a2 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -759,7 +759,7 @@ <signal name="resource_saved"> <param index="0" name="resource" type="Resource" /> <description> - Emitted when the given [param resource] was saved on disc. + Emitted when the given [param resource] was saved on disc. See also [signal scene_saved]. </description> </signal> <signal name="scene_changed"> @@ -771,7 +771,13 @@ <signal name="scene_closed"> <param index="0" name="filepath" type="String" /> <description> - Emitted when user closes a scene. The argument is file path to a closed scene. + Emitted when user closes a scene. The argument is a file path to the closed scene. + </description> + </signal> + <signal name="scene_saved"> + <param index="0" name="filepath" type="String" /> + <description> + Emitted when a scene was saved on disc. The argument is a file path to the saved scene. See also [signal resource_saved]. </description> </signal> </signals> diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 794d1b3e10..786e841c21 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -361,6 +361,12 @@ void EditorData::notify_resource_saved(const Ref<Resource> &p_resource) { } } +void EditorData::notify_scene_saved(const String &p_path) { + for (int i = 0; i < editor_plugins.size(); i++) { + editor_plugins[i]->notify_scene_saved(p_path); + } +} + void EditorData::clear_editor_states() { for (int i = 0; i < editor_plugins.size(); i++) { editor_plugins[i]->clear(); diff --git a/editor/editor_data.h b/editor/editor_data.h index 01e9dc4b07..d1af400e87 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -236,6 +236,7 @@ public: Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorSelectionHistory *p_history); void notify_edited_scene_changed(); void notify_resource_saved(const Ref<Resource> &p_resource); + void notify_scene_saved(const String &p_path); bool script_class_is_parent(const String &p_class, const String &p_inherits); StringName script_class_get_base(const String &p_class) const; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 8cffc2b4b0..24bfba3844 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1805,6 +1805,7 @@ void EditorNode::_save_scene(String p_file, int idx) { // This needs to be emitted before saving external resources. emit_signal(SNAME("scene_saved"), p_file); + editor_data.notify_scene_saved(p_file); _save_external_resources(); saving_scene = p_file; // Some editors may save scenes of built-in resources as external data, so avoid saving this scene again. diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index f0044edff2..866d7ae233 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -249,6 +249,10 @@ void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) { emit_signal(SNAME("resource_saved"), p_resource); } +void EditorPlugin::notify_scene_saved(const String &p_scene_filepath) { + emit_signal(SNAME("scene_saved"), p_scene_filepath); +} + bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { bool success = false; GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success); @@ -632,6 +636,7 @@ void EditorPlugin::_bind_methods() { 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"))); + ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "filepath"))); ADD_SIGNAL(MethodInfo("project_settings_changed")); BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 8870ef425e..a93955046a 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -160,6 +160,7 @@ public: void notify_scene_changed(const Node *scn_root); void notify_scene_closed(const String &scene_filepath); void notify_resource_saved(const Ref<Resource> &p_resource); + void notify_scene_saved(const String &p_scene_filepath); virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event); virtual void forward_canvas_draw_over_viewport(Control *p_overlay); |