Merge pull request #14609 from sersoong/master-test
Enhanced Merge From Scene
This commit is contained in:
commit
2e21a427ee
|
@ -96,14 +96,54 @@ void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorSubScene::ok_pressed() {
|
void EditorSubScene::_selected_changed() {
|
||||||
|
selection.clear();
|
||||||
|
is_root = false;
|
||||||
|
}
|
||||||
|
|
||||||
TreeItem *s = tree->get_selected();
|
void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_selected) {
|
||||||
if (!s)
|
if (!is_root) {
|
||||||
|
TreeItem *item = Object::cast_to<TreeItem>(p_object);
|
||||||
|
ERR_FAIL_COND(!item);
|
||||||
|
|
||||||
|
Node *n = item->get_metadata(0);
|
||||||
|
|
||||||
|
if (!n)
|
||||||
return;
|
return;
|
||||||
Node *selnode = s->get_metadata(0);
|
if (p_selected) {
|
||||||
if (!selnode)
|
if (n == scene) {
|
||||||
|
is_root = true;
|
||||||
|
selection.clear();
|
||||||
|
}
|
||||||
|
selection.push_back(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorSubScene::_remove_selection_child(Node *n) {
|
||||||
|
if (n->get_child_count() > 0) {
|
||||||
|
for (int i = 0; i < n->get_child_count(); i++) {
|
||||||
|
Node *c = n->get_child(i);
|
||||||
|
List<Node *>::Element *E = selection.find(c);
|
||||||
|
if (E) {
|
||||||
|
selection.move_to_back(E);
|
||||||
|
selection.pop_back();
|
||||||
|
}
|
||||||
|
if (c->get_child_count() > 0) {
|
||||||
|
_remove_selection_child(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorSubScene::ok_pressed() {
|
||||||
|
if (selection.size() <= 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||||
|
Node *c = E->get();
|
||||||
|
_remove_selection_child(c);
|
||||||
|
}
|
||||||
emit_signal("subscene_selected");
|
emit_signal("subscene_selected");
|
||||||
hide();
|
hide();
|
||||||
clear();
|
clear();
|
||||||
|
@ -127,23 +167,21 @@ void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) {
|
void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) {
|
||||||
|
|
||||||
if (!scene) {
|
if (!scene) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TreeItem *s = tree->get_selected();
|
|
||||||
if (!s) {
|
if (selection.size() <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *selnode = s->get_metadata(0);
|
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
||||||
|
Node *selnode = E->get();
|
||||||
if (!selnode) {
|
if (!selnode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Node *> to_reown;
|
List<Node *> to_reown;
|
||||||
_reown(selnode, &to_reown);
|
_reown(selnode, &to_reown);
|
||||||
|
|
||||||
if (selnode != scene) {
|
if (selnode != scene) {
|
||||||
selnode->get_parent()->remove_child(selnode);
|
selnode->get_parent()->remove_child(selnode);
|
||||||
}
|
}
|
||||||
|
@ -152,12 +190,11 @@ void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) {
|
||||||
for (List<Node *>::Element *E = to_reown.front(); E; E = E->next()) {
|
for (List<Node *>::Element *E = to_reown.front(); E; E = E->next()) {
|
||||||
E->get()->set_owner(p_new_owner);
|
E->get()->set_owner(p_new_owner);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (selnode != scene) {
|
if (!is_root) {
|
||||||
memdelete(scene);
|
memdelete(scene);
|
||||||
}
|
}
|
||||||
scene = NULL;
|
scene = NULL;
|
||||||
|
|
||||||
//return selnode;
|
//return selnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,12 +209,15 @@ void EditorSubScene::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("_path_selected"), &EditorSubScene::_path_selected);
|
ClassDB::bind_method(D_METHOD("_path_selected"), &EditorSubScene::_path_selected);
|
||||||
ClassDB::bind_method(D_METHOD("_path_changed"), &EditorSubScene::_path_changed);
|
ClassDB::bind_method(D_METHOD("_path_changed"), &EditorSubScene::_path_changed);
|
||||||
ClassDB::bind_method(D_METHOD("_path_browse"), &EditorSubScene::_path_browse);
|
ClassDB::bind_method(D_METHOD("_path_browse"), &EditorSubScene::_path_browse);
|
||||||
|
ClassDB::bind_method(D_METHOD("_item_multi_selected"), &EditorSubScene::_item_multi_selected);
|
||||||
|
ClassDB::bind_method(D_METHOD("_selected_changed"), &EditorSubScene::_selected_changed);
|
||||||
ADD_SIGNAL(MethodInfo("subscene_selected"));
|
ADD_SIGNAL(MethodInfo("subscene_selected"));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorSubScene::EditorSubScene() {
|
EditorSubScene::EditorSubScene() {
|
||||||
|
|
||||||
scene = NULL;
|
scene = NULL;
|
||||||
|
is_root = false;
|
||||||
|
|
||||||
set_title(TTR("Select Node(s) to Import"));
|
set_title(TTR("Select Node(s) to Import"));
|
||||||
set_hide_on_ok(false);
|
set_hide_on_ok(false);
|
||||||
|
@ -200,6 +240,11 @@ EditorSubScene::EditorSubScene() {
|
||||||
tree = memnew(Tree);
|
tree = memnew(Tree);
|
||||||
tree->set_v_size_flags(SIZE_EXPAND_FILL);
|
tree->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
vb->add_margin_child(TTR("Import From Node:"), tree, true);
|
vb->add_margin_child(TTR("Import From Node:"), tree, true);
|
||||||
|
tree->set_select_mode(Tree::SELECT_MULTI);
|
||||||
|
tree->connect("multi_selected", this, "_item_multi_selected");
|
||||||
|
//tree->connect("nothing_selected", this, "_deselect_items");
|
||||||
|
tree->connect("cell_selected", this, "_selected_changed");
|
||||||
|
|
||||||
tree->connect("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED);
|
tree->connect("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED);
|
||||||
|
|
||||||
file_dialog = memnew(EditorFileDialog);
|
file_dialog = memnew(EditorFileDialog);
|
||||||
|
|
|
@ -38,13 +38,18 @@ class EditorSubScene : public ConfirmationDialog {
|
||||||
|
|
||||||
GDCLASS(EditorSubScene, ConfirmationDialog);
|
GDCLASS(EditorSubScene, ConfirmationDialog);
|
||||||
|
|
||||||
|
List<Node *> selection;
|
||||||
LineEdit *path;
|
LineEdit *path;
|
||||||
Tree *tree;
|
Tree *tree;
|
||||||
Node *scene;
|
Node *scene;
|
||||||
|
bool is_root;
|
||||||
|
|
||||||
EditorFileDialog *file_dialog;
|
EditorFileDialog *file_dialog;
|
||||||
|
|
||||||
void _fill_tree(Node *p_node, TreeItem *p_parent);
|
void _fill_tree(Node *p_node, TreeItem *p_parent);
|
||||||
|
void _selected_changed();
|
||||||
|
void _item_multi_selected(Object *p_object, int p_cell, bool p_selected);
|
||||||
|
void _remove_selection_child(Node *c);
|
||||||
void _reown(Node *p_node, List<Node *> *p_to_reown);
|
void _reown(Node *p_node, List<Node *> *p_to_reown);
|
||||||
|
|
||||||
void ok_pressed();
|
void ok_pressed();
|
||||||
|
|
Loading…
Reference in New Issue