diff options
Diffstat (limited to 'src/main/java/com')
11 files changed, 568 insertions, 1201 deletions
diff --git a/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java index 4b57c09ab8..738d7bfc45 100644 --- a/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java +++ b/src/main/java/com/github/technus/tectech/loader/NetworkDispatcher.java @@ -7,7 +7,6 @@ import com.github.technus.tectech.mechanics.data.PlayerDataMessage; import com.github.technus.tectech.mechanics.enderStorage.EnderLinkCoverMessage; import com.github.technus.tectech.mechanics.pipe.PipeActivityMessage; import com.github.technus.tectech.mechanics.spark.RendererMessage; -import com.github.technus.tectech.thing.metaTileEntity.hatch.TextParametersMessage; public class NetworkDispatcher extends eu.usrv.yamcore.network.PacketDispatcher { public static NetworkDispatcher INSTANCE; @@ -35,10 +34,5 @@ public class NetworkDispatcher extends eu.usrv.yamcore.network.PacketDispatcher registerMessage( EnderLinkCoverMessage.ServerUpdateHandler.class, EnderLinkCoverMessage.EnderLinkCoverUpdate.class); registerMessage(EnderLinkCoverMessage.ClientHandler.class, EnderLinkCoverMessage.EnderLinkCoverData.class); - - registerMessage(TextParametersMessage.ServerHandler.class, TextParametersMessage.ParametersTextQuery.class); - registerMessage( - TextParametersMessage.ServerUpdateHandler.class, TextParametersMessage.ParametersTextUpdate.class); - registerMessage(TextParametersMessage.ClientHandler.class, TextParametersMessage.ParametersTextData.class); } } diff --git a/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java b/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java index b09984e388..14ef35b317 100644 --- a/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java +++ b/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java @@ -11,6 +11,8 @@ public class TecTechUITextures { public static final AdaptableUITexture BACKGROUND_SCREEN_BLUE = AdaptableUITexture.of(MODID, "gui/background/screen_blue", 90, 72, 2); + public static final UITexture BACKGROUND_SCREEN_BLUE_PARAMETRIZER_TXT = + UITexture.fullImage(MODID, "gui/background/screen_blue_parametrizer_txt"); public static final UITexture BUTTON_STANDARD_16x16 = UITexture.fullImage(MODID, "gui/button/standard_16x16"); public static final UITexture BUTTON_STANDARD_LIGHT_16x16 = @@ -40,6 +42,22 @@ public class TecTechUITextures { UITexture.fullImage(MODID, "gui/overlay_button/power_pass_off"); public static final UITexture OVERLAY_BUTTON_POWER_PASS_ON = UITexture.fullImage(MODID, "gui/overlay_button/power_pass_on"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_ID = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_id"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_0 = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_0"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_1 = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_1"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_X = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_x"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_S = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_s"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_T = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_t"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_C = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_c"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_IF = + UITexture.fullImage(MODID, "gui/overlay_button/parametrizer_if"); public static final UITexture OVERLAY_SLOT_RACK = UITexture.fullImage(MODID, "gui/overlay_slot/rack"); public static final UITexture OVERLAY_SLOT_MESH = UITexture.fullImage(MODID, "gui/overlay_slot/mesh"); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java index ed6e00dccf..7a59e39c6d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java @@ -3,24 +3,35 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; -import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Param; -import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_ParamAdv; -import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Param; -import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_ParamAdv; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.gui.TecTechUITextures; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +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.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -30,7 +41,7 @@ import org.apache.commons.lang3.reflect.FieldUtils; /** * Created by danie_000 on 15.12.2016. */ -public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { +public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch implements IAddGregtechLogo, IAddUIWidgets { public int pointer = 0; public int param = -1; public double value0D = 0; @@ -60,22 +71,6 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (mTier > 5) { // TODO update mTier to 4 after recipe check - return new GT_Container_ParamAdv(aPlayerInventory, aBaseMetaTileEntity); - } - return new GT_Container_Param(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (mTier > 5) { // TODO update mTier to 4 after recipe check - return new GT_GUIContainer_ParamAdv(aPlayerInventory, aBaseMetaTileEntity); - } - return new GT_GUIContainer_Param(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { return new ITexture[] {aBaseTexture, new GT_RenderedTexture(ScreenON)}; } @@ -214,7 +209,7 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { } catch (Exception e) { clientLocale = "en_US"; } - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -227,4 +222,396 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { + translateToLocal("gt.blockmachines.hatch.param.desc.1") + "\u00b2" // E=mine*craft }; } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget(new DrawableWidget() + .setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(112, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + final boolean isAdvanced = mTier > 5; + builder.widget(new DrawableWidget() + .setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(43, 4) + .setSize(90, 72)); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param -= shift ? 16 : 4, + 7, + 4, + GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? -16 : -4); + } + } else { + value0D -= shift ? 4096 : 256; + } + }, + 7, + 22, + GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? -16 : -4); + } else { + secondRow.set(true); + } + } else { + value1D -= shift ? 4096 : 256; + } + }, + 7, + 40, + GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); + } else { + value0D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp |= 1L << (long) columnPointer.get(); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp |= 1L << (long) columnPointer.get(); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D /= shift ? 4096 : 256; + value1D /= shift ? 4096 : 256; + } + }, + 7, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_S : GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param -= shift ? 2 : 1, + 25, + 4, + GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? -2 : -1); + } + } else { + value0D -= shift ? 16 : 1; + } + }, + 25, + 22, + GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? -2 : -1); + } else { + secondRow.set(true); + } + } else { + value1D -= shift ? 16 : 1; + } + }, + 25, + 40, + GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(0); + } else { + value0D = Double.longBitsToDouble(0); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp &= ~(1L << (long) columnPointer.get()); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp &= ~(1L << (long) columnPointer.get()); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D /= shift ? 16 : 2; + value1D /= shift ? 16 : 2; + } + }, + 25, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_C : GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_X); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param += shift ? 2 : 1, + 133, + 4, + GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? 2 : 1); + } + } else { + value0D += shift ? 16 : 1; + } + }, + 133, + 22, + GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? 2 : 1); + } else { + secondRow.set(true); + } + } else { + value1D += shift ? 16 : 1; + } + }, + 133, + 40, + GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(~Double.doubleToLongBits(value1D)); + } else { + value0D = Double.longBitsToDouble(~Double.doubleToLongBits(value1D)); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp ^= 1L << (long) columnPointer.get(); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp ^= 1L << (long) columnPointer.get(); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D *= shift ? 16 : 2; + value1D *= shift ? 16 : 2; + } + }, + 133, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_T : GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param += shift ? 16 : 4, + 151, + 4, + GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? 16 : 4); + } + } else { + value0D += shift ? 4096 : 256; + } + }, + 151, + 22, + GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? 16 : 4); + } else { + secondRow.set(true); + } + } else { + value1D += shift ? 4096 : 256; + } + }, + 151, + 40, + GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + value0D = input0D; + value1D = input1D; + } else { + value0D *= shift ? 4096 : 256; + value1D *= shift ? 4096 : 256; + } + }, + 151, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_IF : GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> pointer, val -> pointer = val)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> param, val -> param = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value0D, val -> value0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value1D, val -> value1D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input0D, val -> input0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input1D, val -> input1D = val)); + + final String CIRCLED_0 = "\u24EA"; + final String CIRCLED_1 = "\u2460"; + final String ARROW_DOWN = "\u2b07"; + final String ARROW_UP = "\u2b06"; + builder.widget(TextWidget.dynamicString(() -> (isAdvanced ? "Parameters X: " : "Parameters: ") + param) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)) + .widget(TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_DOWN + TT_Utility.formatNumberExp(input0D)) + .setSynced(false) + .setDefaultColor(0x22ddff) + .setPos(46, 16)) + .widget(TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_DOWN + TT_Utility.formatNumberExp(input1D)) + .setSynced(false) + .setDefaultColor(0x00ffff) + .setPos(46, 24)) + .widget(TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_UP + TT_Utility.formatNumberExp(value0D)) + .setSynced(false) + .setDefaultColor(0x00bbff) + .setPos(46, 33)) + .widget(TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_UP + TT_Utility.formatNumberExp(value1D)) + .setSynced(false) + .setDefaultColor(0x0077ff) + .setPos(46, 41)) + .widget(TextWidget.dynamicString(() -> CIRCLED_0 + + ARROW_UP + + TT_Utility.longBitsToShortString(Double.doubleToLongBits(value0D))) + .setSynced(false) + .setDefaultColor(0x00bbff) + .setScale(.5f) + .setTextAlignment(Alignment.CenterLeft) + .setPos(46, 50)) + .widget(TextWidget.dynamicString(() -> CIRCLED_1 + + ARROW_UP + + TT_Utility.longBitsToShortString(Double.doubleToLongBits(value1D))) + .setSynced(false) + .setDefaultColor(0x0077ff) + .setScale(.5f) + .setTextAlignment(Alignment.CenterLeft) + .setPos(46, 58)); + if (isAdvanced) { + builder.widget(TextWidget.dynamicString(() -> + "Pointer " + Integer.toHexString(pointer | 0x10000).substring(1)) + .setSynced(false) + .setDefaultColor(0x0033ff) + .setPos(46, 66)); + } + } + + private void addChangeParamButton( + ModularWindow.Builder builder, + OnClick onClick, + int xPos, + int yPos, + IDrawable overlay1, + IDrawable overlay2) { + final boolean isAdvanced = mTier > 5; + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + AtomicInteger columnPointer = new AtomicInteger(pointer & 0xff); + AtomicBoolean secondRow = new AtomicBoolean((pointer & 0x0100) != 0); + onClick.accept(clickData.shift, columnPointer, secondRow); + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (isAdvanced) { + if (columnPointer.get() >= 64) { + columnPointer.set(63); + } else if (columnPointer.get() < 0) { + columnPointer.set(0); + } + pointer = secondRow.get() ? columnPointer.get() + 0x100 : columnPointer.get(); + } + if (param > 9) { + param = 9; + } else if (param < -1) { + param = -1; + } + }) + .setPlayClickSound(false) + .setBackground( + overlay2 != null + ? new IDrawable[] {GT_UITextures.BUTTON_STANDARD, overlay1, overlay2} + : new IDrawable[] {GT_UITextures.BUTTON_STANDARD, overlay1}) + .setSize(18, 18) + .setPos(xPos, yPos)); + } + + @FunctionalInterface + private interface OnClick { + void accept(boolean shift, AtomicInteger columnPointer, AtomicBoolean secondRow); + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java index e241793e0e..810c04d861 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ParamText.java @@ -3,16 +3,27 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; -import com.github.technus.tectech.loader.NetworkDispatcher; -import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_ParamText; -import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_ParamText; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.thing.gui.TecTechUITextures; import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.TT_Utility; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +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.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -36,20 +47,6 @@ public class GT_MetaTileEntity_Hatch_ParamText extends GT_MetaTileEntity_Hatch_P super(aName, aTier, aDescription, aTextures); } - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (aPlayerInventory.player instanceof EntityPlayerMP) { - NetworkDispatcher.INSTANCE.sendTo( - new TextParametersMessage.ParametersTextData(this), (EntityPlayerMP) aPlayerInventory.player); - } - return new GT_Container_ParamText(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_ParamText(aPlayerInventory, aBaseMetaTileEntity); - } - // @Override // public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { // if (aBaseMetaTileEntity.isClientSide() && (aTick % 20L == 0L)) { @@ -157,7 +154,7 @@ public class GT_MetaTileEntity_Hatch_ParamText extends GT_MetaTileEntity_Hatch_P } catch (Exception e) { clientLocale = "en_US"; } - aBaseMetaTileEntity.openGUI(aPlayer); + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); return true; } @@ -170,4 +167,128 @@ public class GT_MetaTileEntity_Hatch_ParamText extends GT_MetaTileEntity_Hatch_P + translateToLocal("gt.blockmachines.hatch.param.desc.1") + "\u00b2" // E=mine*craft }; } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget(new DrawableWidget() + .setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(148, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget(new DrawableWidget() + .setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_PARAMETRIZER_TXT) + .setPos(7, 4) + .setSize(162, 72)); + + addChangeNumberButton(builder, -16, -4, 7, GT_UITextures.OVERLAY_BUTTON_MINUS_LARGE); + addChangeNumberButton(builder, -2, -1, 25, GT_UITextures.OVERLAY_BUTTON_MINUS_SMALL); + addChangeNumberButton(builder, 2, 1, 133, GT_UITextures.OVERLAY_BUTTON_PLUS_SMALL); + addChangeNumberButton(builder, 16, 4, 151, GT_UITextures.OVERLAY_BUTTON_PLUS_LARGE); + + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> param, val -> param = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value0D, val -> value0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value1D, val -> value1D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input0D, val -> input0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input1D, val -> input1D = val)); + // .widget(new FakeSyncWidget.StringSyncer(() -> value0s, val -> value0s = val)) + // .widget(new FakeSyncWidget.StringSyncer(() -> value1s, val -> value1s = val)); + + final String CIRCLED_0 = "\u24EA"; + final String CIRCLED_1 = "\u2460"; + final String ARROW_DOWN = "\u2b07"; + final String ARROW_UP = "\u2b06"; + builder.widget(TextWidget.dynamicString(() -> "Parameters: " + param) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)) + .widget(new TextWidget(CIRCLED_0 + ARROW_UP) + .setDefaultColor(0x00bbff) + .setPos(10, 29)) + .widget(new TextWidget(CIRCLED_1 + ARROW_UP) + .setDefaultColor(0x0077ff) + .setPos(10, 44)) + .widget(TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_DOWN + TT_Utility.formatNumberExp(input0D)) + .setSynced(false) + .setDefaultColor(0x22ddff) + .setPos(10, 56)) + .widget(TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_DOWN + TT_Utility.formatNumberExp(input1D)) + .setSynced(false) + .setDefaultColor(0x00ffff) + .setPos(10, 65)); + + addTextField(builder, true); + addTextField(builder, false); + } + + private void addChangeNumberButton( + ModularWindow.Builder builder, int changeNumberShift, int changeNumber, int xPos, IDrawable overlay) { + builder.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + param += clickData.shift ? changeNumberShift : changeNumber; + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (param > 9) { + param = 9; + } else if (param < -1) { + param = -1; + } + }) + .setPlayClickSound(false) + .setBackground(GT_UITextures.BUTTON_STANDARD, overlay, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID) + .setSize(18, 18) + .setPos(xPos, 4)); + } + + private void addTextField(ModularWindow.Builder builder, boolean isIndex0) { + TextFieldWidget widget = new TextFieldWidget(); + builder.widget(widget.setGetter(() -> isIndex0 ? value0s : value1s) + .setSetter(str -> { + double val; + try { + val = parse(str); + } catch (Exception e) { + // This shouldn't happen as long as validator works + str = ""; + val = 0; + } + if (isIndex0) { + value0s = str; + value0D = val; + } else { + value1s = str; + value1D = val; + } + }) + .setValidator(str -> { + try { + parse(str); + return str; + } catch (Exception e) { + return widget.getLastText().size() > 0 + ? widget.getLastText().get(0) + : ""; + } + }) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(26, isIndex0 ? 26 : 41) + .setSize(138, 12)); + } + + private double parse(String str) { + double val; + if (str.contains("b")) { + String[] split = str.split("b"); + val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else if (str.contains("x")) { + String[] split = str.split("x"); + val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else { + val = TT_Utility.stringToDouble(str); + } + return val; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/TextParametersMessage.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/TextParametersMessage.java deleted file mode 100644 index 8058c14cf4..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/TextParametersMessage.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.hatch; - -import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_ParamText; -import com.github.technus.tectech.util.TT_Utility; -import cpw.mods.fml.common.network.ByteBufUtils; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; -import eu.usrv.yamcore.network.server.AbstractServerMessageHandler; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; - -public class TextParametersMessage implements IMessage { - int mPosX; - int mPosY; - int mPosZ; - int mPosD; - String mVal0 = ""; - String mVal1 = ""; - - public TextParametersMessage() {} - - @Override - public void fromBytes(ByteBuf pBuffer) { - NBTTagCompound tTag = ByteBufUtils.readTag(pBuffer); - mPosX = tTag.getInteger("posx"); - mPosY = tTag.getInteger("posy"); - mPosZ = tTag.getInteger("posz"); - mPosD = tTag.getInteger("posd"); - mVal0 = tTag.getString("value0s"); - mVal1 = tTag.getString("value1s"); - } - - @Override - public void toBytes(ByteBuf pBuffer) { - NBTTagCompound tFXTag = new NBTTagCompound(); - tFXTag.setInteger("posx", mPosX); - tFXTag.setInteger("posy", mPosY); - tFXTag.setInteger("posz", mPosZ); - tFXTag.setInteger("posd", mPosD); - tFXTag.setString("value0s", mVal0); - tFXTag.setString("value1s", mVal1); - ByteBufUtils.writeTag(pBuffer, tFXTag); - } - - public static class ParametersTextQuery extends TextParametersMessage { - public ParametersTextQuery() {} - - public ParametersTextQuery(GT_MetaTileEntity_Hatch_ParamText metaTile) { - IGregTechTileEntity base = metaTile.getBaseMetaTileEntity(); - mPosX = base.getXCoord(); - mPosY = base.getYCoord(); - mPosZ = base.getZCoord(); - mPosD = base.getWorld().provider.dimensionId; - } - } - - public static class ParametersTextData extends TextParametersMessage { - public ParametersTextData() {} - - public ParametersTextData(GT_MetaTileEntity_Hatch_ParamText metaTile) { - IGregTechTileEntity base = metaTile.getBaseMetaTileEntity(); - mPosX = base.getXCoord(); - mPosY = base.getYCoord(); - mPosZ = base.getZCoord(); - mPosD = base.getWorld().provider.dimensionId; - mVal0 = metaTile.value0s; - mVal1 = metaTile.value1s; - } - } - - public static class ParametersTextUpdate extends TextParametersMessage { - public ParametersTextUpdate() {} - - public ParametersTextUpdate(GT_MetaTileEntity_Hatch_ParamText metaTile) { - IGregTechTileEntity base = metaTile.getBaseMetaTileEntity(); - mPosX = base.getXCoord(); - mPosY = base.getYCoord(); - mPosZ = base.getZCoord(); - mPosD = base.getWorld().provider.dimensionId; - mVal0 = metaTile.value0s; - mVal1 = metaTile.value1s; - } - } - - public static class ClientHandler extends AbstractClientMessageHandler<ParametersTextData> { - @Override - public IMessage handleClientMessage(EntityPlayer pPlayer, ParametersTextData pMessage, MessageContext pCtx) { - if (pPlayer.worldObj.provider.dimensionId == pMessage.mPosD) { - TileEntity te = pPlayer.worldObj.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ); - if (te instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); - if (meta instanceof GT_MetaTileEntity_Hatch_ParamText) { - ((GT_MetaTileEntity_Hatch_ParamText) meta).value0s = pMessage.mVal0; - ((GT_MetaTileEntity_Hatch_ParamText) meta).value1s = pMessage.mVal1; - if (Minecraft.getMinecraft().currentScreen instanceof GT_GUIContainer_ParamText) { - GT_GUIContainer_ParamText gui = - ((GT_GUIContainer_ParamText) Minecraft.getMinecraft().currentScreen); - if (gui.mContainer == meta) { - gui.setTextIn0(pMessage.mVal0); - gui.setTextIn1(pMessage.mVal1); - } - } - } - } - } - return null; - } - } - - public static class ServerHandler extends AbstractServerMessageHandler<ParametersTextQuery> { - @Override - public IMessage handleServerMessage(EntityPlayer pPlayer, ParametersTextQuery pMessage, MessageContext pCtx) { - World world = DimensionManager.getWorld(pMessage.mPosD); - if (world != null) { - TileEntity te = world.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ); - if (te instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); - if (meta instanceof GT_MetaTileEntity_Hatch_ParamText) { - return new ParametersTextData((GT_MetaTileEntity_Hatch_ParamText) meta); - } - } - } - return null; - } - } - - public static class ServerUpdateHandler extends AbstractServerMessageHandler<ParametersTextUpdate> { - @Override - public IMessage handleServerMessage(EntityPlayer pPlayer, ParametersTextUpdate pMessage, MessageContext pCtx) { - World world = DimensionManager.getWorld(pMessage.mPosD); - if (world != null) { - TileEntity te = world.getTileEntity(pMessage.mPosX, pMessage.mPosY, pMessage.mPosZ); - if (te instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); - if (meta instanceof GT_MetaTileEntity_Hatch_ParamText) { - ((GT_MetaTileEntity_Hatch_ParamText) meta).value0s = pMessage.mVal0; - ((GT_MetaTileEntity_Hatch_ParamText) meta).value1s = pMessage.mVal1; - ((GT_MetaTileEntity_Hatch_ParamText) meta).value0D = TT_Utility.getValue(pMessage.mVal0); - ((GT_MetaTileEntity_Hatch_ParamText) meta).value1D = TT_Utility.getValue(pMessage.mVal1); - } - } - } - return null; - } - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java deleted file mode 100644 index f5e0ffd45d..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; -import com.github.technus.tectech.util.TT_Utility; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_Param extends GT_ContainerMetaTile_Machine { - public int param = 0; - public double value0d = 0; - public double value1d = 0; - public double input0d = 0; - public double input1d = 0; - public long value0l = 0; - public long value1l = 0; - public long input0l = 0; - public long input1l = 0; - - public GT_Container_Param(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); - boolean doStuff = true; - if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { - GT_MetaTileEntity_Hatch_Param paramH = (GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity(); - switch (aSlotIndex) { - case 0: - paramH.param -= aShifthold == 1 ? 16 : 4; - break; - case 1: - paramH.value0D -= aShifthold == 1 ? 4096 : 256; - break; - case 2: - paramH.value1D -= aShifthold == 1 ? 4096 : 256; - break; - case 3: - paramH.value0D /= aShifthold == 1 ? 4096 : 256; - paramH.value1D /= aShifthold == 1 ? 4096 : 256; - break; - case 4: - paramH.param -= aShifthold == 1 ? 2 : 1; - break; - case 5: - paramH.value0D -= aShifthold == 1 ? 16 : 1; - break; - case 6: - paramH.value1D -= aShifthold == 1 ? 16 : 1; - break; - case 7: - paramH.value0D /= aShifthold == 1 ? 16 : 2; - paramH.value1D /= aShifthold == 1 ? 16 : 2; - break; - case 8: - paramH.param += aShifthold == 1 ? 16 : 4; - break; - case 9: - paramH.value0D += aShifthold == 1 ? 4096 : 256; - break; - case 10: - paramH.value1D += aShifthold == 1 ? 4096 : 256; - break; - case 11: - paramH.value0D *= aShifthold == 1 ? 4096 : 256; - paramH.value1D *= aShifthold == 1 ? 4096 : 256; - break; - case 12: - paramH.param += aShifthold == 1 ? 2 : 1; - break; - case 13: - paramH.value0D += aShifthold == 1 ? 16 : 1; - break; - case 14: - paramH.value1D += aShifthold == 1 ? 16 : 1; - break; - case 15: - paramH.value0D *= aShifthold == 1 ? 16 : 2; - paramH.value1D *= aShifthold == 1 ? 16 : 2; - break; - default: - doStuff = false; - } - if (doStuff) { - IGregTechTileEntity base = paramH.getBaseMetaTileEntity(); - TecTech.proxy.playSound(base, "fx_click"); - if (paramH.param > 9) { - paramH.param = 9; - } else if (paramH.param < -1) { - paramH.param = -1; - } - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - param = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).param; - value0d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0D; - value1d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1D; - input0d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0D; - input1d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1D; - - for (Object crafter : crafters) { - ICrafting var1 = (ICrafting) crafter; - TT_Utility.sendInteger(param, this, var1, 100); - TT_Utility.sendDouble(value0d, this, var1, 102); - TT_Utility.sendDouble(value1d, this, var1, 106); - TT_Utility.sendDouble(input0d, this, var1, 110); - TT_Utility.sendDouble(input1d, this, var1, 114); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100: - case 101: - param = TT_Utility.receiveInteger(param, 100, par1, par2); - return; - case 102: - case 103: - case 104: - case 105: - value0d = Double.longBitsToDouble(value0l = TT_Utility.receiveLong(value0l, 102, par1, par2)); - return; - case 106: - case 107: - case 108: - case 109: - value1d = Double.longBitsToDouble(value1l = TT_Utility.receiveLong(value1l, 106, par1, par2)); - return; - case 110: - case 111: - case 112: - case 113: - input0d = Double.longBitsToDouble(input0l = TT_Utility.receiveLong(input0l, 110, par1, par2)); - return; - case 114: - case 115: - case 116: - case 117: - input1d = Double.longBitsToDouble(input1l = TT_Utility.receiveLong(input1l, 114, par1, par2)); - return; - default: - } - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java deleted file mode 100644 index 26faae689f..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java +++ /dev/null @@ -1,283 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; -import com.github.technus.tectech.util.TT_Utility; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { - public int pointer = 0; - public int param = 0; - public double value1d = 0; - public double value0d = 0; - public double input0d = 0; - public double input1d = 0; - public long value0l = 0; - public long value1l = 0; - public long input0l = 0; - public long input1l = 0; - - public GT_Container_ParamAdv(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); - if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { - boolean doStuff = true; - GT_MetaTileEntity_Hatch_Param paramH = (GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity(); - int columnPointer = paramH.pointer & 0xff; - boolean secondRow = (paramH.pointer & 0x0100) != 0; - switch (aSlotIndex) { - case 0: - paramH.param -= aShifthold == 1 ? 16 : 4; - break; - case 1: - if (secondRow) { - secondRow = false; - } else { - columnPointer -= aShifthold == 1 ? 16 : 4; - } - break; - case 2: - if (secondRow) { - columnPointer -= aShifthold == 1 ? 16 : 4; - } else { - secondRow = true; - } - break; - case 3: - if (aShifthold == 1) { - if (secondRow) { - paramH.value1D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); - } else { - paramH.value0D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); - } - } else { - if (secondRow) { - long temp = Double.doubleToLongBits(paramH.value1D); - temp |= 1L << (long) columnPointer; - paramH.value1D = Double.longBitsToDouble(temp); - } else { - long temp = Double.doubleToLongBits(paramH.value0D); - temp |= 1L << (long) columnPointer; - paramH.value0D = Double.longBitsToDouble(temp); - } - } - break; - case 4: - paramH.param -= aShifthold == 1 ? 2 : 1; - break; - case 5: - if (secondRow) { - secondRow = false; - } else { - columnPointer -= aShifthold == 1 ? 2 : 1; - } - break; - case 6: - if (secondRow) { - columnPointer -= aShifthold == 1 ? 2 : 1; - } else { - secondRow = true; - } - break; - case 7: - if (aShifthold == 1) { - if (secondRow) { - paramH.value1D = Double.longBitsToDouble(0); - } else { - paramH.value0D = Double.longBitsToDouble(0); - } - } else { - if (secondRow) { - long temp = Double.doubleToLongBits(paramH.value1D); - temp &= ~(1L << (long) columnPointer); - paramH.value1D = Double.longBitsToDouble(temp); - } else { - long temp = Double.doubleToLongBits(paramH.value0D); - temp &= ~(1L << (long) columnPointer); - paramH.value0D = Double.longBitsToDouble(temp); - } - } - break; - case 8: - paramH.param += aShifthold == 1 ? 16 : 4; - break; - case 9: - if (secondRow) { - secondRow = false; - } else { - columnPointer += aShifthold == 1 ? 16 : 4; - } - break; - case 10: - if (secondRow) { - columnPointer += aShifthold == 1 ? 16 : 4; - } else { - secondRow = true; - } - break; - case 11: - paramH.value0D = paramH.input0D; - paramH.value1D = paramH.input1D; - break; - case 12: - paramH.param += aShifthold == 1 ? 2 : 1; - break; - case 13: - if (secondRow) { - secondRow = false; - } else { - columnPointer += aShifthold == 1 ? 2 : 1; - } - break; - case 14: - if (secondRow) { - columnPointer += aShifthold == 1 ? 2 : 1; - } else { - secondRow = true; - } - break; - case 15: - if (aShifthold == 1) { - if (secondRow) { - paramH.value1D = Double.longBitsToDouble(~Double.doubleToLongBits(paramH.value1D)); - } else { - paramH.value0D = Double.longBitsToDouble(~Double.doubleToLongBits(paramH.value1D)); - } - } else { - if (secondRow) { - long temp = Double.doubleToLongBits(paramH.value1D); - temp ^= 1L << (long) columnPointer; - paramH.value1D = Double.longBitsToDouble(temp); - } else { - long temp = Double.doubleToLongBits(paramH.value0D); - temp ^= 1L << (long) columnPointer; - paramH.value0D = Double.longBitsToDouble(temp); - } - } - break; - default: - doStuff = false; - } - if (doStuff) { - IGregTechTileEntity base = paramH.getBaseMetaTileEntity(); - TecTech.proxy.playSound(base, "fx_click"); - if (columnPointer >= 64) { - columnPointer = 63; - } else if (columnPointer < 0) { - columnPointer = 0; - } - paramH.pointer = secondRow ? columnPointer + 0x100 : columnPointer; - if (paramH.param > 9) { - paramH.param = 9; - } else if (paramH.param < -1) { - paramH.param = -1; - } - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - param = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).param; - value0d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0D; - value1d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1D; - input0d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0D; - input1d = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1D; - pointer = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).pointer; - - for (Object crafter : crafters) { - ICrafting var1 = (ICrafting) crafter; - TT_Utility.sendInteger(param, this, var1, 100); - TT_Utility.sendDouble(value0d, this, var1, 102); - TT_Utility.sendDouble(value1d, this, var1, 106); - TT_Utility.sendDouble(input0d, this, var1, 110); - TT_Utility.sendDouble(input1d, this, var1, 114); - TT_Utility.sendInteger(pointer, this, var1, 118); - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100: - case 101: - param = TT_Utility.receiveInteger(param, 100, par1, par2); - return; - case 102: - case 103: - case 104: - case 105: - value0d = Double.longBitsToDouble(value0l = TT_Utility.receiveLong(value0l, 102, par1, par2)); - return; - case 106: - case 107: - case 108: - case 109: - value1d = Double.longBitsToDouble(value1l = TT_Utility.receiveLong(value1l, 106, par1, par2)); - return; - case 110: - case 111: - case 112: - case 113: - input0d = Double.longBitsToDouble(input0l = TT_Utility.receiveLong(input0l, 110, par1, par2)); - return; - case 114: - case 115: - case 116: - case 117: - input1d = Double.longBitsToDouble(input1l = TT_Utility.receiveLong(input1l, 114, par1, par2)); - return; - case 118: - case 119: - pointer = TT_Utility.receiveInteger(pointer, 118, par1, par2); - return; - default: - } - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamText.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamText.java deleted file mode 100644 index f46e69184b..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamText.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.loader.NetworkDispatcher; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_ParamText; -import com.github.technus.tectech.thing.metaTileEntity.hatch.TextParametersMessage; -import com.github.technus.tectech.util.TT_Utility; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Slot_Holo; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import java.util.Objects; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class GT_Container_ParamText extends GT_ContainerMetaTile_Machine { - public int param = 0; - public double value0d = 0; - public double value1d = 0; - public double input0d = 0; - public double input1d = 0; - public long value0l = 0; - public long value1l = 0; - public long input0l = 0; - public long input1l = 0; - public String value0s = ""; - public String value1s = ""; - - public GT_Container_ParamText(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); - if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { - boolean doStuff = true; - GT_MetaTileEntity_Hatch_ParamText paramH = - (GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity(); - switch (aSlotIndex) { - case 0: - paramH.param -= aShifthold == 1 ? 16 : 4; - break; - case 1: - paramH.param -= aShifthold == 1 ? 2 : 1; - break; - case 2: - paramH.param += aShifthold == 1 ? 16 : 4; - break; - case 3: - paramH.param += aShifthold == 1 ? 2 : 1; - break; - default: - doStuff = false; - } - if (doStuff) { - IGregTechTileEntity base = paramH.getBaseMetaTileEntity(); - TecTech.proxy.playSound(base, "fx_click"); - if (paramH.param > 9) { - paramH.param = 9; - } else if (paramH.param < -1) { - paramH.param = -1; - } - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { - return; - } - param = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).param; - value0d = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value0D; - value1d = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value1D; - input0d = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).input0D; - input1d = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).input1D; - for (Object crafter : crafters) { - ICrafting var1 = (ICrafting) crafter; - TT_Utility.sendInteger(param, this, var1, 100); - TT_Utility.sendDouble(value0d, this, var1, 102); - TT_Utility.sendDouble(value1d, this, var1, 106); - TT_Utility.sendDouble(input0d, this, var1, 110); - TT_Utility.sendDouble(input1d, this, var1, 114); - } - if (!Objects.equals(value0s, ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value0s) - || !Objects.equals( - value0s, ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value0s)) { - value0s = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value0s; - value1s = ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity()).value1s; - for (Object object : crafters) { - if (object instanceof EntityPlayerMP) { - NetworkDispatcher.INSTANCE.sendTo( - new TextParametersMessage.ParametersTextData( - ((GT_MetaTileEntity_Hatch_ParamText) mTileEntity.getMetaTileEntity())), - (EntityPlayerMP) object); - } - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int par1, int par2) { - super.updateProgressBar(par1, par2); - switch (par1) { - case 100: - case 101: - param = TT_Utility.receiveInteger(param, 100, par1, par2); - return; - case 102: - case 103: - case 104: - case 105: - value0d = Double.longBitsToDouble(value0l = TT_Utility.receiveLong(value0l, 102, par1, par2)); - return; - case 106: - case 107: - case 108: - case 109: - value1d = Double.longBitsToDouble(value1l = TT_Utility.receiveLong(value1l, 106, par1, par2)); - return; - case 110: - case 111: - case 112: - case 113: - input0d = Double.longBitsToDouble(input0l = TT_Utility.receiveLong(input0l, 110, par1, par2)); - return; - case 114: - case 115: - case 116: - case 117: - input1d = Double.longBitsToDouble(input1l = TT_Utility.receiveLong(input1l, 114, par1, par2)); - return; - default: - } - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java deleted file mode 100644 index d5d3d64b37..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import com.github.technus.tectech.font.TecTechFontRender; -import com.github.technus.tectech.util.TT_Utility; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; -import org.lwjgl.opengl.GL11; - -public class GT_GUIContainer_Param extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_Param(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_Param(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Parametrizer.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (mContainer != null) { - TecTechFontRender.INSTANCE.drawSplitString( - "Parameters: " + ((GT_Container_Param) mContainer).param, 46, 7, 167, 0xffffff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u24EA\u2b07" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).input0d), - 46, - 16, - 167, - 0x22ddff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u2460\u2b07" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).input1d), - 46, - 24, - 167, - 0x00ffff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u24EA\u2b06" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).value0d), - 46, - 33, - 167, - 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u2460\u2b06" + TT_Utility.formatNumberExp(((GT_Container_Param) mContainer).value1d), - 46, - 41, - 167, - 0x0077ff); - GL11.glPushMatrix(); - GL11.glScalef(.5f, .5f, .5f); - TecTechFontRender.INSTANCE.drawSplitString( - "\u24EA\u2b06" - + TT_Utility.longBitsToShortString( - Double.doubleToLongBits(((GT_Container_Param) mContainer).value0d)), - 92, - 100, - 334, - 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u2460\u2b06" - + TT_Utility.longBitsToShortString( - Double.doubleToLongBits(((GT_Container_Param) mContainer).value1d)), - 92, - 116, - 334, - 0x0077ff); - GL11.glPopMatrix(); - } else { - TecTechFontRender.INSTANCE.drawSplitString("Parameters", 46, 7, 167, 0xffffff); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java deleted file mode 100644 index 512a70d0a5..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import com.github.technus.tectech.font.TecTechFontRender; -import com.github.technus.tectech.util.TT_Utility; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.InventoryPlayer; -import org.lwjgl.opengl.GL11; - -public class GT_GUIContainer_ParamAdv extends GT_GUIContainerMetaTile_Machine { - public GT_GUIContainer_ParamAdv(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_ParamAdv(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "ParametrizerAdv.png"); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (mContainer != null) { - TecTechFontRender.INSTANCE.drawSplitString( - "Parameters X: " + ((GT_Container_ParamAdv) mContainer).param, 46, 7, 167, 0xffffff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u24EA\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).input0d)), - 46, - 16, - 167, - 0x22ddff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u2460\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).input1d)), - 46, - 24, - 167, - 0x00ffff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u24EA\u2b06" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).value0d)), - 46, - 33, - 167, - 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u2460\u2b06" + TT_Utility.formatNumberExp((((GT_Container_ParamAdv) mContainer).value1d)), - 46, - 41, - 167, - 0x0077ff); - GL11.glPushMatrix(); - GL11.glScalef(.5f, .5f, .5f); - TecTechFontRender.INSTANCE.drawSplitString( - "\u24EA\u2b06" - + TT_Utility.longBitsToShortString( - Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value0d)), - 92, - 100, - 334, - 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u2460\u2b06" - + TT_Utility.longBitsToShortString( - Double.doubleToLongBits(((GT_Container_ParamAdv) mContainer).value1d)), - 92, - 116, - 334, - 0x0077ff); - GL11.glPopMatrix(); - TecTechFontRender.INSTANCE.drawSplitString( - "Pointer " - + Integer.toHexString(((GT_Container_ParamAdv) mContainer).pointer | 0x10000) - .substring(1), - 46, - 66, - 167, - 0x0033ff); - } else { - TecTechFontRender.INSTANCE.drawSplitString("Parameters X", 46, 7, 167, 0xffffff); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamText.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamText.java deleted file mode 100644 index bff21e5f98..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamText.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; - -import static gregtech.api.enums.GT_Values.RES_PATH_GUI; - -import com.github.technus.tectech.font.TecTechFontRender; -import com.github.technus.tectech.loader.NetworkDispatcher; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_ParamText; -import com.github.technus.tectech.thing.metaTileEntity.hatch.TextParametersMessage; -import com.github.technus.tectech.util.TT_Utility; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import java.util.Objects; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.entity.player.InventoryPlayer; - -public class GT_GUIContainer_ParamText extends GT_GUIContainerMetaTile_Machine { - private GuiTextField value0tb; - private GuiTextField value1tb; - - public GT_GUIContainer_ParamText(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(new GT_Container_ParamText(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "ParametrizerText.png"); - } - - @Override - public void initGui() { - super.initGui(); - value0tb = new GuiTextField( - TecTechFontRender.INSTANCE, - (this.width - 176) / 2 + 12 + 14, - (this.height - 166) / 2 + 26, - 156 - 18, - 12); - value0tb.setMaxStringLength(80); - value1tb = new GuiTextField( - TecTechFontRender.INSTANCE, - (this.width - 176) / 2 + 12 + 14, - (this.height - 166) / 2 + 41, - 156 - 18, - 12); - value1tb.setMaxStringLength(80); - updateValues(); - } - - @Override - public void onGuiClosed() { - super.onGuiClosed(); - value0tb.setFocused(false); - value1tb.setFocused(false); - updateValues(); - } - - @Override - protected void keyTyped(char p_73869_1_, int p_73869_2_) { - value0tb.textboxKeyTyped(p_73869_1_, p_73869_2_); - value1tb.textboxKeyTyped(p_73869_1_, p_73869_2_); - if ((p_73869_2_ != 1 && p_73869_2_ != this.mc.gameSettings.keyBindInventory.getKeyCode()) - || (!value0tb.isFocused() && !value1tb.isFocused())) { - super.keyTyped(p_73869_1_, p_73869_2_); - } - updateValues(); - } - - @Override - public void updateScreen() { - super.updateScreen(); - value0tb.updateCursorCounter(); - value1tb.updateCursorCounter(); - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - value0tb.drawTextBox(); - value1tb.drawTextBox(); - } - - @Override - protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_) { - super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_); - value0tb.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_); - value1tb.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_); - updateValues(); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (mContainer != null) { - TecTechFontRender.INSTANCE.drawSplitString( - "Parameters tXt: " + ((GT_Container_ParamText) mContainer).param, 46, 7, 167, 0xffffff); - TecTechFontRender.INSTANCE.drawSplitString("\u24EA\u2b06", 10, 29, 16, 0x00bbff); - TecTechFontRender.INSTANCE.drawSplitString("\u2460\u2b06", 10, 44, 16, 0x0077ff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u24EA\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamText) mContainer).input0d)), - 10, - 56, - 167, - 0x22ddff); - TecTechFontRender.INSTANCE.drawSplitString( - "\u2460\u2b07" + TT_Utility.formatNumberExp((((GT_Container_ParamText) mContainer).input1d)), - 10, - 65, - 167, - 0x00ffff); - } else { - TecTechFontRender.INSTANCE.drawSplitString("Parameters tXt", 46, 7, 167, 0xffffff); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } - - private void updateValues() { - updateIn0(); - updateIn1(); - } - - private void updateIn0() { - if (!value0tb.isFocused()) { - String str = value0tb.getText().toLowerCase(); - double val; - try { - if (str.contains("b")) { - String[] split = str.split("b"); - val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); - } else if (str.contains("x")) { - String[] split = str.split("x"); - val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); - } else { - val = TT_Utility.stringToDouble(str); - } - if (!Objects.equals( - ((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()) - .value0s, - value0tb.getText())) { - ((GT_Container_ParamText) mContainer).value0s = value0tb.getText(); - ((GT_Container_ParamText) mContainer).value0d = val; - ((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()) - .value0s = - value0tb.getText(); - - NetworkDispatcher.INSTANCE.sendToServer( - new TextParametersMessage.ParametersTextUpdate((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity())); - } - } catch (Exception e) { - value0tb.setText(((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()) - .value0s); - } - } - } - - private void updateIn1() { - if (!value1tb.isFocused()) { - String str = value1tb.getText().toLowerCase(); - double val; - try { - if (str.contains("b")) { - String[] split = str.split("b"); - val = TT_Utility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); - } else if (str.contains("x")) { - String[] split = str.split("x"); - val = TT_Utility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); - } else { - val = TT_Utility.stringToDouble(str); - } - if (!Objects.equals( - ((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()) - .value1s, - value1tb.getText())) { - ((GT_Container_ParamText) mContainer).value1s = value1tb.getText(); - ((GT_Container_ParamText) mContainer).value1d = val; - ((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()) - .value1s = - value1tb.getText(); - - NetworkDispatcher.INSTANCE.sendToServer( - new TextParametersMessage.ParametersTextUpdate((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity())); - } - } catch (Exception e) { - value1tb.setText(((GT_MetaTileEntity_Hatch_ParamText) - ((GT_Container_ParamText) mContainer).mTileEntity.getMetaTileEntity()) - .value1s); - } - } - } - - public void setTextIn0(String in0) { - ((GT_Container_ParamText) mContainer).value0s = in0; - this.value0tb.setText(in0); - } - - public void setTextIn1(String in1) { - ((GT_Container_ParamText) mContainer).value1s = in1; - this.value1tb.setText(in1); - } -} |