diff options
Diffstat (limited to 'scene/gui/graph_node.cpp')
-rw-r--r-- | scene/gui/graph_node.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 3b1c1a153f..1b960a9b62 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -482,6 +482,27 @@ Color GraphNode::get_slot_color_left(int p_slot_index) const { return slot_table[p_slot_index].color_left; } +void GraphNode::set_slot_custom_icon_left(int p_slot_index, const Ref<Texture2D> &p_custom_icon) { + ERR_FAIL_COND_MSG(!slot_table.has(p_slot_index), vformat("Cannot set custom_port_icon_left for the slot with index '%d' because it hasn't been enabled.", p_slot_index)); + + if (slot_table[p_slot_index].custom_port_icon_left == p_custom_icon) { + return; + } + + slot_table[p_slot_index].custom_port_icon_left = p_custom_icon; + queue_redraw(); + port_pos_dirty = true; + + emit_signal(SNAME("slot_updated"), p_slot_index); +} + +Ref<Texture2D> GraphNode::get_slot_custom_icon_left(int p_slot_index) const { + if (!slot_table.has(p_slot_index)) { + return Ref<Texture2D>(); + } + return slot_table[p_slot_index].custom_port_icon_left; +} + bool GraphNode::is_slot_enabled_right(int p_slot_index) const { if (!slot_table.has(p_slot_index)) { return false; @@ -545,6 +566,27 @@ Color GraphNode::get_slot_color_right(int p_slot_index) const { return slot_table[p_slot_index].color_right; } +void GraphNode::set_slot_custom_icon_right(int p_slot_index, const Ref<Texture2D> &p_custom_icon) { + ERR_FAIL_COND_MSG(!slot_table.has(p_slot_index), vformat("Cannot set custom_port_icon_right for the slot with index '%d' because it hasn't been enabled.", p_slot_index)); + + if (slot_table[p_slot_index].custom_port_icon_right == p_custom_icon) { + return; + } + + slot_table[p_slot_index].custom_port_icon_right = p_custom_icon; + queue_redraw(); + port_pos_dirty = true; + + emit_signal(SNAME("slot_updated"), p_slot_index); +} + +Ref<Texture2D> GraphNode::get_slot_custom_icon_right(int p_slot_index) const { + if (!slot_table.has(p_slot_index)) { + return Ref<Texture2D>(); + } + return slot_table[p_slot_index].custom_port_icon_right; +} + bool GraphNode::is_slot_draw_stylebox(int p_slot_index) const { if (!slot_table.has(p_slot_index)) { return false; @@ -797,6 +839,9 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("set_slot_color_left", "slot_index", "color"), &GraphNode::set_slot_color_left); ClassDB::bind_method(D_METHOD("get_slot_color_left", "slot_index"), &GraphNode::get_slot_color_left); + ClassDB::bind_method(D_METHOD("set_slot_custom_icon_left", "slot_index", "custom_icon"), &GraphNode::set_slot_custom_icon_left); + ClassDB::bind_method(D_METHOD("get_slot_custom_icon_left", "slot_index"), &GraphNode::get_slot_custom_icon_left); + ClassDB::bind_method(D_METHOD("is_slot_enabled_right", "slot_index"), &GraphNode::is_slot_enabled_right); ClassDB::bind_method(D_METHOD("set_slot_enabled_right", "slot_index", "enable"), &GraphNode::set_slot_enabled_right); @@ -806,6 +851,9 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("set_slot_color_right", "slot_index", "color"), &GraphNode::set_slot_color_right); ClassDB::bind_method(D_METHOD("get_slot_color_right", "slot_index"), &GraphNode::get_slot_color_right); + ClassDB::bind_method(D_METHOD("set_slot_custom_icon_right", "slot_index", "custom_icon"), &GraphNode::set_slot_custom_icon_right); + ClassDB::bind_method(D_METHOD("get_slot_custom_icon_right", "slot_index"), &GraphNode::get_slot_custom_icon_right); + ClassDB::bind_method(D_METHOD("is_slot_draw_stylebox", "slot_index"), &GraphNode::is_slot_draw_stylebox); ClassDB::bind_method(D_METHOD("set_slot_draw_stylebox", "slot_index", "enable"), &GraphNode::set_slot_draw_stylebox); |