Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save branch as scene by dropping to filesystem #52503

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions editor/scene_tree_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class SceneTreeDock : public VBoxContainer {
public:
String get_filter();
void set_filter(const String &p_filter);
void save_branch_to_file(String p_directory);

void _focus_node();

Expand Down