diff --git a/core/variant.h b/core/variant.h index 87bf20f8ee2..b8b028a7603 100644 --- a/core/variant.h +++ b/core/variant.h @@ -395,6 +395,10 @@ public: void get_method_list(List *p_list) const; bool has_method(const StringName& p_method) const; + static Vector get_method_argument_types(Variant::Type p_type,const StringName& p_method); + static Vector get_method_default_arguments(Variant::Type p_type,const StringName& p_method); + static Variant::Type get_method_return_type(Variant::Type p_type,const StringName& p_method,bool* r_has_return=NULL); + static Vector get_method_argument_names(Variant::Type p_type,const StringName& p_method); void set_named(const StringName& p_index, const Variant& p_value, bool *r_valid=NULL); Variant get_named(const StringName& p_index, bool *r_valid=NULL) const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 7956c14c2c1..069c20bc6e9 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1173,6 +1173,56 @@ bool Variant::has_method(const StringName& p_method) const { } +Vector Variant::get_method_argument_types(Variant::Type p_type,const StringName& p_method) { + + const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type]; + + const Map::Element *E = fd.functions.find(p_method); + if (!E) + return Vector(); + + return E->get().arg_types; +} + +Vector Variant::get_method_argument_names(Variant::Type p_type,const StringName& p_method) { + + + const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type]; + + const Map::Element *E = fd.functions.find(p_method); + if (!E) + return Vector(); + + return E->get().arg_names; + +} + +Variant::Type Variant::get_method_return_type(Variant::Type p_type,const StringName& p_method,bool* r_has_return) { + + const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type]; + + const Map::Element *E = fd.functions.find(p_method); + if (!E) + return Variant::NIL; + + if (r_has_return) + *r_has_return=E->get().return_type; + + return E->get().return_type; +} + +Vector Variant::get_method_default_arguments(Variant::Type p_type,const StringName& p_method) { + + const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type]; + + const Map::Element *E = fd.functions.find(p_method); + if (!E) + return Vector(); + + return E->get().default_args; + +} + void Variant::get_method_list(List *p_list) const { diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index 2cd84203e86..da767c84471 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/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/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index f25bd0b9985..677960a03df 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/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