Now the Access as Unique Name option is in the right place when right clicking the scene tree.

This commit is contained in:
Relintai 2022-10-16 23:52:10 +02:00
parent d963444bad
commit 0b37d5ec86

View File

@ -2828,25 +2828,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_separator();
}
// Allow multi-toggling scene unique names but only if all selected nodes are owned by the edited scene root.
bool all_owned = true;
for (List<Node *>::Element *e = full_selection.front(); e; e = e->next()) {
Node *node = e->get();
if (node->get_owner() != EditorNode::get_singleton()->get_edited_scene()) {
all_owned = false;
break;
}
}
if (all_owned) {
// Group "toggle_unique_name" with "copy_node_path", if it is available.
if (menu->get_item_index(TOOL_COPY_NODE_PATH) == -1) {
menu->add_separator();
}
Node *node = full_selection[0];
menu->add_icon_shortcut(get_theme_icon("SceneUniqueName", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/toggle_unique_name"), TOOL_TOGGLE_SCENE_UNIQUE_NAME);
menu->set_item_text(menu->get_item_index(TOOL_TOGGLE_SCENE_UNIQUE_NAME), node->is_unique_name_in_owner() ? TTR("Revoke Unique Name") : TTR("Access as Unique Name"));
}
add_separator = false;
if (full_selection.size() == 1) {
@ -2912,6 +2893,25 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
}
}
// Allow multi-toggling scene unique names but only if all selected nodes are owned by the edited scene root.
bool all_owned = true;
for (List<Node *>::Element *e = full_selection.front(); e; e = e->next()) {
Node *node = e->get();
if (node->get_owner() != EditorNode::get_singleton()->get_edited_scene()) {
all_owned = false;
break;
}
}
if (all_owned) {
// Group "toggle_unique_name" with "copy_node_path", if it is available.
if (menu->get_item_index(TOOL_COPY_NODE_PATH) == -1) {
menu->add_separator();
}
Node *node = full_selection[0];
menu->add_icon_shortcut(get_theme_icon("SceneUniqueName", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/toggle_unique_name"), TOOL_TOGGLE_SCENE_UNIQUE_NAME);
menu->set_item_text(menu->get_item_index(TOOL_TOGGLE_SCENE_UNIQUE_NAME), node->is_unique_name_in_owner() ? TTR("Revoke Unique Name") : TTR("Access as Unique Name"));
}
#ifdef MODULE_REGEX_ENABLED
if (selection.size() > 1) {
//this is not a commonly used action, it makes no sense for it to be where it was nor always present.