diff options
author | Maxim <maxim235@gmx.de> | 2023-02-26 18:26:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-26 18:26:27 +0100 |
commit | 2651ea95e7af46b2d599f9e6eab25345595c9459 (patch) | |
tree | 6a3b063c1562e4387a3769c6284d65a218787b19 /src/main/java | |
parent | 3175e64e7201fe2f8765e54156f26d684b11276b (diff) | |
download | GT5-Unofficial-2651ea95e7af46b2d599f9e6eab25345595c9459.tar.gz GT5-Unofficial-2651ea95e7af46b2d599f9e6eab25345595c9459.tar.bz2 GT5-Unofficial-2651ea95e7af46b2d599f9e6eab25345595c9459.zip |
Enhanced multiblock GUIs (#1767)
* Added more buttons to multiblock GUI
* Migrated PA to new GUI
* Migrated Nano Forge to new GUI
* Migrated PCB Factory to new GUI
* Reband void protection to void excess to match GTPP logic
* Adjust fusion reactor GUI size
* Added statics for new NBT keys
* Added getters for button status
* Rename methods to reflect that they are about void excess, not the opposite
* Added button textures
Diffstat (limited to 'src/main/java')
6 files changed, 374 insertions, 37 deletions
diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java index d3b353e1ec..49a999b3fe 100644 --- a/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java +++ b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java @@ -207,6 +207,46 @@ public class GT_UITextures { .fullImage(MODID, "gui/overlay_button/redstone_off"); public static final UITexture OVERLAY_BUTTON_REDSTONE_ON = UITexture .fullImage(MODID, "gui/overlay_button/redstone_on"); + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_ON = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_on"); + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_off"); + public static final UITexture OVERLAY_BUTTON_VOID_EXCESS_ON = UITexture + .fullImage(MODID, "gui/overlay_button/void_excess_on"); + public static final UITexture OVERLAY_BUTTON_VOID_EXCESS_ON_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/void_excess_on_disabled"); + public static final UITexture OVERLAY_BUTTON_VOID_EXCESS_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/void_excess_off"); + public static final UITexture OVERLAY_BUTTON_VOID_EXCESS_OFF_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/void_excess_off_disabled"); + public static final UITexture OVERLAY_BUTTON_INPUT_SEPARATION_ON = UITexture + .fullImage(MODID, "gui/overlay_button/input_separation_on"); + public static final UITexture OVERLAY_BUTTON_INPUT_SEPARATION_ON_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/input_separation_on_disabled"); + public static final UITexture OVERLAY_BUTTON_INPUT_SEPARATION_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/input_separation_off"); + public static final UITexture OVERLAY_BUTTON_INPUT_SEPARATION_OFF_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/input_separation_off_disabled"); + public static final UITexture OVERLAY_BUTTON_RECIPE_LOCKED = UITexture + .fullImage(MODID, "gui/overlay_button/recipe_locked"); + public static final UITexture OVERLAY_BUTTON_RECIPE_LOCKED_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/recipe_locked_disabled"); + public static final UITexture OVERLAY_BUTTON_RECIPE_UNLOCKED = UITexture + .fullImage(MODID, "gui/overlay_button/recipe_unlocked"); + public static final UITexture OVERLAY_BUTTON_RECIPE_UNLOCKED_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/recipe_unlocked_disabled"); + public static final UITexture OVERLAY_BUTTON_BATCH_MODE_ON = UITexture + .fullImage(MODID, "gui/overlay_button/batch_mode_on"); + public static final UITexture OVERLAY_BUTTON_BATCH_MODE_ON_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/batch_mode_on_disabled"); + public static final UITexture OVERLAY_BUTTON_BATCH_MODE_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/batch_mode_off"); + public static final UITexture OVERLAY_BUTTON_BATCH_MODE_OFF_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/batch_mode_off_disabled"); + public static final UITexture OVERLAY_BUTTON_DOWN_TIERING_ON = UITexture + .fullImage(MODID, "gui/overlay_button/down_tiering_on"); + public static final UITexture OVERLAY_BUTTON_DOWN_TIERING_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/down_tiering_off"); public static final UITexture OVERLAY_BUTTON_CHECKMARK = UITexture.fullImage(MODID, "gui/overlay_button/checkmark"); public static final UITexture OVERLAY_BUTTON_CROSS = UITexture.fullImage(MODID, "gui/overlay_button/cross"); public static final UITexture OVERLAY_BUTTON_WHITELIST = UITexture.fullImage(MODID, "gui/overlay_button/whitelist"); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 80b6723d81..bcdb456ecc 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -1,6 +1,7 @@ package gregtech.api.metatileentity.implementations; import static gregtech.api.enums.GT_Values.*; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static mcp.mobius.waila.api.SpecialChars.GREEN; import static mcp.mobius.waila.api.SpecialChars.RED; import static mcp.mobius.waila.api.SpecialChars.RESET; @@ -25,13 +26,13 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; import com.google.common.collect.Iterables; +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.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; -import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; -import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.*; import gregtech.GT_Mod; import gregtech.api.GregTech_API; @@ -41,6 +42,7 @@ import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.modularui.IAddGregtechLogo; import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.modularui.IBindPlayerInventoryUI; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; @@ -53,7 +55,7 @@ import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity - implements IAddGregtechLogo, IAddUIWidgets { + implements IAddGregtechLogo, IAddUIWidgets, IBindPlayerInventoryUI { public static boolean disableMaintenance; public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, @@ -70,6 +72,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity public float damageFactorHigh = 0.6f; public boolean mLockedToSingleRecipe = false; + protected boolean inputSeparation = false; + protected boolean voidExcess = true; + protected boolean batchMode = false; + protected static String INPUT_SEPARATION_NBT_KEY = "inputSeparation"; + protected static String VOID_EXCESS_NBT_KEY = "voidExcess"; + protected static String BATCH_MODE_NBT_KEY = "batchMode"; public GT_Single_Recipe_Check mSingleRecipeCheck = null; public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<>(); @@ -205,6 +213,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity aNBT.setBoolean("mHardHammer", mHardHammer); aNBT.setBoolean("mSolderingTool", mSolderingTool); aNBT.setBoolean("mCrowbar", mCrowbar); + aNBT.setBoolean(BATCH_MODE_NBT_KEY, batchMode); + aNBT.setBoolean(INPUT_SEPARATION_NBT_KEY, inputSeparation); + aNBT.setBoolean(VOID_EXCESS_NBT_KEY, voidExcess); } @Override @@ -218,6 +229,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity mPollution = aNBT.getInteger("mPollution"); mRuntime = aNBT.getInteger("mRuntime"); mLockedToSingleRecipe = aNBT.getBoolean("mLockedToSingleRecipe"); + batchMode = aNBT.getBoolean(BATCH_MODE_NBT_KEY); + inputSeparation = aNBT.getBoolean(INPUT_SEPARATION_NBT_KEY); + voidExcess = aNBT.getBoolean(VOID_EXCESS_NBT_KEY); int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength"); if (aOutputItemsLength > 0) { @@ -1343,15 +1357,99 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity } @Override + public int getGUIWidth() { + return 198; + } + + @Override + public int getGUIHeight() { + return 192; + } + + /** + * @return if the multi supports input separation. If you want to use it you need to use {@link #inputSeparation}. + */ + protected boolean isInputSeparationButtonEnabled() { + return false; + } + + /** + * @return if the multi supports batch mode. If you want to use it you need to use {@link #batchMode}. + */ + protected boolean isBatchModeButtonEnabled() { + return false; + } + + /** + * @return if the multi supports void excess to be toggled. If you want to use it you need to use + * {@link #voidExcess}. + */ + protected boolean isVoidExcessButtonEnabled() { + return false; + } + + /** + * @return true if input separation is enabled, else false. This is getter is used for displaying the icon in the + * GUI + */ + protected boolean isInputSeparationEnabled() { + return inputSeparation; + } + + /** + * @return true if batch mode is enabled, else false. This is getter is used for displaying the icon in the GUI + */ + protected boolean isBatchModeEnabled() { + return batchMode; + } + + /** + * @return true if void excess is enabled, else false. This is getter is used for displaying the icon in the GUI + */ + protected boolean isVoidExcessEnabled() { + return voidExcess; + } + + /** + * @return true if recipe locking is enabled, else false. This is getter is used for displaying the icon in the GUI + */ + protected boolean isRecipeLockingEnabled() { + return mLockedToSingleRecipe; + } + + @Override + public void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(7, 109), getGUITextureSet().getItemSlot()); + } + + @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { builder.widget( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK).setPos(7, 4).setSize(143, 75)); + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK).setPos(4, 4).setSize(190, 85)); final SlotWidget inventorySlot = new SlotWidget(inventoryHandler, 1); - builder.widget(inventorySlot.setPos(151, 4)); + builder.widget(inventorySlot.setPos(173, 167).setBackground(GT_UITextures.SLOT_DARK_GRAY)); final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); drawTexts(screenElements, inventorySlot); builder.widget(screenElements); + + builder.widget(createPowerSwitchButton()) + .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> { + if (val) getBaseMetaTileEntity().enableWorking(); + else getBaseMetaTileEntity().disableWorking(); + })); + + builder.widget(createVoidExcessButton()) + .widget(new FakeSyncWidget.BooleanSyncer(() -> voidExcess, val -> voidExcess = val)); + + builder.widget(createInputSeparationButton()) + .widget(new FakeSyncWidget.BooleanSyncer(() -> inputSeparation, val -> inputSeparation = val)); + + builder.widget(createBatchModeButton()) + .widget(new FakeSyncWidget.BooleanSyncer(() -> batchMode, val -> batchMode = val)); + + builder.widget(createLockToSingleRecipeButton()).widget( + new FakeSyncWidget.BooleanSyncer(() -> mLockedToSingleRecipe, val -> mLockedToSingleRecipe = val)); } @Override @@ -1456,4 +1554,138 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity return false; })); } + + protected ButtonWidget createPowerSwitchButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (getBaseMetaTileEntity().isAllowedToWork()) { + getBaseMetaTileEntity().disableWorking(); + } else { + getBaseMetaTileEntity().enableWorking(); + } + }).setPlayClickSound(true).setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + if (getBaseMetaTileEntity().isAllowedToWork()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF); + } + return ret.toArray(new IDrawable[0]); + }).setPos(174, 148).setSize(16, 16); + button.addTooltip(StatCollector.translateToLocal("GT5U.gui.button.power_switch")) + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } + + protected ButtonWidget createVoidExcessButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isVoidExcessButtonEnabled()) { + voidExcess = !voidExcess; + } + }).setPlayClickSound(true).setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + if (isVoidExcessButtonEnabled()) { + if (isVoidExcessEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_OFF); + } + } else { + if (isVoidExcessEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_ON_DISABLED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_OFF_DISABLED); + } + } + return ret.toArray(new IDrawable[0]); + }).setPos(8, 91).setSize(16, 16); + button.addTooltip(StatCollector.translateToLocal("GT5U.gui.button.void_excess")) + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } + + protected ButtonWidget createInputSeparationButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isInputSeparationButtonEnabled()) { + inputSeparation = !inputSeparation; + } + }).setPlayClickSound(true).setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + if (isInputSeparationButtonEnabled()) { + if (isInputSeparationEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF); + } + } else { + if (isInputSeparationEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON_DISABLED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF_DISABLED); + } + } + return ret.toArray(new IDrawable[0]); + }).setPos(26, 91).setSize(16, 16); + button.addTooltip(StatCollector.translateToLocal("GT5U.gui.button.input_separation")) + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } + + protected ButtonWidget createBatchModeButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isBatchModeButtonEnabled()) { + batchMode = !batchMode; + } + }).setPlayClickSound(true).setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + if (isBatchModeButtonEnabled()) { + if (isBatchModeEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_OFF); + } + } else { + if (isBatchModeEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_ON_DISABLED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_OFF_DISABLED); + } + } + return ret.toArray(new IDrawable[0]); + }).setPos(44, 91).setSize(16, 16); + button.addTooltip(StatCollector.translateToLocal("GT5U.gui.button.batch_mode")) + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } + + protected ButtonWidget createLockToSingleRecipeButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (supportsSingleRecipeLocking()) { + mLockedToSingleRecipe = !mLockedToSingleRecipe; + } + }).setPlayClickSound(true).setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + if (supportsSingleRecipeLocking()) { + if (isRecipeLockingEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_LOCKED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED); + } + } else { + if (isRecipeLockingEnabled()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_LOCKED_DISABLED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED_DISABLED); + } + } + return ret.toArray(new IDrawable[0]); + }).setPos(62, 91).setSize(16, 16); + button.addTooltip(StatCollector.translateToLocal("GT5U.gui.button.lock_recipe")) + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java index 1e7e0f822e..c180741313 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -538,6 +538,16 @@ public abstract class GT_MetaTileEntity_FusionComputer } @Override + public int getGUIWidth() { + return 176; + } + + @Override + public int getGUIHeight() { + return 166; + } + + @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { builder.widget( new TextWidget(GT_Utility.trans("138", "Incomplete Structure.")).setDefaultColor(COLOR_TEXT_WHITE.get()) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java index ddb8e302e4..550a8bb761 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_NanoForge.java @@ -147,7 +147,6 @@ public class GT_MetaTileEntity_NanoForge extends .buildAndChain(GregTech_API.sBlockCasings8, 10)) .build(); private byte mSpecialTier = 0; - private boolean mSeparate = false; public GT_MetaTileEntity_NanoForge(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -210,7 +209,7 @@ public class GT_MetaTileEntity_NanoForge extends public boolean checkRecipe(ItemStack aStack) { GT_Recipe.GT_Recipe_Map map = getRecipeMap(); FluidStack[] tFluidInputs = getCompactedFluids(); - if (mSeparate) { + if (inputSeparation) { ArrayList<ItemStack> tInputList = new ArrayList<ItemStack>(); for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { for (int i = tBus.getSizeInventory() - 1; i >= 0; i--) { @@ -339,14 +338,15 @@ public class GT_MetaTileEntity_NanoForge extends @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("mSeparate", mSeparate); aNBT.setByte("mSpecialTier", mSpecialTier); } @Override public void loadNBTData(final NBTTagCompound aNBT) { super.loadNBTData(aNBT); - mSeparate = aNBT.getBoolean("mSeparate"); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + inputSeparation = aNBT.getBoolean("mSeparate"); + } mSpecialTier = aNBT.getByte("mSpecialTier"); } @@ -444,9 +444,14 @@ public class GT_MetaTileEntity_NanoForge extends @Override public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mSeparate = !mSeparate; + inputSeparation = !inputSeparation; GT_Utility.sendChatToPlayer( aPlayer, - StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + mSeparate); + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + } + + @Override + protected boolean isInputSeparationButtonEnabled() { + return true; } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java index fb16756d40..d8d1f6b656 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java @@ -11,6 +11,7 @@ import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofFrame; import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -29,7 +30,9 @@ import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Color; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -77,7 +80,6 @@ public class GT_MetaTileEntity_PCBFactory extends private static final String bioUpgrade = "bioUpgrade"; private static final String ocTier1Upgrade = "ocTier1Upgrade"; private static final String ocTier2Upgrade = "ocTier2Upgrade"; - private boolean mSeparate = false; private float mRoughnessMultiplier = 1; private int mTier = 1, mSetTier = 1, mUpgradesInstalled = 0, mCurrentParallel = 0, mMaxParallel = 0; private boolean mBioUpgrade = false, mBioRotate = false, mOCTier1 = false, mOCTier2 = false; @@ -485,7 +487,7 @@ public class GT_MetaTileEntity_PCBFactory extends mCurrentParallel = 0; GT_Recipe.GT_Recipe_Map aMap = getRecipeMap(); FluidStack[] tFluidInputs = getStoredFluids().toArray(new FluidStack[0]); - if (mSeparate) { + if (inputSeparation) { ArrayList<ItemStack> tInputList = new ArrayList<ItemStack>(); for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { for (int i = tBus.getSizeInventory() - 1; i >= 0; i--) { @@ -822,10 +824,10 @@ public class GT_MetaTileEntity_PCBFactory extends @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mSeparate = !mSeparate; + inputSeparation = !inputSeparation; GT_Utility.sendChatToPlayer( aPlayer, - StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + mSeparate); + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); } @Override @@ -1031,7 +1033,6 @@ public class GT_MetaTileEntity_PCBFactory extends @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("mSeparate", mSeparate); aNBT.setBoolean("mBioUpgrade", mBioUpgrade); aNBT.setBoolean("mBioRotate", mBioRotate); aNBT.setInteger("mBioOffsetX", mBioOffsets[0]); @@ -1049,7 +1050,9 @@ public class GT_MetaTileEntity_PCBFactory extends @Override public void loadNBTData(final NBTTagCompound aNBT) { super.loadNBTData(aNBT); - mSeparate = aNBT.getBoolean("mSeparate"); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + inputSeparation = aNBT.getBoolean("mSeparate"); + } mBioUpgrade = aNBT.getBoolean("mBioUpgrade"); mBioRotate = aNBT.getBoolean("mBioRotate"); mBioOffsets[0] = aNBT.getInteger("mBioOffsetX"); @@ -1111,17 +1114,20 @@ public class GT_MetaTileEntity_PCBFactory extends builder.widget( new ButtonWidget().setOnClick( (clickData, widget) -> { if (!widget.isClient()) widget.getContext().openSyncedWindow(10); }) - .setSize(18, 18).setBackground(GT_UITextures.BUTTON_STANDARD) - .setBackground(GT_UITextures.OVERLAY_BUTTON_CYCLIC).addTooltip("Configuration Menu") - .setPos(151, 24)) + .setSize(16, 16).setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + ret.add(GT_UITextures.OVERLAY_BUTTON_CYCLIC); + return ret.toArray(new IDrawable[0]); + }).addTooltip("Configuration Menu").setPos(174, 130)) .widget( new TextWidget(new Text("Tier")).setTextAlignment(Alignment.Center).setScale(0.91f) - .setSize(20, 16).setPos(152, 46)) + .setSize(20, 16).setPos(173, 98)) .widget( new TextFieldWidget().setGetterInt(() -> mSetTier).setSetterInt(val -> { mSetTier = val; }) .setNumbers(1, 3).setTextColor(Color.WHITE.normal).setTextAlignment(Alignment.Center) .addTooltip("PCB Factory Tier").setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) - .setSize(18, 18).setPos(151, 61)); + .setSize(18, 18).setPos(173, 110)); } protected ModularWindow createConfigurationWindow(final EntityPlayer player) { @@ -1317,4 +1323,9 @@ public class GT_MetaTileEntity_PCBFactory extends .setPos(110, 25)); return builder.build(); } + + @Override + protected boolean isInputSeparationButtonEnabled() { + return true; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java index ff0cae44af..5e330d6742 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -10,6 +10,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_AR import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_GLOW; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.isValidForLowGravity; import java.util.ArrayList; @@ -27,12 +28,19 @@ import net.minecraftforge.fluids.FluidStack; import com.google.common.collect.ImmutableList; import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -55,9 +63,7 @@ public class GT_MetaTileEntity_ProcessingArray private GT_Recipe mLastRecipe; private int tTier = 0; private int mMult = 0; - private boolean mSeparate = false; private boolean downtierUEV = true; - private boolean mUseMultiparallelMode = false; private String mMachineName = ""; // Value needed so that the PA can use energy above MAX voltage private long mEUPerTick = 0; @@ -172,7 +178,7 @@ public class GT_MetaTileEntity_ProcessingArray } ArrayList<FluidStack> tFluidList = getStoredFluids(); FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); - if (mSeparate) { + if (inputSeparation) { ArrayList<ItemStack> tInputList = new ArrayList<>(); for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { IGregTechTileEntity tInputBus = tHatch.getBaseMetaTileEntity(); @@ -243,7 +249,7 @@ public class GT_MetaTileEntity_ProcessingArray // Check how many times we can run the same recipe int multiplier = 1; - if (mUseMultiparallelMode && i == machines) { + if (batchMode && i == machines) { for (; multiplier < 128; ++multiplier) { if (!tRecipe.isRecipeInputEqual(true, false, machines, tFluids, tInputs)) { break; @@ -360,18 +366,20 @@ public class GT_MetaTileEntity_ProcessingArray @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setBoolean("mSeparate", mSeparate); aNBT.setBoolean("downtierUEV", downtierUEV); - aNBT.setBoolean("mUseMultiparallelMode", mUseMultiparallelMode); aNBT.setLong("mEUPerTick", mEUPerTick); } @Override public void loadNBTData(final NBTTagCompound aNBT) { super.loadNBTData(aNBT); - mSeparate = aNBT.getBoolean("mSeparate"); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + inputSeparation = aNBT.getBoolean("mSeparate"); + } + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } downtierUEV = aNBT.getBoolean("downtierUEV"); - mUseMultiparallelMode = aNBT.getBoolean("mUseMultiparallelMode"); mEUPerTick = aNBT.getLong("mEUPerTick"); } @@ -381,10 +389,10 @@ public class GT_MetaTileEntity_ProcessingArray // Lock to single recipe super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); } else { - mSeparate = !mSeparate; + inputSeparation = !inputSeparation; GT_Utility.sendChatToPlayer( aPlayer, - StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + mSeparate); + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); } } @@ -392,8 +400,8 @@ public class GT_MetaTileEntity_ProcessingArray public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { - mUseMultiparallelMode = !mUseMultiparallelMode; - if (mUseMultiparallelMode) { + batchMode = !batchMode; + if (batchMode) { GT_Utility.sendChatToPlayer(aPlayer, "Batch recipes"); } else { GT_Utility.sendChatToPlayer(aPlayer, "Don't batch recipes"); @@ -584,4 +592,35 @@ public class GT_MetaTileEntity_ProcessingArray } } } + + @Override + protected boolean isInputSeparationButtonEnabled() { + return true; + } + + @Override + protected boolean isBatchModeButtonEnabled() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + + builder.widget( + new ButtonWidget().setOnClick((clickData, widget) -> downtierUEV = !downtierUEV).setPlayClickSound(true) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GT_UITextures.BUTTON_STANDARD); + if (downtierUEV) { + ret.add(GT_UITextures.OVERLAY_BUTTON_DOWN_TIERING_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_DOWN_TIERING_OFF); + } + return ret.toArray(new IDrawable[0]); + }).setPos(80, 91).setSize(16, 16) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.down_tier")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> downtierUEV, val -> downtierUEV = val)); + } } |