diff options
author | Max Hilbrunner <mhilbrunner@users.noreply.github.com> | 2021-09-10 12:58:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 12:58:03 +0200 |
commit | cf08fadbadb55656813612fdba2cb763423d9612 (patch) | |
tree | 8228a04c1cfdebb7eabe0f5697ecb213239bd81b | |
parent | 729461b2a455bd3b4afb26bb362863a68e98a9ee (diff) | |
parent | d4f4cfbb40de69613a3dc4cfb1a974c237c93ef3 (diff) |
Merge pull request #52503 from KoBeWi/DROPNODESTOFOLDERRRR
Save branch as scene by dropping to filesystem
-rw-r--r-- | editor/filesystem_dock.cpp | 15 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 5 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index daee61c2dd..5dd5c050e0 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2158,6 +2158,14 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da return true; } + if (drag_data.has("type") && String(drag_data["type"]) == "nodes") { + // Save branch as scene. + String to_dir; + bool favorite; + _get_drag_target_folder(to_dir, favorite, p_point, p_from); + return !favorite && Array(drag_data["nodes"]).size() == 1; + } + return false; } @@ -2296,6 +2304,13 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, _update_tree(_compute_uncollapsed_paths()); } } + + if (drag_data.has("type") && String(drag_data["type"]) == "nodes") { + String to_dir; + bool favorite; + _get_drag_target_folder(to_dir, favorite, p_point, p_from); + EditorNode::get_singleton()->get_scene_tree_dock()->save_branch_to_file(to_dir); + } } void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favorites, const Point2 &p_point, Control *p_from) const { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 2ec4a088a2..a08a628216 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2837,6 +2837,11 @@ void SceneTreeDock::set_filter(const String &p_filter) { scene_tree->set_filter(p_filter); } +void SceneTreeDock::save_branch_to_file(String p_directory) { + new_scene_from_dialog->set_current_dir(p_directory); + _tool_selected(TOOL_NEW_SCENE_FROM); +} + void SceneTreeDock::_focus_node() { Node *node = scene_tree->get_selected(); ERR_FAIL_COND(!node); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 387a35acbb..1086e8615f 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -269,6 +269,7 @@ protected: public: String get_filter(); void set_filter(const String &p_filter); + void save_branch_to_file(String p_directory); void _focus_node(); |