|
26 | 26 | import com.cleanroommc.modularui.drawable.GuiDraw; |
27 | 27 | import com.cleanroommc.modularui.factory.PosGuiData; |
28 | 28 | import com.cleanroommc.modularui.screen.ModularPanel; |
29 | | -import com.cleanroommc.modularui.screen.viewport.ModularGuiContext; |
| 29 | +import com.cleanroommc.modularui.screen.RichTooltip; |
30 | 30 | import com.cleanroommc.modularui.value.sync.PanelSyncManager; |
31 | 31 | import com.cleanroommc.modularui.value.sync.SyncHandlers; |
32 | 32 | import com.cleanroommc.modularui.widgets.ItemSlot; |
@@ -80,16 +80,19 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) |
80 | 80 | return GTGuis.createPanel(this, 176, 18 + 18 + 94) |
81 | 81 | .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) |
82 | 82 | .child(SlotGroupWidget.playerInventory().left(7).bottom(7)) |
83 | | - .child(new ItemSlot() { |
84 | | - |
85 | | - // Don't draw tooltip if the slot is blocked |
86 | | - @Override |
87 | | - public void drawForeground(ModularGuiContext context) { |
88 | | - if (!isSlotBlocked()) super.drawForeground(context); |
89 | | - } |
90 | | - } |
| 83 | + .child(new ItemSlot() |
91 | 84 | .slot(SyncHandlers.itemSlot(machineHandler, 0) |
92 | 85 | .slotGroup("item_inv")) |
| 86 | + .tooltip(t -> t.setAutoUpdate(false)) |
| 87 | + .onUpdateListener(itemSlot -> { |
| 88 | + RichTooltip tooltip = itemSlot.tooltip(); |
| 89 | + if (isSlotBlocked()) { |
| 90 | + tooltip.buildTooltip(); |
| 91 | + tooltip.clearText(); |
| 92 | + } else if (tooltip.isEmpty()) { |
| 93 | + tooltip.markDirty(); |
| 94 | + } |
| 95 | + }) |
93 | 96 | .overlay((context, x, y, width, height, widgetTheme) -> GuiDraw.drawRect(x, y, width, height, |
94 | 97 | 0x80404040)) |
95 | 98 | .left(79).top(18)); |
|
0 commit comments