aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUICover.java11
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java1
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java12
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java31
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java12
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java58
6 files changed, 118 insertions, 7 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_GUICover.java b/src/main/java/gregtech/api/gui/GT_GUICover.java
index 94346186a8..f1232c9432 100644
--- a/src/main/java/gregtech/api/gui/GT_GUICover.java
+++ b/src/main/java/gregtech/api/gui/GT_GUICover.java
@@ -157,8 +157,10 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender
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
+ if (tBox.isEnabled() || hadFocus)
+ tBox.mouseClicked(x,y,button);
+
+ if (tBox.isFocused() && button == 1 && tBox.isEnabled()) //rightclick -> lcear it
tBox.setText("0");
else if (hadFocus && !tBox.isFocused())
applyTextBox(tBox);
@@ -193,6 +195,9 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender
return;
}
}
+ if (textBoxes.size() > 0 )
+ setFocusedTextBox(textBoxes.get(0));
+ return;
}
if (focusedTextBox != null && focusedTextBox.textboxKeyTyped(c, key)){
@@ -239,7 +244,7 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender
*/
private void setFocusedTextBox(GT_GuiIntegerTextBox boxToFocus) {
for (GT_GuiIntegerTextBox textBox : textBoxes) {
- textBox.setFocused(textBox.equals(boxToFocus));
+ textBox.setFocused(textBox.equals(boxToFocus) && textBox.isEnabled());
}
}
public void applyTextBox(GT_GuiIntegerTextBox box) {
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
index 1c31462e62..41e851054d 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
@@ -18,6 +18,7 @@ public enum GT_GuiIcon {
CROSS (0, 32*4, 32),
WHITELIST (0, 32*5, 32),
BLACKLIST (0, 32*6, 32),
+ PROGRESS (0, 32*7, 32),
EXPORT (0, 0, 32*2),
IMPORT (0, 32, 32*2),
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
index f68962f58f..e081c4227d 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
@@ -12,7 +12,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
protected GT_GuiIcon icon;
private int x0, y0;
- private IGuiScreen gui;
+ protected IGuiScreen gui;
private String[] tooltipText;
private GT_GuiTooltip tooltip;
@@ -56,7 +56,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
int x = xPosition;
int y = yPosition;
if(!this.field_146123_n) {
- GL11.glColor4f(200F/255F, 210F/255F, 1, 1);
+ // GL11.glColor4f(200F/255F, 210F/255F, 1, 1);
}
else
GL11.glColor4f(1, 1, 1, 1);
@@ -84,13 +84,17 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
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;
+
+ return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL;
}
public GT_GuiIcon getIcon() {
return icon;
}
+ public GT_GuiIconButton setIcon(GT_GuiIcon icon) {
+ this.icon = icon;
+ return this;
+ }
public GT_GuiTooltip getTooltip() {
return tooltip;
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
new file mode 100644
index 0000000000..4e6fd86f55
--- /dev/null
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
@@ -0,0 +1,31 @@
+package gregtech.api.gui.widgets;
+
+import gregtech.api.interfaces.IGuiScreen;
+
+public class GT_GuiIconCheckButton extends GT_GuiIconButton {
+ private GT_GuiIcon checkedIcon, normalIcon;
+ private boolean checked = false;
+
+ public GT_GuiIconCheckButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon checkedIcon, GT_GuiIcon normalIcon) {
+ super(gui, id, x, y, normalIcon);
+ this.checkedIcon = checkedIcon;
+ this.normalIcon = normalIcon;
+ }
+
+ public GT_GuiIcon getButtonTexture(boolean mouseOver) {
+ if (!enabled)
+ return GT_GuiIcon.BUTTON_DISABLED;
+ if (this.equals(super.gui.getSelectedButton()))
+ return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN;
+ return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL;
+ }
+
+ public boolean isChecked() {
+ return checked;
+ }
+
+ public void setChecked(boolean checked) {
+ super.setIcon(checked ? checkedIcon : normalIcon);
+ this.checked = checked;
+ }
+}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
index 3f6fe64e73..e2ba53e4c9 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
@@ -10,6 +10,7 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu
private final int x0, y0;
private final IGuiScreen gui;
public final int id;
+ private boolean enabled;
public GT_GuiIntegerTextBox(IGuiScreen gui, int id, int x, int y, int width, int height) {
super(Minecraft.getMinecraft().fontRenderer, x, y, width, height);
@@ -18,6 +19,7 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu
x0 = x;
y0 = y;
this.gui = gui;
+ enabled = true;
gui.addElement(this);
}
@@ -47,4 +49,14 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu
}
return false;
}
+
+ @Override
+ public void setEnabled(boolean p_146184_1_) {
+ super.setEnabled(p_146184_1_);
+ enabled = p_146184_1_;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 8584e849bb..f5dfb42a2c 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -665,6 +665,64 @@ public class GT_Utility {
return 0;
}
+ /**
+ * Moves Stack from Inv-Side to Inv-Slot.
+ *
+ * @return the Amount of moved Items
+ */
+ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) {
+ if (fromTile == null || aGrabFrom < 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce)
+ return 0;
+
+ if (!listContainsItem(aFilter, fromTile.getStackInSlot(aGrabFrom), true, aInvertFilter) ||
+ !isAllowedToTakeFromSlot(fromTile, aGrabFrom, (byte) 6, fromTile.getStackInSlot(aGrabFrom)))
+ return 0;
+
+ if (toTile instanceof IInventory) {
+ int[] tPutSlots = null;
+ if (toTile instanceof ISidedInventory)
+ tPutSlots = ((ISidedInventory) toTile).getAccessibleSlotsFromSide(aPutTo);
+
+ if (tPutSlots == null) {
+ tPutSlots = new int[((IInventory) toTile).getSizeInventory()];
+ for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i;
+ }
+
+ byte tMovedItemCount = 0;
+ for (int tPutSlot : tPutSlots) {
+ if (isAllowedToPutIntoSlot((IInventory) toTile, tPutSlot, aPutTo, fromTile.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) {
+ tMovedItemCount += moveStackFromSlotAToSlotB(fromTile, (IInventory) toTile, aGrabFrom, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce);
+ if (tMovedItemCount >= aMaxMoveAtOnce) {
+ return tMovedItemCount;
+
+ }
+ }
+ }
+ if (tMovedItemCount > 0) return tMovedItemCount;
+
+ if (aDoCheckChests && toTile instanceof TileEntityChest) {
+ TileEntityChest tTileEntity2 = (TileEntityChest) toTile;
+ if (tTileEntity2.adjacentChestChecked) {
+ if (tTileEntity2.adjacentChestXNeg != null) {
+ tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity2.adjacentChestZNeg != null) {
+ tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity2.adjacentChestXPos != null) {
+ tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ } else if (tTileEntity2.adjacentChestZPos != null) {
+ tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false);
+ }
+ if (tMovedItemCount > 0) return tMovedItemCount;
+ }
+ }
+ }
+ return moveStackIntoPipe(fromTile, toTile, new int[]{aGrabFrom}, (byte) 6, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests);
+ }
+
+ public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) {
+ return moveFromSlotToSide(fromTile, toTile, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true);
+ }
+
public static boolean listContainsItem(Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) {
if (aStack == null || aStack.stackSize < 1) return false;
if (aList == null) return aTIfListEmpty;