From 914671c0dd72c314aa8882837d6db6297cbe3d64 Mon Sep 17 00:00:00 2001 From: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:53:55 +0300 Subject: [PATCH] sketch gui - fix conflict --- src/main/java/gregtech/api/gui/GUIHost.java | 5 +- .../interfaces/IMultiBlockController.java | 4 - .../machine/MultiTileBasicMachine.java | 8 +- .../multiblock/base/Controller.java | 45 ++----- .../multiblock/base/MultiBlockPart.java | 8 +- .../ComplexParallelMachineGUIProvider.java | 2 +- .../common/gui/MachineGUIProvider.java | 125 ++++++++++++------ .../gregtech/common/gui/PartGUIProvider.java | 5 +- .../multiblock/AdvChemicalProcessor.java | 1 - 9 files changed, 114 insertions(+), 89 deletions(-) diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java index 9d63151ebd6..bbb94317c47 100644 --- a/src/main/java/gregtech/api/gui/GUIHost.java +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -4,13 +4,12 @@ import javax.annotation.Nonnull; -import com.gtnewhorizons.modularui.api.math.Size; +import net.minecraft.item.ItemStack; + import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import net.minecraft.item.ItemStack; - public interface GUIHost extends ITileWithModularUI { @Nonnull diff --git a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java index 4423b32d181..71052b0a586 100644 --- a/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java +++ b/src/main/java/gregtech/api/multitileentity/interfaces/IMultiBlockController.java @@ -8,12 +8,8 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraftforge.common.util.ForgeDirection; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; - import gregtech.api.enums.InventoryType; import gregtech.api.gui.GUIHost; -import gregtech.api.gui.GUIProvider; import gregtech.api.logic.FluidInventoryLogic; import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.logic.interfaces.FluidInventoryLogicHost; diff --git a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java index 4dc3e8fef9e..6442d296628 100644 --- a/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java +++ b/src/main/java/gregtech/api/multitileentity/machine/MultiTileBasicMachine.java @@ -53,8 +53,8 @@ import gregtech.client.GT_SoundLoop; import gregtech.common.gui.MachineGUIProvider; -public abstract class MultiTileBasicMachine

> - extends TickableMultiTileEntity implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost, GUIHost { +public abstract class MultiTileBasicMachine

> extends TickableMultiTileEntity + implements IMultiTileMachine, ProcessingLogicHost

, PowerLogicHost, GUIHost { protected static final int ACTIVE = B[0]; protected static final int TICKS_BETWEEN_RECIPE_CHECKS = 5 * TickTime.SECOND; @@ -792,7 +792,8 @@ public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { @Override public ItemStack getAsItem() { - return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()).getItem(getMultiTileEntityID()); + return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()) + .getItem(getMultiTileEntityID()); } @Override @@ -800,5 +801,4 @@ public String getMachineName() { return StatCollector.translateToLocal(getAsItem().getUnlocalizedName()); } - } diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java index cbec71b839b..42c4b9cbfe7 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/Controller.java @@ -43,30 +43,20 @@ import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.util.Vec3Impl; -import com.gtnewhorizons.modularui.api.ModularUITextures; -import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; -import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.*; -import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; -import com.gtnewhorizons.modularui.api.widget.Widget; -import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; -import com.gtnewhorizons.modularui.common.widget.TabButton; -import com.gtnewhorizons.modularui.common.widget.TabContainer; import cpw.mods.fml.common.network.NetworkRegistry; import gregtech.api.enums.GT_Values.NBT; import gregtech.api.enums.InventoryType; import gregtech.api.enums.VoidingMode; -import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.IDescribable; import gregtech.api.interfaces.fluid.IFluidStore; -import gregtech.api.interfaces.modularui.ControllerWithOptionalFeatures; import gregtech.api.logic.ControllerFluidLogic; import gregtech.api.logic.ControllerItemLogic; import gregtech.api.logic.FluidInventoryLogic; import gregtech.api.logic.ItemInventoryLogic; import gregtech.api.logic.MuTEProcessingLogic; +import gregtech.api.logic.PowerLogic; import gregtech.api.multitileentity.enums.MultiTileCasingPurpose; import gregtech.api.multitileentity.interfaces.IMultiBlockController; import gregtech.api.multitileentity.interfaces.IMultiBlockPart; @@ -77,10 +67,8 @@ import gregtech.api.net.GT_Packet_MultiTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.GT_Waila; -import gregtech.common.tileentities.casings.upgrade.Inventory; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -88,8 +76,8 @@ * Multi Tile Entities - or MuTEs - don't have dedicated hatches, but their casings can become hatches. */ public abstract class Controller, P extends MuTEProcessingLogic

> - extends MultiTileBasicMachine

implements IAlignment, IMultiBlockController, IDescribable, - IMTE_AddToolTips, ISurvivalConstructable { + extends MultiTileBasicMachine

+ implements IAlignment, IMultiBlockController, IDescribable, IMTE_AddToolTips, ISurvivalConstructable { public static final String ALL_INVENTORIES_NAME = "all"; protected static final int AUTO_OUTPUT_FREQUENCY_TICK = 20; @@ -867,6 +855,15 @@ public void changeItemInventoryDisplayName(@Nullable UUID id, @Nullable String d // #endregion Item + // #region Energy + + @Override + public PowerLogic getPowerLogic() { + return getPowerLogic(ForgeDirection.UNKNOWN); + } + + // #endregion Energy + @Override protected void updateSlots() { controllerItemInput.getAllInventoryLogics() @@ -887,24 +884,6 @@ public boolean useModularUI() { return true; } - @Override - public ModularWindow createWindow(UIBuildContext buildContext) { - System.out.println("MultiBlockController::createWindow"); - if (!useModularUI()) return null; - - buildContext.setValidator(getValidator()); - final ModularWindow.Builder builder = ModularWindow.builder(getGUIWidth(), getGUIHeight()); - builder.setBackground(getGUITextureSet().getMainBackground()); - builder.setGuiTint(getGUIColorization()); - if (doesBindPlayerInventory()) { - bindPlayerInventoryUI(builder, buildContext); - } - addUIWidgets(builder, buildContext); - addTitleToUI(builder); - addCoverTabs(builder, buildContext); - return builder.build(); - } - @Override public boolean hasGui(ForgeDirection side) { return true; diff --git a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java index e352bf15ea0..d970f2b631c 100644 --- a/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java +++ b/src/main/java/gregtech/api/multitileentity/multiblock/base/MultiBlockPart.java @@ -27,7 +27,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.common.widget.*; @@ -699,14 +698,16 @@ public GUIProvider getGUI(@Nonnull UIBuildContext uiContext) { if (controller == null) return guiProvider; if (!modeSelected(NOTHING, ENERGY_IN, ENERGY_OUT)) return guiProvider; if (!canOpenControllerGui()) return guiProvider; - if (uiContext.getPlayer().isSneaking()) return guiProvider; + if (uiContext.getPlayer() + .isSneaking()) return guiProvider; GUIProvider controllerGUI = controller.getGUI(uiContext); return controllerGUI; } @Override public ItemStack getAsItem() { - return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()).getItem(getMultiTileEntityID()); + return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()) + .getItem(getMultiTileEntityID()); } @Override @@ -714,5 +715,4 @@ public String getMachineName() { return StatCollector.translateToLocal(getAsItem().getUnlocalizedName()); } - } diff --git a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java index f28b0c997c6..89b42c8500f 100644 --- a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java +++ b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java @@ -19,7 +19,7 @@ public class ComplexParallelMachineGUIProvider { private static final int LOGO_SIZE = 17; + @Nonnull protected static final Pos2d POWER_SWITCH_BUTTON_DEFAULT_POS = new Pos2d(144, 0); + @Nonnull protected static final Pos2d VOIDING_MODE_BUTTON_DEFAULT_POS = new Pos2d(54, 0); + @Nonnull protected static final Pos2d INPUT_SEPARATION_BUTTON_DEFAULT_POS = new Pos2d(36, 0); + @Nonnull protected static final Pos2d BATCH_MODE_BUTTON_DEFAULT_POS = new Pos2d(18, 0); + @Nonnull protected static final Pos2d RECIPE_LOCKING_BUTTON_DEFAULT_POS = new Pos2d(0, 0); public MachineGUIProvider(@Nonnull T host) { @@ -58,12 +65,13 @@ public MachineGUIProvider(@Nonnull T host) { @Override protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { - + } @Override protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { int page = 0; + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); MultiChildWidget mainTab = new MultiChildWidget(); mainTab.setSize(host.getWidth(), host.getHeight()); createMainTab(mainTab, builder, uiContext); @@ -101,9 +109,7 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Item Input Inventory") .setPos(20 * (page - 1), -20)) - .addPage( - itemInputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(itemInputTab.addChild(getLogo().setPos(147, 86))); } if (host.hasItemOutput()) { @@ -124,9 +130,7 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Item Output Inventory") .setPos(20 * (page - 1), -20)) - .addPage( - itemOutputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(itemOutputTab.addChild(getLogo().setPos(147, 86))); } if (host.hasFluidInput()) { @@ -147,9 +151,7 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Fluid Input Tanks") .setPos(20 * (page - 1), -20)) - .addPage( - fluidInputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(fluidInputTab.addChild(getLogo().setPos(147, 86))); } if (host.hasFluidOutput()) { @@ -170,14 +172,31 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo .withOffset(2, 4)) .addTooltip("Fluid Output Tanks") .setPos(20 * (page - 1), -20)) - .addPage( - fluidOutputTab - .addChild(getLogo().setPos(147, 86))); + .addPage(fluidOutputTab.addChild(getLogo().setPos(147, 86))); } + MultiChildWidget powerInfoTab = new MultiChildWidget(); + powerInfoTab.setSize(host.getWidth(), host.getHeight()); + createPowerTab(powerInfoTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Power Information") + .setPos(20 * (page - 1), -20)) + .addPage(powerInfoTab.addChild(getLogo().setPos(147, 86))); builder.widget(tabs); } - protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { + protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { MultiChildWidget buttons = new MultiChildWidget(); buttons.setSize(16, 167) .setPos(7, 86); @@ -193,34 +212,61 @@ protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder bui .addChild(buttons); } - protected void createItemInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createItemInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getItemLogic(InventoryType.Input, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createItemOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createItemOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getItemLogic(InventoryType.Output, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createFluidInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createFluidInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getFluidLogic(InventoryType.Input, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createFluidOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createFluidOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getFluidLogic(InventoryType.Output, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); } - protected void createPowerTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, @Nonnull UIBuildContext uiBuildContext) { - + protected void createPowerTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + PowerLogic power = host.getPowerLogic(); + tab.addChild( + TextWidget.dynamicString(() -> power.getStoredEnergy() + "/" + power.getCapacity() + " EU") + .setPos(10, 30)) + .addChild( + TextWidget.dynamicString(() -> power.getVoltage() + " EU/t" + "(" + power.getMaxAmperage() + " A)") + .setPos(10, 60)); } - /** * Should return the logo you want to use that is pasted on each tab. Default is the GT logo. */ @Nonnull protected Widget getLogo() { DrawableWidget logo = new DrawableWidget(); - logo.setDrawable(GUITextureSet.DEFAULT.getGregTechLogo()).setSize(LOGO_SIZE, LOGO_SIZE); + logo.setDrawable(GUITextureSet.DEFAULT.getGregTechLogo()) + .setSize(LOGO_SIZE, LOGO_SIZE); return logo; } @@ -269,8 +315,12 @@ protected ButtonWidget createVoidExcessButton(IWidgetBuilder builder) { if (host.supportsVoidProtection()) { Set allowed = host.getAllowedVoidingModes(); switch (clickData.mouseButton) { - case 0 -> host.setVoidingMode(host.getVoidingMode().nextInCollection(allowed)); - case 1 -> host.setVoidingMode(host.getVoidingMode().previousInCollection(allowed)); + case 0 -> host.setVoidingMode( + host.getVoidingMode() + .nextInCollection(allowed)); + case 1 -> host.setVoidingMode( + host.getVoidingMode() + .previousInCollection(allowed)); } widget.notifyTooltipChange(); } @@ -287,13 +337,16 @@ protected ButtonWidget createVoidExcessButton(IWidgetBuilder builder) { }) .attachSyncer( new FakeSyncWidget.IntegerSyncer( - () -> host.getVoidingMode().ordinal(), + () -> host.getVoidingMode() + .ordinal(), val -> host.setVoidingMode(VoidingMode.fromOrdinal(val))), builder) .dynamicTooltip( () -> Arrays.asList( StatCollector.translateToLocal("GT5U.gui.button.voiding_mode"), - StatCollector.translateToLocal(host.getVoidingMode().getTransKey()))) + StatCollector.translateToLocal( + host.getVoidingMode() + .getTransKey()))) .setTooltipShowUpDelay(TOOLTIP_DELAY) .setPos(getVoidingModeButtonPos()) .setSize(16, 16); @@ -338,9 +391,7 @@ protected ButtonWidget createInputSeparationButton(IWidgetBuilder builder) { } return ret.toArray(new IDrawable[0]); }) - .attachSyncer( - new FakeSyncWidget.BooleanSyncer(host::isInputSeparated, host::setInputSeparation), - builder) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isInputSeparated, host::setInputSeparation), builder) .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.input_separation")) .setTooltipShowUpDelay(TOOLTIP_DELAY) .setPos(getInputSeparationButtonPos()) diff --git a/src/main/java/gregtech/common/gui/PartGUIProvider.java b/src/main/java/gregtech/common/gui/PartGUIProvider.java index d71e7c05559..7600444f712 100644 --- a/src/main/java/gregtech/common/gui/PartGUIProvider.java +++ b/src/main/java/gregtech/common/gui/PartGUIProvider.java @@ -11,7 +11,8 @@ import gregtech.api.logic.interfaces.ItemInventoryLogicHost; import gregtech.api.logic.interfaces.PowerLogicHost; -public class PartGUIProvider extends GUIProvider { +public class PartGUIProvider + extends GUIProvider { public PartGUIProvider(@Nonnull T host) { super(host); @@ -28,5 +29,5 @@ protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiCo // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'addWidgets'"); } - + } diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java index 55ccb78928d..a253f6ac1ea 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java @@ -50,7 +50,6 @@ import gregtech.api.multitileentity.multiblock.base.ComplexParallelController; import gregtech.api.multitileentity.multiblock.casing.Glasses; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_StructureUtility; import gregtech.api.util.GT_StructureUtilityMuTE; import gregtech.common.tileentities.machines.multiblock.logic.AdvChemicalProcessorProcessingLogic;