diff options
Diffstat (limited to 'tools/editor/scene_tree_dock.cpp')
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 328 |
1 files changed, 234 insertions, 94 deletions
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 3e36a30361..506dfd3889 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -33,29 +33,76 @@ #include "scene/resources/packed_scene.h" #include "editor_settings.h" #include "tools/editor/plugins/canvas_item_editor_plugin.h" +#include "tools/editor/plugins/spatial_editor_plugin.h" #include "script_editor_debugger.h" #include "tools/editor/plugins/script_editor_plugin.h" #include "core/io/resource_saver.h" #include "multi_node_edit.h" #include "tools/editor/plugins/animation_player_editor_plugin.h" #include "animation_editor.h" +#include "scene/main/viewport.h" +void SceneTreeDock::_nodes_drag_begin() { + if (restore_script_editor_on_drag) { + EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); + restore_script_editor_on_drag=false; + } + +} + +void SceneTreeDock::_input(InputEvent p_event) { + + if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==BUTTON_LEFT) { + restore_script_editor_on_drag=false; //lost chance + } +} + void SceneTreeDock::_unhandled_key_input(InputEvent p_event) { - uint32_t sc = p_event.key.get_scancode_with_modifiers(); + if (get_viewport()->get_modal_stack_top()) + return; //ignore because of modal window + if (!p_event.key.pressed || p_event.key.echo) return; - switch(sc) { - case KEY_MASK_CMD|KEY_A: { _tool_selected(TOOL_NEW); } break; - case KEY_MASK_CMD|KEY_D: { _tool_selected(TOOL_DUPLICATE); } break; - case KEY_MASK_CMD|KEY_UP: { _tool_selected(TOOL_MOVE_UP); } break; - case KEY_MASK_CMD|KEY_DOWN: { _tool_selected(TOOL_MOVE_DOWN); } break; - case KEY_MASK_SHIFT|KEY_DELETE: { _tool_selected(TOOL_ERASE, true); } break; - case KEY_DELETE: { _tool_selected(TOOL_ERASE); } break; + if (ED_IS_SHORTCUT("scene_tree/add_child_node", p_event)) { + _tool_selected(TOOL_NEW); + } + else if (ED_IS_SHORTCUT("scene_tree/instance_scene", p_event)) { + _tool_selected(TOOL_INSTANCE); + } + else if (ED_IS_SHORTCUT("scene_tree/change_node_type", p_event)) { + _tool_selected(TOOL_REPLACE); + } + else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) { + _tool_selected(TOOL_DUPLICATE); + } + else if (ED_IS_SHORTCUT("scene_tree/add_script", p_event)) { + _tool_selected(TOOL_SCRIPT); + } + else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) { + _tool_selected(TOOL_MOVE_UP); + } + else if (ED_IS_SHORTCUT("scene_tree/move_down", p_event)) { + _tool_selected(TOOL_MOVE_DOWN); + } + else if (ED_IS_SHORTCUT("scene_tree/reparent", p_event)) { + _tool_selected(TOOL_REPARENT); + } + else if (ED_IS_SHORTCUT("scene_tree/merge_from_scene", p_event)) { + _tool_selected(TOOL_MERGE_FROM_SCENE); + } + else if (ED_IS_SHORTCUT("scene_tree/save_branch_as_scene", p_event)) { + _tool_selected(TOOL_NEW_SCENE_FROM); + } + else if (ED_IS_SHORTCUT("scene_tree/delete_no_confirm", p_event)) { + _tool_selected(TOOL_ERASE, true); + } + else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) { + _tool_selected(TOOL_ERASE); } } @@ -76,11 +123,30 @@ void SceneTreeDock::instance(const String& p_file) { Vector<String> scenes; scenes.push_back(p_file); - instance_scenes(scenes,parent,-1); + _perform_instance_scenes(scenes,parent,-1); + +} + +void SceneTreeDock::instance_scenes(const Vector<String>& p_files, Node *p_parent) { + + Node *parent = p_parent; + if (!parent) { + parent = scene_tree->get_selected(); + } + + if (!parent || !edited_scene) { + + accept->get_ok()->set_text(TTR("OK")); + accept->set_text(TTR("No parent to instance the scenes at.")); + accept->popup_centered_minsize(); + return; + }; + + _perform_instance_scenes(p_files, parent, -1); } -void SceneTreeDock::instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos) { +void SceneTreeDock::_perform_instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos) { @@ -201,6 +267,7 @@ static String _get_name_num_separator() { return " "; } + void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option=p_tool; @@ -212,7 +279,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { //if (!_validate_no_foreign()) // break; - create_dialog->popup_centered_ratio(); + create_dialog->popup(true); } break; case TOOL_INSTANCE: { @@ -250,7 +317,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_REPLACE: { - create_dialog->popup_centered_ratio(); + create_dialog->popup(false); } break; case TOOL_CONNECT: { @@ -260,8 +327,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { //if (!_validate_no_foreign()) // break; - connect_dialog->popup_centered_ratio(); - connect_dialog->set_node(current); + //connect_dialog->popup_centered_ratio(); + //connect_dialog->set_node(current); } break; case TOOL_GROUP: { @@ -271,8 +338,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; //if (!_validate_no_foreign()) // break; - groups_editor->set_current(current); - groups_editor->popup_centered_ratio(); + //groups_editor->set_current(current); + //groups_editor->popup_centered_ratio(); } break; case TOOL_SCRIPT: { @@ -351,11 +418,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { ERR_FAIL_COND(!top_node->get_parent()); ERR_FAIL_COND(!bottom_node->get_parent()); - int top_node_pos = top_node->get_index(); int bottom_node_pos = bottom_node->get_index(); - - int top_node_pos_next = top_node_pos + (MOVING_DOWN ? 1 : -1); - int bottom_node_pos_next = bottom_node_pos + (MOVING_DOWN ? 1 : -1); + int top_node_pos_next = top_node->get_index() + (MOVING_DOWN ? 1 : -1); editor_data->get_undo_redo().add_do_method(top_node->get_parent(), "move_child", top_node, top_node_pos_next); editor_data->get_undo_redo().add_undo_method(bottom_node->get_parent(), "move_child", bottom_node, bottom_node_pos); @@ -519,6 +583,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { EditorNode::get_singleton()->push_item(mne.ptr()); } break; + case TOOL_ERASE: { List<Node*> remove_list = editor_selection->get_selected_node_list(); @@ -619,6 +684,8 @@ void SceneTreeDock::_notification(int p_what) { } button_add->set_icon(get_icon("Add","EditorIcons")); button_instance->set_icon(get_icon("Instance","EditorIcons")); + button_create_script->set_icon(get_icon("Script","EditorIcons")); + filter_icon->set_texture(get_icon("Zoom","EditorIcons")); @@ -650,7 +717,13 @@ void SceneTreeDock::_node_selected() { return; } + if (ScriptEditor::get_singleton()->is_visible()) { + restore_script_editor_on_drag=true; + } + editor->push_item(node); + + } void SceneTreeDock::_node_renamed() { @@ -1037,6 +1110,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec List<Pair<NodePath,NodePath> > path_renames; + int inc=0; + for(int ni=0;ni<p_nodes.size();ni++) { //no undo for now, sorry @@ -1053,12 +1128,16 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec } + if (new_parent==node->get_parent() && node->get_index() < p_position_in_parent+ni) { + //if child will generate a gap when moved, adjust + inc--; + } editor_data->get_undo_redo().add_do_method(node->get_parent(),"remove_child",node); editor_data->get_undo_redo().add_do_method(new_parent,"add_child",node); if (p_position_in_parent>=0) - editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+ni); + editor_data->get_undo_redo().add_do_method(new_parent,"move_child",node,p_position_in_parent+inc); ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger(); String new_name = new_parent->validate_child_name(node->get_name()); @@ -1070,17 +1149,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Node2D>()->get_global_transform()); if (node->cast_to<Spatial>()) editor_data->get_undo_redo().add_do_method(node,"set_global_transform",node->cast_to<Spatial>()->get_global_transform()); - if (node->cast_to<Control>()) { - bool can_do_it=false; - Control *c=node->cast_to<Control>(); - if (c->get_parent()->cast_to<Container>()) - can_do_it=false; - for(int i=0;i<4;i++) { - if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN) - can_do_it=false; - } + if (node->cast_to<Control>()) editor_data->get_undo_redo().add_do_method(node,"set_global_pos",node->cast_to<Control>()->get_global_pos()); - } } editor_data->get_undo_redo().add_do_method(this,"_set_owners",edited_scene,owners); @@ -1090,6 +1160,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_undo_method(new_parent,"remove_child",node); + inc++; + } //add and move in a second step.. (so old order is preserved) @@ -1121,17 +1193,8 @@ void SceneTreeDock::_do_reparent(Node* p_new_parent,int p_position_in_parent,Vec editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Node2D>()->get_transform()); if (node->cast_to<Spatial>()) editor_data->get_undo_redo().add_undo_method(node,"set_transform",node->cast_to<Spatial>()->get_transform()); - if (node->cast_to<Control>()) { - bool can_do_it=false; - Control *c=node->cast_to<Control>(); - if (c->get_parent()->cast_to<Container>()) - can_do_it=false; - for(int i=0;i<4;i++) { - if (c->get_anchor(Margin(i))!=ANCHOR_BEGIN) - can_do_it=false; - } + if (node->cast_to<Control>()) editor_data->get_undo_redo().add_undo_method(node,"set_pos",node->cast_to<Control>()->get_pos()); - } } @@ -1242,11 +1305,18 @@ void SceneTreeDock::_delete_confirm() { void SceneTreeDock::_selection_changed() { - if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size()>1) { + int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size(); + if (selection_size>1) { //automatically turn on multi-edit _tool_selected(TOOL_MULTI_EDIT); } + if (selection_size==1 && EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) { + button_create_script->show(); + } else { + button_create_script->hide(); + } + //tool_buttons[TOOL_MULTI_EDIT]->set_disabled(EditorNode::get_singleton()->get_editor_selection()->get_selection().size()<2); } @@ -1360,6 +1430,13 @@ void SceneTreeDock::_create() { } String newname=n->get_name(); + + List<Node*> to_erase; + for(int i=0;i<n->get_child_count();i++) { + if (n->get_child(i)->get_owner()==NULL && n->is_owned_by_parent()) { + to_erase.push_back(n->get_child(i)); + } + } n->replace_by(newnode,true); if (n==edited_scene) { @@ -1380,6 +1457,11 @@ void SceneTreeDock::_create() { memdelete(n); + while(to_erase.front()) { + memdelete(to_erase.front()->get()); + to_erase.pop_front(); + } + } @@ -1458,8 +1540,8 @@ void SceneTreeDock::_new_scene_from(String p_file) { int flg=0; if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources")) flg|=ResourceSaver::FLAG_COMPRESS; - if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative")) - flg|=ResourceSaver::FLAG_RELATIVE_PATHS; + //if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative")) + // flg|=ResourceSaver::FLAG_RELATIVE_PATHS; err = ResourceSaver::save(p_file,sdata,flg); @@ -1499,7 +1581,7 @@ static bool _has_visible_children(Node* p_node) { for(int i=0;i<p_node->get_child_count();i++) { Node* child = p_node->get_child(i); - if (!_is_node_visible(p_node)) + if (!_is_node_visible(child)) continue; return true; @@ -1510,12 +1592,18 @@ static bool _has_visible_children(Node* p_node) { } -static Node* _find_last_visible(Node*p_node) { - Node*last=NULL; - for(int i=0;i<p_node->get_child_count();i++) { - if (_is_node_visible(p_node->get_child(i))) { - last=p_node->get_child(i); +static Node* _find_last_visible(Node* p_node) { + + Node* last=NULL; + + bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; + + if (!collapsed) { + for(int i=0;i<p_node->get_child_count();i++) { + if (_is_node_visible(p_node->get_child(i))) { + last=p_node->get_child(i); + } } } @@ -1533,18 +1621,16 @@ static Node* _find_last_visible(Node*p_node) { } -void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) { +void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) { to_pos=-1; - if (p_type==1 && to_node==EditorNode::get_singleton()->get_edited_scene()) { - //if at lower sibling of root node - to_pos=0; //just insert at begining of root node - } else if (p_type==-1) { + if (p_type==-1) { //drop at above selected node if (to_node==EditorNode::get_singleton()->get_edited_scene()) { to_node=NULL; - ERR_FAIL_COND(to_node==EditorNode::get_singleton()->get_edited_scene()); + ERR_EXPLAIN("Cannot perform drop above the root node!"); + ERR_FAIL(); } Node* upper_sibling=NULL; @@ -1574,30 +1660,42 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos,int p_type) { //just insert over this node because nothing is above at the same level to_pos=to_node->get_index(); to_node=to_node->get_parent(); + } } else if (p_type==1) { //drop at below selected node if (to_node==EditorNode::get_singleton()->get_edited_scene()) { - to_node=NULL; - ERR_FAIL_COND(to_node==EditorNode::get_singleton()->get_edited_scene()); + //if at lower sibling of root node + to_pos=0; //just insert at begining of root node + return; } Node* lower_sibling=NULL; - for(int i=to_node->get_index()+1;i<to_node->get_parent()->get_child_count();i++) { - Node *c =to_node->get_parent()->get_child(i); - if (_is_node_visible(c)) { - lower_sibling=c; + + + if (_has_visible_children(to_node) ) { + to_pos=0; + } else { + + + for(int i=to_node->get_index()+1;i<to_node->get_parent()->get_child_count();i++) { + Node *c =to_node->get_parent()->get_child(i); + if (_is_node_visible(c)) { + lower_sibling=c; + break; + } + } + if (lower_sibling) { + to_pos=lower_sibling->get_index(); } - } - if (lower_sibling) { - to_pos=lower_sibling->get_index(); - } + to_node=to_node->get_parent(); - to_node=to_node->get_parent(); + + } #if 0 //quite complicated, look for next visible in tree upper_sibling=_find_last_visible(upper_sibling); @@ -1630,7 +1728,7 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files,NodePath p_to,int p_ty int to_pos=-1; _normalize_drop(node,to_pos,p_type); - instance_scenes(p_files,node,to_pos); + _perform_instance_scenes(p_files,node,to_pos); } void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) { @@ -1658,13 +1756,11 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) { } void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) { - - if (!EditorNode::get_singleton()->get_edited_scene()) { menu->clear(); - menu->add_item(TTR("New Scene Root"),TOOL_NEW,KEY_MASK_CMD|KEY_A); - menu->add_item(TTR("Inherit Scene"),TOOL_INSTANCE); + menu->add_icon_shortcut(get_icon("Add","EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_icon("Instance","EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->set_size(Size2(1,1)); menu->set_pos(p_menu_pos); @@ -1681,31 +1777,31 @@ void SceneTreeDock::_tree_rmb(const Vector2& p_menu_pos) { if (selection.size()==1) { - menu->add_item(TTR("Add Child Node"),TOOL_NEW,KEY_MASK_CMD|KEY_A); - menu->add_item(TTR("Instance Child Scene"),TOOL_INSTANCE); + menu->add_icon_shortcut(get_icon("Add","EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_icon("Instance","EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->add_separator(); - menu->add_item(TTR("Change Type"),TOOL_REPLACE); + menu->add_icon_shortcut(get_icon("Reload","EditorIcons"),ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); + //menu->add_separator(); moved to their own dock + //menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP); + //menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT); menu->add_separator(); - menu->add_item(TTR("Edit Groups"),TOOL_GROUP); - menu->add_item(TTR("Edit Connections"),TOOL_CONNECT); - menu->add_separator(); - menu->add_item(TTR("Add Script"),TOOL_SCRIPT); + menu->add_icon_shortcut(get_icon("Script","EditorIcons"),ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_SCRIPT); menu->add_separator(); } - menu->add_item(TTR("Move Up"),TOOL_MOVE_UP,KEY_MASK_CMD|KEY_UP); - menu->add_item(TTR("Move Down"),TOOL_MOVE_DOWN,KEY_MASK_CMD|KEY_DOWN); - menu->add_item(TTR("Duplicate"),TOOL_DUPLICATE,KEY_MASK_CMD|KEY_D); - menu->add_item(TTR("Reparent"),TOOL_REPARENT); + menu->add_icon_shortcut(get_icon("Up","EditorIcons"),ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); + menu->add_icon_shortcut(get_icon("Down","EditorIcons"),ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); + menu->add_icon_shortcut(get_icon("Duplicate","EditorIcons"),ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); + menu->add_icon_shortcut(get_icon("Reparent","EditorIcons"),ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); if (selection.size()==1) { menu->add_separator(); - menu->add_item(TTR("Merge From Scene"),TOOL_MERGE_FROM_SCENE); - menu->add_item(TTR("Save Branch as Scene"),TOOL_NEW_SCENE_FROM); + menu->add_icon_shortcut(get_icon("Blend","EditorIcons"),ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE); + menu->add_icon_shortcut(get_icon("Save","EditorIcons"),ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); } menu->add_separator(); - menu->add_item(TTR("Delete Node(s)"),TOOL_ERASE,KEY_DELETE); + menu->add_icon_shortcut(get_icon("Remove","EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); menu->set_size(Size2(1,1)); menu->set_pos(p_menu_pos); @@ -1730,6 +1826,21 @@ void SceneTreeDock::set_filter(const String& p_filter){ scene_tree->set_filter(p_filter); } + +void SceneTreeDock::_focus_node() { + + Node *node = scene_tree->get_selected(); + ERR_FAIL_COND(!node); + + if (node->is_type("CanvasItem")) { + CanvasItemEditorPlugin *editor = editor_data->get_editor("2D")->cast_to<CanvasItemEditorPlugin>(); + editor->get_canvas_item_editor()->focus_selection(); + } else { + SpatialEditorPlugin *editor = editor_data->get_editor("3D")->cast_to<SpatialEditorPlugin>(); + editor->get_spatial_editor()->get_editor_viewport(0)->focus_selection(); + } +} + void SceneTreeDock::_bind_methods() { ObjectTypeDB::bind_method(_MD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false)); @@ -1743,6 +1854,8 @@ void SceneTreeDock::_bind_methods() { ObjectTypeDB::bind_method(_MD("_load_request"),&SceneTreeDock::_load_request); ObjectTypeDB::bind_method(_MD("_script_open_request"),&SceneTreeDock::_script_open_request); ObjectTypeDB::bind_method(_MD("_unhandled_key_input"),&SceneTreeDock::_unhandled_key_input); + ObjectTypeDB::bind_method(_MD("_input"),&SceneTreeDock::_input); + ObjectTypeDB::bind_method(_MD("_nodes_drag_begin"),&SceneTreeDock::_nodes_drag_begin); ObjectTypeDB::bind_method(_MD("_delete_confirm"),&SceneTreeDock::_delete_confirm); ObjectTypeDB::bind_method(_MD("_node_prerenamed"),&SceneTreeDock::_node_prerenamed); ObjectTypeDB::bind_method(_MD("_import_subscene"),&SceneTreeDock::_import_subscene); @@ -1752,6 +1865,7 @@ void SceneTreeDock::_bind_methods() { ObjectTypeDB::bind_method(_MD("_files_dropped"),&SceneTreeDock::_files_dropped); ObjectTypeDB::bind_method(_MD("_tree_rmb"),&SceneTreeDock::_tree_rmb); ObjectTypeDB::bind_method(_MD("_filter_changed"),&SceneTreeDock::_filter_changed); + ObjectTypeDB::bind_method(_MD("_focus_node"),&SceneTreeDock::_focus_node); ObjectTypeDB::bind_method(_MD("instance"),&SceneTreeDock::instance); @@ -1772,15 +1886,30 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec HBoxContainer *filter_hbc = memnew( HBoxContainer ); ToolButton *tb; + ED_SHORTCUT("scene_tree/add_child_node",TTR("Add Child Node"), KEY_MASK_CMD|KEY_A); + ED_SHORTCUT("scene_tree/instance_scene",TTR("Instance Child Scene")); + ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type")); + ED_SHORTCUT("scene_tree/add_script", TTR("Add Script")); + ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP); + ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN); + ED_SHORTCUT("scene_tree/duplicate", TTR("Duplicate"),KEY_MASK_CMD | KEY_D); + ED_SHORTCUT("scene_tree/reparent", TTR("Reparent")); + ED_SHORTCUT("scene_tree/merge_from_scene", TTR("Merge From Scene")); + ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene")); + ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KEY_MASK_SHIFT|KEY_DELETE); + ED_SHORTCUT("scene_tree/delete", TTR("Delete"), KEY_DELETE); + tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW, false)); - tb->set_tooltip(TTR("Add/Create a New Node")+"\n("+keycode_get_string(KEY_MASK_CMD|KEY_A)+")"); + tb->set_tooltip(TTR("Add/Create a New Node")); + tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_child_node")); filter_hbc->add_child(tb); button_add=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_INSTANCE, false)); tb->set_tooltip(TTR("Instance a scene file as a Node. Creates an inherited scene if no root node exists.")); + tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/instance_scene")); filter_hbc->add_child(tb); button_instance=tb; @@ -1796,6 +1925,12 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec filter->connect("text_changed",this,"_filter_changed"); + tb = memnew( ToolButton ); + tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_SCRIPT, false)); + tb->set_tooltip(TTR("Create a new script for the selected node.")); + tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_script")); + filter_hbc->add_child(tb); + button_create_script=tb; scene_tree = memnew( SceneTreeEditor(false,true,true )); @@ -1810,6 +1945,10 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec scene_tree->connect("open_script",this,"_script_open_request"); scene_tree->connect("nodes_rearranged",this,"_nodes_dragged"); scene_tree->connect("files_dropped",this,"_files_dropped"); + scene_tree->connect("nodes_dragged",this,"_nodes_drag_begin"); + + scene_tree->get_scene_tree()->connect("item_double_clicked", this, "_focus_node"); + scene_tree->get_scene_tree()->set_delayed_text_editor(true); scene_tree->set_undo_redo(&editor_data->get_undo_redo()); scene_tree->set_editor_selection(editor_selection); @@ -1820,13 +1959,13 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec add_child(create_dialog); create_dialog->connect("create",this,"_create"); - groups_editor = memnew( GroupsEditor ); - add_child(groups_editor); - groups_editor->set_undo_redo(&editor_data->get_undo_redo()); + //groups_editor = memnew( GroupsEditor ); + //add_child(groups_editor); + //groups_editor->set_undo_redo(&editor_data->get_undo_redo()); - connect_dialog = memnew( ConnectionsDialog(p_editor) ); - add_child(connect_dialog); - connect_dialog->set_undoredo(&editor_data->get_undo_redo()); + //connect_dialog = memnew( ConnectionsDialog(p_editor) ); + //add_child(connect_dialog); + //connect_dialog->set_undoredo(&editor_data->get_undo_redo()); script_create_dialog = memnew( ScriptCreateDialog ); add_child(script_create_dialog); @@ -1862,7 +2001,8 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec add_child(menu); menu->connect("item_pressed",this,"_tool_selected"); first_enter=true; - + restore_script_editor_on_drag=false; vbc->add_constant_override("separation",4); + set_process_input(true); } |