summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-09-12 19:31:07 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-09-12 19:32:09 -0300
commitf51b202566e9b2a9deb3eb4836f6e00fb30e8500 (patch)
treef592afe5052a98d240a0edf5d87069140afea971
parentdc6eefdbf2b3f9362dbb571e9fb2f3df60760c04 (diff)
Modified resource menu for node scripts so it always goes through the new script wizard.
-rw-r--r--tools/editor/property_editor.cpp12
-rw-r--r--tools/editor/property_editor.h1
-rw-r--r--tools/editor/scene_tree_dock.cpp6
-rw-r--r--tools/editor/scene_tree_dock.h1
4 files changed, 18 insertions, 2 deletions
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index de10e68f33..1a8d373f7f 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<Node>())
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to<Node>());
+
+ } 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<Node>()) {
+ 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;i<hint_text.get_slice_count(",");i++) {
diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h
index 6c6c309d32..3fe332bf87 100644
--- a/tools/editor/property_editor.h
+++ b/tools/editor/property_editor.h
@@ -65,6 +65,7 @@ class CustomPropertyEditor : public Popup {
OBJ_MENU_COPY=4,
OBJ_MENU_PASTE=5,
OBJ_MENU_REIMPORT=6,
+ OBJ_MENU_NEW_SCRIPT=7,
TYPE_BASE_ID=100
};
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index 506dfd3889..9c4e641535 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -1841,6 +1841,12 @@ void SceneTreeDock::_focus_node() {
}
}
+void SceneTreeDock::open_script_dialog(Node* p_for_node) {
+
+ scene_tree->set_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 d92f12c34b..971013a568 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);
};