diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java index dc61866b03..1be0d7e91e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/PatternPreviewWidget.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.gui.widget; import com.gregtechceu.gtceu.GTCEu; +import com.gregtechceu.gtceu.api.gui.GuiTextures; import com.gregtechceu.gtceu.api.machine.MultiblockMachineDefinition; import com.gregtechceu.gtceu.api.pattern.BlockPattern; import com.gregtechceu.gtceu.api.block.MetaMachineBlock; @@ -53,6 +54,7 @@ public class PatternPreviewWidget extends WidgetGroup { private static BlockPos LAST_POS = new BlockPos(0, 50, 0); private static final Map CACHE = new HashMap<>(); private final SceneWidget sceneWidget; + private final DraggableScrollableWidgetGroup scrollableWidgetGroup; public final MultiblockMachineDefinition controllerDefinition; public final MBPattern[] patterns; private final List predicates; @@ -62,17 +64,25 @@ public class PatternPreviewWidget extends WidgetGroup { private SlotWidget[] candidates; protected PatternPreviewWidget(MultiblockMachineDefinition controllerDefinition) { - super(0, 0, 176, 176); + super(0, 0, 160, 160); setClientSideWidget(); this.controllerDefinition = controllerDefinition; predicates = new ArrayList<>(); layer = -1; - addWidget(sceneWidget = new SceneWidget(3, 3, 170, 170, LEVEL) + addWidget(sceneWidget = new SceneWidget(3, 3, 150, 150, LEVEL) .setOnSelected(this::onPosSelected) .setRenderFacing(false) .setRenderFacing(false)); + scrollableWidgetGroup = new DraggableScrollableWidgetGroup(3, 132, 154, 22) + .setXScrollBarHeight(4) + .setXBarStyle(GuiTextures.SLIDER_BACKGROUND, GuiTextures.BUTTON) + .setScrollable(true) + .setDraggable(true); + scrollableWidgetGroup.setScrollYOffset(0); + addWidget(scrollableWidgetGroup); + if (ConfigHolder.INSTANCE.client.useVBO) { if (!RenderSystem.isOnRenderThread()) { RenderSystem.recordRenderCall(sceneWidget::useCacheBuffer); @@ -81,7 +91,7 @@ protected PatternPreviewWidget(MultiblockMachineDefinition controllerDefinition) } } - addWidget(new ImageWidget(3, 3, 170, 10, + addWidget(new ImageWidget(3, 3, 160, 10, new TextTexture(controllerDefinition.getDescriptionId(), -1) .setType(TextTexture.TextType.ROLL) .setWidth(170) @@ -96,13 +106,13 @@ protected PatternPreviewWidget(MultiblockMachineDefinition controllerDefinition) .toArray(MBPattern[]::new); }); - addWidget(new ButtonWidget(150, 40, 18, 18, new GuiTextureGroup( + addWidget(new ButtonWidget(138, 30, 18, 18, new GuiTextureGroup( ColorPattern.T_GRAY.rectTexture(), new TextTexture("1").setSupplier(() -> "P:" + index)), (x) -> setPage((index + 1 >= patterns.length) ? 0 : index + 1)) .setHoverBorderTexture(1, -1)); - addWidget(new ButtonWidget(150, 60, 18, 18, new GuiTextureGroup( + addWidget(new ButtonWidget(138, 50, 18, 18, new GuiTextureGroup( ColorPattern.T_GRAY.rectTexture(), new TextTexture("1").setSupplier(() -> layer >= 0 ? "L:" + layer : "ALL")), cd -> updateLayer()) @@ -167,10 +177,10 @@ public void setPage(int index) { slotWidgets = new SlotWidget[Math.min(pattern.parts.size(), 18)]; var itemHandler = new CycleItemStackHandler(pattern.parts); for (int i = 0; i < slotWidgets.length; i++) { - slotWidgets[i] = new SlotWidget(itemHandler, i, 7 + (i % 9) * 18, 173 - (((slotWidgets.length - 1) / 9 + 1) * 18) + (i / 9) * 18, false, false) + slotWidgets[i] = new SlotWidget(itemHandler, i, 4 + i * 18, 0, false, false) .setBackgroundTexture(ColorPattern.T_GRAY.rectTexture()) .setIngredientIO(IngredientIO.INPUT); - addWidget(slotWidgets[i]); + scrollableWidgetGroup.addWidget(slotWidgets[i]); } } @@ -210,10 +220,10 @@ private void onPosSelected(BlockPos pos, Direction facing) { } candidates = new SlotWidget[candidateStacks.size()]; CycleItemStackHandler itemHandler = new CycleItemStackHandler(candidateStacks); - int maxCol = (173 - (((slotWidgets.length - 1) / 9 + 1) * 18) - 35) % 18; + int maxCol = (160 - (((slotWidgets.length - 1) / 9 + 1) * 18) - 35) % 18; for (int i = 0; i < candidateStacks.size(); i++) { int finalI = i; - candidates[i] = new SlotWidget(itemHandler, i, 9 + (i / maxCol) * 18, 33 + (i % maxCol) * 18, false, false) + candidates[i] = new SlotWidget(itemHandler, i, 3 + (i / maxCol) * 18, 3 + (i % maxCol) * 18, false, false) .setIngredientIO(IngredientIO.INPUT) .setBackgroundTexture(new ColorRectTexture(0x4fffffff)) .setOnAddedTooltips((slot, list) -> list.addAll(predicateTips.get(finalI)));