Removed unused variables from the SceneTreeDock.

This commit is contained in:
Relintai 2022-10-16 23:46:55 +02:00
parent 4e5f2f684a
commit d963444bad
2 changed files with 100 additions and 209 deletions

View File

@ -393,18 +393,12 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
switch (p_tool) {
#ifdef MODULE_REGEX_ENABLED
case TOOL_BATCH_RENAME: {
if (!profile_allow_editing) {
break;
}
if (editor_selection->get_selected_node_list().size() > 1) {
rename_dialog->popup_centered();
}
} break;
#endif // MODULE_REGEX_ENABLED
case TOOL_RENAME: {
if (!profile_allow_editing) {
break;
}
Tree *tree = scene_tree->get_scene_tree();
if (tree->is_anything_selected()) {
tree->grab_focus();
@ -413,10 +407,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_NEW:
case TOOL_REPARENT_TO_NEW_NODE: {
if (!profile_allow_editing) {
break;
}
if (reset_create_dialog && !p_confirm_override) {
create_dialog->set_base_type("Node");
reset_create_dialog = false;
@ -447,9 +437,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_INSTANCE: {
if (!profile_allow_editing) {
break;
}
Node *scene = edited_scene;
if (!scene) {
@ -590,10 +577,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().commit_action();
} break;
case TOOL_REPLACE: {
if (!profile_allow_editing) {
break;
}
if (!_validate_no_foreign()) {
break;
}
@ -624,10 +607,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
attach_script_to_selected(false);
} break;
case TOOL_DETACH_SCRIPT: {
if (!profile_allow_script_editing) {
break;
}
Array selection = editor_selection->get_selected_nodes();
if (selection.empty()) {
@ -654,10 +633,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_MOVE_UP:
case TOOL_MOVE_DOWN: {
if (!profile_allow_editing) {
break;
}
if (!scene_tree->get_selected()) {
break;
}
@ -729,10 +704,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_DUPLICATE: {
if (!profile_allow_editing) {
break;
}
if (!edited_scene) {
break;
}
@ -807,10 +778,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_REPARENT: {
if (!profile_allow_editing) {
break;
}
if (!scene_tree->get_selected()) {
break;
}
@ -836,10 +803,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_MAKE_ROOT: {
if (!profile_allow_editing) {
break;
}
List<Node *> nodes = editor_selection->get_selected_node_list();
ERR_FAIL_COND(nodes.size() != 1);
@ -895,10 +858,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().commit_action();
} break;
case TOOL_MULTI_EDIT: {
if (!profile_allow_editing) {
break;
}
Node *root = EditorNode::get_singleton()->get_edited_scene();
if (!root) {
break;
@ -913,10 +872,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_ERASE: {
if (!profile_allow_editing) {
break;
}
List<Node *> remove_list = editor_selection->get_selected_node_list();
if (remove_list.empty()) {
@ -962,17 +917,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
} break;
case TOOL_MERGE_FROM_SCENE: {
if (!profile_allow_editing) {
break;
}
EditorNode::get_singleton()->merge_from_scene();
} break;
case TOOL_NEW_SCENE_FROM: {
if (!profile_allow_editing) {
break;
}
Node *scene = editor_data->get_edited_scene_root();
if (!scene) {
@ -1055,10 +1002,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
} break;
case TOOL_SCENE_EDITABLE_CHILDREN: {
if (!profile_allow_editing) {
break;
}
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@ -1076,10 +1019,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_SCENE_USE_PLACEHOLDER: {
if (!profile_allow_editing) {
break;
}
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@ -1107,10 +1046,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_SCENE_MAKE_LOCAL: {
if (!profile_allow_editing) {
break;
}
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@ -1144,17 +1079,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_SCENE_CLEAR_INHERITANCE: {
if (!profile_allow_editing) {
break;
}
clear_inherit_confirm->popup_centered_minsize();
} break;
case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: {
if (!profile_allow_editing) {
break;
}
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@ -2243,10 +2170,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
}
void SceneTreeDock::_update_script_button() {
if (!profile_allow_script_editing) {
button_create_script->hide();
button_detach_script->hide();
} else if (editor_selection->get_selection().size() == 0) {
if (editor_selection->get_selection().size() == 0) {
button_create_script->hide();
button_detach_script->hide();
} else if (editor_selection->get_selection().size() == 1) {
@ -2823,11 +2747,8 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) {
void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (!EditorNode::get_singleton()->get_edited_scene()) {
menu->clear();
if (profile_allow_editing) {
menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
}
menu->set_size(Size2(1, 1));
menu->set_position(p_menu_pos);
menu->popup();
@ -2848,7 +2769,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (selection.size() == 1) {
Node *selected = selection[0];
if (profile_allow_editing) {
subresources.clear();
menu_subresources->clear();
menu_subresources->set_size(Size2(1, 1));
@ -2859,7 +2779,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW);
menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE);
}
menu->add_icon_shortcut(get_theme_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE);
menu->add_separator();
@ -2870,16 +2789,13 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
}
}
if (profile_allow_editing) {
menu->add_shortcut(ED_GET_SHORTCUT("scene_tree/cut_node"), TOOL_CUT);
menu->add_shortcut(ED_GET_SHORTCUT("scene_tree/copy_node"), TOOL_COPY);
if (selection.size() == 1 && !node_clipboard.empty()) {
menu->add_shortcut(ED_GET_SHORTCUT("scene_tree/paste_node"), TOOL_PASTE);
}
menu->add_separator();
}
if (profile_allow_script_editing) {
bool add_separator = false;
if (full_selection.size() == 1) {
@ -2908,12 +2824,10 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
}
}
if (add_separator && profile_allow_editing) {
if (add_separator) {
menu->add_separator();
}
}
if (profile_allow_editing) {
// 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()) {
@ -2932,10 +2846,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
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"));
}
}
if (profile_allow_editing) {
bool add_separator = false;
add_separator = false;
if (full_selection.size() == 1) {
add_separator = true;
@ -2968,13 +2880,11 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
menu->add_icon_shortcut(get_theme_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT);
}
}
}
if (selection.size() == 1) {
if (profile_allow_editing) {
menu->add_separator();
menu->add_icon_shortcut(get_theme_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
menu->add_icon_shortcut(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
}
if (full_selection.size() == 1) {
menu->add_separator();
menu->add_icon_shortcut(get_theme_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH);
@ -2986,30 +2896,24 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
bool is_top_level = selection[0]->get_owner() == nullptr;
if (is_inherited && is_top_level) {
menu->add_separator();
if (profile_allow_editing) {
menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE);
}
menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED);
} else if (!is_top_level) {
menu->add_separator();
bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]);
bool placeholder = selection[0]->get_scene_instance_load_placeholder();
if (profile_allow_editing) {
menu->add_check_item(TTR("Editable Children"), TOOL_SCENE_EDITABLE_CHILDREN);
menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER);
menu->add_item(TTR("Make Local"), TOOL_SCENE_MAKE_LOCAL);
}
menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN);
if (profile_allow_editing) {
menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable);
menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder);
}
}
}
}
#ifdef MODULE_REGEX_ENABLED
if (profile_allow_editing && selection.size() > 1) {
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.
menu->add_separator();
menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME);
@ -3017,11 +2921,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
#endif // MODULE_REGEX_ENABLED
menu->add_separator();
menu->add_icon_item(get_theme_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION);
if (profile_allow_editing) {
menu->add_separator();
menu->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE);
}
menu->set_size(Size2(1, 1));
menu->set_position(p_menu_pos);
menu->popup();
@ -3064,10 +2965,6 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) {
return;
}
if (!profile_allow_script_editing) {
return;
}
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
return;
@ -3553,9 +3450,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
set_process_input(true);
set_process(true);
profile_allow_editing = true;
profile_allow_script_editing = true;
EDITOR_DEF("interface/editors/show_scene_tree_root_selection", true);
EDITOR_DEF("interface/editors/derive_script_globals_by_name", true);
EDITOR_DEF("_use_favorites_root_selection", false);

View File

@ -276,9 +276,6 @@ class SceneTreeDock : public VBoxContainer {
void _create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap);
void _create_remap_for_resource(RES p_resource, Map<RES, RES> &r_remap);
bool profile_allow_editing;
bool profile_allow_script_editing;
bool _update_node_path(Node *p_root_node, NodePath &r_node_path, Map<Node *, NodePath> *p_renames) const;
bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, Map<Node *, NodePath> *p_renames) const;