From f51b202566e9b2a9deb3eb4836f6e00fb30e8500 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 12 Sep 2016 19:31:07 -0300 Subject: [PATCH] Modified resource menu for node scripts so it always goes through the new script wizard. --- tools/editor/property_editor.cpp | 12 ++++++++++-- tools/editor/property_editor.h | 1 + tools/editor/scene_tree_dock.cpp | 6 ++++++ tools/editor/scene_tree_dock.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index de10e68f334..1a8d373f7fc 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -214,6 +214,12 @@ void CustomPropertyEditor::_menu_option(int p_which) { } } } break; + case OBJ_MENU_NEW_SCRIPT: { + + if (owner->cast_to()) + EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to()); + + } break; default: { @@ -850,8 +856,10 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty menu->clear(); menu->set_size(Size2(1,1)); - - if (hint_text!="") { + if (p_name=="script/script" && hint_text=="Script" && owner->cast_to()) { + menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("New Script"),OBJ_MENU_NEW_SCRIPT); + menu->add_separator(); + } else if (hint_text!="") { int idx=0; for(int i=0;iset_selected(p_for_node,false); + _tool_selected(TOOL_SCRIPT); +} + void SceneTreeDock::_bind_methods() { ObjectTypeDB::bind_method(_MD("_tool_selected"),&SceneTreeDock::_tool_selected,DEFVAL(false)); diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h index d92f12c34ba..971013a568d 100644 --- a/tools/editor/scene_tree_dock.h +++ b/tools/editor/scene_tree_dock.h @@ -175,6 +175,7 @@ public: SceneTreeEditor *get_tree_editor() { return scene_tree; } + void open_script_dialog(Node* p_for_node); SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelection *p_editor_selection,EditorData &p_editor_data); };