Modified resource menu for node scripts so it always goes through the new script wizard.
This commit is contained in:
parent
dc6eefdbf2
commit
f51b202566
4 changed files with 18 additions and 2 deletions
|
@ -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++) {
|
||||
|
|
|
@ -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
|
||||
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue