diff options
Diffstat (limited to 'modules/visual_script/visual_script_func_nodes.cpp')
-rw-r--r-- | modules/visual_script/visual_script_func_nodes.cpp | 215 |
1 files changed, 0 insertions, 215 deletions
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 3b6ae369ae..4ba0c27ec0 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -42,7 +42,6 @@ ////////////////////////////////////////// int VisualScriptFunctionCall::get_output_sequence_port_count() const { - if ((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function))) return 0; else @@ -50,13 +49,11 @@ int VisualScriptFunctionCall::get_output_sequence_port_count() const { } bool VisualScriptFunctionCall::has_input_sequence_port() const { - return !((method_cache.flags & METHOD_FLAG_CONST && call_mode != CALL_MODE_INSTANCE) || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function))); } #ifdef TOOLS_ENABLED static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { - if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) return nullptr; @@ -76,7 +73,6 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const #endif Node *VisualScriptFunctionCall::_get_base_node() const { - #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) @@ -111,7 +107,6 @@ Node *VisualScriptFunctionCall::_get_base_node() const { } StringName VisualScriptFunctionCall::_get_base_type() const { - if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) return get_visual_script()->get_instance_base_type(); else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) { @@ -124,13 +119,11 @@ StringName VisualScriptFunctionCall::_get_base_type() const { } int VisualScriptFunctionCall::get_input_value_port_count() const { - if (call_mode == CALL_MODE_BASIC_TYPE) { Vector<Variant::Type> types = Variant::get_method_argument_types(basic_type, function); return types.size() + (rpc_call_mode >= RPC_RELIABLE_TO_ID ? 1 : 0) + 1; } else { - MethodBind *mb = ClassDB::get_method(_get_base_type(), function); if (mb) { int defaulted_args = mb->get_argument_count() < use_default_args ? mb->get_argument_count() : use_default_args; @@ -142,9 +135,7 @@ int VisualScriptFunctionCall::get_input_value_port_count() const { } } int VisualScriptFunctionCall::get_output_value_port_count() const { - if (call_mode == CALL_MODE_BASIC_TYPE) { - bool returns = false; Variant::get_method_return_type(basic_type, function, &returns); return returns ? 1 : 0; @@ -166,12 +157,10 @@ int VisualScriptFunctionCall::get_output_value_port_count() const { } String VisualScriptFunctionCall::get_output_sequence_port_text(int p_port) const { - return String(); } PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) const { - if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) { if (p_idx == 0) { PropertyInfo pi; @@ -184,7 +173,6 @@ PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) cons } if (rpc_call_mode >= RPC_RELIABLE_TO_ID) { - if (p_idx == 0) { return PropertyInfo(Variant::INT, "peer_id"); } else { @@ -195,13 +183,11 @@ PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) cons #ifdef DEBUG_METHODS_ENABLED if (call_mode == CALL_MODE_BASIC_TYPE) { - Vector<StringName> names = Variant::get_method_argument_names(basic_type, function); Vector<Variant::Type> types = Variant::get_method_argument_types(basic_type, function); return PropertyInfo(types[p_idx], names[p_idx]); } else { - MethodBind *mb = ClassDB::get_method(_get_base_type(), function); if (mb) { return mb->get_argument_info(p_idx); @@ -219,14 +205,11 @@ PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) cons } PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) const { - #ifdef DEBUG_METHODS_ENABLED if (call_mode == CALL_MODE_BASIC_TYPE) { - return PropertyInfo(Variant::get_method_return_type(basic_type, function), ""); } else { - if (call_mode == CALL_MODE_INSTANCE) { if (p_idx == 0) { return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type()); @@ -273,7 +256,6 @@ String VisualScriptFunctionCall::get_caption() const { } String VisualScriptFunctionCall::get_text() const { - if (rpc_call_mode) { return "RPC"; } @@ -281,7 +263,6 @@ String VisualScriptFunctionCall::get_text() const { } void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { - if (basic_type == p_type) return; basic_type = p_type; @@ -291,12 +272,10 @@ void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { } Variant::Type VisualScriptFunctionCall::get_basic_type() const { - return basic_type; } void VisualScriptFunctionCall::set_base_type(const StringName &p_type) { - if (base_type == p_type) return; @@ -306,12 +285,10 @@ void VisualScriptFunctionCall::set_base_type(const StringName &p_type) { } StringName VisualScriptFunctionCall::get_base_type() const { - return base_type; } void VisualScriptFunctionCall::set_base_script(const String &p_path) { - if (base_script == p_path) return; @@ -321,12 +298,10 @@ void VisualScriptFunctionCall::set_base_script(const String &p_path) { } String VisualScriptFunctionCall::get_base_script() const { - return base_script; } void VisualScriptFunctionCall::set_singleton(const StringName &p_type) { - if (singleton == p_type) return; @@ -341,7 +316,6 @@ void VisualScriptFunctionCall::set_singleton(const StringName &p_type) { } StringName VisualScriptFunctionCall::get_singleton() const { - return singleton; } @@ -350,7 +324,6 @@ void VisualScriptFunctionCall::_update_method_cache() { Ref<Script> script; if (call_mode == CALL_MODE_NODE_PATH) { - Node *node = _get_base_node(); if (node) { type = node->get_class(); @@ -358,7 +331,6 @@ void VisualScriptFunctionCall::_update_method_cache() { script = node->get_script(); } } else if (call_mode == CALL_MODE_SELF) { - if (get_visual_script().is_valid()) { type = get_visual_script()->get_instance_base_type(); base_type = type; //cache, too @@ -366,7 +338,6 @@ void VisualScriptFunctionCall::_update_method_cache() { } } else if (call_mode == CALL_MODE_SINGLETON) { - Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { type = obj->get_class(); @@ -374,17 +345,13 @@ void VisualScriptFunctionCall::_update_method_cache() { } } else if (call_mode == CALL_MODE_INSTANCE) { - type = base_type; if (base_script != String()) { - if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { - ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { - script = Ref<Resource>(ResourceCache::get(base_script)); } else { return; @@ -421,14 +388,12 @@ void VisualScriptFunctionCall::_update_method_cache() { } } } else if (script.is_valid() && script->has_method(function)) { - method_cache = script->get_method_info(function); use_default_args = method_cache.default_arguments.size(); } } void VisualScriptFunctionCall::set_function(const StringName &p_type) { - if (function == p_type) return; @@ -446,12 +411,10 @@ void VisualScriptFunctionCall::set_function(const StringName &p_type) { ports_changed_notify(); } StringName VisualScriptFunctionCall::get_function() const { - return function; } void VisualScriptFunctionCall::set_base_path(const NodePath &p_type) { - if (base_path == p_type) return; @@ -461,12 +424,10 @@ void VisualScriptFunctionCall::set_base_path(const NodePath &p_type) { } NodePath VisualScriptFunctionCall::get_base_path() const { - return base_path; } void VisualScriptFunctionCall::set_call_mode(CallMode p_mode) { - if (call_mode == p_mode) return; @@ -475,12 +436,10 @@ void VisualScriptFunctionCall::set_call_mode(CallMode p_mode) { ports_changed_notify(); } VisualScriptFunctionCall::CallMode VisualScriptFunctionCall::get_call_mode() const { - return call_mode; } void VisualScriptFunctionCall::set_use_default_args(int p_amount) { - if (use_default_args == p_amount) return; @@ -489,7 +448,6 @@ void VisualScriptFunctionCall::set_use_default_args(int p_amount) { } void VisualScriptFunctionCall::set_rpc_call_mode(VisualScriptFunctionCall::RPCCallMode p_mode) { - if (rpc_call_mode == p_mode) return; rpc_call_mode = p_mode; @@ -498,22 +456,18 @@ void VisualScriptFunctionCall::set_rpc_call_mode(VisualScriptFunctionCall::RPCCa } VisualScriptFunctionCall::RPCCallMode VisualScriptFunctionCall::get_rpc_call_mode() const { - return rpc_call_mode; } int VisualScriptFunctionCall::get_use_default_args() const { - return use_default_args; } void VisualScriptFunctionCall::set_validate(bool p_amount) { - validate = p_amount; } bool VisualScriptFunctionCall::get_validate() const { - return validate; } @@ -523,12 +477,10 @@ void VisualScriptFunctionCall::_set_argument_cache(const Dictionary &p_cache) { } Dictionary VisualScriptFunctionCall::_get_argument_cache() const { - return method_cache; } void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const { - if (property.name == "base_type") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; @@ -568,7 +520,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const if (call_mode != CALL_MODE_NODE_PATH) { property.usage = 0; } else { - Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string @@ -577,9 +528,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const } if (property.name == "function") { - if (call_mode == CALL_MODE_BASIC_TYPE) { - property.hint = PROPERTY_HINT_METHOD_OF_VARIANT_TYPE; property.hint_string = Variant::get_type_name(basic_type); @@ -587,13 +536,11 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT; property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_SINGLETON) { - Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE; property.hint_string = itos(obj->get_instance_id()); } else { - property.hint = PROPERTY_HINT_METHOD_OF_BASE_TYPE; property.hint_string = base_type; //should be cached } @@ -603,15 +550,12 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { - ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { - Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script)); if (script.is_valid()) { - property.hint = PROPERTY_HINT_METHOD_OF_SCRIPT; property.hint_string = itos(script->get_instance_id()); } @@ -631,18 +575,15 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const } if (property.name == "use_default_args") { - property.hint = PROPERTY_HINT_RANGE; int mc = 0; if (call_mode == CALL_MODE_BASIC_TYPE) { - mc = Variant::get_method_default_arguments(basic_type, function).size(); } else { MethodBind *mb = ClassDB::get_method(_get_base_type(), function); if (mb) { - mc = mb->get_default_argument_count(); } } @@ -650,7 +591,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const if (mc == 0) { property.usage = 0; //do not show } else { - property.hint_string = "0," + itos(mc) + ",1"; } } @@ -663,7 +603,6 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const } void VisualScriptFunctionCall::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptFunctionCall::set_base_type); ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptFunctionCall::get_base_type); @@ -761,7 +700,6 @@ public: //virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; } _FORCE_INLINE_ bool call_rpc(Object *p_base, const Variant **p_args, int p_argcount) { - if (!p_base) return false; @@ -789,11 +727,8 @@ public: } virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { - switch (call_mode) { - case VisualScriptFunctionCall::CALL_MODE_SELF: { - Object *object = instance->get_owner_ptr(); if (rpc_mode) { @@ -805,7 +740,6 @@ public: } } break; case VisualScriptFunctionCall::CALL_MODE_NODE_PATH: { - Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -831,7 +765,6 @@ public: } break; case VisualScriptFunctionCall::CALL_MODE_INSTANCE: case VisualScriptFunctionCall::CALL_MODE_BASIC_TYPE: { - Variant v = *p_inputs[0]; if (rpc_mode) { @@ -863,7 +796,6 @@ public: } break; case VisualScriptFunctionCall::CALL_MODE_SINGLETON: { - Object *object = Engine::get_singleton()->get_singleton_object(singleton); if (!object) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -882,7 +814,6 @@ public: } if (!validate) { - //ignore call errors if validation is disabled r_error.error = Callable::CallError::CALL_OK; r_error_str = String(); @@ -893,7 +824,6 @@ public: }; VisualScriptNodeInstance *VisualScriptFunctionCall::instance(VisualScriptInstance *p_instance) { - VisualScriptNodeInstanceFunctionCall *instance = memnew(VisualScriptNodeInstanceFunctionCall); instance->node = this; instance->instance = p_instance; @@ -909,7 +839,6 @@ VisualScriptNodeInstance *VisualScriptFunctionCall::instance(VisualScriptInstanc } VisualScriptFunctionCall::TypeGuess VisualScriptFunctionCall::guess_output_type(TypeGuess *p_inputs, int p_output) const { - if (p_output == 0 && call_mode == CALL_MODE_INSTANCE) { return p_inputs[0]; } @@ -918,7 +847,6 @@ VisualScriptFunctionCall::TypeGuess VisualScriptFunctionCall::guess_output_type( } VisualScriptFunctionCall::VisualScriptFunctionCall() { - validate = true; call_mode = CALL_MODE_SELF; basic_type = Variant::NIL; @@ -929,7 +857,6 @@ VisualScriptFunctionCall::VisualScriptFunctionCall() { template <VisualScriptFunctionCall::CallMode cmode> static Ref<VisualScriptNode> create_function_call_node(const String &p_name) { - Ref<VisualScriptFunctionCall> node; node.instance(); node->set_call_mode(cmode); @@ -941,17 +868,14 @@ static Ref<VisualScriptNode> create_function_call_node(const String &p_name) { ////////////////////////////////////////// int VisualScriptPropertySet::get_output_sequence_port_count() const { - return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0; } bool VisualScriptPropertySet::has_input_sequence_port() const { - return call_mode != CALL_MODE_BASIC_TYPE; } Node *VisualScriptPropertySet::_get_base_node() const { - #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) @@ -987,7 +911,6 @@ Node *VisualScriptPropertySet::_get_base_node() const { } StringName VisualScriptPropertySet::_get_base_type() const { - if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) return get_visual_script()->get_instance_base_type(); else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) { @@ -1000,25 +923,20 @@ StringName VisualScriptPropertySet::_get_base_type() const { } int VisualScriptPropertySet::get_input_value_port_count() const { - int pc = (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 2 : 1; return pc; } int VisualScriptPropertySet::get_output_value_port_count() const { - return (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0; } String VisualScriptPropertySet::get_output_sequence_port_text(int p_port) const { - return String(); } void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const { - if (index != StringName()) { - Variant v; Callable::CallError ce; v = Variant::construct(pinfo.type, nullptr, 0, ce); @@ -1065,7 +983,6 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons } String VisualScriptPropertySet::get_caption() const { - static const char *opname[ASSIGN_OP_MAX] = { "Set", "Add", "Subtract", "Multiply", "Divide", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor" }; @@ -1079,7 +996,6 @@ String VisualScriptPropertySet::get_caption() const { } String VisualScriptPropertySet::get_text() const { - if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); } @@ -1096,20 +1012,17 @@ 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_class(); } } 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) return; basic_type = p_type; @@ -1120,12 +1033,10 @@ void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) { } Variant::Type VisualScriptPropertySet::get_basic_type() const { - return basic_type; } void VisualScriptPropertySet::set_base_type(const StringName &p_type) { - if (base_type == p_type) return; @@ -1135,12 +1046,10 @@ void VisualScriptPropertySet::set_base_type(const StringName &p_type) { } StringName VisualScriptPropertySet::get_base_type() const { - return base_type; } void VisualScriptPropertySet::set_base_script(const String &p_path) { - if (base_script == p_path) return; @@ -1150,12 +1059,10 @@ void VisualScriptPropertySet::set_base_script(const String &p_path) { } String VisualScriptPropertySet::get_base_script() const { - return base_script; } void VisualScriptPropertySet::_update_cache() { - if (!Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop())) return; @@ -1163,7 +1070,6 @@ void VisualScriptPropertySet::_update_cache() { return; if (call_mode == CALL_MODE_BASIC_TYPE) { - //not super efficient.. Variant v; @@ -1174,21 +1080,17 @@ void VisualScriptPropertySet::_update_cache() { v.get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get(); } } } else { - StringName type; Ref<Script> script; Node *node = nullptr; if (call_mode == CALL_MODE_NODE_PATH) { - node = _get_base_node(); if (node) { type = node->get_class(); @@ -1196,24 +1098,19 @@ void VisualScriptPropertySet::_update_cache() { script = node->get_script(); } } else if (call_mode == CALL_MODE_SELF) { - if (get_visual_script().is_valid()) { type = get_visual_script()->get_instance_base_type(); base_type = type; //cache, too script = get_visual_script(); } } else if (call_mode == CALL_MODE_INSTANCE) { - type = base_type; if (base_script != String()) { - if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { - ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { - script = Ref<Resource>(ResourceCache::get(base_script)); } else { return; @@ -1224,19 +1121,16 @@ void VisualScriptPropertySet::_update_cache() { List<PropertyInfo> pinfo; if (node) { - node->get_property_list(&pinfo); } else { ClassDB::get_property_list(type, &pinfo); } if (script.is_valid()) { - script->get_script_property_list(&pinfo); } for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { type_cache = E->get(); return; @@ -1246,7 +1140,6 @@ void VisualScriptPropertySet::_update_cache() { } void VisualScriptPropertySet::set_property(const StringName &p_type) { - if (property == p_type) return; @@ -1257,12 +1150,10 @@ void VisualScriptPropertySet::set_property(const StringName &p_type) { ports_changed_notify(); } StringName VisualScriptPropertySet::get_property() const { - return property; } void VisualScriptPropertySet::set_base_path(const NodePath &p_type) { - if (base_path == p_type) return; @@ -1273,12 +1164,10 @@ void VisualScriptPropertySet::set_base_path(const NodePath &p_type) { } NodePath VisualScriptPropertySet::get_base_path() const { - return base_path; } void VisualScriptPropertySet::set_call_mode(CallMode p_mode) { - if (call_mode == p_mode) return; @@ -1288,7 +1177,6 @@ void VisualScriptPropertySet::set_call_mode(CallMode p_mode) { ports_changed_notify(); } VisualScriptPropertySet::CallMode VisualScriptPropertySet::get_call_mode() const { - return call_mode; } @@ -1297,12 +1185,10 @@ void VisualScriptPropertySet::_set_type_cache(const Dictionary &p_type) { } Dictionary VisualScriptPropertySet::_get_type_cache() const { - return type_cache; } void VisualScriptPropertySet::set_index(const StringName &p_type) { - if (index == p_type) return; index = p_type; @@ -1312,12 +1198,10 @@ void VisualScriptPropertySet::set_index(const StringName &p_type) { } StringName VisualScriptPropertySet::get_index() const { - return index; } void VisualScriptPropertySet::set_assign_op(AssignOp p_op) { - ERR_FAIL_INDEX(p_op, ASSIGN_OP_MAX); if (assign_op == p_op) return; @@ -1333,7 +1217,6 @@ VisualScriptPropertySet::AssignOp VisualScriptPropertySet::get_assign_op() const } void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { - if (property.name == "base_type") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; @@ -1356,7 +1239,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { if (call_mode != CALL_MODE_NODE_PATH) { property.usage = 0; } else { - Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string @@ -1365,9 +1247,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { } if (property.name == "property") { - if (call_mode == CALL_MODE_BASIC_TYPE) { - property.hint = PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE; property.hint_string = Variant::get_type_name(basic_type); @@ -1380,15 +1260,12 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { - ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { - Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script)); if (script.is_valid()) { - property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; property.hint_string = itos(script->get_instance_id()); } @@ -1408,7 +1285,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { } if (property.name == "index") { - Callable::CallError ce; Variant v = Variant::construct(type_cache.type, nullptr, 0, ce); List<PropertyInfo> plist; @@ -1427,7 +1303,6 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { } void VisualScriptPropertySet::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptPropertySet::set_base_type); ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptPropertySet::get_base_type); @@ -1520,11 +1395,9 @@ public: //virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; } _FORCE_INLINE_ void _process_get(Variant &source, const Variant &p_argument, bool &valid) { - if (index != StringName() && assign_op == VisualScriptPropertySet::ASSIGN_OP_NONE) { source.set_named(index, p_argument, &valid); } else { - Variant value; if (index != StringName()) { value = source.get_named(index, &valid); @@ -1579,11 +1452,8 @@ public: } virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { - switch (call_mode) { - case VisualScriptPropertySet::CALL_MODE_SELF: { - Object *object = instance->get_owner_ptr(); bool valid; @@ -1602,7 +1472,6 @@ public: } } break; case VisualScriptPropertySet::CALL_MODE_NODE_PATH: { - Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -1620,7 +1489,6 @@ public: bool valid; if (needs_get) { - Variant value = another->get(property, &valid); _process_get(value, *p_inputs[0], valid); another->set(property, value, &valid); @@ -1636,7 +1504,6 @@ public: } break; case VisualScriptPropertySet::CALL_MODE_INSTANCE: case VisualScriptPropertySet::CALL_MODE_BASIC_TYPE: { - Variant v = *p_inputs[0]; bool valid; @@ -1664,7 +1531,6 @@ public: }; VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance *p_instance) { - VisualScriptNodeInstancePropertySet *instance = memnew(VisualScriptNodeInstancePropertySet); instance->node = this; instance->instance = p_instance; @@ -1678,7 +1544,6 @@ VisualScriptNodeInstance *VisualScriptPropertySet::instance(VisualScriptInstance } VisualScriptPropertySet::TypeGuess VisualScriptPropertySet::guess_output_type(TypeGuess *p_inputs, int p_output) const { - if (p_output == 0 && call_mode == CALL_MODE_INSTANCE) { return p_inputs[0]; } @@ -1686,7 +1551,6 @@ VisualScriptPropertySet::TypeGuess VisualScriptPropertySet::guess_output_type(Ty return VisualScriptNode::guess_output_type(p_inputs, p_output); } VisualScriptPropertySet::VisualScriptPropertySet() { - assign_op = ASSIGN_OP_NONE; call_mode = CALL_MODE_SELF; base_type = "Object"; @@ -1695,7 +1559,6 @@ VisualScriptPropertySet::VisualScriptPropertySet() { template <VisualScriptPropertySet::CallMode cmode> static Ref<VisualScriptNode> create_property_set_node(const String &p_name) { - Ref<VisualScriptPropertySet> node; node.instance(); node->set_call_mode(cmode); @@ -1707,31 +1570,26 @@ static Ref<VisualScriptNode> create_property_set_node(const String &p_name) { ////////////////////////////////////////// int VisualScriptPropertyGet::get_output_sequence_port_count() const { - return 0; // (call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?0:1; } bool VisualScriptPropertyGet::has_input_sequence_port() const { - return false; //(call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?false: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_class(); } } 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 Ref<Script> script = get_visual_script(); if (!script.is_valid()) @@ -1767,7 +1625,6 @@ Node *VisualScriptPropertyGet::_get_base_node() const { } StringName VisualScriptPropertyGet::_get_base_type() const { - if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) return get_visual_script()->get_instance_base_type(); else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) { @@ -1780,21 +1637,17 @@ StringName VisualScriptPropertyGet::_get_base_type() const { } int VisualScriptPropertyGet::get_input_value_port_count() const { - return (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 1 : 0; } int VisualScriptPropertyGet::get_output_value_port_count() const { - return 1; } String VisualScriptPropertyGet::get_output_sequence_port_text(int p_port) const { - return String(); } PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const { - if (call_mode == CALL_MODE_INSTANCE || call_mode == CALL_MODE_BASIC_TYPE) { if (p_idx == 0) { PropertyInfo pi; @@ -1819,12 +1672,10 @@ PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) cons } String VisualScriptPropertyGet::get_caption() const { - return String("Get ") + property; } String VisualScriptPropertyGet::get_text() const { - if (call_mode == CALL_MODE_BASIC_TYPE) { return String("On ") + Variant::get_type_name(basic_type); } @@ -1839,7 +1690,6 @@ String VisualScriptPropertyGet::get_text() const { } void VisualScriptPropertyGet::set_base_type(const StringName &p_type) { - if (base_type == p_type) return; @@ -1849,12 +1699,10 @@ void VisualScriptPropertyGet::set_base_type(const StringName &p_type) { } StringName VisualScriptPropertyGet::get_base_type() const { - return base_type; } void VisualScriptPropertyGet::set_base_script(const String &p_path) { - if (base_script == p_path) return; @@ -1864,14 +1712,11 @@ void VisualScriptPropertyGet::set_base_script(const String &p_path) { } String VisualScriptPropertyGet::get_base_script() const { - return base_script; } void VisualScriptPropertyGet::_update_cache() { - if (call_mode == CALL_MODE_BASIC_TYPE) { - //not super efficient.. Variant v; @@ -1882,22 +1727,18 @@ void VisualScriptPropertyGet::_update_cache() { v.get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == property) { - type_cache = E->get().type; return; } } } else { - StringName type; Ref<Script> script; Node *node = nullptr; if (call_mode == CALL_MODE_NODE_PATH) { - node = _get_base_node(); if (node) { type = node->get_class(); @@ -1905,24 +1746,19 @@ void VisualScriptPropertyGet::_update_cache() { script = node->get_script(); } } else if (call_mode == CALL_MODE_SELF) { - if (get_visual_script().is_valid()) { type = get_visual_script()->get_instance_base_type(); base_type = type; //cache, too script = get_visual_script(); } } else if (call_mode == CALL_MODE_INSTANCE) { - type = base_type; if (base_script != String()) { - if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { - ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { - script = Ref<Resource>(ResourceCache::get(base_script)); } else { return; @@ -1942,7 +1778,6 @@ void VisualScriptPropertyGet::_update_cache() { } if (node) { - Variant prop = node->get(property, &valid); if (valid) { type_cache = prop.get_type(); @@ -1951,7 +1786,6 @@ void VisualScriptPropertyGet::_update_cache() { } if (script.is_valid()) { - type_ret = script->get_static_property_type(property, &valid); if (valid) { @@ -1963,7 +1797,6 @@ void VisualScriptPropertyGet::_update_cache() { } void VisualScriptPropertyGet::set_property(const StringName &p_type) { - if (property == p_type) return; @@ -1974,12 +1807,10 @@ void VisualScriptPropertyGet::set_property(const StringName &p_type) { ports_changed_notify(); } StringName VisualScriptPropertyGet::get_property() const { - return property; } void VisualScriptPropertyGet::set_base_path(const NodePath &p_type) { - if (base_path == p_type) return; @@ -1990,12 +1821,10 @@ void VisualScriptPropertyGet::set_base_path(const NodePath &p_type) { } NodePath VisualScriptPropertyGet::get_base_path() const { - return base_path; } void VisualScriptPropertyGet::set_call_mode(CallMode p_mode) { - if (call_mode == p_mode) return; @@ -2005,12 +1834,10 @@ void VisualScriptPropertyGet::set_call_mode(CallMode p_mode) { ports_changed_notify(); } VisualScriptPropertyGet::CallMode VisualScriptPropertyGet::get_call_mode() const { - return call_mode; } void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) { - if (basic_type == p_type) return; basic_type = p_type; @@ -2020,7 +1847,6 @@ void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) { } Variant::Type VisualScriptPropertyGet::get_basic_type() const { - return basic_type; } @@ -2029,12 +1855,10 @@ void VisualScriptPropertyGet::_set_type_cache(Variant::Type p_type) { } Variant::Type VisualScriptPropertyGet::_get_type_cache() const { - return type_cache; } void VisualScriptPropertyGet::set_index(const StringName &p_type) { - if (index == p_type) return; index = p_type; @@ -2044,12 +1868,10 @@ void VisualScriptPropertyGet::set_index(const StringName &p_type) { } StringName VisualScriptPropertyGet::get_index() const { - return index; } void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { - if (property.name == "base_type") { if (call_mode != CALL_MODE_INSTANCE) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; @@ -2072,7 +1894,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { if (call_mode != CALL_MODE_NODE_PATH) { property.usage = 0; } else { - Node *bnode = _get_base_node(); if (bnode) { property.hint_string = bnode->get_path(); //convert to loong string @@ -2081,9 +1902,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { } if (property.name == "property") { - if (call_mode == CALL_MODE_BASIC_TYPE) { - property.hint = PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE; property.hint_string = Variant::get_type_name(basic_type); @@ -2096,15 +1915,12 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { if (base_script != String()) { if (!ResourceCache::has(base_script) && ScriptServer::edit_request_func) { - ScriptServer::edit_request_func(base_script); //make sure it's loaded } if (ResourceCache::has(base_script)) { - Ref<Script> script = Ref<Resource>(ResourceCache::get(base_script)); if (script.is_valid()) { - property.hint = PROPERTY_HINT_PROPERTY_OF_SCRIPT; property.hint_string = itos(script->get_instance_id()); } @@ -2123,7 +1939,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { } if (property.name == "index") { - Callable::CallError ce; Variant v = Variant::construct(type_cache, nullptr, 0, ce); List<PropertyInfo> plist; @@ -2142,7 +1957,6 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { } void VisualScriptPropertyGet::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptPropertyGet::set_base_type); ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptPropertyGet::get_base_type); @@ -2212,11 +2026,8 @@ public: VisualScriptInstance *instance; virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { - switch (call_mode) { - case VisualScriptPropertyGet::CALL_MODE_SELF: { - Object *object = instance->get_owner_ptr(); bool valid; @@ -2234,7 +2045,6 @@ public: } } break; case VisualScriptPropertyGet::CALL_MODE_NODE_PATH: { - Node *node = Object::cast_to<Node>(instance->get_owner_ptr()); if (!node) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; @@ -2265,7 +2075,6 @@ public: } break; default: { - bool valid; Variant v = *p_inputs[0]; @@ -2286,7 +2095,6 @@ public: }; VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance *p_instance) { - VisualScriptNodeInstancePropertyGet *instance = memnew(VisualScriptNodeInstancePropertyGet); instance->node = this; instance->instance = p_instance; @@ -2299,7 +2107,6 @@ VisualScriptNodeInstance *VisualScriptPropertyGet::instance(VisualScriptInstance } VisualScriptPropertyGet::VisualScriptPropertyGet() { - call_mode = CALL_MODE_SELF; base_type = "Object"; basic_type = Variant::NIL; @@ -2308,7 +2115,6 @@ VisualScriptPropertyGet::VisualScriptPropertyGet() { template <VisualScriptPropertyGet::CallMode cmode> static Ref<VisualScriptNode> create_property_get_node(const String &p_name) { - Ref<VisualScriptPropertyGet> node; node.instance(); node->set_call_mode(cmode); @@ -2320,20 +2126,16 @@ static Ref<VisualScriptNode> create_property_get_node(const String &p_name) { ////////////////////////////////////////// int VisualScriptEmitSignal::get_output_sequence_port_count() const { - return 1; } bool VisualScriptEmitSignal::has_input_sequence_port() const { - return true; } int VisualScriptEmitSignal::get_input_value_port_count() const { - Ref<VisualScript> vs = get_visual_script(); if (vs.is_valid()) { - if (!vs->has_custom_signal(name)) return 0; @@ -2347,15 +2149,12 @@ int VisualScriptEmitSignal::get_output_value_port_count() const { } String VisualScriptEmitSignal::get_output_sequence_port_text(int p_port) const { - return String(); } PropertyInfo VisualScriptEmitSignal::get_input_value_port_info(int p_idx) const { - Ref<VisualScript> vs = get_visual_script(); if (vs.is_valid()) { - if (!vs->has_custom_signal(name)) return PropertyInfo(); @@ -2366,17 +2165,14 @@ PropertyInfo VisualScriptEmitSignal::get_input_value_port_info(int p_idx) const } PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const { - return PropertyInfo(); } String VisualScriptEmitSignal::get_caption() const { - return "Emit " + String(name); } void VisualScriptEmitSignal::set_signal(const StringName &p_type) { - if (name == p_type) return; @@ -2386,12 +2182,10 @@ void VisualScriptEmitSignal::set_signal(const StringName &p_type) { ports_changed_notify(); } StringName VisualScriptEmitSignal::get_signal() const { - return name; } void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { - if (property.name == "signal") { property.hint = PROPERTY_HINT_ENUM; @@ -2399,13 +2193,11 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { Ref<VisualScript> vs = get_visual_script(); if (vs.is_valid()) { - vs->get_custom_signal_list(&sigs); } String ml; for (List<StringName>::Element *E = sigs.front(); E; E = E->next()) { - if (ml != String()) ml += ","; ml += E->get(); @@ -2416,7 +2208,6 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const { } void VisualScriptEmitSignal::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_signal", "name"), &VisualScriptEmitSignal::set_signal); ClassDB::bind_method(D_METHOD("get_signal"), &VisualScriptEmitSignal::get_signal); @@ -2435,7 +2226,6 @@ public: //virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; } virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) { - Object *obj = instance->get_owner_ptr(); obj->emit_signal(name, p_inputs, argcount); @@ -2445,7 +2235,6 @@ public: }; VisualScriptNodeInstance *VisualScriptEmitSignal::instance(VisualScriptInstance *p_instance) { - VisualScriptNodeInstanceEmitSignal *instance = memnew(VisualScriptNodeInstanceEmitSignal); instance->node = this; instance->instance = p_instance; @@ -2458,7 +2247,6 @@ VisualScriptEmitSignal::VisualScriptEmitSignal() { } static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) { - Vector<String> path = p_name.split("/"); ERR_FAIL_COND_V(path.size() < 4, Ref<VisualScriptNode>()); String base_type = path[2]; @@ -2470,7 +2258,6 @@ static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) { Variant::Type type = Variant::VARIANT_MAX; for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (Variant::get_type_name(Variant::Type(i)) == base_type) { type = Variant::Type(i); break; @@ -2487,7 +2274,6 @@ static Ref<VisualScriptNode> create_basic_type_call_node(const String &p_name) { } void register_visual_script_func_nodes() { - VisualScriptLanguage::singleton->add_register_func("functions/call", create_node_generic<VisualScriptFunctionCall>); VisualScriptLanguage::singleton->add_register_func("functions/set", create_node_generic<VisualScriptPropertySet>); VisualScriptLanguage::singleton->add_register_func("functions/get", create_node_generic<VisualScriptPropertyGet>); @@ -2497,7 +2283,6 @@ void register_visual_script_func_nodes() { VisualScriptLanguage::singleton->add_register_func("functions/emit_signal", create_node_generic<VisualScriptEmitSignal>); for (int i = 0; i < Variant::VARIANT_MAX; i++) { - Variant::Type t = Variant::Type(i); String type_name = Variant::get_type_name(t); Callable::CallError ce; |