From 1b92c090ae8971dab041c239d1352b5f00f605ea Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 3 Aug 2016 11:28:20 -0300 Subject: [PATCH] More progress on visual script editing --- register_types.cpp | 4 +- visual_script_editor.cpp | 258 +++++++++++++++++++++- visual_script_editor.h | 8 + visual_script_func_nodes.cpp | 413 ++++++++++++++++++++++++++++------- visual_script_func_nodes.h | 18 ++ visual_script_nodes.cpp | 192 ++++++++++++++-- visual_script_nodes.h | 77 ++++++- 7 files changed, 869 insertions(+), 101 deletions(-) diff --git a/register_types.cpp b/register_types.cpp index 2cd8420..da767c8 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -52,8 +52,10 @@ void register_visual_script_types() { ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); + ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); + ObjectTypeDB::register_type(); + ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); ObjectTypeDB::register_type(); diff --git a/visual_script_editor.cpp b/visual_script_editor.cpp index f25bd0b..677960a 100644 --- a/visual_script_editor.cpp +++ b/visual_script_editor.cpp @@ -3,6 +3,8 @@ #include "visual_script_nodes.h" #include "visual_script_flow_control.h" #include "visual_script_func_nodes.h" +#include "os/input.h" +#include "os/keyboard.h" class VisualScriptEditorSignalEdit : public Object { @@ -363,8 +365,14 @@ void VisualScriptEditor::_update_graph(int p_only_id) { } } - if (!script->has_function(edited_func)) + if (!script->has_function(edited_func)) { + graph->hide(); + select_func_text->show(); return; + } + + graph->show(); + select_func_text->hide(); Ref type_icons[Variant::VARIANT_MAX]={ Control::get_icon("MiniVariant","EditorIcons"), @@ -762,6 +770,9 @@ void VisualScriptEditor::_override_pressed(int p_id) { undo_redo->add_undo_method(script.ptr(),"remove_function",name); undo_redo->add_do_method(this,"_update_members"); undo_redo->add_undo_method(this,"_update_members"); + undo_redo->add_do_method(this,"_update_graph"); + undo_redo->add_undo_method(this,"_update_graph"); + undo_redo->commit_action(); @@ -858,6 +869,9 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt undo_redo->add_undo_method(script.ptr(),"remove_function",name); undo_redo->add_do_method(this,"_update_members"); undo_redo->add_undo_method(this,"_update_members"); + undo_redo->add_do_method(this,"_update_graph"); + undo_redo->add_undo_method(this,"_update_graph"); + undo_redo->commit_action(); _update_graph(); @@ -935,6 +949,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt //} undo_redo->add_do_method(this,"_update_members"); undo_redo->add_undo_method(this,"_update_members"); + undo_redo->add_do_method(this,"_update_graph"); + undo_redo->add_undo_method(this,"_update_graph"); undo_redo->commit_action(); } else if (p_button==0) { @@ -1309,20 +1325,62 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2& p_point,const Variant& p if (p_from==graph) { + Dictionary d = p_data; if (d.has("type") && ( String(d["type"])=="visual_script_node_drag" || String(d["type"])=="visual_script_function_drag" || String(d["type"])=="visual_script_variable_drag" || - String(d["type"])=="visual_script_signal_drag" - ) ) + String(d["type"])=="visual_script_signal_drag" || + String(d["type"])=="obj_property" || + String(d["type"])=="nodes" + ) ) { + + + if (String(d["type"])=="obj_property") { + +#ifdef OSX_ENABLED + const_cast(this)->_show_hint("Hold Meta to drop a Setter, Shift+Meta to drop a Setter and copy the value."); +#else + const_cast(this)->_show_hint("Hold Ctrl to drop a Setter, Shift+Ctrl to drop a Setter and copy the value."); +#endif + } return true; + + } + + + } return false; } + +#ifdef TOOLS_ENABLED + +static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const Ref