Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-179 Function Call Target pin no longer autowired #189

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/editor/graph/graph_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ void OrchestratorGraphEdit::_attempt_autowire(const Ref<OScriptNode>& p_new_node
if (!pin.is_valid() || pin->get_flags().has_flag(OScriptNodePin::Flags::HIDDEN))
continue;

// Skip pins that are specifically flagged as non-autowirable
if (pin->get_flags().has_flag(OScriptNodePin::Flags::NO_AUTOWIRE))
continue;

// If pin direction matches drag, skip
if (_drag_context.get_direction() == pin->get_direction())
continue;
Expand Down
14 changes: 14 additions & 0 deletions src/editor/graph/pins/graph_node_pin_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
//
#include "graph_node_pin_object.h"

#include "script/node.h"
#include "script/nodes/functions/call_function.h"

OrchestratorGraphNodePinObject::OrchestratorGraphNodePinObject(OrchestratorGraphNode* p_node, const Ref<OScriptNodePin>& p_pin)
: OrchestratorGraphNodePin(p_node, p_pin)
{
Expand All @@ -27,6 +30,17 @@ void OrchestratorGraphNodePinObject::_bind_methods()

Control* OrchestratorGraphNodePinObject::_get_default_value_widget()
{
// Specifically checks if the node is a CallFunction node and if the pin is not the "Target" pin.
// In these cases, we should not render the "(self)" label.
if (OScriptNode* node = _pin->get_owning_node())
{
if (OScriptNodeCallFunction* call_function = Object::cast_to<OScriptNodeCallFunction>(node))
{
if (!_pin->get_pin_name().match("target"))
return nullptr;
}
}

Label* label = memnew(Label);
label->set_text("(self)");
return label;
Expand Down
1 change: 1 addition & 0 deletions src/script/node_pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class OScriptNodePin : public Resource
SHOW_LABEL = 1 << 9, //! Label should be shown, always
HIDE_LABEL = 1 << 10, //! Label should be hidden, always
NO_CAPITALIZE = 1 << 11, //! Label is not capitalized
NO_AUTOWIRE = 1 << 12, //! Prevents being autowired
CONST = 1 << 20, //! Represents a "const" data port
REFERENCE = 1 << 21, //! Represents a "reference" data port
OBJECT = 1 << 22, //! Refers to an object type
Expand Down
2 changes: 1 addition & 1 deletion src/script/nodes/functions/call_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void OScriptNodeCallFunction::_create_pins_for_method(const MethodInfo& p_method
{
Variant::Type target_type = _reference.target_type != Variant::NIL ? _reference.target_type : Variant::OBJECT;
Ref<OScriptNodePin> target = create_pin(PD_Input, "target", target_type);
target->set_flags(OScriptNodePin::Flags::DATA);
target->set_flags(OScriptNodePin::Flags::DATA | OScriptNodePin::Flags::NO_AUTOWIRE);
if (_reference.target_type == Variant::NIL)
{
if (_function_flags.has_flag(FF_IS_SELF))
Expand Down
Loading