From 225b1d2d768ca415355ea0f5daba9f92e1a93121 Mon Sep 17 00:00:00 2001 From: William Tumeo Date: Wed, 29 Mar 2017 02:16:26 -0300 Subject: [PATCH] Re-add script button from b77200728e7f2b2dd446a9717c83a20c9aac0ce4 --- editor/scene_tree_dock.cpp | 17 ++++++++++++++++- editor/scene_tree_dock.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 8c2aa4097f2..0d0dbc64147 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 e651c59d664..c6331c8241a 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;