@@ -647,24 +647,24 @@ void GraphNode::_notification(int p_what) {
647647
648648 // Take the HboxContainer child into account.
649649 if (get_child_count (false ) > 0 ) {
650- int slot_index = 0 ;
651650 for (const KeyValue<int , Slot> &E : slot_table) {
652- if (E.key < 0 || E.key >= slot_y_cache.size ()) {
653- continue ;
654- }
655- if (!slot_table.has (E.key )) {
651+ const int slot_index = E.key ;
652+
653+ if (slot_index < 0 || slot_index >= slot_y_cache.size ()) {
656654 continue ;
657655 }
658- const Slot &slot = slot_table[E.key ];
656+
657+ const Slot &slot = E.value ;
658+ const int slot_y = slot_y_cache[slot_index];
659659
660660 // Left port.
661661 if (slot.enable_left ) {
662- draw_port (slot_index, Point2i (port_h_offset, slot_y_cache[E. key ] ), true , slot.color_left );
662+ draw_port (slot_index, Point2i (port_h_offset, slot_y ), true , slot.color_left );
663663 }
664664
665665 // Right port.
666666 if (slot.enable_right ) {
667- draw_port (slot_index, Point2i (get_size ().x - port_h_offset, slot_y_cache[E. key ] ), false , slot.color_right );
667+ draw_port (slot_index, Point2i (get_size ().x - port_h_offset, slot_y ), false , slot.color_right );
668668 }
669669
670670 if (slot_index == selected_slot) {
@@ -673,28 +673,25 @@ void GraphNode::_notification(int p_what) {
673673 port_icon = theme_cache.port ;
674674 }
675675 Size2i port_sz = port_icon->get_size () + sb_slot_selected->get_minimum_size ();
676- draw_style_box (sb_slot_selected, Rect2i (port_h_offset - port_sz.x * 0.5 , slot_y_cache[E. key ] - port_sz.y * 0.5 , port_sz.x , port_sz.y ));
676+ draw_style_box (sb_slot_selected, Rect2i (port_h_offset - port_sz.x * 0.5 , slot_y - port_sz.y * 0.5 , port_sz.x , port_sz.y ));
677677 port_icon = slot.custom_port_icon_right ;
678678 if (port_icon.is_null ()) {
679679 port_icon = theme_cache.port ;
680680 }
681681 port_sz = port_icon->get_size () + sb_slot_selected->get_minimum_size ();
682- draw_style_box (sb_slot_selected, Rect2i (get_size ().x - port_h_offset - port_sz.x * 0.5 , slot_y_cache[E. key ] - port_sz.y * 0.5 , port_sz.x , port_sz.y ));
682+ draw_style_box (sb_slot_selected, Rect2i (get_size ().x - port_h_offset - port_sz.x * 0.5 , slot_y - port_sz.y * 0.5 , port_sz.x , port_sz.y ));
683683 }
684684
685685 // Draw slot stylebox.
686686 if (slot.draw_stylebox ) {
687- Control *child = Object::cast_to<Control>(get_child (E.key , false ));
688- if (!child || !child->is_visible_in_tree ()) {
689- continue ;
687+ Control *child = Object::cast_to<Control>(get_child (slot_index, false ));
688+ if (child && child->is_visible_in_tree ()) {
689+ Rect2 child_rect = child->get_rect ();
690+ child_rect.position .x = sb_panel->get_margin (SIDE_LEFT);
691+ child_rect.size .width = width;
692+ draw_style_box (sb_slot, child_rect);
690693 }
691- Rect2 child_rect = child->get_rect ();
692- child_rect.position .x = sb_panel->get_margin (SIDE_LEFT);
693- child_rect.size .width = width;
694- draw_style_box (sb_slot, child_rect);
695694 }
696-
697- slot_index++;
698695 }
699696 }
700697
0 commit comments