aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/gui
diff options
context:
space:
mode:
authorKiwi <42833050+Kiwi233@users.noreply.github.com>2020-05-24 08:28:19 +0800
committerGitHub <noreply@github.com>2020-05-24 08:28:19 +0800
commitf0bce85d3faf040d87a22d83250ae2d9767c3642 (patch)
treeed60c1d975c8b06a27cae03d148714f7bb9e9805 /src/main/java/gregtech/api/gui
parentac7282a30ef161101cabc921e52db5c5d7e0096c (diff)
parentd6c19a9b6434c8a4c59ea8452603f85cfd2ad208 (diff)
downloadGT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.gz
GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.bz2
GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.zip
Merge pull request #1 from GTNewHorizons/experimental
5/24
Diffstat (limited to 'src/main/java/gregtech/api/gui')
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container.java41
-rw-r--r--src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java48
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java12
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container_BasicTank.java7
-rw-r--r--src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java6
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java13
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java2
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java14
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java23
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUICover.java307
-rw-r--r--src/main/java/gregtech/api/gui/GT_Slot_Holo.java7
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java64
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java77
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java111
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java50
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java37
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java71
17 files changed, 819 insertions, 71 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java
index 49aa1d9fe8..4ce583cff5 100644
--- a/src/main/java/gregtech/api/gui/GT_Container.java
+++ b/src/main/java/gregtech/api/gui/GT_Container.java
@@ -167,7 +167,7 @@ public class GT_Container extends Container {
aSlot.putStack(var13.splitStack(tTempStackSize));
if (var13.stackSize == 0) {
- aPlayerInventory.setItemStack((ItemStack) null);
+ aPlayerInventory.setItemStack(null);
}
}
} else if (aSlot.canTakeStack(aPlayer)) {
@@ -176,7 +176,7 @@ public class GT_Container extends Container {
aHoldStack = aSlot.decrStackSize(tTempStackSize);
aPlayerInventory.setItemStack(aHoldStack);
if (tTempStack.stackSize == 0) {
- aSlot.putStack((ItemStack) null);
+ aSlot.putStack(null);
}
aSlot.onPickupFromSlot(aPlayer, aPlayerInventory.getItemStack());
} else if (aSlot.isItemValid(var13)) {
@@ -190,7 +190,7 @@ public class GT_Container extends Container {
}
var13.splitStack(tTempStackSize);
if (var13.stackSize == 0) {
- aPlayerInventory.setItemStack((ItemStack) null);
+ aPlayerInventory.setItemStack(null);
}
tTempStack.stackSize += tTempStackSize;
} else if (var13.stackSize <= aSlot.getSlotStackLimit()) {
@@ -205,7 +205,7 @@ public class GT_Container extends Container {
tTempStack = aSlot.decrStackSize(tTempStackSize);
if (tTempStack.stackSize == 0) {
- aSlot.putStack((ItemStack) null);
+ aSlot.putStack(null);
}
aSlot.onPickupFromSlot(aPlayer, aPlayerInventory.getItemStack());
@@ -225,7 +225,7 @@ public class GT_Container extends Container {
if (!var9) {
tTempStackSize = aPlayerInventory.getFirstEmptyStack();
- var9 |= tTempStackSize > -1;
+ var9 = tTempStackSize > -1;
}
if (var9 && aSlot.getHasStack()) {
@@ -236,7 +236,7 @@ public class GT_Container extends Container {
if (tTempStackSize > -1) {
aPlayerInventory.addItemStackToInventory(tTempStack);
aSlot.decrStackSize(aHoldStack.stackSize);
- aSlot.putStack((ItemStack) null);
+ aSlot.putStack(null);
aSlot.onPickupFromSlot(aPlayer, aHoldStack);
}
} else {
@@ -245,7 +245,7 @@ public class GT_Container extends Container {
aSlot.onPickupFromSlot(aPlayer, aHoldStack);
}
} else if (tTempStack != null && !aSlot.getHasStack() && aSlot.isItemValid(tTempStack)) {
- aPlayerInventory.setInventorySlotContents(aMouseclick, (ItemStack) null);
+ aPlayerInventory.setInventorySlotContents(aMouseclick, null);
aSlot.putStack(tTempStack);
}
}
@@ -315,18 +315,19 @@ public class GT_Container extends Container {
var8 = var7.getStack();
if (!(var7 instanceof GT_Slot_Holo) && !(var7 instanceof GT_Slot_Output) && var8 != null && var8.getItem() == aStack.getItem() && (!aStack.getHasSubtypes() || aStack.getItemDamage() == var8.getItemDamage()) && ItemStack.areItemStackTagsEqual(aStack, var8)) {
int var9 = var8.stackSize + aStack.stackSize;
- if(var8.stackSize<mTileEntity.getInventoryStackLimit()){
- if (var9 <= aStack.getMaxStackSize()) {
- aStack.stackSize = 0;
- var8.stackSize = var9;
- var7.onSlotChanged();
- var5 = true;
- } else if (var8.stackSize < aStack.getMaxStackSize()) {
- aStack.stackSize -= aStack.getMaxStackSize() - var8.stackSize;
- var8.stackSize = aStack.getMaxStackSize();
- var7.onSlotChanged();
- var5 = true;
- }}
+ if (var8.stackSize < mTileEntity.getInventoryStackLimit()) {
+ if (var9 <= aStack.getMaxStackSize()) {
+ aStack.stackSize = 0;
+ var8.stackSize = var9;
+ var7.onSlotChanged();
+ var5 = true;
+ } else if (var8.stackSize < aStack.getMaxStackSize()) {
+ aStack.stackSize -= aStack.getMaxStackSize() - var8.stackSize;
+ var8.stackSize = aStack.getMaxStackSize();
+ var7.onSlotChanged();
+ var5 = true;
+ }
+ }
}
if (par4) {
@@ -348,7 +349,7 @@ public class GT_Container extends Container {
var8 = var7.getStack();
if (var8 == null) {
- int var10 = Math.min(aStack.stackSize, mTileEntity.getInventoryStackLimit());
+ int var10 = Math.min(aStack.stackSize, mTileEntity.getInventoryStackLimit());
var7.putStack(GT_Utility.copyAmount(var10, aStack));
var7.onSlotChanged();
aStack.stackSize -= var10;
diff --git a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
index 14d2db52dd..33bdec53e1 100644
--- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
+++ b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java
@@ -8,8 +8,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
-import java.util.Iterator;
-
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
@@ -17,8 +15,29 @@ import java.util.Iterator;
*/
public class GT_ContainerMetaTile_Machine extends GT_Container {
- public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mEnergy = 0, mSteam = 0, mSteamStorage = 0, mStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0;
- private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oEnergy = 0, oSteam = 0, oSteamStorage = 0, oStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0, mTimer = 0;
+ public int mActive = 0,
+ mMaxProgressTime = 0,
+ mProgressTime = 0,
+ mEnergy = 0,
+ mSteam = 0,
+ mSteamStorage = 0,
+ mStorage = 0,
+ mOutput = 0,
+ mInput = 0,
+ mID = 0,
+ mDisplayErrorCode = 0;
+ private int oActive = 0,
+ oMaxProgressTime = 0,
+ oProgressTime = 0,
+ oEnergy = 0,
+ oSteam = 0,
+ oSteamStorage = 0,
+ oStorage = 0,
+ oOutput = 0,
+ oInput = 0,
+ oID = 0,
+ oDisplayErrorCode = 0,
+ mTimer = 0;
public GT_ContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
@@ -28,19 +47,22 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) {
addSlots(aInventoryPlayer);
- if (doesBindPlayerInventory()) bindPlayerInventory(aInventoryPlayer);
+ if (doesBindPlayerInventory())
+ bindPlayerInventory(aInventoryPlayer);
detectAndSendChanges();
} else {
aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer;
}
}
+
public GT_ContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, boolean doesBindInventory) {
super(aInventoryPlayer, aTileEntity);
mTileEntity = aTileEntity;
if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) {
addSlots(aInventoryPlayer);
- if (doesBindPlayerInventory() && doesBindInventory) bindPlayerInventory(aInventoryPlayer);
+ if (doesBindPlayerInventory() && doesBindInventory)
+ bindPlayerInventory(aInventoryPlayer);
detectAndSendChanges();
} else {
aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer;
@@ -50,7 +72,8 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
- if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return;
+ if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null)
+ return;
mStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getEUCapacity());
mEnergy = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredEU());
mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity());
@@ -63,9 +86,8 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
mActive = mTileEntity.isActive() ? 1 : 0;
mTimer++;
- Iterator var2 = this.crafters.iterator();
- while (var2.hasNext()) {
- ICrafting var1 = (ICrafting) var2.next();
+ for (Object crafter : this.crafters) {
+ ICrafting var1 = (ICrafting) crafter;
if (mTimer % 500 == 10 || oEnergy != mEnergy) {
var1.sendProgressBarUpdate(this, 0, mEnergy & 65535);
var1.sendProgressBarUpdate(this, 1, mEnergy >>> 16);
@@ -183,8 +205,8 @@ public class GT_ContainerMetaTile_Machine extends GT_Container {
public boolean canInteractWith(EntityPlayer player) {
return mTileEntity.isUseableByPlayer(player);
}
-
- public String trans(String aKey, String aEnglish){
- return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false);
+
+ public String trans(String aKey, String aEnglish) {
+ return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false);
}
} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java
index 2dbc298d44..7e14061d2f 100644
--- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java
+++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java
@@ -10,8 +10,6 @@ import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
-import java.util.Iterator;
-
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
@@ -19,7 +17,10 @@ import java.util.Iterator;
*/
public class GT_Container_BasicMachine extends GT_Container_BasicTank {
- public boolean mFluidTransfer = false, mItemTransfer = false, mStuttering = false;
+ public boolean
+ mFluidTransfer = false,
+ mItemTransfer = false,
+ mStuttering = false;
public GT_Container_BasicMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
super(aInventoryPlayer, aTileEntity);
@@ -201,9 +202,8 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank {
mItemTransfer = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mItemTransfer;
mStuttering = ((GT_MetaTileEntity_BasicMachine) mTileEntity.getMetaTileEntity()).mStuttering;
- Iterator var2 = this.crafters.iterator();
- while (var2.hasNext()) {
- ICrafting var1 = (ICrafting) var2.next();
+ for (Object crafter : this.crafters) {
+ ICrafting var1 = (ICrafting) crafter;
var1.sendProgressBarUpdate(this, 102, mFluidTransfer ? 1 : 0);
var1.sendProgressBarUpdate(this, 103, mItemTransfer ? 1 : 0);
var1.sendProgressBarUpdate(this, 104, mStuttering ? 1 : 0);
diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
index aeb0ef0c45..c80874eef4 100644
--- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
+++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
@@ -8,8 +8,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
-import java.util.Iterator;
-
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
@@ -38,9 +36,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
mContent = ((GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity()).mFluid.amount;
else
mContent = 0;
- Iterator var2 = this.crafters.iterator();
- while (var2.hasNext()) {
- ICrafting var1 = (ICrafting) var2.next();
+ for (Object crafter : this.crafters) {
+ ICrafting var1 = (ICrafting) crafter;
var1.sendProgressBarUpdate(this, 100, mContent & 65535);
var1.sendProgressBarUpdate(this, 101, mContent >>> 16);
}
diff --git a/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java b/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java
index 5c469f8704..c8a70e71f2 100644
--- a/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java
+++ b/src/main/java/gregtech/api/gui/GT_Container_MaintenanceHatch.java
@@ -19,11 +19,13 @@ public class GT_Container_MaintenanceHatch extends GT_ContainerMetaTile_Machine
@Override
public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) {
- if (aSlotIndex != 0) return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
+ if (aSlotIndex != 0)
+ return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
ItemStack tStack = aPlayer.inventory.getItemStack();
if (tStack != null) {
((GT_MetaTileEntity_Hatch_Maintenance) mTileEntity.getMetaTileEntity()).onToolClick(tStack, aPlayer);
- if (tStack.stackSize <= 0) aPlayer.inventory.setItemStack(null);
+ if (tStack.stackSize <= 0)
+ aPlayer.inventory.setItemStack(null);
}
return null;
}
diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java
index 9cdb74c2f1..532ce85146 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java
@@ -28,11 +28,14 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer {
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
if (GregTech_API.sColoredGUI && mContainer != null && mContainer.mTileEntity != null) {
- byte colorByte=mContainer.mTileEntity.getColorization();
+ byte colorByte = mContainer.mTileEntity.getColorization();
Dyes color;
- if(colorByte != -1) color= Dyes.get(colorByte);
- else color=Dyes.MACHINE_METAL;
- GL11.glColor3ub((byte)color.mRGBa[0], (byte)color.mRGBa[1], (byte)color.mRGBa[2]);
- } else GL11.glColor3ub((byte)255,(byte)255,(byte)255);
+ if (colorByte != -1)
+ color = Dyes.get(colorByte);
+ else
+ color = Dyes.MACHINE_METAL;
+ GL11.glColor3ub((byte) color.mRGBa[0], (byte) color.mRGBa[1], (byte) color.mRGBa[2]);
+ } else
+ GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
}
} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java
index acf9d54c15..ae17087670 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java
@@ -16,7 +16,7 @@ public class GT_GUIContainer_2by2 extends GT_GUIContainerMetaTile_Machine {
public GT_GUIContainer_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) {
super(new GT_Container_2by2(aInventoryPlayer, aTileEntity), RES_PATH_GUI + aBackground + "2by2.png");
- mName = aName;
+ mName = aName;
}
@Override
diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java
index 0a2176010c..3bb802fcf7 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java
@@ -17,8 +17,12 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
*/
public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machine {
- public final String mName, mNEI;
- public final byte mProgressBarDirection, mProgressBarAmount;
+ public final String
+ mName,
+ mNEI;
+ public final byte
+ mProgressBarDirection,
+ mProgressBarAmount;
public GT_GUIContainer_BasicMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile, String aNEI) {
this(aInventoryPlayer, aTileEntity, aName, aTextureFile, aNEI, (byte) 0, (byte) 1);
@@ -34,8 +38,8 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin
@Override
public void drawScreen(int par1, int par2, float par3) {
- super.drawScreen(par1, par2, par3);
- drawTooltip(par1, par2);
+ super.drawScreen(par1, par2, par3);
+ drawTooltip(par1, par2);
}
@Override
@@ -48,7 +52,7 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin
int yStart = (height - ySize) / 2;
int x = x2 - xStart;
int y = y2 - yStart + 5;
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
if (y >= 67 && y <= 84) {
if (x >= 7 && x <= 24) {
list.add("Fluid Auto-Output");
diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java
index 470f504f19..0620701311 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java
@@ -13,7 +13,6 @@ import net.minecraft.item.ItemStack;
import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
-
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
@@ -36,27 +35,27 @@ public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machin
if (mContainer != null) {//(mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64));
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 1) != 0)
- fontRendererObj.drawString(trans("132","Pipe is loose."), 10, 16, 16448255);
+ fontRendererObj.drawString(trans("132", "Pipe is loose."), 10, 16, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 2) != 0)
- fontRendererObj.drawString(trans("133","Screws are loose."), 10, 24, 16448255);
+ fontRendererObj.drawString(trans("133", "Screws are loose."), 10, 24, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 4) != 0)
- fontRendererObj.drawString(trans("134","Something is stuck."), 10, 32, 16448255);
+ fontRendererObj.drawString(trans("134", "Something is stuck."), 10, 32, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 8) != 0)
- fontRendererObj.drawString(trans("135","Platings are dented."), 10, 40, 16448255);
+ fontRendererObj.drawString(trans("135", "Platings are dented."), 10, 40, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 16) != 0)
- fontRendererObj.drawString(trans("136","Circuitry burned out."), 10, 48, 16448255);
+ fontRendererObj.drawString(trans("136", "Circuitry burned out."), 10, 48, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 32) != 0)
- fontRendererObj.drawString(trans("137","That doesn't belong there."), 10, 56, 16448255);
+ fontRendererObj.drawString(trans("137", "That doesn't belong there."), 10, 56, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 64) != 0)
- fontRendererObj.drawString(trans("138","Incomplete Structure."), 10, 64, 16448255);
+ fontRendererObj.drawString(trans("138", "Incomplete Structure."), 10, 64, 16448255);
if (((GT_Container_MultiMachine) mContainer).mDisplayErrorCode == 0) {
if (((GT_Container_MultiMachine) mContainer).mActive == 0) {
- fontRendererObj.drawString(trans("139","Hit with Soft Mallet"), 10, 16, 16448255);
- fontRendererObj.drawString(trans("140","to (re-)start the Machine"), 10, 24, 16448255);
- fontRendererObj.drawString(trans("141","if it doesn't start."), 10, 32, 16448255);
+ fontRendererObj.drawString(trans("139", "Hit with Soft Mallet"), 10, 16, 16448255);
+ fontRendererObj.drawString(trans("140", "to (re-)start the Machine"), 10, 24, 16448255);
+ fontRendererObj.drawString(trans("141", "if it doesn't start."), 10, 32, 16448255);
} else {
- fontRendererObj.drawString(trans("142","Running perfectly."), 10, 16, 16448255);
+ fontRendererObj.drawString(trans("142", "Running perfectly."), 10, 16, 16448255);
}
if (mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_DrillerBase) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
diff --git a/src/main/java/gregtech/api/gui/GT_GUICover.java b/src/main/java/gregtech/api/gui/GT_GUICover.java
new file mode 100644
index 0000000000..94346186a8
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/GT_GUICover.java
@@ -0,0 +1,307 @@
+package gregtech.api.gui;
+
+import gregtech.api.enums.Dyes;
+import gregtech.api.gui.widgets.GT_GuiFakeItemButton;
+import gregtech.api.gui.widgets.GT_GuiIntegerTextBox;
+import gregtech.api.gui.widgets.GT_GuiTooltip;
+import gregtech.api.gui.widgets.GT_GuiTooltipManager;
+import gregtech.api.gui.widgets.GT_GuiTooltipManager.GT_IToolTipRenderer;
+import gregtech.api.interfaces.IGuiScreen;
+import gregtech.api.interfaces.tileentity.ICoverable;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRenderer, IGuiScreen {
+
+ protected GT_GuiTooltipManager ttManager = new GT_GuiTooltipManager();
+
+ protected int gui_width = 176;
+ protected int gui_height = 107;
+ protected int guiTop, guiLeft;
+ protected boolean drawButtons = true;
+ private GuiButton selectedButton;
+ public String header;
+ public GT_GuiFakeItemButton headerIcon;
+ public final ICoverable tile;
+
+
+ protected List<IGuiElement> elements = new ArrayList<>();
+ protected List<GT_GuiIntegerTextBox> textBoxes = new ArrayList<>();
+
+ public GT_GUICover(ICoverable tile, int width, int height, ItemStack cover) {
+ this.tile = tile;
+ this.gui_width = width;
+ this.gui_height = height;
+ this.header = (cover != null) ? cover.getDisplayName() : "";
+ this.headerIcon = new GT_GuiFakeItemButton(this, 5, 5, null).setItem(cover);
+ }
+
+ @Override
+ public void initGui() {
+ guiLeft = (this.width - this.gui_width) / 2;
+ guiTop = (this.height - this.gui_height) / 2;
+
+ for (IGuiElement element : elements) {
+ if (element instanceof GuiButton)
+ buttonList.add(element);
+ if (element instanceof GT_GuiIntegerTextBox)
+ textBoxes.add((GT_GuiIntegerTextBox) element);
+ }
+
+ onInitGui(guiLeft, guiTop, gui_width, gui_height);
+
+ for (IGuiElement element : elements) {
+ element.onInit();
+ }
+ }
+
+ protected abstract void onInitGui(int guiLeft, int guiTop, int gui_width, int gui_height);
+
+ public void onMouseWheel(int x, int y, int delta) {
+ }
+
+ @Override
+ public void handleMouseInput() {
+ int delta = Mouse.getEventDWheel();
+ if (delta != 0) {
+ int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
+ onMouseWheel(i, j, delta);
+ }
+ super.handleMouseInput();
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float parTicks) {
+ drawDefaultBackground();
+
+ drawBackground(mouseX, mouseY, parTicks);
+
+ RenderHelper.disableStandardItemLighting();
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_DEPTH_TEST);
+ GL11.glDisable(GL12.GL_RESCALE_NORMAL);
+ if (drawButtons) {
+ RenderHelper.enableGUIStandardItemLighting();
+ for (IGuiElement e : elements)
+ e.draw(mouseX, mouseY, parTicks);
+ }
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(guiLeft, guiTop, 0.0F);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+
+ GL11.glDisable(GL11.GL_LIGHTING);
+ drawForegroundLayer(mouseX, mouseY, parTicks);
+ GL11.glEnable(GL11.GL_LIGHTING);
+
+ GL11.glPopMatrix();
+
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glEnable(GL11.GL_DEPTH_TEST);
+ RenderHelper.enableStandardItemLighting();
+ }
+
+ public void drawForegroundLayer(int mouseX, int mouseY, float parTicks) {
+ drawExtras(mouseX, mouseY, parTicks);
+ ttManager.onTick(this, mouseX, mouseY);
+ }
+
+ public void drawBackground(int mouseX, int mouseY, float parTicks) {
+ short[] color = Dyes.MACHINE_METAL.getRGBA();
+ GL11.glColor3ub((byte) color[0], (byte) color[1], (byte) color[2]);
+ this.mc.renderEngine.bindTexture(new ResourceLocation("gregtech:textures/gui/GuiCover.png"));
+ drawTexturedModalRect(guiLeft, guiTop, 0,0, gui_width, gui_height);
+ }
+
+ public void drawExtras(int mouseX, int mouseY, float parTicks) {
+ this.fontRendererObj.drawString(header, 25, 9, 0xFF222222);
+ }
+
+ @Override
+ public boolean doesGuiPauseGame()
+ {
+ return false;
+ }
+
+ public void closeScreen() {
+ this.mc.displayGuiScreen((GuiScreen) null);
+ this.mc.setIngameFocus();
+ }
+
+ @Override
+ public void updateScreen() {
+ super.updateScreen();
+ if (!tile.isUseableByPlayer(mc.thePlayer)) {
+ closeScreen();
+ return;
+ }
+ for (GuiTextField f : textBoxes) {
+ f.updateCursorCounter();
+ }
+ }
+
+ public void mouseClicked(int x, int y, int button) {
+ for (GT_GuiIntegerTextBox tBox : textBoxes) {
+ boolean hadFocus = tBox.isFocused();
+ tBox.mouseClicked(x,y,button);
+ if (tBox.isFocused() && button == 1) //rightclick -> lcear it
+ tBox.setText("0");
+ else if (hadFocus && !tBox.isFocused())
+ applyTextBox(tBox);
+ }
+ super.mouseClicked(x, y, button);
+ }
+
+ @Override
+ public void keyTyped(char c, int key) {
+ GT_GuiIntegerTextBox focusedTextBox = null;
+ for (GT_GuiIntegerTextBox textBox : textBoxes) {
+ if (textBox.isFocused())
+ focusedTextBox = textBox;
+ }
+
+ if (key == 1) { //esc
+ if(focusedTextBox != null) {
+ resetTextBox(focusedTextBox);
+ setFocusedTextBox(null);
+ return;
+ } else {
+ closeScreen();
+ }
+ }
+
+ if (c == '\t') { //tab
+ for (int i = 0; i < textBoxes.size(); i++) {
+ GT_GuiIntegerTextBox box = textBoxes.get(i);
+ if (box.isFocused()) {
+ applyTextBox(box);
+ setFocusedTextBox(((i+1) < textBoxes.size()) ? textBoxes.get(i+1) : null);
+ return;
+ }
+ }
+ }
+
+ if (focusedTextBox != null && focusedTextBox.textboxKeyTyped(c, key)){
+ return;
+ }
+
+ if (key == 28 && focusedTextBox != null) { // enter
+ applyTextBox(focusedTextBox);
+ setFocusedTextBox(null);
+ return;
+ }
+
+ if (key == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
+ if (focusedTextBox != null) {
+ applyTextBox(focusedTextBox);
+ setFocusedTextBox(null);
+ return;
+ }
+ closeScreen();
+ return;
+ }
+ super.keyTyped(c, key);
+ }
+
+ /**
+ * Button
+ */
+
+ public void actionPerformed(GuiButton button) {
+ selectedButton = button;
+ }
+
+ public void clearSelectedButton() {
+ selectedButton = null;
+ }
+ public GuiButton getSelectedButton(){return selectedButton;}
+
+ public void buttonClicked(GuiButton button) {
+
+ }
+
+ /**
+ * TextBoxes
+ */
+ private void setFocusedTextBox(GT_GuiIntegerTextBox boxToFocus) {
+ for (GT_GuiIntegerTextBox textBox : textBoxes) {
+ textBox.setFocused(textBox.equals(boxToFocus));
+ }
+ }
+ public void applyTextBox(GT_GuiIntegerTextBox box) {
+
+ }
+
+ public void resetTextBox(GT_GuiIntegerTextBox box) {
+
+ }
+
+ /**
+ * GT_IToolTipRenderer
+ */
+ @Override
+ public void drawHoveringText(List par1List, int par2, int par3, FontRenderer render) {
+ super.drawHoveringText(par1List, par2, par3, render);
+ }
+ @Override
+ public FontRenderer getFontRenderer() {
+ return super.fontRendererObj;
+ }
+ @Override
+ public void addToolTip(GT_GuiTooltip toolTip) {
+ ttManager.addToolTip(toolTip);
+ }
+ @Override
+ public boolean removeToolTip(GT_GuiTooltip toolTip) {
+ return ttManager.removeToolTip(toolTip);
+ }
+
+ /**
+ * Junk
+ */
+ @Override
+ public int getGuiTop() {
+ return guiTop;
+ }
+ @Override
+ public int getGuiLeft() {
+ return guiLeft;
+ }
+ @Override
+ public int getXSize() {
+ return gui_width;
+ }
+ @Override
+ public int getYSize() {
+ return gui_height;
+ }
+
+ public RenderItem getItemRenderer() {
+ return itemRender;
+ }
+
+ @Override
+ public void addElement(IGuiElement element) {
+ if (elements.contains(element))
+ return;
+ elements.add(element);
+ }
+ @Override
+ public boolean removeElement(IGuiElement element) {
+ return elements.remove(element);
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/GT_Slot_Holo.java b/src/main/java/gregtech/api/gui/GT_Slot_Holo.java
index c6b577514b..22d4f091a4 100644
--- a/src/main/java/gregtech/api/gui/GT_Slot_Holo.java
+++ b/src/main/java/gregtech/api/gui/GT_Slot_Holo.java
@@ -7,7 +7,9 @@ import net.minecraft.item.ItemStack;
public class GT_Slot_Holo extends Slot {
public final int mSlotIndex;
- public boolean mCanInsertItem, mCanStackItem;
+ public boolean
+ mCanInsertItem,
+ mCanStackItem;
public int mMaxStacksize = 127;
public GT_Slot_Holo(IInventory par1iInventory, int par2, int par3, int par4, boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize) {
@@ -35,7 +37,8 @@ public class GT_Slot_Holo extends Slot {
@Override
public ItemStack decrStackSize(int par1) {
- if (!mCanStackItem) return null;
+ if (!mCanStackItem)
+ return null;
return super.decrStackSize(par1);
}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java
new file mode 100644
index 0000000000..db7029d60f
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java
@@ -0,0 +1,64 @@
+package gregtech.api.gui.widgets;
+
+import gregtech.api.interfaces.IGuiScreen;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+
+public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
+
+ private final GT_GuiIcon bgIcon;
+ private ItemStack item;
+ private IGuiScreen gui;
+ private int x0, y0, xPosition, yPosition;
+ private int width, height;
+
+ public GT_GuiFakeItemButton(IGuiScreen gui, int x, int y, GT_GuiIcon bgIcon) {
+ this.gui = gui;
+ this.x0 = x;
+ this.y0 = y;
+ this.bgIcon = bgIcon;
+ item = null;
+ width = 18;
+ height = 18;
+ gui.addElement(this);
+ }
+
+ public GT_GuiFakeItemButton setItem(ItemStack i) {
+ item = i;
+ return this;
+ }
+
+ public ItemStack getItem(){
+ return item;
+ }
+
+ @Override
+ public void onInit() {
+ xPosition = x0 + gui.getGuiLeft();
+ yPosition = y0 + gui.getGuiTop();
+ }
+
+ @Override
+ public void draw(int mouseX, int mouseY, float parTicks) {
+ GL11.glColor4f(1, 1, 1, 1);
+ GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ if (bgIcon != null){
+ GT_GuiIcon.render(bgIcon, xPosition-1, yPosition-1, 18, 18,0,true);
+ }
+
+ if (item != null)
+ gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(), Minecraft.getMinecraft().getTextureManager(), item, xPosition, yPosition);
+
+ GL11.glPopAttrib();
+ }
+
+ public Rectangle getBounds() {
+ return new Rectangle(x0, y0, width, height);
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
new file mode 100644
index 0000000000..1c31462e62
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
@@ -0,0 +1,77 @@
+package gregtech.api.gui.widgets;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.ResourceLocation;
+
+public enum GT_GuiIcon {
+ BUTTON_NORMAL (0, 0, 0),
+ BUTTON_DOWN (0, 32, 0),
+ BUTTON_HIGHLIGHT (0, 32*2, 0),
+ BUTTON_HIGHLIGHT_DOWN (0, 32*3, 0),
+ BUTTON_DISABLED (0, 32*4, 0),
+
+ DISABLE (0, 0, 32),
+ REDSTONE_OFF (0, 32, 32),
+ REDSTONE_ON (0, 32*2, 32),
+ CHECKMARK (0, 32*3, 32),
+ CROSS (0, 32*4, 32),
+ WHITELIST (0, 32*5, 32),
+ BLACKLIST (0, 32*6, 32),
+
+ EXPORT (0, 0, 32*2),
+ IMPORT (0, 32, 32*2),
+ ALLOW_INPUT (0, 32*2, 32*2),
+ BLOCK_INPUT (0, 32*3, 32*2),
+
+ SLOT_DARKGRAY (1, 176,0,18,18),
+ SLOT_GRAY (1, 176,18,18,18);
+
+ private static final int T_SIZE = 256;
+ private static final ResourceLocation[] TEXTURES = {
+ new ResourceLocation("gregtech", "textures/gui/GuiButtons.png"),
+ new ResourceLocation("gregtech", "textures/gui/GuiCover.png")
+ };
+
+ public final int x, y, width, height;
+ public final GT_GuiIcon overlay;
+ private final int texID;
+
+ GT_GuiIcon(int texID, int x, int y, int width, int height, GT_GuiIcon overlay) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ this.overlay = overlay;
+ this.texID = texID;
+ }
+
+ GT_GuiIcon(int texID, int x, int y) {
+ this(texID, x, y,32,32,null);
+ }
+ GT_GuiIcon(int texID, int x, int y, int width, int height) {
+ this(texID, x, y, width, height,null);
+ }
+
+ public static void render(GT_GuiIcon icon, double x, double y, double width, double height, double zLevel, boolean doDraw) {
+ Tessellator tess = Tessellator.instance;
+ if (doDraw) {
+ Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURES[icon.texID]);
+ tess.startDrawingQuads();
+ }
+ double minU = (double) icon.x / T_SIZE;
+ double maxU = (double) (icon.x + icon.width) / T_SIZE;
+ double minV = (double) icon.y / T_SIZE;
+ double maxV = (double) (icon.y + icon.height) / T_SIZE;
+ tess.addVertexWithUV(x, y + height, zLevel, minU, maxV);
+ tess.addVertexWithUV(x + width, y + height, zLevel, maxU, maxV);
+ tess.addVertexWithUV(x + width, y + 0, zLevel, maxU, minV);
+ tess.addVertexWithUV(x, y + 0, zLevel, minU, minV);
+
+ if (icon.overlay != null)
+ render(icon.overlay, x, y, width, height, zLevel, false);
+
+ if (doDraw)
+ tess.draw();
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
new file mode 100644
index 0000000000..f68962f58f
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
@@ -0,0 +1,111 @@
+package gregtech.api.gui.widgets;
+
+import gregtech.api.interfaces.IGuiScreen;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import org.lwjgl.opengl.GL11;
+import java.awt.Rectangle;
+
+public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElement {
+ public static final int DEFAULT_WIDTH = 16;
+ public static final int DEFAULT_HEIGHT = 16;
+
+ protected GT_GuiIcon icon;
+ private int x0, y0;
+ private IGuiScreen gui;
+ private String[] tooltipText;
+
+ private GT_GuiTooltip tooltip;
+
+
+ public GT_GuiIconButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon icon) {
+ super(id, x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT, "");
+ this.gui = gui;
+ this.icon = icon;
+ this.x0 = x;
+ this.y0 = y;
+ gui.addElement(this);
+ }
+
+ public void onInit() {
+ if (tooltip != null)
+ gui.addToolTip(tooltip);
+ xPosition = x0 + gui.getGuiLeft();
+ yPosition = y0 + gui.getGuiTop();
+ }
+
+ @Override
+ public void draw(int mouseX, int mouseY, float parTicks) {
+ drawButton(Minecraft.getMinecraft(), mouseX, mouseY);
+ }
+
+ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
+ if (this.tooltip != null)
+ this.tooltip.enabled = true;
+
+ if (this.visible) {
+ //moused over
+ this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + width && mouseY < this.yPosition + height;
+
+ mouseDragged(mc, mouseX, mouseY);
+
+ GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ int x = xPosition;
+ int y = yPosition;
+ if(!this.field_146123_n) {
+ GL11.glColor4f(200F/255F, 210F/255F, 1, 1);
+ }
+ else
+ GL11.glColor4f(1, 1, 1, 1);
+
+ GT_GuiIcon.render(getButtonTexture(this.field_146123_n), x, y, width, height, 0, true);
+
+ GL11.glColor4f(1, 1, 1, 1);
+ if (icon != null) {
+ GT_GuiIcon.render(icon, x, y, width, height , 0, true);
+ }
+
+ GL11.glPopAttrib();
+ }
+ }
+
+ @Override
+ public void mouseReleased(int mouseX, int mouseY) {
+ this.gui.clearSelectedButton();
+ if(mousePressed(Minecraft.getMinecraft(), mouseX, mouseY))
+ this.gui.buttonClicked(this);
+ }
+
+ public GT_GuiIcon getButtonTexture(boolean mouseOver) {
+ if (!enabled)
+ return GT_GuiIcon.BUTTON_DISABLED;
+ if (this.equals(this.gui.getSelectedButton()))
+ return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN;
+ else
+ return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL;
+ }
+
+ public GT_GuiIcon getIcon() {
+ return icon;
+ }
+
+ public GT_GuiTooltip getTooltip() {
+ return tooltip;
+ }
+
+ public GT_GuiIconButton setTooltipText(String... text) {
+ if (tooltip == null)
+ tooltip = new GT_GuiTooltip(getBounds(), text);
+ else
+ tooltip.setToolTipText(text);
+ this.tooltipText = text;
+ return this;
+ }
+
+ public Rectangle getBounds() {
+ return new Rectangle(x0, y0, width, height);
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
new file mode 100644
index 0000000000..3f6fe64e73
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
@@ -0,0 +1,50 @@
+package gregtech.api.gui.widgets;
+
+import gregtech.api.interfaces.IGuiScreen;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiTextField;
+
+import java.awt.*;
+
+public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGuiElement {
+ private final int x0, y0;
+ private final IGuiScreen gui;
+ public final int id;
+
+ public GT_GuiIntegerTextBox(IGuiScreen gui, int id, int x, int y, int width, int height) {
+ super(Minecraft.getMinecraft().fontRenderer, x, y, width, height);
+ super.setText("");
+ this.id = id;
+ x0 = x;
+ y0 = y;
+ this.gui = gui;
+ gui.addElement(this);
+ }
+
+ @Override
+ public void onInit() {
+ xPosition = x0 + gui.getGuiLeft();
+ yPosition = y0 + gui.getGuiTop();
+ }
+
+ @Override
+ public void draw(int mouseX, int mouseY, float parTicks) {
+ super.drawTextBox();
+ }
+
+ public Rectangle getBounds() {
+ return new Rectangle(x0, y0, width, height);
+ }
+
+ public boolean validChar(char c, int key) {
+ return Character.isDigit(c);
+ }
+
+ @Override
+ public boolean textboxKeyTyped(char c, int key) {
+ if (validChar(c, key) || c == 1 || c == 3 || c == 22 || c == 24 || key == 14 || key == 199 || key == 203 || key == 205 || key == 207 || key == 211) {
+ return super.textboxKeyTyped(c, key);
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java
new file mode 100644
index 0000000000..d24437f018
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java
@@ -0,0 +1,37 @@
+package gregtech.api.gui.widgets;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class GT_GuiTooltip {
+
+ protected Rectangle bounds;
+ private List<String> text;
+ public boolean enabled = true;
+
+ public GT_GuiTooltip(Rectangle bounds, String... text) {
+ this.bounds = bounds;
+ setToolTipText(text);
+ }
+
+ protected void updateText() {
+ }
+
+ public void setToolTipText(String... text) {
+ if (text != null) {
+ this.text = new ArrayList<>(text.length);
+ for (int i = 0; i < text.length; i++) {
+ if (i == 0)
+ this.text.add("\u00a7f" + text[i]);
+ else
+ this.text.add("\u00a77" + text[i]);
+ }
+ } else
+ this.text = new ArrayList<>();
+ }
+
+ public List<String> getToolTipText() {
+ return text;
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java
new file mode 100644
index 0000000000..d0e6964abc
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java
@@ -0,0 +1,71 @@
+package gregtech.api.gui.widgets;
+
+import net.minecraft.client.gui.FontRenderer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GT_GuiTooltipManager {
+ public interface GT_IToolTipRenderer {
+ int getGuiLeft();
+ int getGuiTop();
+ int getXSize();
+ FontRenderer getFontRenderer();
+ void drawHoveringText(List<String> par1List, int par2, int par3, FontRenderer font);
+ }
+
+ private static final long DELAY = 5;
+ private int mouseStopped;
+ private int lastMouseX = -1;
+ private int lastMouseY = -1;
+ private final List<GT_GuiTooltip> tips = new ArrayList<>();
+
+ public void addToolTip(GT_GuiTooltip tip) {
+ if (!tips.contains(tip)) tips.add(tip);
+ }
+
+ public boolean removeToolTip(GT_GuiTooltip tip) {
+ return tips.remove(tip);
+ }
+
+ public final void onTick(GT_IToolTipRenderer render, int mouseX, int mouseY) {
+ if ((Math.abs(mouseX-lastMouseX) < 2 ) && (Math.abs(mouseY-lastMouseY) < 2 ))
+ mouseStopped = Math.min(mouseStopped+1, 50);
+ else
+ mouseStopped = 0;
+
+ lastMouseX = mouseX;
+ lastMouseY = mouseY;
+
+ if (mouseStopped > DELAY)
+ mouseX -= render.getGuiLeft();
+ mouseY -= render.getGuiTop();
+ for (GT_GuiTooltip tip : tips) {
+ if(tip.enabled && tip.bounds.contains(mouseX, mouseY)){
+ tip.updateText();
+ drawTooltip(tip, mouseX, mouseY, render);
+ break;
+ }
+ }
+ }
+
+ private void drawTooltip(GT_GuiTooltip tip, int mouseX, int mouseY, GT_IToolTipRenderer render) {
+ List<String> text = tip.getToolTipText();
+ if (text == null)
+ return;
+
+ if (mouseX > render.getGuiLeft() + render.getXSize()/2) {
+ int maxWidth = 0;
+ for (String s : text) {
+ int w = render.getFontRenderer().getStringWidth(s);
+ if (w > maxWidth) {
+ maxWidth = w;
+ }
+ }
+ mouseX -= (maxWidth + 18);
+ }
+
+ render.drawHoveringText(text, mouseX, mouseY, render.getFontRenderer());
+ }
+
+}