Skip to content

Commit e55ce6f

Browse files
committed
improve item/fluid groups
move special machine widgets around
1 parent aa30cfa commit e55ce6f

2 files changed

Lines changed: 46 additions & 35 deletions

File tree

src/main/java/gregtech/api/metatileentity/SimpleMachineMetaTileEntity.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,6 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
525525
.child(col)
526526
.child(SlotGroupWidget.playerInventory().left(7));
527527

528-
col.child(new ItemSlot()
529-
.debugName("charger.slot")
530-
.slot(SyncHandlers.itemSlot(chargerInventory, 0))
531-
.background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY)
532-
.addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip",
533-
GTValues.VNF[getTier()], GTValues.VNF[getTier()])));
534-
535528
if (exportItems.getSlots() > 0) {
536529
col.child(new ToggleButton()
537530
.overlay(GTGuiTextures.BUTTON_ITEM_OUTPUT)
@@ -548,15 +541,24 @@ public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager)
548541
.addTooltip(false, IKey.lang("gregtech.gui.fluid_auto_output.tooltip.disabled")));
549542
}
550543

544+
col.child(new ItemSlot()
545+
.debugName("charger.slot")
546+
.slot(SyncHandlers.itemSlot(chargerInventory, 0))
547+
.background(GTGuiTextures.SLOT, GTGuiTextures.CHARGER_OVERLAY)
548+
.bottom(18 + 4)
549+
.addTooltipLine(IKey.lang("gregtech.gui.charger_slot.tooltip",
550+
GTValues.VNF[getTier()], GTValues.VNF[getTier()])));
551+
551552
col.child(new Widget<>()
552553
.size(17)
553554
.marginTop(1)
554555
.marginRight(1)
555-
.bottom(0)
556+
.top(-17 - 2)
556557
.background(GTGuiTextures.getLogo(getUITheme())));
557558

558559
if (hasGhostCircuitInventory() && circuitInventory != null) {
559560
col.child(new GhostCircuitSlotWidget()
561+
.bottom(0)
560562
.slot(SyncHandlers.itemSlot(circuitInventory, 0))
561563
.background(GTGuiTextures.SLOT, GTGuiTextures.INT_CIRCUIT_OVERLAY));
562564
}

src/main/java/gregtech/api/recipes/ui/RecipeMapUI.java

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -609,34 +609,45 @@ private boolean isSingleRow(int[] grid, int fluidCount) {
609609
return grid[1] >= fluidCount && grid[0] < 3;
610610
}
611611

612-
private Widget<?> makeItemGroup(int width, IItemHandlerModifiable handler, boolean isOutputs) {
613-
Flow col = Flow.column().mainAxisAlignment(Alignment.MainAxis.END)
614-
.coverChildren().debugName("item.col");
615-
int c = handler.getSlots();
616-
int h = (int) Math.ceil((double) c / width);
617-
SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items",
618-
width, 1, !isOutputs);
619-
for (int i = 0; i < h; i++) {
620-
Flow row = Flow.row().mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END)
621-
.coverChildren().debugName("item.row." + i);
612+
/**
613+
* @param grid [item grid width, item grid height, fluid grid width, fluid grid height]
614+
*/
615+
private Widget<?> makeItemGroup(int[] grid, IItemHandlerModifiable handler, boolean isOutputs) {
616+
Flow col = Flow.column()
617+
.mainAxisAlignment(Alignment.MainAxis.END)
618+
.coverChildren()
619+
.debugName("col:item_grid");
620+
int width = grid[0], height = grid[1];
621+
SlotGroup slotGroup = new SlotGroup(isOutputs ? "output_items" : "input_items", width, 1, !isOutputs);
622+
for (int i = 0; i < height; i++) {
623+
Flow row = Flow.row()
624+
.mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END)
625+
.coverChildren()
626+
.debugName("row:item_" + i);
622627
for (int j = 0; j < width; j++) {
623-
row.child(makeItemSlot(slotGroup, (i * h) + j, handler, isOutputs));
628+
row.child(makeItemSlot(slotGroup, (i * height) + j, handler, isOutputs));
624629
}
625630
col.child(row);
626631
}
627632
return col;
628633
}
629634

630-
private Widget<?> makeFluidGroup(int width, FluidTankList handler, boolean isOutputs) {
631-
Flow col = Flow.column().mainAxisAlignment(Alignment.MainAxis.START)
632-
.coverChildren().debugName("fluid.col");
633-
int c = handler.getTanks();
634-
int h = (int) Math.ceil((double) c / width);
635-
for (int i = 0; i < h; i++) {
636-
Flow row = Flow.row().mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END)
637-
.coverChildren().debugName("fluid.row");
635+
/**
636+
* @param grid [item grid width, item grid height, fluid grid width, fluid grid height]
637+
*/
638+
private Widget<?> makeFluidGroup(int[] grid, FluidTankList handler, boolean isOutputs) {
639+
Flow col = Flow.column()
640+
.mainAxisAlignment(Alignment.MainAxis.START)
641+
.coverChildren()
642+
.debugName("col:fluid_grid");
643+
int width = grid[2], height = grid[3];
644+
for (int i = 0; i < height; i++) {
645+
Flow row = Flow.row()
646+
.mainAxisAlignment(isOutputs ? Alignment.MainAxis.START : Alignment.MainAxis.END)
647+
.coverChildren()
648+
.debugName("row:fluid_" + i);
638649
for (int j = 0; j < width; j++) {
639-
row.child(makeFluidSlot((i * h) + j, handler, isOutputs));
650+
row.child(makeFluidSlot((i * height) + j, handler, isOutputs));
640651
}
641652
col.child(row);
642653
}
@@ -655,11 +666,9 @@ protected Widget<?> makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH
655666
}
656667

657668
int[] slotGridSizes = determineSlotsGrid(itemInputsCount, fluidInputsCount);
658-
int itemGridWidth = slotGridSizes[onlyFluids ? 2 : 0];
659669
int itemGridHeight = slotGridSizes[onlyFluids ? 3 : 1];
660-
661-
int fluidGridWidth = slotGridSizes[2];
662670
int fluidGridHeight = slotGridSizes[3];
671+
663672
boolean singleRow = isSingleRow(slotGridSizes, fluidInputsCount);
664673

665674
Flow flow = (singleRow ? Flow.row() : Flow.column())
@@ -678,11 +687,11 @@ protected Widget<?> makeInventorySlotGroup(@NotNull IItemHandlerModifiable itemH
678687
}
679688

680689
if (onlyFluids) {
681-
flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(fluidGridWidth, fluidHandler, isOutputs));
690+
flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(slotGridSizes, fluidHandler, isOutputs));
682691
} else {
683-
flow.childIf(!singleRow || isOutputs, () -> makeItemGroup(itemGridWidth, itemHandler, isOutputs));
684-
flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(fluidGridWidth, fluidHandler, isOutputs));
685-
flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(itemGridWidth, itemHandler, isOutputs));
692+
flow.childIf(!singleRow || isOutputs, () -> makeItemGroup(slotGridSizes, itemHandler, isOutputs));
693+
flow.childIf(fluidInputsCount > 0, () -> makeFluidGroup(slotGridSizes, fluidHandler, isOutputs));
694+
flow.childIf(singleRow && !isOutputs, () -> makeItemGroup(slotGridSizes, itemHandler, isOutputs));
686695
}
687696

688697
return flow;

0 commit comments

Comments
 (0)