|
@@ -563,7 +563,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
if (!profile_allow_editing) {
|
|
|
break;
|
|
|
}
|
|
|
- if (editor_selection->get_top_selected_node_list().size() > 1) {
|
|
|
+ if (editor_selection->get_selection().size() > 1) {
|
|
|
if (!_validate_no_foreign()) {
|
|
|
break;
|
|
|
}
|
|
@@ -1153,7 +1153,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
|
|
|
if (selection.size() != 1) {
|
|
|
accept->set_text(vformat(TTR("Saving the branch as a scene requires selecting only one node, but you have selected %d nodes."), selection.size()));
|
|
@@ -1214,8 +1214,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
new_scene_from_dialog->popup_file_dialog();
|
|
|
} break;
|
|
|
case TOOL_COPY_NODE_PATH: {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
|
if (node) {
|
|
@@ -1226,8 +1226,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
}
|
|
|
} break;
|
|
|
case TOOL_SHOW_IN_FILE_SYSTEM: {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
const Node *node = e->get();
|
|
|
if (node) {
|
|
@@ -1236,7 +1236,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
}
|
|
|
} break;
|
|
|
case TOOL_OPEN_DOCUMENTATION: {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
for (const Node *node : selection) {
|
|
|
String class_name;
|
|
|
Ref<Script> script_base = node->get_script();
|
|
@@ -1272,12 +1272,12 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
if (selection.size() != 1) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
|
if (node) {
|
|
@@ -1307,8 +1307,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
|
if (node) {
|
|
@@ -1342,8 +1342,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
|
if (node) {
|
|
@@ -1367,8 +1367,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
}
|
|
|
} break;
|
|
|
case TOOL_SCENE_OPEN: {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
|
if (node) {
|
|
@@ -1388,8 +1388,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
|
if (node) {
|
|
@@ -1400,8 +1400,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|
|
}
|
|
|
} break;
|
|
|
case TOOL_SCENE_OPEN_INHERITED: {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
|
if (node && node->get_scene_inherited_state().is_valid()) {
|
|
@@ -2295,7 +2295,7 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) {
|
|
|
}
|
|
|
|
|
|
bool SceneTreeDock::_validate_no_foreign() {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
|
|
|
for (Node *E : selection) {
|
|
|
if (E != edited_scene && E->get_owner() != edited_scene) {
|
|
@@ -2324,7 +2324,7 @@ bool SceneTreeDock::_validate_no_foreign() {
|
|
|
}
|
|
|
|
|
|
bool SceneTreeDock::_validate_no_instance() {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
|
|
|
for (Node *E : selection) {
|
|
|
if (E != edited_scene && !E->get_scene_file_path().is_empty()) {
|
|
@@ -2341,7 +2341,7 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) {
|
|
|
Node *new_parent = scene_root->get_node(p_path);
|
|
|
ERR_FAIL_NULL(new_parent);
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
|
|
|
if (selection.is_empty()) {
|
|
|
return; // Nothing to reparent.
|
|
@@ -2563,7 +2563,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
|
|
|
}
|
|
|
|
|
|
void SceneTreeDock::_script_created(Ref<Script> p_script) {
|
|
|
- List<Node *> selected = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selected = editor_selection->get_top_selected_node_list();
|
|
|
|
|
|
if (selected.is_empty()) {
|
|
|
return;
|
|
@@ -2624,8 +2624,8 @@ void SceneTreeDock::_shader_creation_closed() {
|
|
|
}
|
|
|
|
|
|
void SceneTreeDock::_toggle_editable_children_from_selection() {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
|
|
|
if (e) {
|
|
|
_toggle_editable_children(e->get());
|
|
@@ -2633,8 +2633,8 @@ void SceneTreeDock::_toggle_editable_children_from_selection() {
|
|
|
}
|
|
|
|
|
|
void SceneTreeDock::_toggle_placeholder_from_selection() {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
- List<Node *>::Element *e = selection.front();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *>::Element *e = selection.front();
|
|
|
|
|
|
if (e) {
|
|
|
Node *node = e->get();
|
|
@@ -3023,7 +3023,7 @@ void SceneTreeDock::_create() {
|
|
|
_do_create(parent);
|
|
|
|
|
|
} else if (current_option == TOOL_REPLACE) {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
ERR_FAIL_COND(selection.is_empty());
|
|
|
|
|
|
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
|
|
@@ -3042,7 +3042,7 @@ void SceneTreeDock::_create() {
|
|
|
|
|
|
ur->commit_action(false);
|
|
|
} else if (current_option == TOOL_REPARENT_TO_NEW_NODE) {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
ERR_FAIL_COND(selection.is_empty());
|
|
|
|
|
|
// Find top level node in selection
|
|
@@ -3056,7 +3056,7 @@ void SceneTreeDock::_create() {
|
|
|
bool center_parent = EDITOR_GET("docks/scene_tree/center_node_on_reparent");
|
|
|
Vector<Node *> top_level_nodes;
|
|
|
|
|
|
- for (List<Node *>::Element *E = selection.front()->next(); E; E = E->next()) {
|
|
|
+ for (const List<Node *>::Element *E = selection.front()->next(); E; E = E->next()) {
|
|
|
Node *n = E->get();
|
|
|
ERR_FAIL_NULL(n);
|
|
|
|
|
@@ -3363,12 +3363,12 @@ void SceneTreeDock::set_edited_scene(Node *p_scene) {
|
|
|
edited_scene = p_scene;
|
|
|
}
|
|
|
|
|
|
-static bool _is_same_selection(const Vector<Node *> &p_first, const List<Node *> &p_second) {
|
|
|
+static bool _is_same_selection(const Vector<Node *> &p_first, const HashMap<Node *, Object *> &p_second) {
|
|
|
if (p_first.size() != p_second.size()) {
|
|
|
return false;
|
|
|
}
|
|
|
- for (Node *node : p_second) {
|
|
|
- if (!p_first.has(node)) {
|
|
|
+ for (Node *node : p_first) {
|
|
|
+ if (!p_second.has(node)) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -3387,7 +3387,7 @@ void SceneTreeDock::clear_previous_node_selection() {
|
|
|
|
|
|
void SceneTreeDock::set_selection(const Vector<Node *> &p_nodes) {
|
|
|
// If the nodes selected are the same independently of order then return early.
|
|
|
- if (_is_same_selection(p_nodes, editor_selection->get_full_selected_node_list())) {
|
|
|
+ if (_is_same_selection(p_nodes, editor_selection->get_selection())) {
|
|
|
return;
|
|
|
}
|
|
|
editor_selection->clear();
|
|
@@ -3401,7 +3401,7 @@ void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected) {
|
|
|
}
|
|
|
|
|
|
void SceneTreeDock::_new_scene_from(const String &p_file) {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
|
|
|
if (selection.size() != 1) {
|
|
|
accept->set_text(TTR("This operation requires a single selected node."));
|
|
@@ -3579,7 +3579,7 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) {
|
|
|
}
|
|
|
|
|
|
Array SceneTreeDock::_get_selection_array() {
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
TypedArray<Node> array;
|
|
|
array.resize(selection.size());
|
|
|
|
|
@@ -3728,7 +3728,7 @@ void SceneTreeDock::_nodes_dragged(const Array &p_nodes, NodePath p_to, int p_ty
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
|
|
|
if (selection.is_empty()) {
|
|
|
return; //nothing to reparent
|
|
@@ -3791,7 +3791,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
|
|
|
ERR_FAIL_COND(!EditorNode::get_singleton()->get_edited_scene());
|
|
|
menu->clear(false);
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
List<Node *> full_selection = editor_selection->get_full_selected_node_list(); // Above method only returns nodes with common parent.
|
|
|
|
|
|
if (selection.is_empty()) {
|
|
@@ -4007,7 +4007,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
|
|
|
|
|
|
Vector<String> p_paths;
|
|
|
Node *root = EditorNode::get_singleton()->get_edited_scene();
|
|
|
- for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
|
|
+ for (const List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
|
|
String node_path = String(root->get_path().rel_path_to(E->get()->get_path()));
|
|
|
p_paths.push_back(node_path);
|
|
|
}
|
|
@@ -4144,7 +4144,7 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
if (selection.is_empty()) {
|
|
|
return;
|
|
|
}
|
|
@@ -4274,7 +4274,7 @@ List<Node *> SceneTreeDock::paste_nodes(bool p_paste_as_sibling) {
|
|
|
Node *paste_parent = edited_scene;
|
|
|
Node *paste_sibling = nullptr;
|
|
|
|
|
|
- List<Node *> selection = editor_selection->get_top_selected_node_list();
|
|
|
+ const List<Node *> &selection = editor_selection->get_top_selected_node_list();
|
|
|
if (selection.size() > 0) {
|
|
|
paste_parent = selection.back()->get();
|
|
|
}
|