Clean up amount specifying GUIs.
This commit is contained in:
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.container;
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.container.slot.*;
|
import com.raoulvdberge.refinedstorage.container.slot.*;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiFluidAmount;
|
import com.raoulvdberge.refinedstorage.gui.grid.GuiGridPatternFluidAmount;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataWatcher;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataWatcher;
|
||||||
@@ -92,7 +92,7 @@ public abstract class ContainerBase extends Container {
|
|||||||
} else if (slot.getHasStack()) {
|
} else if (slot.getHasStack()) {
|
||||||
if (slot instanceof SlotFilterType && ((SlotFilterType) slot).getType().getType() == IType.FLUIDS) {
|
if (slot instanceof SlotFilterType && ((SlotFilterType) slot).getType().getType() == IType.FLUIDS) {
|
||||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
||||||
FMLClientHandler.instance().showGuiScreen(new GuiFluidAmount((GuiBase) Minecraft.getMinecraft().currentScreen, player, slot.getSlotIndex(), ((SlotFilterType) slot).getActualStack()));
|
FMLClientHandler.instance().showGuiScreen(new GuiGridPatternFluidAmount((GuiBase) Minecraft.getMinecraft().currentScreen, player, slot.getSlotIndex(), ((SlotFilterType) slot).getActualStack()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
slot.getStack().setCount(((SlotFilter) slot).getAmountModified(dragType));
|
slot.getStack().setCount(((SlotFilter) slot).getAmountModified(dragType));
|
||||||
|
|||||||
@@ -0,0 +1,188 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.gui;
|
||||||
|
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public abstract class GuiAmountSpecifying extends GuiBase {
|
||||||
|
protected GuiTextField amountField;
|
||||||
|
|
||||||
|
private GuiBase parent;
|
||||||
|
|
||||||
|
protected GuiButton okButton;
|
||||||
|
private GuiButton cancelButton;
|
||||||
|
|
||||||
|
private GuiButton[] incrementButtons = new GuiButton[6];
|
||||||
|
|
||||||
|
public GuiAmountSpecifying(GuiBase parent, Container container, int width, int height) {
|
||||||
|
super(container, width, height);
|
||||||
|
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract String getOkButtonText();
|
||||||
|
|
||||||
|
protected abstract String getTitle();
|
||||||
|
|
||||||
|
protected abstract String getTexture();
|
||||||
|
|
||||||
|
protected abstract int[] getIncrements();
|
||||||
|
|
||||||
|
protected abstract int getDefaultAmount();
|
||||||
|
|
||||||
|
protected abstract boolean canAmountGoNegative();
|
||||||
|
|
||||||
|
protected abstract int getMaxAmount();
|
||||||
|
|
||||||
|
protected Pair<Integer, Integer> getAmountPos() {
|
||||||
|
return Pair.of(7 + 2, 50 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Pair<Integer, Integer> getOkCancelPos() {
|
||||||
|
return Pair.of(114, 33);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(int x, int y) {
|
||||||
|
Pair<Integer, Integer> pos = getOkCancelPos();
|
||||||
|
|
||||||
|
okButton = addButton(x + pos.getLeft(), y + pos.getRight(), 50, 20, getOkButtonText());
|
||||||
|
cancelButton = addButton(x + pos.getLeft(), y + pos.getRight() + 24, 50, 20, t("gui.cancel"));
|
||||||
|
|
||||||
|
amountField = new GuiTextField(0, fontRenderer, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6, fontRenderer.FONT_HEIGHT);
|
||||||
|
amountField.setEnableBackgroundDrawing(false);
|
||||||
|
amountField.setVisible(true);
|
||||||
|
amountField.setText(String.valueOf(getDefaultAmount()));
|
||||||
|
amountField.setTextColor(16777215);
|
||||||
|
amountField.setCanLoseFocus(false);
|
||||||
|
amountField.setFocused(true);
|
||||||
|
|
||||||
|
int[] increments = getIncrements();
|
||||||
|
|
||||||
|
int xx = 7;
|
||||||
|
int width = 30;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
String text = "+" + increments[i];
|
||||||
|
|
||||||
|
if (text.equals("+1000")) {
|
||||||
|
text = "+1B";
|
||||||
|
}
|
||||||
|
|
||||||
|
incrementButtons[i] = addButton(x + xx, y + 20, width, 20, text);
|
||||||
|
|
||||||
|
xx += width + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
xx = 7;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
String text = "-" + increments[i];
|
||||||
|
|
||||||
|
if (text.equals("-1000")) {
|
||||||
|
text = "-1B";
|
||||||
|
}
|
||||||
|
|
||||||
|
incrementButtons[3 + i] = addButton(x + xx, y + screenHeight - 20 - 7, width, 20, text);
|
||||||
|
|
||||||
|
xx += width + 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(int x, int y) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||||
|
bindTexture(getTexture());
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||||
|
|
||||||
|
amountField.drawTextBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
|
drawString(7, 7, getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char character, int keyCode) throws IOException {
|
||||||
|
if (!checkHotbarKeys(keyCode) && amountField.textboxKeyTyped(character, keyCode)) {
|
||||||
|
// NO OP
|
||||||
|
} else {
|
||||||
|
if (keyCode == Keyboard.KEY_RETURN) {
|
||||||
|
onOkButtonPressed(isShiftKeyDown());
|
||||||
|
} else if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||||
|
close();
|
||||||
|
} else {
|
||||||
|
super.keyTyped(character, keyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
|
super.actionPerformed(button);
|
||||||
|
|
||||||
|
if (button.id == okButton.id) {
|
||||||
|
onOkButtonPressed(isShiftKeyDown());
|
||||||
|
} else if (button.id == cancelButton.id) {
|
||||||
|
close();
|
||||||
|
} else {
|
||||||
|
for (GuiButton incrementButton : incrementButtons) {
|
||||||
|
if (incrementButton.id == button.id) {
|
||||||
|
Integer oldAmount = Ints.tryParse(amountField.getText());
|
||||||
|
|
||||||
|
if (oldAmount == null) {
|
||||||
|
oldAmount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
String incrementButtonText = incrementButton.displayString;
|
||||||
|
|
||||||
|
if (incrementButtonText.equals("+1B")) {
|
||||||
|
incrementButtonText = "1000";
|
||||||
|
} else if (incrementButtonText.equals("-1B")) {
|
||||||
|
incrementButtonText = "-1000";
|
||||||
|
}
|
||||||
|
|
||||||
|
int newAmount = Integer.parseInt(incrementButtonText);
|
||||||
|
|
||||||
|
if (!canAmountGoNegative()) {
|
||||||
|
newAmount = Math.max(1, ((oldAmount == 1 && newAmount != 1) ? 0 : oldAmount) + newAmount);
|
||||||
|
} else {
|
||||||
|
newAmount = oldAmount + newAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newAmount > getMaxAmount()) {
|
||||||
|
newAmount = getMaxAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
amountField.setText(String.valueOf(newAmount));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onOkButtonPressed(boolean shiftDown) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
FMLClientHandler.instance().showGuiScreen(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiBase getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
package com.raoulvdberge.refinedstorage.gui;
|
package com.raoulvdberge.refinedstorage.gui;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiCraftingStart;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.util.Tuple;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
public class GuiPriority extends GuiCraftingStart {
|
public class GuiPriority extends GuiAmountSpecifying {
|
||||||
private TileDataParameter<Integer, ?> priority;
|
private TileDataParameter<Integer, ?> priority;
|
||||||
|
|
||||||
public GuiPriority(GuiBase parent, TileDataParameter<Integer, ?> priority) {
|
public GuiPriority(GuiBase parent, TileDataParameter<Integer, ?> priority) {
|
||||||
super(parent, null, new Container() {
|
super(parent, new Container() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player) {
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
return false;
|
return false;
|
||||||
@@ -23,12 +22,12 @@ public class GuiPriority extends GuiCraftingStart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getAmount() {
|
protected int getDefaultAmount() {
|
||||||
return priority.getValue();
|
return priority.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStartButtonText() {
|
protected String getOkButtonText() {
|
||||||
return t("misc.refinedstorage:set");
|
return t("misc.refinedstorage:set");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,18 +42,13 @@ public class GuiPriority extends GuiCraftingStart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Tuple<Integer, Integer> getAmountPos() {
|
protected Pair<Integer, Integer> getAmountPos() {
|
||||||
return new Tuple<>(18 + 1, 47 + 1);
|
return Pair.of(18 + 1, 47 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Tuple<Integer, Integer> getIncrementButtonPos(int x, int y) {
|
protected Pair<Integer, Integer> getOkCancelPos() {
|
||||||
return new Tuple<>(6 + (x * (30 + 3)), y + (y == 0 ? 20 : 64));
|
return Pair.of(107, 30);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Tuple<Integer, Integer> getStartCancelPos() {
|
|
||||||
return new Tuple<>(107, 30);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,6 +56,11 @@ public class GuiPriority extends GuiCraftingStart {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMaxAmount() {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int[] getIncrements() {
|
protected int[] getIncrements() {
|
||||||
return new int[]{
|
return new int[]{
|
||||||
@@ -71,7 +70,7 @@ public class GuiPriority extends GuiCraftingStart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startRequest(boolean noPreview) {
|
protected void onOkButtonPressed(boolean noPreview) {
|
||||||
Integer amount = Ints.tryParse(amountField.getText());
|
Integer amount = Ints.tryParse(amountField.getText());
|
||||||
|
|
||||||
if (amount != null) {
|
if (amount != null) {
|
||||||
|
|||||||
@@ -1,210 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.gui.grid;
|
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
|
||||||
import com.raoulvdberge.refinedstorage.container.ContainerCraftingSettings;
|
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreview;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
import net.minecraft.client.gui.GuiTextField;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.util.Tuple;
|
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
// TODO: Change quantities for fluid craft.
|
|
||||||
// TODO: Cleanup childclasses.
|
|
||||||
public class GuiCraftingStart extends GuiBase {
|
|
||||||
private static final int DEFAULT_AMOUNT = 1;
|
|
||||||
|
|
||||||
protected GuiTextField amountField;
|
|
||||||
private GuiBase parent;
|
|
||||||
private IGridStack stack;
|
|
||||||
private GuiButton startButton;
|
|
||||||
private GuiButton cancelButton;
|
|
||||||
private GuiButton[] incrementButtons = new GuiButton[6];
|
|
||||||
|
|
||||||
public GuiCraftingStart(GuiBase parent, IGridStack stack, Container container, int w, int h) {
|
|
||||||
super(container, w, h);
|
|
||||||
|
|
||||||
this.parent = parent;
|
|
||||||
this.stack = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiCraftingStart(GuiGrid parent, EntityPlayer player, IGridStack stack) {
|
|
||||||
this(parent, stack, new ContainerCraftingSettings(player, stack), 172, 99);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getStartButtonText() {
|
|
||||||
return t("misc.refinedstorage:start");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getTitle() {
|
|
||||||
return t("container.crafting");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getTexture() {
|
|
||||||
return "gui/crafting_settings.png";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int[] getIncrements() {
|
|
||||||
if (stack instanceof GridStackFluid) {
|
|
||||||
return new int[]{
|
|
||||||
1, 500, 1000,
|
|
||||||
-1, -500, -1000
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return new int[]{
|
|
||||||
1, 10, 64,
|
|
||||||
-1, -10, -64
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getAmount() {
|
|
||||||
return stack instanceof GridStackFluid ? 1000 : DEFAULT_AMOUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Tuple<Integer, Integer> getAmountPos() {
|
|
||||||
return new Tuple<>(7 + 1, 50 + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Tuple<Integer, Integer> getIncrementButtonPos(int x, int y) {
|
|
||||||
return new Tuple<>(6 + (x * (30 + 3)), y + (y == 0 ? 20 : 72));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Tuple<Integer, Integer> getStartCancelPos() {
|
|
||||||
return new Tuple<>(114, 33);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canAmountGoNegative() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(int x, int y) {
|
|
||||||
Tuple<Integer, Integer> pos = getStartCancelPos();
|
|
||||||
|
|
||||||
startButton = addButton(x + pos.getFirst(), y + pos.getSecond(), 50, 20, getStartButtonText());
|
|
||||||
cancelButton = addButton(x + pos.getFirst(), y + pos.getSecond() + 24, 50, 20, t("gui.cancel"));
|
|
||||||
|
|
||||||
amountField = new GuiTextField(0, fontRenderer, x + getAmountPos().getFirst(), y + getAmountPos().getSecond(), 69 - 6, fontRenderer.FONT_HEIGHT);
|
|
||||||
amountField.setEnableBackgroundDrawing(false);
|
|
||||||
amountField.setVisible(true);
|
|
||||||
amountField.setText(String.valueOf(getAmount()));
|
|
||||||
amountField.setTextColor(16777215);
|
|
||||||
amountField.setCanLoseFocus(false);
|
|
||||||
amountField.setFocused(true);
|
|
||||||
|
|
||||||
int[] increments = getIncrements();
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
pos = getIncrementButtonPos(i, 0);
|
|
||||||
|
|
||||||
incrementButtons[i] = addButton(x + pos.getFirst(), y + pos.getSecond(), 30, 20, "+" + increments[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
pos = getIncrementButtonPos(i, 1);
|
|
||||||
|
|
||||||
incrementButtons[3 + i] = addButton(x + pos.getFirst(), y + pos.getSecond(), 30, 20, String.valueOf(increments[3 + i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(int x, int y) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
|
||||||
bindTexture(getTexture());
|
|
||||||
|
|
||||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
|
||||||
|
|
||||||
amountField.drawTextBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawForeground(int mouseX, int mouseY) {
|
|
||||||
drawString(7, 7, getTitle());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char character, int keyCode) throws IOException {
|
|
||||||
if (!checkHotbarKeys(keyCode) && amountField.textboxKeyTyped(character, keyCode)) {
|
|
||||||
// NO OP
|
|
||||||
} else {
|
|
||||||
if (keyCode == Keyboard.KEY_RETURN) {
|
|
||||||
startRequest(isShiftKeyDown());
|
|
||||||
} else if (keyCode == Keyboard.KEY_ESCAPE) {
|
|
||||||
close();
|
|
||||||
} else {
|
|
||||||
super.keyTyped(character, keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void actionPerformed(GuiButton button) throws IOException {
|
|
||||||
super.actionPerformed(button);
|
|
||||||
|
|
||||||
if (button.id == startButton.id) {
|
|
||||||
startRequest(isShiftKeyDown());
|
|
||||||
} else if (button.id == cancelButton.id) {
|
|
||||||
close();
|
|
||||||
} else {
|
|
||||||
for (GuiButton incrementButton : incrementButtons) {
|
|
||||||
if (incrementButton.id == button.id) {
|
|
||||||
Integer oldAmount = Ints.tryParse(amountField.getText());
|
|
||||||
|
|
||||||
if (oldAmount == null) {
|
|
||||||
oldAmount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newAmount = Integer.parseInt(incrementButton.displayString);
|
|
||||||
|
|
||||||
if (!canAmountGoNegative()) {
|
|
||||||
newAmount = Math.max(DEFAULT_AMOUNT, ((oldAmount == 1 && newAmount != 1) ? 0 : oldAmount) + newAmount);
|
|
||||||
} else {
|
|
||||||
newAmount = oldAmount + newAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newAmount > getMaxAmount()) {
|
|
||||||
newAmount = getMaxAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
amountField.setText(String.valueOf(newAmount));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getMaxAmount() {
|
|
||||||
return Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void startRequest(boolean noPreview) {
|
|
||||||
Integer quantity = Ints.tryParse(amountField.getText());
|
|
||||||
|
|
||||||
if (quantity != null && quantity > 0) {
|
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity, noPreview, stack instanceof GridStackFluid));
|
|
||||||
|
|
||||||
startButton.enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
FMLClientHandler.instance().showGuiScreen(parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiBase getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -452,7 +452,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
|||||||
|
|
||||||
if (isPulling) {
|
if (isPulling) {
|
||||||
if (stack.isCraftable() && view.canCraft() && (stack.doesDisplayCraftText() || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown()))) {
|
if (stack.isCraftable() && view.canCraft() && (stack.doesDisplayCraftText() || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown()))) {
|
||||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingStart(this, ((ContainerGrid) this.inventorySlots).getPlayer(), stack));
|
FMLCommonHandler.instance().showGuiScreen(new GuiGridCraftingSettings(this, ((ContainerGrid) this.inventorySlots).getPlayer(), stack));
|
||||||
} else if (grid.getGridType() == GridType.FLUID && held.isEmpty()) {
|
} else if (grid.getGridType() == GridType.FLUID && held.isEmpty()) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridFluidPull(view.getStacks().get(slotNumber).getHash(), GuiScreen.isShiftKeyDown()));
|
RS.INSTANCE.network.sendToServer(new MessageGridFluidPull(view.getStacks().get(slotNumber).getHash(), GuiScreen.isShiftKeyDown()));
|
||||||
} else if (grid.getGridType() == GridType.NORMAL || grid.getGridType() == GridType.PATTERN) {
|
} else if (grid.getGridType() == GridType.NORMAL || grid.getGridType() == GridType.PATTERN) {
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.gui.grid;
|
||||||
|
|
||||||
|
import com.google.common.primitives.Ints;
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.ContainerCraftingSettings;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiAmountSpecifying;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||||
|
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreview;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
|
||||||
|
public class GuiGridCraftingSettings extends GuiAmountSpecifying {
|
||||||
|
private IGridStack stack;
|
||||||
|
|
||||||
|
public GuiGridCraftingSettings(GuiBase parent, EntityPlayer player, IGridStack stack) {
|
||||||
|
super(parent, new ContainerCraftingSettings(player, stack), 172, 99);
|
||||||
|
|
||||||
|
this.stack = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getOkButtonText() {
|
||||||
|
return t("misc.refinedstorage:start");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTitle() {
|
||||||
|
return t("container.crafting");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTexture() {
|
||||||
|
return "gui/crafting_settings.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int[] getIncrements() {
|
||||||
|
if (stack instanceof GridStackFluid) {
|
||||||
|
return new int[]{
|
||||||
|
100, 500, 1000,
|
||||||
|
-100, -500, -1000
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return new int[]{
|
||||||
|
1, 10, 64,
|
||||||
|
-1, -10, -64
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultAmount() {
|
||||||
|
return stack instanceof GridStackFluid ? Fluid.BUCKET_VOLUME : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canAmountGoNegative() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMaxAmount() {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onOkButtonPressed(boolean shiftDown) {
|
||||||
|
Integer quantity = Ints.tryParse(amountField.getText());
|
||||||
|
|
||||||
|
if (quantity != null && quantity > 0) {
|
||||||
|
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity, shiftDown, stack instanceof GridStackFluid));
|
||||||
|
|
||||||
|
okButton.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,32 +1,43 @@
|
|||||||
package com.raoulvdberge.refinedstorage.gui;
|
package com.raoulvdberge.refinedstorage.gui.grid;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.container.ContainerFluidAmount;
|
import com.raoulvdberge.refinedstorage.container.ContainerFluidAmount;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiCraftingStart;
|
import com.raoulvdberge.refinedstorage.gui.GuiAmountSpecifying;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageGridFluidAmount;
|
import com.raoulvdberge.refinedstorage.network.MessageGridFluidAmount;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
|
||||||
public class GuiFluidAmount extends GuiCraftingStart {
|
public class GuiGridPatternFluidAmount extends GuiAmountSpecifying {
|
||||||
private int slot;
|
private int slot;
|
||||||
private ItemStack fluidContainer;
|
private ItemStack fluidContainer;
|
||||||
|
|
||||||
public GuiFluidAmount(GuiBase parent, EntityPlayer player, int slot, ItemStack fluidContainer) {
|
public GuiGridPatternFluidAmount(GuiBase parent, EntityPlayer player, int slot, ItemStack fluidContainer) {
|
||||||
super(parent, null, new ContainerFluidAmount(player, fluidContainer), 172, 99);
|
super(parent, new ContainerFluidAmount(player, fluidContainer), 172, 99);
|
||||||
|
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.fluidContainer = fluidContainer;
|
this.fluidContainer = fluidContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getAmount() {
|
protected int getDefaultAmount() {
|
||||||
return fluidContainer.getCount();
|
return fluidContainer.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStartButtonText() {
|
protected boolean canAmountGoNegative() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMaxAmount() {
|
||||||
|
return Fluid.BUCKET_VOLUME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getOkButtonText() {
|
||||||
return t("misc.refinedstorage:set");
|
return t("misc.refinedstorage:set");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,8 +47,8 @@ public class GuiFluidAmount extends GuiCraftingStart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canAmountGoNegative() {
|
protected String getTexture() {
|
||||||
return false;
|
return "gui/crafting_settings.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,12 +60,7 @@ public class GuiFluidAmount extends GuiCraftingStart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMaxAmount() {
|
protected void onOkButtonPressed(boolean shiftDown) {
|
||||||
return Fluid.BUCKET_VOLUME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void startRequest(boolean noPreview) {
|
|
||||||
Integer amount = Ints.tryParse(amountField.getText());
|
Integer amount = Ints.tryParse(amountField.getText());
|
||||||
|
|
||||||
if (amount != null && amount > 0 && amount <= Fluid.BUCKET_VOLUME) {
|
if (amount != null && amount > 0 && amount <= Fluid.BUCKET_VOLUME) {
|
||||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.network;
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiCraftingPreview;
|
import com.raoulvdberge.refinedstorage.gui.GuiCraftingPreview;
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiCraftingStart;
|
import com.raoulvdberge.refinedstorage.gui.grid.GuiGridCraftingSettings;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@@ -69,8 +69,8 @@ public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHan
|
|||||||
Minecraft.getMinecraft().addScheduledTask(() -> {
|
Minecraft.getMinecraft().addScheduledTask(() -> {
|
||||||
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
||||||
|
|
||||||
if (screen instanceof GuiCraftingStart) {
|
if (screen instanceof GuiGridCraftingSettings) {
|
||||||
screen = ((GuiCraftingStart) screen).getParent();
|
screen = ((GuiGridCraftingSettings) screen).getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingPreview(screen, message.stacks, message.hash, message.quantity, message.fluids));
|
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingPreview(screen, message.stacks, message.hash, message.quantity, message.fluids));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.network;
|
package com.raoulvdberge.refinedstorage.network;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiCraftingStart;
|
import com.raoulvdberge.refinedstorage.gui.grid.GuiGridCraftingSettings;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
@@ -30,8 +30,8 @@ public class MessageGridCraftingStartResponse implements IMessage, IMessageHandl
|
|||||||
Minecraft.getMinecraft().addScheduledTask(() -> {
|
Minecraft.getMinecraft().addScheduledTask(() -> {
|
||||||
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
||||||
|
|
||||||
if (screen instanceof GuiCraftingStart) {
|
if (screen instanceof GuiGridCraftingSettings) {
|
||||||
((GuiCraftingStart) screen).close();
|
((GuiGridCraftingSettings) screen).close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Reference in New Issue
Block a user