From b9c78ba17429947789f3efafa7cee53da8a99a05 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 5 Apr 2024 22:26:29 +0200 Subject: [PATCH] Prevent dropping Resource to the same resource picker --- editor/editor_node.cpp | 4 ++-- editor/editor_node.h | 4 ++-- editor/editor_resource_picker.cpp | 11 ++++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6f984f6fabc5..1c079bfca2b6 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5324,7 +5324,7 @@ bool EditorNode::is_distraction_free_mode_enabled() const { return distraction_free->is_pressed(); } -Variant EditorNode::drag_resource(const Ref &p_res, Control *p_from) { +Dictionary EditorNode::drag_resource(const Ref &p_res, Control *p_from) { Control *drag_control = memnew(Control); TextureRect *drag_preview = memnew(TextureRect); Label *label = memnew(Label); @@ -5364,7 +5364,7 @@ Variant EditorNode::drag_resource(const Ref &p_res, Control *p_from) { return drag_data; } -Variant EditorNode::drag_files_and_dirs(const Vector &p_paths, Control *p_from) { +Dictionary EditorNode::drag_files_and_dirs(const Vector &p_paths, Control *p_from) { bool has_folder = false; bool has_file = false; for (int i = 0; i < p_paths.size(); i++) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 8bcf29811d8a..96acc8bf469c 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -870,8 +870,8 @@ public: bool is_exiting() const { return exiting; } - Variant drag_resource(const Ref &p_res, Control *p_from); - Variant drag_files_and_dirs(const Vector &p_paths, Control *p_from); + Dictionary drag_resource(const Ref &p_res, Control *p_from); + Dictionary drag_files_and_dirs(const Vector &p_paths, Control *p_from); void add_tool_menu_item(const String &p_name, const Callable &p_callback); void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 1cb71aa933b5..eee589489da2 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -615,6 +615,13 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, HashSetdrag_resource(edited_resource, p_from); + Dictionary drag_data = EditorNode::get_singleton()->drag_resource(edited_resource, p_from); + drag_data["source_picker"] = get_instance_id(); + return drag_data; } return Variant();