diff options
| author | miozune <miozune@gmail.com> | 2022-11-26 01:45:28 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-25 17:45:28 +0100 |
| commit | 9a2741128a78bb52eba50a631126e090a5a2abd8 (patch) | |
| tree | a90f47aa94951acb4050e45dc3ed60698e79cf32 /src/main/java/gregtech/api/metatileentity/implementations | |
| parent | 51537482fefc4f9c6d3fbd93d119c333a63dcd7b (diff) | |
| download | GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.tar.gz GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.tar.bz2 GT5-Unofficial-9a2741128a78bb52eba50a631126e090a5a2abd8.zip | |
Rewrite GUIs with ModularUI (#1381)
* Base work for ModularUI compat
* Remove useless interface
* Add almost all the widgets
* Invert method
* Refactor NEI stack placement positions
* NEI handlers on ModularUI
* Add some more docs
* AdvDebugStructureWriter
* Fix NEI progressbar not working
* PrimitiveBlastFurnace
* clean
* derp
* clean
* spotlessApply
* Boilers
* Buffers
* clean
* N by N slots containers
* Fix boilers not having bucket interaction
Put opening UI to individual MetaTEs
* Maintenance Hatch
* clean
* spotlessApply
* Add dependency
* IndustrialApiary
* Adapt to ModularUI change
* Base work for covers & fix crash with MP
* Fix crash with server
* Rewrite base work for covers
* Send initial cover data on cover GUI open
so that the time of showing incorrect data will be eliminated
* Covers part 1
* Rename package: ModularUI -> modularui
* Rename class: GT_UIInfo -> GT_UIInfos
* Fix build
* Covers part2
* Fix missing client check with tile UI & fix title overlap
* CoverTabLine
* Move cover window creators to inner class
* Fix crash with null base TE
* Close GUI when tile is broken
* Color cover window with tile colorization
* Change signature of addUIWidgets
* FluidFilter cover, FluidDisplaySlotWidget, BasicTank, BasicGenerator, Output Hatch, MicrowaveEnergyTransmitter, Teleporter, DigitalChest, DigitalTank
* Add title tab
* Move package: modularui -> modularui/widget
* Programmed circuit + IConfigurationCircuitSupport
* clean
* VolumetricFlask
* Remove integrated circuit overlay from recipe input slots
* Input Hatch & Quadruple Input Hatch
* Multiblock
* Deprecate old cover GUI
* BasicMachines
* Finish BasicMachine & NEI
* Expand DTPF NEI to 9 slots
* Fix ME input bus on MP
* Move AESlotWidget to public class
* Move GT_Recipe_Map constructors with mNEIUnificateOutput to setter method
* Move SteamTexture.Variant to outer enum
* Switch to remote repository
* oops
* Update MUI
* Update MUI
* Minor refactor for change amount buttons
* Display items and fluids that exceed usual count
* blah
* use +=, why didn't I do this
* Update MUI
* Move ModularUI to Base (#1510)
* Move ModularUI to Base
* Move most of the ModularUI functionality to `BaseTileEntity` (and `CoverableTileEntity`)
* `CommonMetaTileEntity` delegates ato the MetaTileEntity
* Added several interfaces (with defaults) to indicate if a tile/metatile override/implement certain behaviors.
* Moved `IConfigurationCircuitSupport` interface such that it will work with BaseTileEntity or a MetaTileEntity
* Address reviews
Co-authored-by: miozune <miozune@gmail.com>
* Update MUI
* Minor changes to NEI
* Return :facepalm:
* IGetTabIconSet override
* Some more changes to NEI
* Merge texture getter interfaces to new class GUITextureSet
* Remove BBF structure picture as it's auto-buildable now
* Make unified title tab style of texture angular
* Expose some boiler texture getters for addon
* Fix crash with cover GUI on pipe
* Lower the number of recipe per page for DTPF & update MUI
* Update MUI
* Fix crash with middle-clicking slot on circuit selection GUI
* Fix circuit selection window not syncing item from base machine
* Merge GT_NEI_AssLineHandler into GT_NEI_DefaultHandler
* Update MUI
* Add in TecTech multi message
* Allow changing the way of binding player inventory
* Update MUI
* Update MUI
* Update MUI
* Update MUI
* Update MUI
* Make MUI non-transitive to allow addons to use their own version
* Force enable mixin
* Format fluid amount tooltip
* Add GUITextureSet.STEAM
* Add guard against null ModularWindow creation
* Add constructors for Muffler Hatch with inventory
* Fix output slot on digital chest and tank allowing insertion
* Don't log null ModularWindow
* Add default implementation for IHasWorldObjectAndCoords#openGUI
* Make openGTTileEntityUI accept MultiTE & cleanup
Co-authored-by: Jason Mitchell <mitchej@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
18 files changed, 1162 insertions, 244 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index 67c3c672ae..45c07cf4c3 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -2,17 +2,19 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.V; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import gregtech.api.enums.Textures; -import gregtech.api.gui.*; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -23,7 +25,8 @@ import net.minecraft.util.EnumChatFormatting; * This is the main construct for my Basic Machines such as the Automatic Extractor * Extend this class to make a simple Machine */ -public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_TieredMachineBlock { +public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_TieredMachineBlock + implements IAddUIWidgets { public boolean mCharge = false, mDecharge = false; public int mBatteryCount = 0, mChargeableCount = 0; private long count = 0; @@ -208,42 +211,11 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 1: - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - case 4: - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - case 9: - return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - case 16: - return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 1: - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 4: - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 9: - return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 16: - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; @@ -357,4 +329,27 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier public boolean isGivingInformation() { return true; } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + switch (mInventory.length) { + case 4: + getBaseMetaTileEntity().add2by2Slots(builder); + break; + case 9: + getBaseMetaTileEntity().add3by3Slots(builder); + break; + case 16: + getBaseMetaTileEntity().add4by4Slots(builder); + break; + default: + getBaseMetaTileEntity().add1by1Slot(builder); + break; + } + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 091c364b4f..ca5f255302 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.V; import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.ItemData; @@ -85,8 +86,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -355,4 +355,9 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity public int getTankPressure() { return -100; } + + @Override + public boolean useModularUI() { + return true; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 15ce40cebf..a07fb5fb0d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -4,25 +4,57 @@ import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.debugCleanroom; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import static gregtech.api.metatileentity.BaseTileEntity.FLUID_INPUT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.FLUID_OUTPUT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.FLUID_TRANSFER_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.ITEM_TRANSFER_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.NEI_TRANSFER_STEAM_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.NEI_TRANSFER_VOLTAGE_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.POWER_SOURCE_KEY; +import static gregtech.api.metatileentity.BaseTileEntity.SPECIAL_SLOT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.STALLED_STUTTERING_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.STALLED_VENT_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.metatileentity.BaseTileEntity.UNUSED_SLOT_TOOLTIP; import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.SoundResource; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.SteamTexture; +import gregtech.api.interfaces.IConfigurationCircuitSupport; import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.common.gui.modularui.widget.FluidDisplaySlotWidget; import gregtech.common.power.BasicMachineEUPower; import gregtech.common.power.Power; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; import java.util.Arrays; +import java.util.Collections; import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -39,6 +71,7 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; +import org.apache.commons.lang3.tuple.Pair; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -47,7 +80,7 @@ import net.minecraftforge.fluids.IFluidHandler; * Extend this class to make a simple Machine */ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank - implements IConfigurationCircuitSupport { + implements IConfigurationCircuitSupport, IAddUIWidgets { /** * return values for checkRecipe() @@ -369,6 +402,10 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return OTHER_SLOT_COUNT + mInputSlotCount; } + public int getSpecialSlotIndex() { + return 3; + } + @Override public int getStackDisplaySlot() { return 2; @@ -482,12 +519,20 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; if (!GT_Mod.gregtechproxy.mForceFreeFace) { - aBaseMetaTileEntity.openGUI(aPlayer); + if (useModularUI()) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + } return true; } for (byte i = 0; i < 6; i++) { if (aBaseMetaTileEntity.getAirAtSide(i)) { - aBaseMetaTileEntity.openGUI(aPlayer); + if (useModularUI()) { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + } return true; } } @@ -495,11 +540,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return true; } + @Deprecated @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); } + @Deprecated @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_BasicMachine( @@ -685,7 +732,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { if (checkRecipe() == FOUND_AND_SUCCESSFULLY_USED_RECIPE) { - if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; + if (getSpecialSlot() != null && getSpecialSlot().stackSize <= 0) + mInventory[getSpecialSlotIndex()] = null; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; for (int i = 0; i < mOutputItems.length; i++) { @@ -734,7 +782,15 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public void updateFluidDisplayItem() { + updateFluidOutputDisplayItem(); + updateFluidInputDisplayItem(); + } + + public void updateFluidOutputDisplayItem() { super.updateFluidDisplayItem(); + } + + public void updateFluidInputDisplayItem() { if (displaysInputFluid()) { int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; if (getFillableStack() == null) { @@ -771,7 +827,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected ItemStack getSpecialSlot() { - return mInventory[3]; + return mInventory[getSpecialSlotIndex()]; } protected ItemStack getOutputAt(int aIndex) { @@ -1231,6 +1287,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return mPower; } + // GUI stuff + + @Override + public boolean useModularUI() { + return getRecipeList() != null && getRecipeList().useModularUI; + } + @Override public int getCircuitSlotX() { return 153; @@ -1240,4 +1303,252 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public int getCircuitSlotY() { return 63; } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (!isSteampowered()) { + builder.widget(createFluidAutoOutputButton()); + builder.widget(createItemAutoOutputButton()); + } + + addIOSlots(builder); + + builder.widget(createChargerSlot(79, 62)); + if (getRecipeList() != null) { + builder.widget(setNEITransferRect( + createProgressBar( + isSteampowered() + ? getRecipeList().progressBarTextureSteam.get(getSteamVariant()) + : getRecipeList().progressBarTexture, + getRecipeList().getProgressBarImageSize(), + getRecipeList().progressBarDirection, + getRecipeList().progressBarPos, + getRecipeList().progressBarSize), + getRecipeList().mNEIName)); + addProgressBarSpecialTextures(builder); + } + builder.widget(createErrorStatusArea( + builder, + isSteampowered() ? GT_UITextures.PICTURE_STALLED_STEAM : GT_UITextures.PICTURE_STALLED_ELECTRICITY)); + } + + /** + * Adds item I/O, special item, and fluid I/O slots. + */ + protected void addIOSlots(ModularWindow.Builder builder) { + final boolean hasFluidInput = + getRecipeList() != null ? (getRecipeList().hasFluidInputs()) : (getCapacity() != 0); + final boolean hasFluidOutput = + getRecipeList() != null && getRecipeList().hasFluidOutputs(); + UIHelper.forEachSlots( + (i, backgrounds, pos) -> builder.widget(createItemInputSlot(i, backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createItemOutputSlot(i, backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createSpecialSlot(backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createFluidInputSlot(backgrounds, pos)), + (i, backgrounds, pos) -> builder.widget(createFluidOutputSlot(backgrounds, pos)), + getGUITextureSet().getItemSlot(), + getGUITextureSet().getFluidSlot(), + getRecipeList(), + mInputSlotCount, + mOutputItems.length, + hasFluidInput ? 1 : 0, + hasFluidOutput ? 1 : 0, + getSteamVariant(), + Pos2d.ZERO); + } + + /** + * Override this as needed instead of calling. + */ + protected SlotWidget createItemInputSlot(int index, IDrawable[] backgrounds, Pos2d pos) { + return (SlotWidget) new SlotWidget(inventoryHandler, getInputSlot() + index) + .setAccess(true, true) + .setBackground(backgrounds) + .setPos(pos); + } + + /** + * Override this as needed instead of calling. + */ + protected SlotWidget createItemOutputSlot(int index, IDrawable[] backgrounds, Pos2d pos) { + return (SlotWidget) new SlotWidget(inventoryHandler, getOutputSlot() + index) + .setAccess(true, false) + .setBackground(backgrounds) + .setPos(pos); + } + + /** + * Override this as needed instead of calling. + */ + protected SlotWidget createSpecialSlot(IDrawable[] backgrounds, Pos2d pos) { + return (SlotWidget) new SlotWidget(inventoryHandler, getSpecialSlotIndex()) + .setAccess(true, true) + .disableShiftInsert() + .setGTTooltip(() -> mTooltipCache.getData( + getRecipeList() != null && getRecipeList().usesSpecialSlot() + ? SPECIAL_SLOT_TOOLTIP + : UNUSED_SLOT_TOOLTIP)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(backgrounds) + .setPos(pos); + } + + protected FluidDisplaySlotWidget createFluidInputSlot(IDrawable[] backgrounds, Pos2d pos) { + return (FluidDisplaySlotWidget) new FluidDisplaySlotWidget( + inventoryHandler, OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length) + .setFluidAccessConstructor(() -> constructFluidAccess(true)) + .setIHasFluidDisplay(this) + .setCanDrain(true) + .setCanFill(true) + .setActionRealClick(FluidDisplaySlotWidget.Action.TRANSFER) + .setBeforeRealClick((clickData, widget) -> { + if (NetworkUtils.isClient()) { + // propagate display item content to actual fluid stored in this tank + setFillableStack(GT_Utility.getFluidFromDisplayStack( + widget.getMcSlot().getStack())); + } + return true; + }) + .setUpdateFluidDisplayItem(this::updateFluidInputDisplayItem) + .setGTTooltip(() -> mTooltipCache.getData(FLUID_INPUT_TOOLTIP, GT_Utility.formatNumbers(getCapacity()))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(backgrounds) + .setPos(pos); + } + + protected FluidDisplaySlotWidget createFluidOutputSlot(IDrawable[] backgrounds, Pos2d pos) { + return (FluidDisplaySlotWidget) createDrainableFluidSlot() + .setUpdateFluidDisplayItem(this::updateFluidOutputDisplayItem) + .setGTTooltip( + () -> mTooltipCache.getData(FLUID_OUTPUT_TOOLTIP, GT_Utility.formatNumbers(getCapacity()))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(backgrounds) + .setPos(pos); + } + + @Override + protected SlotWidget createChargerSlot(int x, int y) { + if (isSteampowered()) { + return (SlotWidget) createChargerSlot(x, y, UNUSED_SLOT_TOOLTIP, new String[0]) + .setBackground(getGUITextureSet().getItemSlot()); + } else { + return super.createChargerSlot(x, y); + } + } + + protected CycleButtonWidget createItemAutoOutputButton() { + return (CycleButtonWidget) new CycleButtonWidget() + .setToggle(() -> mItemTransfer, val -> mItemTransfer = val) + .setStaticTexture(GT_UITextures.OVERLAY_BUTTON_AUTOOUTPUT_ITEM) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) + .setGTTooltip(() -> mTooltipCache.getData(ITEM_TRANSFER_TOOLTIP)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(25, 62) + .setSize(18, 18); + } + + protected CycleButtonWidget createFluidAutoOutputButton() { + return (CycleButtonWidget) new CycleButtonWidget() + .setToggle(() -> mFluidTransfer, val -> mFluidTransfer = val) + .setStaticTexture(GT_UITextures.OVERLAY_BUTTON_AUTOOUTPUT_FLUID) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) + .setGTTooltip(() -> mTooltipCache.getData(FLUID_TRANSFER_TOOLTIP)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(7, 62) + .setSize(18, 18); + } + + protected ProgressBar createProgressBar( + UITexture texture, int imageSize, ProgressBar.Direction direction, Pos2d pos, Size size) { + final ProgressBar ret = new ProgressBar(); + ret.setProgress(() -> maxProgresstime() != 0 ? (float) getProgresstime() / maxProgresstime() : 0) + .setTexture(texture, imageSize) + .setDirection(direction) + .setPos(pos) + .setSize(size); + return ret; + } + + public boolean hasNEITransferRect() { + return getRecipeList() != null; + } + + protected Widget setNEITransferRect(Widget widget, String transferRectID) { + if (hasNEITransferRect()) { + final Power powerInfo = getPower(); + final String transferRectTooltip; + if (isSteampowered()) { + transferRectTooltip = + StatCollector.translateToLocalFormatted(NEI_TRANSFER_STEAM_TOOLTIP, powerInfo.getTierString()); + } else { + transferRectTooltip = StatCollector.translateToLocalFormatted( + NEI_TRANSFER_VOLTAGE_TOOLTIP, powerInfo.getTierString()); + } + widget.setNEITransferRect(transferRectID, new Object[] {powerInfo}, transferRectTooltip); + } + return widget; + } + + protected void addProgressBarSpecialTextures(ModularWindow.Builder builder) { + if (isSteampowered()) { + for (Pair<SteamTexture, Pair<Size, Pos2d>> specialTexture : getRecipeList().specialTexturesSteam) { + builder.widget(new DrawableWidget() + .setDrawable(specialTexture.getLeft().get(getSteamVariant())) + .setSize(specialTexture.getRight().getLeft()) + .setPos(specialTexture.getRight().getRight())); + } + } else { + for (Pair<IDrawable, Pair<Size, Pos2d>> specialTexture : getRecipeList().specialTextures) { + builder.widget(new DrawableWidget() + .setDrawable(specialTexture.getLeft()) + .setSize(specialTexture.getRight().getLeft()) + .setPos(specialTexture.getRight().getRight())); + } + } + } + + protected DrawableWidget createErrorStatusArea(ModularWindow.Builder builder, IDrawable picture) { + return (DrawableWidget) new DrawableWidget() + .setDrawable(picture) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setEnabled(widget -> !widget.getTooltip().isEmpty()) + .dynamicTooltip(this::getErrorDescriptions) + .dynamicTooltipShift(this::getErrorDescriptionsShift) + .setPos(79, 44) + .setSize(18, 18) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> mStuttering, val -> mStuttering = val), + builder, + (widget, val) -> widget.notifyTooltipChange()) + .attachSyncer( + new FakeSyncWidget.IntegerSyncer( + () -> getBaseMetaTileEntity().getErrorDisplayID(), + val -> getBaseMetaTileEntity().setErrorDisplayID(val)), + builder, + (widget, val) -> widget.notifyTooltipChange()); + } + + protected List<String> getErrorDescriptions() { + final GT_TooltipDataCache.TooltipData tooltip = getErrorTooltip(); + return tooltip != null ? tooltip.text : Collections.emptyList(); + } + + protected List<String> getErrorDescriptionsShift() { + final GT_TooltipDataCache.TooltipData tooltip = getErrorTooltip(); + return tooltip != null ? tooltip.shiftText : Collections.emptyList(); + } + + protected GT_TooltipDataCache.TooltipData getErrorTooltip() { + if (isSteampowered()) { + if ((getBaseMetaTileEntity().getErrorDisplayID() & 64) != 0) { + return mTooltipCache.getData(STALLED_VENT_TOOLTIP); + } + } + if (mStuttering) { + return mTooltipCache.getData( + STALLED_STUTTERING_TOOLTIP, + StatCollector.translateToLocal(POWER_SOURCE_KEY + (isSteampowered() ? "steam" : "power"))); + } + return null; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index aa893c0bc2..049aaa45bf 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -8,6 +8,8 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; import gregtech.api.enums.ParticleFX; import gregtech.api.enums.SoundResource; +import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.modularui.GUITextureSet; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; @@ -427,4 +429,14 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE TextureFactory.of(OVERLAY_PIPE_OUT) }; } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.BRONZE; + } + + @Override + public GUITextureSet getGUITextureSet() { + return GUITextureSet.STEAM.apply(getSteamVariant()); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.j |
