diff options
Diffstat (limited to 'modules/visual_script/visual_script_yield_nodes.cpp')
-rw-r--r-- | modules/visual_script/visual_script_yield_nodes.cpp | 79 |
1 files changed, 51 insertions, 28 deletions
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index a035efd25d..dd07cc45a7 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -147,8 +147,9 @@ VisualScriptNodeInstance *VisualScriptYield::instance(VisualScriptInstance *p_in } void VisualScriptYield::set_yield_mode(YieldMode p_mode) { - if (yield_mode == p_mode) + if (yield_mode == p_mode) { return; + } yield_mode = p_mode; ports_changed_notify(); _change_notify(); @@ -159,8 +160,9 @@ VisualScriptYield::YieldMode VisualScriptYield::get_yield_mode() { } void VisualScriptYield::set_wait_time(float p_time) { - if (wait_time == p_time) + if (wait_time == p_time) { return; + } wait_time = p_time; ports_changed_notify(); } @@ -219,18 +221,21 @@ bool VisualScriptYieldSignal::has_input_sequence_port() const { #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) + if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) { return nullptr; + } Ref<Script> scr = p_current_node->get_script(); - if (scr.is_valid() && scr == script) + if (scr.is_valid() && scr == script) { return p_current_node; + } for (int i = 0; i < p_current_node->get_child_count(); i++) { Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script); - if (n) + if (n) { return n; + } } return nullptr; @@ -240,27 +245,32 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Node *VisualScriptYieldSignal::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); - if (!script.is_valid()) + if (!script.is_valid()) { return nullptr; + } MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); - if (!scene_tree) + if (!scene_tree) { return nullptr; + } Node *edited_scene = scene_tree->get_edited_scene_root(); - if (!edited_scene) + if (!edited_scene) { return nullptr; + } Node *script_node = _find_script_node(edited_scene, edited_scene, script); - if (!script_node) + if (!script_node) { return nullptr; + } - if (!script_node->has_node(base_path)) + if (!script_node->has_node(base_path)) { return nullptr; + } Node *path_to = script_node->get_node(base_path); @@ -272,29 +282,32 @@ Node *VisualScriptYieldSignal::_get_base_node() const { } StringName VisualScriptYieldSignal::_get_base_type() const { - if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) + 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()) { + } else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) { Node *path = _get_base_node(); - if (path) + if (path) { return path->get_class(); + } } return base_type; } int VisualScriptYieldSignal::get_input_value_port_count() const { - if (call_mode == CALL_MODE_INSTANCE) + if (call_mode == CALL_MODE_INSTANCE) { return 1; - else + } else { return 0; + } } int VisualScriptYieldSignal::get_output_value_port_count() const { MethodInfo sr; - if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) + if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) { return 0; + } return sr.arguments.size(); } @@ -304,17 +317,19 @@ String VisualScriptYieldSignal::get_output_sequence_port_text(int p_port) const } PropertyInfo VisualScriptYieldSignal::get_input_value_port_info(int p_idx) const { - if (call_mode == CALL_MODE_INSTANCE) + if (call_mode == CALL_MODE_INSTANCE) { return PropertyInfo(Variant::OBJECT, "instance"); - else + } else { return PropertyInfo(); + } } PropertyInfo VisualScriptYieldSignal::get_output_value_port_info(int p_idx) const { MethodInfo sr; - if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) + if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) { return PropertyInfo(); //no signal + } ERR_FAIL_INDEX_V(p_idx, sr.arguments.size(), PropertyInfo()); return sr.arguments[p_idx]; } @@ -330,15 +345,17 @@ String VisualScriptYieldSignal::get_caption() const { } String VisualScriptYieldSignal::get_text() const { - if (call_mode == CALL_MODE_SELF) + if (call_mode == CALL_MODE_SELF) { return " " + String(signal) + "()"; - else + } else { return " " + _get_base_type() + "." + String(signal) + "()"; + } } void VisualScriptYieldSignal::set_base_type(const StringName &p_type) { - if (base_type == p_type) + if (base_type == p_type) { return; + } base_type = p_type; @@ -351,8 +368,9 @@ StringName VisualScriptYieldSignal::get_base_type() const { } void VisualScriptYieldSignal::set_signal(const StringName &p_type) { - if (signal == p_type) + if (signal == p_type) { return; + } signal = p_type; @@ -365,8 +383,9 @@ StringName VisualScriptYieldSignal::get_signal() const { } void VisualScriptYieldSignal::set_base_path(const NodePath &p_type) { - if (base_path == p_type) + if (base_path == p_type) { return; + } base_path = p_type; @@ -379,8 +398,9 @@ NodePath VisualScriptYieldSignal::get_base_path() const { } void VisualScriptYieldSignal::set_call_mode(CallMode p_mode) { - if (call_mode == p_mode) + if (call_mode == p_mode) { return; + } call_mode = p_mode; @@ -419,8 +439,9 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { List<String> mstring; for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("_")) + if (E->get().name.begins_with("_")) { continue; + } mstring.push_back(E->get().name.get_slice(":", 0)); } @@ -428,8 +449,9 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const { String ml; for (List<String>::Element *E = mstring.front(); E; E = E->next()) { - if (ml != String()) + if (ml != String()) { ml += ","; + } ml += E->get(); } @@ -452,8 +474,9 @@ void VisualScriptYieldSignal::_bind_methods() { String bt; for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (i > 0) + if (i > 0) { bt += ","; + } bt += Variant::get_type_name(Variant::Type(i)); } |