Skip to content

Commit 06d82bd

Browse files
committed
add title row back
ensure only one cover panel can be open at a time
1 parent 4ee3ba1 commit 06d82bd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/main/java/gregtech/api/cover/CoverWithUI.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ default ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncMa
7272
var panel = GTGuis.createPanel(getPickItem(), getWidth(), getHeight());
7373
var w = createUI(panel, guiSyncManager);
7474
return panel.childIf(w != null, w)
75+
.child(createTitleRow(getPickItem()).pos(5, 5))
7576
.bindPlayerInventory();
7677
}
7778

@@ -85,9 +86,11 @@ default int getHeight() {
8586

8687
default @NotNull ModularPanel getSmallGUI(@NotNull SidedPosGuiData guiData,
8788
@NotNull PanelSyncManager guiSyncManager) {
88-
var panel = GTGuis.createPopupPanel(getPickItem().getTranslationKey(), getWidth(), getHeight());
89+
var panel = GTGuis.createPopupPanel(getPickItem().getTranslationKey(), getWidth(), 100);
8990
var w = createUI(panel, guiSyncManager);
9091
return panel.childIf(w != null, w)
92+
.child(createTitleRow(getPickItem()).pos(5, 5))
93+
.paddingBottom(24)
9194
.coverChildrenHeight();
9295
}
9396

src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCrate.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.cleanroommc.modularui.factory.SidedPosGuiData;
4343
import com.cleanroommc.modularui.screen.ModularPanel;
4444
import com.cleanroommc.modularui.utils.Alignment;
45+
import com.cleanroommc.modularui.value.sync.PanelSyncHandler;
4546
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
4647
import com.cleanroommc.modularui.value.sync.SyncHandlers;
4748
import com.cleanroommc.modularui.widgets.ButtonWidget;
@@ -194,6 +195,7 @@ private Row createCoverWidgets(PosGuiData data, PanelSyncManager manager, Modula
194195
.height(24 * 3);
195196

196197
int numCovers = 0;
198+
List<PanelSyncHandler> coverPanels = new ArrayList<>();
197199
for (EnumFacing side : EnumFacing.VALUES) {
198200
if (getCoverAtSide(side) instanceof CoverWithUI cover) {
199201
if (!cover.shouldShowSmallUI()) continue;
@@ -204,9 +206,13 @@ private Row createCoverWidgets(PosGuiData data, PanelSyncManager manager, Modula
204206
// todo better key for this?
205207
var panel = manager.panel("cover at side: " + side.getName(), mainPanel,
206208
(syncManager, syncHandler) -> cover.getSmallGUI(sideData, syncManager));
209+
coverPanels.add(panel);
207210

208211
IGuiAction.MousePressed handlePanel = i -> {
209212
if (!panel.isPanelOpen()) {
213+
coverPanels.forEach(h -> {
214+
if (h.isPanelOpen()) h.closePanel();
215+
});
210216
panel.openPanel();
211217
} else {
212218
panel.closePanel();

0 commit comments

Comments
 (0)