Save branch as scene by dropping to filesystem

(cherry picked from commit d4f4cfbb40)
This commit is contained in:
kobewi 2021-09-09 00:43:14 +02:00 committed by Rémi Verschelde
parent 723ad5ef61
commit 0da326c8b3
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 21 additions and 0 deletions

View file

@ -2127,6 +2127,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;
}
@ -2265,6 +2273,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 {

View file

@ -2841,6 +2841,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);

View file

@ -265,6 +265,7 @@ protected:
public:
String get_filter();
void set_filter(const String &p_filter);
void save_branch_to_file(String p_directory);
void _focus_node();