diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-08-08 13:14:36 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-08-08 13:14:36 -0300 |
commit | 8a4bce6ebd843f9a8f482f74601f4933aae737a3 (patch) | |
tree | 6a94023a24cc326cee5283d68314b9ca9c1060a2 /modules | |
parent | 95f10c620d475245e62bed81cb981aa47c926d0b (diff) |
Ability to set a function as sequenced, so when called you can choose not to use sequence ports. Fixes #6346
Diffstat (limited to 'modules')
-rw-r--r-- | modules/visual_script/visual_script.cpp | 8 | ||||
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 49 | ||||
-rw-r--r-- | modules/visual_script/visual_script_nodes.h | 10 |
3 files changed, 55 insertions, 12 deletions
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 376329715b..7a368fbace 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -1058,6 +1058,10 @@ MethodInfo VisualScript::get_method_info(const StringName &p_method) const { arg.type = func->get_argument_type(i); mi.arguments.push_back(arg); } + + if (!func->is_sequenced()) { + mi.flags |= METHOD_FLAG_CONST; + } } } @@ -1401,6 +1405,10 @@ void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const { mi.arguments.push_back(arg); } + if (!vsf->is_sequenced()) { //assumed constant if not sequenced + mi.flags |= METHOD_FLAG_CONST; + } + //vsf->Get_ for now at least it does not return.. } } diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index d5d8b8fe6e..4fefa01584 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -95,6 +95,12 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value return true; } + if (p_name == "sequenced/sequenced") { + sequenced = p_value; + ports_changed_notify(); + return true; + } + return false; } @@ -133,6 +139,11 @@ bool VisualScriptFunction::_get(const StringName &p_name, Variant &r_ret) const return true; } + if (p_name == "sequenced/sequenced") { + r_ret = sequenced; + return true; + } + return false; } void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const { @@ -147,6 +158,9 @@ void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const p_list->push_back(PropertyInfo(Variant::INT, "argument_" + itos(i + 1) + "/type", PROPERTY_HINT_ENUM, argt)); p_list->push_back(PropertyInfo(Variant::STRING, "argument_" + itos(i + 1) + "/name")); } + + p_list->push_back(PropertyInfo(Variant::BOOL, "sequenced/sequenced")); + if (!stack_less) { p_list->push_back(PropertyInfo(Variant::INT, "stack/size", PROPERTY_HINT_RANGE, "1,100000")); } @@ -302,6 +316,7 @@ VisualScriptFunction::VisualScriptFunction() { stack_size = 256; stack_less = false; + sequenced = true; rpc_mode = ScriptInstance::RPC_MODE_DISABLED; } @@ -314,6 +329,16 @@ bool VisualScriptFunction::is_stack_less() const { return stack_less; } +void VisualScriptFunction::set_sequenced(bool p_enable) { + + sequenced = p_enable; +} + +bool VisualScriptFunction::is_sequenced() const { + + return sequenced; +} + void VisualScriptFunction::set_stack_size(int p_size) { ERR_FAIL_COND(p_size < 1 || p_size > 100000); @@ -1467,7 +1492,7 @@ void VisualScriptGlobalConstant::_bind_methods() { cc += ","; cc += GlobalConstants::get_global_constant_name(i); } - ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant"); } VisualScriptGlobalConstant::VisualScriptGlobalConstant() { @@ -1572,7 +1597,7 @@ VisualScriptNodeInstance *VisualScriptClassConstant::instance(VisualScriptInstan void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const { - if (property.name == "constant") { + if (property.name == "constant/constant") { List<String> constants; ClassDB::get_integer_constant_list(base_type, &constants, true); @@ -1596,7 +1621,7 @@ void VisualScriptClassConstant::_bind_methods() { ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptClassConstant::get_base_type); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant"); } VisualScriptClassConstant::VisualScriptClassConstant() { @@ -1701,7 +1726,7 @@ VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instance(VisualScriptIn void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) const { - if (property.name == "constant") { + if (property.name == "constant/constant") { List<StringName> constants; Variant::get_numeric_constants_for_type(type, &constants); @@ -1734,7 +1759,7 @@ void VisualScriptBasicTypeConstant::_bind_methods() { } ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, argt), "set_basic_type", "get_basic_type"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant"); } VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() { @@ -1855,7 +1880,7 @@ void VisualScriptMathConstant::_bind_methods() { cc += ","; cc += const_name[i]; } - ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant"); } VisualScriptMathConstant::VisualScriptMathConstant() { @@ -1976,7 +2001,7 @@ void VisualScriptEngineSingleton::_bind_methods() { cc += E->get().name; } - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton"); } VisualScriptEngineSingleton::VisualScriptEngineSingleton() { @@ -3702,11 +3727,11 @@ void register_visual_script_nodes() { VisualScriptLanguage::singleton->add_register_func("data/preload", create_node_generic<VisualScriptPreload>); VisualScriptLanguage::singleton->add_register_func("data/action", create_node_generic<VisualScriptInputAction>); - VisualScriptLanguage::singleton->add_register_func("constants/constant", create_node_generic<VisualScriptConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/math_constant", create_node_generic<VisualScriptMathConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/class_constant", create_node_generic<VisualScriptClassConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/global_constant", create_node_generic<VisualScriptGlobalConstant>); - VisualScriptLanguage::singleton->add_register_func("constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/constant", create_node_generic<VisualScriptConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/math_constant", create_node_generic<VisualScriptMathConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/class_constant", create_node_generic<VisualScriptClassConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/global_constant", create_node_generic<VisualScriptGlobalConstant>); + VisualScriptLanguage::singleton->add_register_func("constant/constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>); VisualScriptLanguage::singleton->add_register_func("custom/custom_node", create_node_generic<VisualScriptCustomNode>); VisualScriptLanguage::singleton->add_register_func("custom/sub_call", create_node_generic<VisualScriptSubCall>); diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index 7a3b26fe55..ff49417114 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -46,6 +46,7 @@ class VisualScriptFunction : public VisualScriptNode { bool stack_less; int stack_size; ScriptInstance::RPCMode rpc_mode; + bool sequenced; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -79,9 +80,18 @@ public: void set_stack_less(bool p_enable); bool is_stack_less() const; + void set_sequenced(bool p_enable); + bool is_sequenced() const; + void set_stack_size(int p_size); int get_stack_size() const; + void set_return_type_enabled(bool p_returns); + bool is_return_type_enabled() const; + + void set_return_type(Variant::Type p_type); + Variant::Type get_return_type() const; + void set_rpc_mode(ScriptInstance::RPCMode p_mode); ScriptInstance::RPCMode get_rpc_mode() const; |