Skip to content
31 changes: 31 additions & 0 deletions src/main/java/gregtech/api/cover/CoverWithUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gregtech.api.gui.ModularUI;
import gregtech.api.mui.GTGuiTextures;
import gregtech.api.mui.GTGuiTheme;
import gregtech.api.mui.GTGuis;
import gregtech.api.mui.GregTechGuiScreen;
import gregtech.api.mui.factory.CoverGuiFactory;

Expand All @@ -17,6 +18,7 @@
import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.api.drawable.IDrawable;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.api.widget.IWidget;
import com.cleanroommc.modularui.drawable.ItemDrawable;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
Expand All @@ -32,6 +34,8 @@
import com.cleanroommc.modularui.widgets.ToggleButton;
import com.cleanroommc.modularui.widgets.layout.Flow;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder<SidedPosGuiData> {

Expand Down Expand Up @@ -66,9 +70,36 @@ default GTGuiTheme getUITheme() {

@Override
default ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
var w = createUI(guiData, guiSyncManager);
return confgurePanel(GTGuis.defaultPanel(getPickItem()), false)
.childIf(w != null, w)
.child(createTitleRow(getPickItem()).pos(5, 5))
.bindPlayerInventory();
}

default ModularPanel confgurePanel(ModularPanel panel, boolean isSmallGui) {
return panel;
}

default @NotNull ModularPanel getSmallGUI(@NotNull SidedPosGuiData guiData,
@NotNull PanelSyncManager guiSyncManager) {
var w = createUI(guiData, guiSyncManager);
return confgurePanel(GTGuis.defaultPopupPanel(getPickItem().getTranslationKey()), true)
.coverChildrenHeight()
.paddingBottom(16)
.childIf(w != null, w)
.child(createTitleRow(getPickItem()).pos(5, 5));
}

default @Nullable IWidget createUI(SidedPosGuiData data, PanelSyncManager manager) {
return null;
}

default boolean shouldShowSmallUI() {
// Check buildUI is not null?
return usesMui2();
}

@Override
default boolean isValid() {
return getCoverableView().isValid();
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/gregtech/common/covers/CoverConveyor.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import gregtech.api.cover.CoverWithUI;
import gregtech.api.cover.CoverableView;
import gregtech.api.mui.GTGuiTextures;
import gregtech.api.mui.GTGuis;
import gregtech.api.util.GTTransferUtils;
import gregtech.api.util.ItemStackHashStrategy;
import gregtech.client.renderer.texture.Textures;
Expand Down Expand Up @@ -44,7 +43,6 @@
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IDrawable;
import com.cleanroommc.modularui.drawable.DynamicDrawable;
import com.cleanroommc.modularui.factory.GuiData;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Color;
Expand Down Expand Up @@ -503,17 +501,13 @@ public boolean usesMui2() {
}

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
var panel = GTGuis.createPanel(this, 176, 192 + 18);
public ModularPanel confgurePanel(ModularPanel panel, boolean isSmallGui) {
return panel.height(210);
}

public @NotNull ParentWidget<?> createUI(SidedPosGuiData data, PanelSyncManager guiSyncManager) {
getItemFilterContainer().setMaxTransferSize(getMaxStackSize());

return panel.child(CoverWithUI.createTitleRow(getPickItem()))
.child(createUI(guiData, guiSyncManager))
.bindPlayerInventory();
}

protected ParentWidget<Flow> createUI(GuiData data, PanelSyncManager guiSyncManager) {
var column = Flow.column().top(24).margin(7, 0)
.widthRel(1f).coverChildrenHeight();

Expand Down
70 changes: 38 additions & 32 deletions src/main/java/gregtech/common/covers/CoverFluidFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.api.widget.IWidget;
import com.cleanroommc.modularui.drawable.Rectangle;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
Expand Down Expand Up @@ -145,44 +146,49 @@ public boolean usesMui2() {

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
var filteringMode = new EnumSyncValue<>(FluidFilterMode.class, this::getFilterMode, this::setFilterMode);

guiSyncManager.syncValue("filtering_mode", filteringMode);
this.fluidFilterContainer.setMaxTransferSize(1);

return getFilter().createPanel(guiSyncManager)
.size(176, 212).padding(7)
.child(CoverWithUI.createTitleRow(getFilterContainer().getFilterStack()))
.child(Flow.column().widthRel(1f).align(Alignment.TopLeft).top(22).coverChildrenHeight()
.child(new EnumRowBuilder<>(FluidFilterMode.class)
.value(filteringMode)
.lang("cover.filter.mode.title")
.overlay(16, GTGuiTextures.FILTER_MODE_OVERLAY)
.build())
.child(Flow.row()
.marginBottom(2)
.widthRel(1f)
.coverChildrenHeight()
.setEnabledIf(b -> getFilterMode() != FluidFilterMode.FILTER_BOTH)
.child(new ToggleButton()
.overlay(IKey.dynamic(() -> IKey.lang(allowFlow ?
"cover.generic.enabled" :
"cover.generic.disabled").get())
.color(Color.WHITE.main).shadow(false))
.tooltip(tooltip -> tooltip
.addLine(IKey.lang("cover.filter.allow_flow.tooltip")))
.size(72, 18)
.value(new BooleanSyncValue(() -> allowFlow, b -> allowFlow = b)))
.child(IKey.lang("cover.filter.allow_flow.label")
.asWidget()
.height(18)
.alignX(1f)))
.child(new Rectangle().setColor(UI_TEXT_COLOR).asWidget()
.height(1).widthRel(0.95f).margin(0, 4))
.child(getFilter().createWidgets(guiSyncManager)))
.child(createUI(guiData, guiSyncManager))
.child(SlotGroupWidget.playerInventory().bottom(7).left(7));
}

@Override
public @Nullable IWidget createUI(SidedPosGuiData data, PanelSyncManager manager) {
var filteringMode = new EnumSyncValue<>(FluidFilterMode.class, this::getFilterMode, this::setFilterMode);

manager.syncValue("filtering_mode", filteringMode);
this.fluidFilterContainer.setMaxTransferSize(1);

return Flow.column().widthRel(1f).align(Alignment.TopLeft).top(22).coverChildrenHeight()
.child(new EnumRowBuilder<>(FluidFilterMode.class)
.value(filteringMode)
.lang("cover.filter.mode.title")
.overlay(16, GTGuiTextures.FILTER_MODE_OVERLAY)
.build())
.child(Flow.row()
.marginBottom(2)
.widthRel(1f)
.coverChildrenHeight()
.setEnabledIf(b -> getFilterMode() != FluidFilterMode.FILTER_BOTH)
.child(new ToggleButton()
.overlay(IKey.dynamic(() -> IKey.lang(allowFlow ?
"cover.generic.enabled" :
"cover.generic.disabled").get())
.color(Color.WHITE.main).shadow(false))
.tooltip(tooltip -> tooltip
.addLine(IKey.lang("cover.filter.allow_flow.tooltip")))
.size(72, 18)
.value(new BooleanSyncValue(() -> allowFlow, b -> allowFlow = b)))
.child(IKey.lang("cover.filter.allow_flow.label")
.asWidget()
.height(18)
.alignX(1f)))
.child(new Rectangle().setColor(UI_TEXT_COLOR).asWidget()
.height(1).widthRel(0.95f).margin(0, 4))
.child(getFilter().createWidgets(manager));
}

@Override
public void renderCover(@NotNull CCRenderState renderState, @NotNull Matrix4 translation,
IVertexOperation[] pipeline, @NotNull Cuboid6 plateBox, @NotNull BlockRenderLayer layer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.minecraftforge.fml.relauncher.SideOnly;

import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.factory.GuiData;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Color;
Expand Down Expand Up @@ -243,12 +242,12 @@ private boolean shouldDisplayAmountSlider() {
}

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
return super.buildUI(guiData, guiSyncManager).height(192 + 36);
public ModularPanel confgurePanel(ModularPanel panel, boolean isSmallGui) {
return panel.height(228);
}

@Override
protected ParentWidget<?> createUI(GuiData data, PanelSyncManager syncManager) {
public @NotNull ParentWidget<?> createUI(SidedPosGuiData data, PanelSyncManager syncManager) {
var transferMode = new EnumSyncValue<>(TransferMode.class, this::getTransferMode, this::setTransferMode);
transferMode.updateCacheFromSource(true);
syncManager.syncValue("transfer_mode", transferMode);
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/gregtech/common/covers/CoverFluidVoiding.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.factory.GuiData;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Color;
Expand Down Expand Up @@ -72,12 +71,12 @@ public void renderCover(@NotNull CCRenderState renderState, @NotNull Matrix4 tra
}

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
return super.buildUI(guiData, guiSyncManager).height(192 - 22);
public ModularPanel confgurePanel(ModularPanel panel, boolean isSmallGui) {
return panel.height(170);
}

@Override
protected ParentWidget<?> createUI(GuiData data, PanelSyncManager syncManager) {
public @NotNull ParentWidget<?> createUI(SidedPosGuiData data, PanelSyncManager syncManager) {
var isWorking = new BooleanSyncValue(this::isWorkingEnabled, this::setWorkingEnabled);

return super.createUI(data, syncManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.factory.GuiData;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Color;
Expand Down Expand Up @@ -101,12 +100,13 @@ public VoidingMode getVoidingMode() {
}

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
return super.buildUI(guiData, guiSyncManager).height(192 + 20);
public ModularPanel confgurePanel(ModularPanel panel, boolean isSmallGui) {
return super.confgurePanel(panel, isSmallGui)
.height(212);
}

@Override
protected ParentWidget<?> createUI(GuiData data, PanelSyncManager syncManager) {
public @NotNull ParentWidget<?> createUI(SidedPosGuiData data, PanelSyncManager syncManager) {
var voidingMode = new EnumSyncValue<>(VoidingMode.class, this::getVoidingMode, this::setVoidingMode);
syncManager.syncValue("voiding_mode", voidingMode);

Expand Down
78 changes: 44 additions & 34 deletions src/main/java/gregtech/common/covers/CoverItemFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.api.widget.IWidget;
import com.cleanroommc.modularui.drawable.Rectangle;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Alignment;
import com.cleanroommc.modularui.utils.Color;
import com.cleanroommc.modularui.value.sync.BooleanSyncValue;
import com.cleanroommc.modularui.value.sync.EnumSyncValue;
Expand Down Expand Up @@ -148,41 +148,51 @@ public boolean usesMui2() {

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
var filteringMode = new EnumSyncValue<>(ItemFilterMode.class, this::getFilterMode, this::setFilterMode);

guiSyncManager.syncValue("filtering_mode", filteringMode);

return getFilter().createPanel(guiSyncManager)
.size(176, 212).padding(7)
.size(176, 212)
.child(CoverWithUI.createTitleRow(getFilterContainer().getFilterStack()).left(4))
.child(Flow.column().widthRel(1f).align(Alignment.TopLeft).top(22).coverChildrenHeight()
.child(new EnumRowBuilder<>(ItemFilterMode.class)
.value(filteringMode)
.lang("cover.filter.mode.title")
.overlay(16, GTGuiTextures.FILTER_MODE_OVERLAY)
.build())
.child(Flow.row()
.marginBottom(2)
.widthRel(1f)
.coverChildrenHeight()
.setEnabledIf(b -> getFilterMode() != ItemFilterMode.FILTER_BOTH)
.child(new ToggleButton()
.overlay(IKey.dynamic(() -> IKey.lang(allowFlow ?
"cover.generic.enabled" :
"cover.generic.disabled").get())
.color(Color.WHITE.main).shadow(false))
.tooltip(tooltip -> tooltip
.addLine(IKey.lang("cover.filter.allow_flow.tooltip")))
.size(72, 18)
.value(new BooleanSyncValue(() -> allowFlow, b -> allowFlow = b)))
.child(IKey.lang("cover.filter.allow_flow.label")
.asWidget()
.height(18)
.alignX(1f)))
.child(new Rectangle().setColor(UI_TEXT_COLOR).asWidget()
.height(1).widthRel(0.95f).margin(0, 4))
.child(getFilter().createWidgets(guiSyncManager).left(0)))
.child(SlotGroupWidget.playerInventory().bottom(7).left(7));
.child(createUI(guiData, guiSyncManager))
.child(SlotGroupWidget.playerInventory().left(7));
}

@Override
public @Nullable IWidget createUI(SidedPosGuiData data, PanelSyncManager manager) {
var filteringMode = new EnumSyncValue<>(ItemFilterMode.class, this::getFilterMode, this::setFilterMode);

manager.syncValue("filtering_mode", filteringMode);

return Flow.column()
.widthRel(1f)
// .align(Alignment.TopLeft)
.margin(7, 0)
.top(22)
.coverChildrenHeight()
.child(new EnumRowBuilder<>(ItemFilterMode.class)
.value(filteringMode)
.lang("cover.filter.mode.title")
.overlay(16, GTGuiTextures.FILTER_MODE_OVERLAY)
.build())
.child(Flow.row()
.marginBottom(2)
.widthRel(1f)
.coverChildrenHeight()
.setEnabledIf(b -> getFilterMode() != ItemFilterMode.FILTER_BOTH)
.child(new ToggleButton()
.overlay(IKey.dynamic(() -> IKey.lang(allowFlow ?
"cover.generic.enabled" :
"cover.generic.disabled").get())
.color(Color.WHITE.main).shadow(false))
.tooltip(tooltip -> tooltip
.addLine(IKey.lang("cover.filter.allow_flow.tooltip")))
.size(72, 18)
.value(new BooleanSyncValue(() -> allowFlow, b -> allowFlow = b)))
.child(IKey.lang("cover.filter.allow_flow.label")
.asWidget()
.height(18)
.alignX(1f)))
.child(new Rectangle().setColor(UI_TEXT_COLOR).asWidget()
.height(1).widthRel(0.95f).margin(0, 4))
.child(getFilter().createWidgets(manager).left(0));
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gregtech/common/covers/CoverItemVoiding.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.factory.GuiData;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Color;
Expand Down Expand Up @@ -73,12 +72,13 @@ void voidAny(IItemHandler myItemHandler) {
}

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager) {
return super.buildUI(guiData, guiSyncManager).height(192 - 22);
public ModularPanel confgurePanel(ModularPanel panel, boolean isSmallGui) {
return super.confgurePanel(panel, isSmallGui)
.height(170);
}

@Override
protected ParentWidget<Flow> createUI(GuiData data, PanelSyncManager guiSyncManager) {
public @NotNull ParentWidget<?> createUI(SidedPosGuiData data, PanelSyncManager guiSyncManager) {
var isWorking = new BooleanSyncValue(this::isWorkingEnabled, this::setWorkingEnabled);

return super.createUI(data, guiSyncManager)
Expand Down
Loading
Loading