|
1 | 1 | package gregtech.api.mui.widget; |
2 | 2 |
|
| 3 | +import com.cleanroommc.modularui.api.widget.Interactable; |
| 4 | + |
3 | 5 | import gregtech.api.capability.impl.GhostCircuitItemStackHandler; |
4 | 6 | import gregtech.api.mui.GTGuiTextures; |
5 | 7 | import gregtech.api.mui.GTGuis; |
@@ -97,38 +99,38 @@ private boolean isSelectorPanelOpen() { |
97 | 99 | private void createSelectorPanel() { |
98 | 100 | ItemDrawable circuitPreview = new ItemDrawable(getSyncHandler().getSlot().getStack()); |
99 | 101 |
|
100 | | - List<List<IWidget>> options = new ArrayList<>(); |
101 | | - for (int i = 0; i < 4; i++) { |
102 | | - options.add(new ArrayList<>()); |
103 | | - for (int j = 0; j < 9; j++) { |
104 | | - int index = i * 9 + j; |
105 | | - if (index > 32) break; |
106 | | - options.get(i).add(new ButtonWidget<>() |
107 | | - .size(18) |
108 | | - .background(GTGuiTextures.SLOT, new ItemDrawable( |
109 | | - IntCircuitIngredient.getIntegratedCircuit(index)).asIcon()) |
110 | | - .disableHoverBackground() |
111 | | - .onMousePressed(mouseButton -> { |
112 | | - getSyncHandler().syncToServer(SYNC_CIRCUIT_INDEX, buf -> buf.writeShort(index)); |
113 | | - circuitPreview.setItem(IntCircuitIngredient.getIntegratedCircuit(index)); |
114 | | - return true; |
115 | | - })); |
| 102 | + IPanelHandler.simple(getPanel(), (mainPanel, player) -> { |
| 103 | + var panel = GTGuis.createPopupPanel("circuit_selector", 176, 120); |
| 104 | + List<List<IWidget>> options = new ArrayList<>(); |
| 105 | + for (int i = 0; i < 4; i++) { |
| 106 | + options.add(new ArrayList<>()); |
| 107 | + for (int j = 0; j < 9; j++) { |
| 108 | + int index = i * 9 + j; |
| 109 | + if (index > 32) break; |
| 110 | + options.get(i).add(new ButtonWidget<>() |
| 111 | + .size(18) |
| 112 | + .background(GTGuiTextures.SLOT, new ItemDrawable( |
| 113 | + IntCircuitIngredient.getIntegratedCircuit(index)).asIcon()) |
| 114 | + .disableHoverBackground() |
| 115 | + .onMousePressed(mouseButton -> { |
| 116 | + getSyncHandler().syncToServer(SYNC_CIRCUIT_INDEX, buf -> buf.writeShort(index)); |
| 117 | + circuitPreview.setItem(IntCircuitIngredient.getIntegratedCircuit(index)); |
| 118 | + if (Interactable.hasShiftDown()) panel.animateClose(); |
| 119 | + return true; |
| 120 | + })); |
| 121 | + } |
116 | 122 | } |
117 | | - } |
118 | | - |
119 | | - IPanelHandler.simple(getPanel(), (mainPanel, player) -> GTGuis.createPopupPanel("circuit_selector", 176, 120) |
120 | | - .child(IKey.lang("metaitem.circuit.integrated.gui").asWidget().pos(5, 5)) |
121 | | - .child(circuitPreview.asIcon().size(16).asWidget() |
122 | | - .size(18) |
123 | | - .top(19).alignX(0.5f) |
124 | | - .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)) |
125 | | - .child(new Grid() |
126 | | - .left(7).right(7).top(41).height(4 * 18) |
127 | | - .matrix(options) |
128 | | - .minColWidth(18).minRowHeight(18) |
129 | | - .minElementMargin(0, 0)), |
130 | | - true) |
131 | | - .openPanel(); |
| 123 | + return panel.child(IKey.lang("metaitem.circuit.integrated.gui").asWidget().pos(5, 5)) |
| 124 | + .child(circuitPreview.asIcon().size(16).asWidget() |
| 125 | + .size(18) |
| 126 | + .top(19).alignX(0.5f) |
| 127 | + .background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY)) |
| 128 | + .child(new Grid() |
| 129 | + .left(7).right(7).top(41).height(4 * 18) |
| 130 | + .matrix(options) |
| 131 | + .minColWidth(18).minRowHeight(18) |
| 132 | + .minElementMargin(0, 0)); |
| 133 | + }, true).openPanel(); |
132 | 134 | } |
133 | 135 |
|
134 | 136 | private static class GhostCircuitSyncHandler extends ItemSlotSH { |
|
0 commit comments