diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 6541ac6b861..6f18bcfaee9 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -1,9 +1,87 @@ #include "visual_script.h" #include "visual_script_nodes.h" + +void VisualScriptNode::_notification(int p_what) { + + if (p_what==NOTIFICATION_POSTINITIALIZE) { + + int dvc = get_input_value_port_count(); + for(int i=0;i=default_input_values.size()) { + + Variant::CallError ce; + saved_values.push_back(Variant::construct(expected,NULL,0,ce,false)); + } else { + + if (expected==Variant::NIL || expected==default_input_values[i].get_type()) { + saved_values.push_back(default_input_values[i]); + } else { + //not the same, reconvert + Variant::CallError ce; + Variant existing = default_input_values[i]; + const Variant *existingp=&existing; + saved_values.push_back( Variant::construct(expected,&existingp,1,ce,false) ); + } + } + } + return saved_values; +} + + + void VisualScriptNode::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_visual_script:VisualScript"),&VisualScriptNode::get_visual_script); + ObjectTypeDB::bind_method(_MD("set_default_input_value","port_idx","value:Variant"),&VisualScriptNode::set_default_input_value); + ObjectTypeDB::bind_method(_MD("get_default_input_value:Variant","port_idx"),&VisualScriptNode::get_default_input_value); + ObjectTypeDB::bind_method(_MD("_set_default_input_values","values"),&VisualScriptNode::_set_default_input_values); + ObjectTypeDB::bind_method(_MD("_get_default_input_values"),&VisualScriptNode::_get_default_input_values); + + ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"_default_input_values",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_default_input_values"),_SCS("_get_default_input_values")); ADD_SIGNAL(MethodInfo("ports_changed")); } @@ -381,6 +459,19 @@ bool VisualScript::has_data_connection(const StringName& p_func,int p_from_node, } +bool VisualScript::is_input_value_port_connected(const StringName& p_func,int p_node,int p_port) const { + + ERR_FAIL_COND_V(!functions.has(p_func),false); + const Function &func = functions[p_func]; + + for (const Set::Element *E=func.data_connections.front();E;E=E->next()) { + if (E->get().to_node==p_node && E->get().to_port==p_port) + return true; + } + + return false; +} + void VisualScript::get_data_connection_list(const StringName& p_func,List *r_connection) const { ERR_FAIL_COND(!functions.has(p_func)); diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 5ea466c5792..26daddbba68 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -14,7 +14,15 @@ class VisualScriptNode : public Resource { friend class VisualScript; Set scripts_used; + + Array default_input_values; + + void _set_default_input_values(Array p_values); + Array _get_default_input_values() const; protected: + + void _notification(int p_what); + void ports_changed_notify(); static void _bind_methods(); public: @@ -32,6 +40,9 @@ public: virtual PropertyInfo get_input_value_port_info(int p_idx) const=0; virtual PropertyInfo get_output_value_port_info(int p_idx) const=0; + void set_default_input_value(int p_port,const Variant& p_value); + Variant get_default_input_value(int p_port) const; + virtual String get_caption() const=0; virtual String get_text() const=0; @@ -175,6 +186,7 @@ public: void data_disconnect(const StringName& p_func,int p_from_node,int p_from_port,int p_to_node,int p_to_port); bool has_data_connection(const StringName& p_func,int p_from_node,int p_from_port,int p_to_node,int p_to_port) const; void get_data_connection_list(const StringName& p_func,List *r_connection) const; + bool is_input_value_port_connected(const StringName& p_name,int p_node,int p_port) const; void add_variable(const StringName& p_name,const Variant& p_default_value=Variant()); bool has_variable(const StringName& p_name) const; diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 80468ca77b4..58edafd9639 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -386,8 +386,9 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons case MATH_FMOD: case MATH_FPOSMOD: case MATH_FLOOR: - case MATH_CEIL: + case MATH_CEIL: { t=Variant::REAL; + } break; case MATH_ROUND: { t=Variant::INT; } break; @@ -529,7 +530,7 @@ void VisualScriptBuiltinFunc::set_func(BuiltinFunc p_which) { ERR_FAIL_INDEX(p_which,FUNC_MAX); func=p_which; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::get_func() { diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 677960a03df..c6c58209b39 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -499,6 +499,22 @@ void VisualScriptEditor::_update_graph(int p_only_id) { } hbc->add_child(memnew(Label(left_name))); + + if (left_type!=Variant::NIL && !script->is_input_value_port_connected(edited_func,E->get(),i)) { + Button *button = memnew( Button ); + Variant value = node->get_default_input_value(i); + if (value.get_type()!=left_type) { + //different type? for now convert + //not the same, reconvert + Variant::CallError ce; + const Variant *existingp=&value; + value = Variant::construct(left_type,&existingp,1,ce,false); + } + + button->set_text(value); + button->connect("pressed",this,"_default_value_edited",varray(button,E->get(),i)); + hbc->add_child(button); + } } else { Control *c = memnew(Control); c->set_custom_minimum_size(Size2(10,0)*EDSCALE); @@ -1077,12 +1093,19 @@ void VisualScriptEditor::_update_available_nodes() { Map path_cache; + String filter = node_filter->get_text(); + List fnodes; VisualScriptLanguage::singleton->get_registered_node_names(&fnodes); for (List::Element *E=fnodes.front();E;E=E->next()) { + Vector path = E->get().split("/"); + + if (filter!=String() && path.size() && path[path.size()-1].findn(filter)==-1) + continue; + String sp; TreeItem* parent=root; @@ -1097,7 +1120,9 @@ void VisualScriptEditor::_update_available_nodes() { pathn->set_text(0,path[i].capitalize()); path_cache[sp]=pathn; parent=pathn; - pathn->set_collapsed(true); //should remember state + if (filter==String()) { + pathn->set_collapsed(true); //should remember state + } } else { parent=path_cache[sp]; } @@ -1952,6 +1977,11 @@ void VisualScriptEditor::_graph_connected(const String& p_from,int p_from_slot,c } else { undo_redo->add_do_method(script.ptr(),"data_connect",edited_func,p_from.to_int(),from_port,p_to.to_int(),to_port); undo_redo->add_undo_method(script.ptr(),"data_disconnect",edited_func,p_from.to_int(),from_port,p_to.to_int(),to_port); + //update nodes in sgraph + undo_redo->add_do_method(this,"_update_graph",p_from.to_int()); + undo_redo->add_do_method(this,"_update_graph",p_to.to_int()); + undo_redo->add_undo_method(this,"_update_graph",p_from.to_int()); + undo_redo->add_undo_method(this,"_update_graph",p_to.to_int()); } undo_redo->add_do_method(this,"_update_graph_connections"); @@ -1993,8 +2023,12 @@ void VisualScriptEditor::_graph_disconnected(const String& p_from,int p_from_slo } else { undo_redo->add_do_method(script.ptr(),"data_disconnect",edited_func,p_from.to_int(),from_port,p_to.to_int(),to_port); undo_redo->add_undo_method(script.ptr(),"data_connect",edited_func,p_from.to_int(),from_port,p_to.to_int(),to_port); + //update nodes in sgraph + undo_redo->add_do_method(this,"_update_graph",p_from.to_int()); + undo_redo->add_do_method(this,"_update_graph",p_to.to_int()); + undo_redo->add_undo_method(this,"_update_graph",p_from.to_int()); + undo_redo->add_undo_method(this,"_update_graph",p_to.to_int()); } - undo_redo->add_do_method(this,"_update_graph_connections"); undo_redo->add_undo_method(this,"_update_graph_connections"); @@ -2002,6 +2036,49 @@ void VisualScriptEditor::_graph_disconnected(const String& p_from,int p_from_slo } +void VisualScriptEditor::_default_value_changed() { + + + Ref vsn = script->get_node(edited_func,editing_id); + if (vsn.is_null()) + return; + + undo_redo->create_action("Change Input Value"); + undo_redo->add_do_method(vsn.ptr(),"set_default_input_value",editing_input,default_value_edit->get_variant()); + undo_redo->add_undo_method(vsn.ptr(),"set_default_input_value",editing_input,vsn->get_default_input_value(editing_input)); + + undo_redo->add_do_method(this,"_update_graph",editing_id); + undo_redo->add_undo_method(this,"_update_graph",editing_id); + undo_redo->commit_action(); + +} + +void VisualScriptEditor::_default_value_edited(Node * p_button,int p_id,int p_input_port) { + + Ref vsn = script->get_node(edited_func,p_id); + if (vsn.is_null()) + return; + + PropertyInfo pinfo = vsn->get_input_value_port_info(p_input_port); + Variant existing = vsn->get_default_input_value(p_input_port); + if (pinfo.type!=Variant::NIL && existing.get_type()!=pinfo.type) { + + Variant::CallError ce; + const Variant *existingp=&existing; + existing = Variant::construct(pinfo.type,&existingp,1,ce,false); + + } + + default_value_edit->set_pos(p_button->cast_to()->get_global_pos()+Vector2(0,p_button->cast_to()->get_size().y)); + default_value_edit->set_size(Size2(1,1)); + if (default_value_edit->edit(NULL,pinfo.name,pinfo.type,existing,pinfo.hint,pinfo.hint_string)) + default_value_edit->popup(); + + editing_id = p_id; + editing_input=p_input_port; + +} + void VisualScriptEditor::_show_hint(const String& p_hint) { hint_text->set_text(p_hint); @@ -2014,7 +2091,17 @@ void VisualScriptEditor::_hide_timer() { hint_text->hide(); } +void VisualScriptEditor::_node_filter_changed(const String& p_text) { + _update_available_nodes(); +} + +void VisualScriptEditor::_notification(int p_what) { + + if (p_what==NOTIFICATION_READY) { + node_filter_icon->set_texture(Control::get_icon("Zoom","EditorIcons")); + } +} void VisualScriptEditor::_bind_methods() { @@ -2034,6 +2121,10 @@ void VisualScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_update_graph",&VisualScriptEditor::_update_graph,DEFVAL(-1)); ObjectTypeDB::bind_method("_node_ports_changed",&VisualScriptEditor::_node_ports_changed); ObjectTypeDB::bind_method("_available_node_doubleclicked",&VisualScriptEditor::_available_node_doubleclicked); + ObjectTypeDB::bind_method("_default_value_edited",&VisualScriptEditor::_default_value_edited); + ObjectTypeDB::bind_method("_default_value_changed",&VisualScriptEditor::_default_value_changed); + + ObjectTypeDB::bind_method("get_drag_data_fw",&VisualScriptEditor::get_drag_data_fw); ObjectTypeDB::bind_method("can_drop_data_fw",&VisualScriptEditor::can_drop_data_fw); @@ -2048,6 +2139,7 @@ void VisualScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_graph_connected",&VisualScriptEditor::_graph_connected); ObjectTypeDB::bind_method("_graph_disconnected",&VisualScriptEditor::_graph_disconnected); ObjectTypeDB::bind_method("_update_graph_connections",&VisualScriptEditor::_update_graph_connections); + ObjectTypeDB::bind_method("_node_filter_changed",&VisualScriptEditor::_node_filter_changed); } @@ -2087,8 +2179,24 @@ VisualScriptEditor::VisualScriptEditor() { left_vsplit->add_child(left_vb2); left_vb2->set_v_size_flags(SIZE_EXPAND_FILL); + + VBoxContainer *vbc_nodes = memnew( VBoxContainer ); + HBoxContainer *hbc_nodes = memnew( HBoxContainer ); + node_filter = memnew (LineEdit); + node_filter->connect("text_changed",this,"_node_filter_changed"); + hbc_nodes->add_child(node_filter); + node_filter->set_h_size_flags(SIZE_EXPAND_FILL); + node_filter_icon = memnew( TextureFrame ); + node_filter_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED); + hbc_nodes->add_child(node_filter_icon); + vbc_nodes->add_child(hbc_nodes); + nodes = memnew( Tree ); - left_vb2->add_margin_child(TTR("Available Nodes:"),nodes,true); + vbc_nodes->add_child(nodes); + nodes->set_v_size_flags(SIZE_EXPAND_FILL); + + left_vb2->add_margin_child(TTR("Available Nodes:"),vbc_nodes,true); + nodes->set_hide_root(true); nodes->connect("item_activated",this,"_available_node_doubleclicked"); nodes->set_drag_forwarding(this); @@ -2182,6 +2290,11 @@ VisualScriptEditor::VisualScriptEditor() { set_process_input(true); //for revert on drag set_process_unhandled_input(true); //for revert on drag + + default_value_edit= memnew( CustomPropertyEditor); + add_child(default_value_edit); + default_value_edit->connect("variant_changed",this,"_default_value_changed"); + } VisualScriptEditor::~VisualScriptEditor() { diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 6194058564a..61a486da020 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -31,6 +31,9 @@ class VisualScriptEditor : public ScriptEditorBase { GraphEdit *graph; + LineEdit *node_filter; + TextureFrame *node_filter_icon; + VisualScriptEditorSignalEdit *signal_editor; AcceptDialog *edit_signal_dialog; @@ -42,6 +45,8 @@ class VisualScriptEditor : public ScriptEditorBase { AcceptDialog *edit_variable_dialog; PropertyEditor *edit_variable_edit; + CustomPropertyEditor *default_value_edit; + UndoRedo *undo_redo; Tree *members; @@ -85,6 +90,7 @@ class VisualScriptEditor : public ScriptEditorBase { void _node_selected(Node* p_node); + void _node_filter_changed(const String& p_text); void _change_base_type_callback(); void _change_base_type(); void _member_selected(); @@ -118,8 +124,14 @@ class VisualScriptEditor : public ScriptEditorBase { void drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from); + int editing_id; + int editing_input; + + void _default_value_changed(); + void _default_value_edited(Node * p_button,int p_id,int p_input_port); protected: + void _notification(int p_what); static void _bind_methods(); public: diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index f735564b8b8..83d975fbca5 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -54,7 +54,7 @@ void VisualScriptReturn::set_return_type(Variant::Type p_type) { if (type==p_type) return; type=p_type; - emit_signal("ports_changed"); + ports_changed_notify(); } @@ -68,7 +68,7 @@ void VisualScriptReturn::set_enable_return_value(bool p_enable) { return; with_value=p_enable; - emit_signal("ports_changed"); + ports_changed_notify(); } bool VisualScriptReturn::is_return_value_enabled() const { @@ -378,7 +378,7 @@ void VisualScriptSequence::set_steps(int p_steps) { return; steps=p_steps; - emit_signal("ports_changed"); + ports_changed_notify(); } diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 6494df76679..750ad00a56b 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -216,6 +216,22 @@ String VisualScriptFunctionCall::get_text() const { void VisualScriptFunctionCall::_update_defargs() { + //save base type if accessible + + if (call_mode==CALL_MODE_NODE_PATH) { + + Node* node=_get_base_node(); + if (node) { + base_type=node->get_type(); + } + } else if (call_mode==CALL_MODE_SELF) { + + if (get_visual_script().is_valid()) { + base_type=get_visual_script()->get_instance_base_type(); + } + } + + if (call_mode==CALL_MODE_BASIC_TYPE) { use_default_args = Variant::get_method_default_arguments(basic_type,function).size(); } else { @@ -239,7 +255,7 @@ void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { _update_defargs(); _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } Variant::Type VisualScriptFunctionCall::get_basic_type() const{ @@ -255,7 +271,7 @@ void VisualScriptFunctionCall::set_base_type(const StringName& p_type) { base_type=p_type; _update_defargs(); _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } StringName VisualScriptFunctionCall::get_base_type() const{ @@ -271,7 +287,7 @@ void VisualScriptFunctionCall::set_function(const StringName& p_type){ function=p_type; _update_defargs(); _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } StringName VisualScriptFunctionCall::get_function() const { @@ -284,10 +300,10 @@ void VisualScriptFunctionCall::set_base_path(const NodePath& p_type) { if (base_path==p_type) return; - base_path=p_type; + base_path=p_type; _update_defargs(); _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } NodePath VisualScriptFunctionCall::get_base_path() const { @@ -304,7 +320,7 @@ void VisualScriptFunctionCall::set_call_mode(CallMode p_mode) { call_mode=p_mode; _update_defargs(); _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } VisualScriptFunctionCall::CallMode VisualScriptFunctionCall::get_call_mode() const { @@ -318,7 +334,7 @@ void VisualScriptFunctionCall::set_use_default_args(int p_amount) { return; use_default_args=p_amount; - emit_signal("ports_changed"); + ports_changed_notify(); } @@ -331,7 +347,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo& property) const if (property.name=="function/base_type") { if (call_mode!=CALL_MODE_INSTANCE) { - property.usage=0; + property.usage=PROPERTY_USAGE_NOEDITOR; } } @@ -676,7 +692,22 @@ String VisualScriptPropertySet::get_text() const { } +void VisualScriptPropertySet::_update_base_type() { + //cache it because this information may not be available on load + if (call_mode==CALL_MODE_NODE_PATH) { + Node* node=_get_base_node(); + if (node) { + base_type=node->get_type(); + } + } else if (call_mode==CALL_MODE_SELF) { + + if (get_visual_script().is_valid()) { + base_type=get_visual_script()->get_instance_base_type(); + } + } + +} void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) { if (basic_type==p_type) @@ -685,7 +716,8 @@ void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) { _change_notify(); - emit_signal("ports_changed"); + _update_base_type(); + ports_changed_notify(); } Variant::Type VisualScriptPropertySet::get_basic_type() const{ @@ -700,8 +732,8 @@ void VisualScriptPropertySet::set_base_type(const StringName& p_type) { return; base_type=p_type; - _change_notify(); - emit_signal("ports_changed"); + _change_notify(); + ports_changed_notify(); } StringName VisualScriptPropertySet::get_base_type() const{ @@ -715,8 +747,8 @@ void VisualScriptPropertySet::set_property(const StringName& p_type){ return; property=p_type; - _change_notify(); - emit_signal("ports_changed"); + _change_notify(); + ports_changed_notify(); } StringName VisualScriptPropertySet::get_property() const { @@ -730,8 +762,9 @@ void VisualScriptPropertySet::set_base_path(const NodePath& p_type) { return; base_path=p_type; + _update_base_type(); _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } NodePath VisualScriptPropertySet::get_base_path() const { @@ -746,8 +779,9 @@ void VisualScriptPropertySet::set_call_mode(CallMode p_mode) { return; call_mode=p_mode; + _update_base_type(); _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } VisualScriptPropertySet::CallMode VisualScriptPropertySet::get_call_mode() const { @@ -763,7 +797,7 @@ void VisualScriptPropertySet::set_use_builtin_value(bool p_use) { use_builtin_value=p_use; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } @@ -788,7 +822,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo& property) const { if (property.name=="property/base_type") { if (call_mode!=CALL_MODE_INSTANCE) { - property.usage=0; + property.usage=PROPERTY_USAGE_NOEDITOR; } } @@ -985,7 +1019,22 @@ bool VisualScriptPropertyGet::has_input_sequence_port() const{ return true; } +void VisualScriptPropertyGet::_update_base_type() { + //cache it because this information may not be available on load + if (call_mode==CALL_MODE_NODE_PATH) { + Node* node=_get_base_node(); + if (node) { + base_type=node->get_type(); + } + } else if (call_mode==CALL_MODE_SELF) { + + if (get_visual_script().is_valid()) { + base_type=get_visual_script()->get_instance_base_type(); + } + } + +} Node *VisualScriptPropertyGet::_get_base_node() const { #ifdef TOOLS_ENABLED @@ -1142,9 +1191,9 @@ void VisualScriptPropertyGet::set_base_type(const StringName& p_type) { if (base_type==p_type) return; - base_type=p_type; + base_type=p_type; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } StringName VisualScriptPropertyGet::get_base_type() const{ @@ -1159,7 +1208,7 @@ void VisualScriptPropertyGet::set_property(const StringName& p_type){ property=p_type; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } StringName VisualScriptPropertyGet::get_property() const { @@ -1174,7 +1223,8 @@ void VisualScriptPropertyGet::set_base_path(const NodePath& p_type) { base_path=p_type; _change_notify(); - emit_signal("ports_changed"); + _update_base_type(); + ports_changed_notify(); } NodePath VisualScriptPropertyGet::get_base_path() const { @@ -1190,7 +1240,8 @@ void VisualScriptPropertyGet::set_call_mode(CallMode p_mode) { call_mode=p_mode; _change_notify(); - emit_signal("ports_changed"); + _update_base_type(); + ports_changed_notify(); } VisualScriptPropertyGet::CallMode VisualScriptPropertyGet::get_call_mode() const { @@ -1208,7 +1259,7 @@ void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) { _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } Variant::Type VisualScriptPropertyGet::get_basic_type() const{ @@ -1221,7 +1272,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo& property) const { if (property.name=="property/base_type") { if (call_mode!=CALL_MODE_INSTANCE) { - property.usage=0; + property.usage=PROPERTY_USAGE_NOEDITOR; } } @@ -1532,7 +1583,7 @@ void VisualScriptScriptCall::set_function(const StringName& p_type){ function=p_type; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } StringName VisualScriptScriptCall::get_function() const { @@ -1548,7 +1599,7 @@ void VisualScriptScriptCall::set_base_path(const NodePath& p_type) { base_path=p_type; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } NodePath VisualScriptScriptCall::get_base_path() const { @@ -1565,7 +1616,7 @@ void VisualScriptScriptCall::set_call_mode(CallMode p_mode) { call_mode=p_mode; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } VisualScriptScriptCall::CallMode VisualScriptScriptCall::get_call_mode() const { @@ -1763,7 +1814,7 @@ void VisualScriptEmitSignal::set_signal(const StringName& p_type){ name=p_type; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } StringName VisualScriptEmitSignal::get_signal() const { diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h index 3d8f953a27d..940a133d634 100644 --- a/modules/visual_script/visual_script_func_nodes.h +++ b/modules/visual_script/visual_script_func_nodes.h @@ -102,6 +102,7 @@ private: Node *_get_base_node() const; StringName _get_base_type() const; + void _update_base_type(); protected: virtual void _validate_property(PropertyInfo& property) const; @@ -175,7 +176,7 @@ private: NodePath base_path; StringName property; - + void _update_base_type(); Node *_get_base_node() const; StringName _get_base_type() const; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index f29b6e34a7f..1e898675d3b 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -26,7 +26,7 @@ bool VisualScriptFunction::_set(const StringName& p_name, const Variant& p_valu arguments[i].name="arg"+itos(i+1); arguments[i].type=Variant::NIL; } - emit_signal("ports_changed"); + ports_changed_notify(); _change_notify(); return true; } @@ -38,7 +38,7 @@ bool VisualScriptFunction::_set(const StringName& p_name, const Variant& p_valu Variant::Type new_type = Variant::Type(int(p_value)); arguments[idx].type=new_type; - emit_signal("ports_changed"); + ports_changed_notify(); return true; } @@ -46,7 +46,7 @@ bool VisualScriptFunction::_set(const StringName& p_name, const Variant& p_valu if (what=="name") { arguments[idx].name=p_value; - emit_signal("ports_changed"); + ports_changed_notify(); return true; } @@ -157,7 +157,7 @@ void VisualScriptFunction::add_argument(Variant::Type p_type,const String& p_nam else arguments.push_back(arg); - emit_signal("ports_changed"); + ports_changed_notify(); } void VisualScriptFunction::set_argument_type(int p_argidx,Variant::Type p_type){ @@ -165,7 +165,7 @@ void VisualScriptFunction::set_argument_type(int p_argidx,Variant::Type p_type){ ERR_FAIL_INDEX(p_argidx,arguments.size()); arguments[p_argidx].type=p_type; - emit_signal("ports_changed"); + ports_changed_notify(); } Variant::Type VisualScriptFunction::get_argument_type(int p_argidx) const { @@ -178,7 +178,7 @@ void VisualScriptFunction::set_argument_name(int p_argidx,const String& p_name) ERR_FAIL_INDEX(p_argidx,arguments.size()); arguments[p_argidx].name=p_name; - emit_signal("ports_changed"); + ports_changed_notify(); } String VisualScriptFunction::get_argument_name(int p_argidx) const { @@ -192,7 +192,7 @@ void VisualScriptFunction::remove_argument(int p_argidx) { ERR_FAIL_INDEX(p_argidx,arguments.size()); arguments.remove(p_argidx); - emit_signal("ports_changed"); + ports_changed_notify(); } @@ -400,7 +400,7 @@ void VisualScriptOperator::set_operator(Variant::Operator p_op) { if (op==p_op) return; op=p_op; - emit_signal("ports_changed"); + ports_changed_notify(); } @@ -516,7 +516,7 @@ void VisualScriptVariable::set_variable(StringName p_variable) { if (variable==p_variable) return; variable=p_variable; - emit_signal("ports_changed"); + ports_changed_notify(); } @@ -625,7 +625,7 @@ void VisualScriptConstant::set_constant_type(Variant::Type p_type) { return; type=p_type; - emit_signal("ports_changed"); + ports_changed_notify(); Variant::CallError ce; value=Variant::construct(type,NULL,0,ce); _change_notify(); @@ -643,7 +643,7 @@ void VisualScriptConstant::set_constant_value(Variant p_value){ return; value=p_value; - emit_signal("ports_changed"); + ports_changed_notify(); } Variant VisualScriptConstant::get_constant_value() const{ @@ -881,7 +881,7 @@ void VisualScriptGlobalConstant::set_global_constant(int p_which) { index=p_which; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } int VisualScriptGlobalConstant::get_global_constant() { @@ -980,7 +980,7 @@ void VisualScriptMathConstant::set_math_constant(MathConstant p_which) { constant=p_which; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } VisualScriptMathConstant::MathConstant VisualScriptMathConstant::get_math_constant() { @@ -1071,7 +1071,7 @@ void VisualScriptEngineSingleton::set_singleton(const String& p_string) { singleton=p_string; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } String VisualScriptEngineSingleton::get_singleton() { @@ -1168,7 +1168,7 @@ void VisualScriptSceneNode::set_node_path(const NodePath& p_path) { path=p_path; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } NodePath VisualScriptSceneNode::get_node_path() { @@ -1374,7 +1374,7 @@ void VisualScriptResourcePath::set_resource_path(const String& p_path) { path=p_path; _change_notify(); - emit_signal("ports_changed"); + ports_changed_notify(); } String VisualScriptResourcePath::get_resource_path() { @@ -1416,8 +1416,8 @@ void register_visual_script_nodes() { VisualScriptLanguage::singleton->add_register_func("data/resource_path",create_node_generic); - VisualScriptLanguage::singleton->add_register_func("index/get",create_node_generic); - VisualScriptLanguage::singleton->add_register_func("index/set",create_node_generic); + VisualScriptLanguage::singleton->add_register_func("index/get_index",create_node_generic); + VisualScriptLanguage::singleton->add_register_func("index/set_index",create_node_generic); VisualScriptLanguage::singleton->add_register_func("operators/compare/equal",create_op_node); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 135eca68606..f66cdd7cae9 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -1362,11 +1362,21 @@ void CustomPropertyEditor::_modified(String p_string) { return; updating=true; switch(type) { + case Variant::INT: { + + if (evaluator) + v=evaluator->eval(value_editor[0]->get_text()); + else + v=value_editor[0]->get_text().to_int(); + emit_signal("variant_changed"); + + + } break; case Variant::REAL: { if (hint!=PROPERTY_HINT_EXP_EASING) { if (evaluator) - evaluator->eval(value_editor[0]->get_text()); + v=evaluator->eval(value_editor[0]->get_text()); else v=value_editor[0]->get_text().to_double(); emit_signal("variant_changed"); @@ -1570,7 +1580,8 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::NODE_PATH: { - + v=NodePath(value_editor[0]->get_text()); + emit_signal("variant_changed"); } break; case Variant::INPUT_EVENT: {