Skip to content

Commit 01be8ca

Browse files
committed
use progress value directly in widget
fix special texture use GTFluidSlot instead of FluidSlot use IDrawable.of() for slot overlays
1 parent c064d58 commit 01be8ca

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ protected void renderOverlays(CCRenderState renderState, Matrix4 translation, IV
128128
workable.isWorkingEnabled());
129129
}
130130

131+
// todo mui2 check
132+
131133
@Override
132134
protected ModularUI createUI(EntityPlayer entityPlayer) {
133135
return createGuiTemplate(entityPlayer).build(getHolder(), entityPlayer);

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import gregtech.api.mui.widget.RecipeProgressWidget;
1111
import gregtech.api.recipes.Recipe;
1212
import gregtech.api.recipes.RecipeMap;
13+
import gregtech.common.mui.widget.GTFluidSlot;
1314

1415
import net.minecraftforge.items.IItemHandlerModifiable;
1516

@@ -19,9 +20,7 @@
1920
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
2021
import com.cleanroommc.modularui.value.sync.SyncHandlers;
2122
import com.cleanroommc.modularui.widget.ParentWidget;
22-
import com.cleanroommc.modularui.widget.Widget;
2323
import com.cleanroommc.modularui.widget.sizer.Area;
24-
import com.cleanroommc.modularui.widgets.FluidSlot;
2524
import com.cleanroommc.modularui.widgets.ItemSlot;
2625
import com.cleanroommc.modularui.widgets.ProgressWidget;
2726
import com.cleanroommc.modularui.widgets.slot.SlotGroup;
@@ -522,22 +521,22 @@ public ParentWidget<?> buildWidget(DoubleSupplier progressSupplier, IItemHandler
522521
IItemHandlerModifiable exportItems, FluidTankList importFluids,
523522
FluidTankList exportFluids, int yOffset, PanelSyncManager syncManager) {
524523
DoubleSyncValue progressValue = new DoubleSyncValue(progressSupplier);
525-
syncManager.syncValue("recipe_progress", progressValue);
526524

527525
ParentWidget<?> group = new ParentWidget<>().size(176, 166 + yOffset);
528526
group.child(new RecipeProgressWidget()
529527
.recipeMap(recipeMap)
530528
.size(20)
531529
.alignX(0.5f).top(23 + yOffset)
532-
.progress(progressValue::getDoubleValue)
530+
.value(progressValue)
533531
.texture(progressTexture, 20)
534532
.direction(progressDirection));
535533
addInventorySlotGroup(group, importItems, importFluids, false, yOffset);
536534
addInventorySlotGroup(group, exportItems, exportFluids, true, yOffset);
537535
if (specialTextureNew != null) {
538-
group.child(new Widget<>()
539-
.flex(flex -> flex.getArea().set(specialTexturePosition))
540-
.background(specialTextureNew));
536+
group.child(specialTextureNew.asWidget()
537+
.debugName("special_texture")
538+
.pos(specialTexturePosition.x(), specialTexturePosition.y())
539+
.size(specialTexturePosition.w(), specialTexturePosition.h()));
541540
}
542541
return group;
543542
}
@@ -616,23 +615,23 @@ protected ItemSlot makeItemSlot(SlotGroup group, int x, int y, int slotIndex, II
616615
.background(getOverlaysForSlotNew(isOutputs, false, slotIndex == itemHandler.getSlots() - 1));
617616
}
618617

619-
protected FluidSlot makeFluidSlot(int x, int y, int slotIndex, FluidTankList fluidHandler, boolean isOutputs) {
620-
return new FluidSlot()
621-
.syncHandler(SyncHandlers.fluidSlot(fluidHandler.getTankAt(slotIndex))
622-
.canFillSlot(!isOutputs))
623-
.alwaysShowFull(true)
618+
protected GTFluidSlot makeFluidSlot(int x, int y, int slotIndex, FluidTankList fluidHandler, boolean isOutputs) {
619+
return new GTFluidSlot()
620+
.syncHandler(GTFluidSlot.sync(fluidHandler.getTankAt(slotIndex))
621+
.accessibility(true, !isOutputs))
622+
// todo show always full, should be implemented with mui2 multis
624623
.pos(x, y)
625624
.background(getOverlaysForSlotNew(isOutputs, true, slotIndex == fluidHandler.getTanks() - 1));
626625
}
627626

628627
@ApiStatus.Experimental
629-
protected IDrawable[] getOverlaysForSlotNew(boolean isOutput, boolean isFluid, boolean isLast) {
628+
protected IDrawable getOverlaysForSlotNew(boolean isOutput, boolean isFluid, boolean isLast) {
630629
UITexture base = isFluid ? GTGuiTextures.FLUID_SLOT : GTGuiTextures.SLOT;
631630
byte overlayKey = computeOverlayKey(isOutput, isFluid, isLast);
632631
if (slotTextureOverlays.containsKey(overlayKey)) {
633-
return new UITexture[] { base, slotTextureOverlays.get(overlayKey) };
632+
return IDrawable.of(base, slotTextureOverlays.get(overlayKey));
634633
}
635-
return new UITexture[] { base };
634+
return IDrawable.of(base);
636635
}
637636

638637
/** Marked experimental as this method will be removed when all GTCEu UIs are ported to MUI2. */

0 commit comments

Comments
 (0)