diff options
| -rw-r--r-- | editor/scene_tree_dock.cpp | 17 | ||||
| -rw-r--r-- | editor/scene_tree_dock.h | 1 |
2 files changed, 17 insertions, 1 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 8c2aa4097..0d0dbc641 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -675,6 +675,7 @@ 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")); @@ -1239,11 +1240,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); } @@ -1779,6 +1787,13 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel filter_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED); 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)); vbc->add_child(scene_tree); scene_tree->set_v_size_flags(SIZE_EXPAND | SIZE_FILL); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index e651c59d6..c6331c824 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -76,6 +76,7 @@ class SceneTreeDock : public VBoxContainer { ToolButton *button_add; ToolButton *button_instance; + ToolButton *button_create_script; SceneTreeEditor *scene_tree; |
