Add "alternatives" button to item/fluid amount
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- The Pattern Grid now switches automatically between crafting pattern and processing pattern mode when re-inserting an existing Pattern (raoulvdberge)
|
- The Pattern Grid now switches automatically between crafting pattern and processing pattern mode when re-inserting an existing Pattern (raoulvdberge)
|
||||||
- Removed migration code for the development builds that were released on Discord (not on CurseForge). If you used the development builds and never used version 1.7 before, first switch to 1.7, open your world, modify a storage disk, and then upgrade to 1.7.1 (raoulvdberge)
|
- Removed migration code for the development builds that were released on Discord (not on CurseForge). If you used the development builds and never used version 1.7 before, first switch to 1.7, open your world, modify a storage disk, and then upgrade to 1.7.1 (raoulvdberge)
|
||||||
- Grids now do not sort if you interact with it while holding shift (Darkere)
|
- Grids now do not sort if you interact with it while holding shift (Darkere)
|
||||||
|
- Fixed Pattern Grid causing world hanging on load (raoulvdberge)
|
||||||
|
|
||||||
### 1.7
|
### 1.7
|
||||||
NOTE: This is an alpha release. Bugs may happen. Remember to take backups.
|
NOTE: This is an alpha release. Bugs may happen. Remember to take backups.
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.raoulvdberge.refinedstorage.container;
|
|||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
public class InputConfigurationContainer extends BaseContainer {
|
public class AlternativesContainer extends BaseContainer {
|
||||||
public InputConfigurationContainer(PlayerEntity player) {
|
public AlternativesContainer(PlayerEntity player) {
|
||||||
super(null, null, player, 0);
|
super(null, null, player, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,12 +171,12 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
|||||||
for (int i = 0; i < 9 * 2; ++i) {
|
for (int i = 0; i < 9 * 2; ++i) {
|
||||||
int itemFilterSlotConfig = FilterSlot.FILTER_ALLOW_SIZE;
|
int itemFilterSlotConfig = FilterSlot.FILTER_ALLOW_SIZE;
|
||||||
if (i < 9) {
|
if (i < 9) {
|
||||||
itemFilterSlotConfig |= FilterSlot.FILTER_ALLOW_INPUT_CONFIGURATION;
|
itemFilterSlotConfig |= FilterSlot.FILTER_ALLOW_ALTERNATIVES;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fluidFilterSlotConfig = FluidFilterSlot.FILTER_ALLOW_SIZE;
|
int fluidFilterSlotConfig = FluidFilterSlot.FILTER_ALLOW_SIZE;
|
||||||
if (i < 9) {
|
if (i < 9) {
|
||||||
fluidFilterSlotConfig |= FluidFilterSlot.FILTER_ALLOW_INPUT_CONFIGURATION;
|
fluidFilterSlotConfig |= FluidFilterSlot.FILTER_ALLOW_ALTERNATIVES;
|
||||||
}
|
}
|
||||||
|
|
||||||
addSlot(new FilterSlot(((GridNetworkNode) grid).getProcessingMatrix(), i, x, y, itemFilterSlotConfig).setEnableHandler(() -> ((GridNetworkNode) grid).isProcessingPattern() && ((GridNetworkNode) grid).getType() == IType.ITEMS));
|
addSlot(new FilterSlot(((GridNetworkNode) grid).getProcessingMatrix(), i, x, y, itemFilterSlotConfig).setEnableHandler(() -> ((GridNetworkNode) grid).isProcessingPattern() && ((GridNetworkNode) grid).getType() == IType.ITEMS));
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import javax.annotation.Nonnull;
|
|||||||
public class FilterSlot extends BaseSlot {
|
public class FilterSlot extends BaseSlot {
|
||||||
public static final int FILTER_ALLOW_SIZE = 1;
|
public static final int FILTER_ALLOW_SIZE = 1;
|
||||||
public static final int FILTER_ALLOW_BLOCKS = 2;
|
public static final int FILTER_ALLOW_BLOCKS = 2;
|
||||||
public static final int FILTER_ALLOW_INPUT_CONFIGURATION = 4;
|
public static final int FILTER_ALLOW_ALTERNATIVES = 4;
|
||||||
|
|
||||||
private int flags;
|
private int flags;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public class FilterSlot extends BaseSlot {
|
|||||||
return (flags & FILTER_ALLOW_BLOCKS) == FILTER_ALLOW_BLOCKS;
|
return (flags & FILTER_ALLOW_BLOCKS) == FILTER_ALLOW_BLOCKS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInputConfigurationAllowed() {
|
public boolean isAlternativesAllowed() {
|
||||||
return (flags & FILTER_ALLOW_INPUT_CONFIGURATION) == FILTER_ALLOW_INPUT_CONFIGURATION;
|
return (flags & FILTER_ALLOW_ALTERNATIVES) == FILTER_ALLOW_ALTERNATIVES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
public class FluidFilterSlot extends BaseSlot {
|
public class FluidFilterSlot extends BaseSlot {
|
||||||
public static final int FILTER_ALLOW_SIZE = 1;
|
public static final int FILTER_ALLOW_SIZE = 1;
|
||||||
public static final int FILTER_ALLOW_INPUT_CONFIGURATION = 2;
|
public static final int FILTER_ALLOW_ALTERNATIVES = 2;
|
||||||
|
|
||||||
private int flags;
|
private int flags;
|
||||||
private FluidInventory fluidInventory;
|
private FluidInventory fluidInventory;
|
||||||
@@ -39,8 +39,8 @@ public class FluidFilterSlot extends BaseSlot {
|
|||||||
return (flags & FILTER_ALLOW_SIZE) == FILTER_ALLOW_SIZE;
|
return (flags & FILTER_ALLOW_SIZE) == FILTER_ALLOW_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInputConfigurationAllowed() {
|
public boolean isAlternativesAllowed() {
|
||||||
return (flags & FILTER_ALLOW_INPUT_CONFIGURATION) == FILTER_ALLOW_INPUT_CONFIGURATION;
|
return (flags & FILTER_ALLOW_ALTERNATIVES) == FILTER_ALLOW_ALTERNATIVES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FluidInventory getFluidInventory() {
|
public FluidInventory getFluidInventory() {
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.screen;
|
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
|
||||||
import com.raoulvdberge.refinedstorage.container.AmountContainer;
|
|
||||||
import com.raoulvdberge.refinedstorage.network.SetFilterSlotMessage;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
|
|
||||||
public class AmountScreen extends AmountSpecifyingScreen<AmountContainer> {
|
|
||||||
private int containerSlot;
|
|
||||||
private ItemStack stack;
|
|
||||||
private int maxAmount;
|
|
||||||
|
|
||||||
public AmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, ItemStack stack, int maxAmount) {
|
|
||||||
super(parent, new AmountContainer(player, stack), 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.item_amount"));
|
|
||||||
|
|
||||||
this.containerSlot = containerSlot;
|
|
||||||
this.stack = stack;
|
|
||||||
this.maxAmount = maxAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getDefaultAmount() {
|
|
||||||
return stack.getCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canAmountGoNegative() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getMaxAmount() {
|
|
||||||
return maxAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getOkButtonText() {
|
|
||||||
return I18n.format("misc.refinedstorage.set");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getTexture() {
|
|
||||||
return "gui/crafting_settings.png";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int[] getIncrements() {
|
|
||||||
return new int[]{
|
|
||||||
1, 10, 64,
|
|
||||||
-1, -10, -64
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onOkButtonPressed(boolean shiftDown) {
|
|
||||||
try {
|
|
||||||
int amount = Integer.parseInt(amountField.getText());
|
|
||||||
|
|
||||||
RS.NETWORK_HANDLER.sendToServer(new SetFilterSlotMessage(containerSlot, ItemHandlerHelper.copyStackWithSize(stack, amount)));
|
|
||||||
|
|
||||||
close();
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// NO OP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,7 @@ public abstract class AmountSpecifyingScreen<T extends Container> extends BaseSc
|
|||||||
|
|
||||||
protected TextFieldWidget amountField;
|
protected TextFieldWidget amountField;
|
||||||
protected Button okButton;
|
protected Button okButton;
|
||||||
|
protected Button cancelButton;
|
||||||
|
|
||||||
public AmountSpecifyingScreen(BaseScreen parent, T container, int width, int height, PlayerInventory playerInventory, ITextComponent title) {
|
public AmountSpecifyingScreen(BaseScreen parent, T container, int width, int height, PlayerInventory playerInventory, ITextComponent title) {
|
||||||
super(container, width, height, playerInventory, title);
|
super(container, width, height, playerInventory, title);
|
||||||
@@ -42,12 +43,16 @@ public abstract class AmountSpecifyingScreen<T extends Container> extends BaseSc
|
|||||||
return Pair.of(114, 33);
|
return Pair.of(114, 33);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getOkCancelButtonWidth() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostInit(int x, int y) {
|
public void onPostInit(int x, int y) {
|
||||||
Pair<Integer, Integer> pos = getOkCancelPos();
|
Pair<Integer, Integer> pos = getOkCancelPos();
|
||||||
|
|
||||||
okButton = addButton(x + pos.getLeft(), y + pos.getRight(), 50, 20, getOkButtonText(), true, true, btn -> onOkButtonPressed(hasShiftDown()));
|
okButton = addButton(x + pos.getLeft(), y + pos.getRight(), getOkCancelButtonWidth(), 20, getOkButtonText(), true, true, btn -> onOkButtonPressed(hasShiftDown()));
|
||||||
addButton(x + pos.getLeft(), y + pos.getRight() + 24, 50, 20, I18n.format("gui.cancel"), true, true, btn -> close());
|
cancelButton = addButton(x + pos.getLeft(), y + pos.getRight() + 24, getOkCancelButtonWidth(), 20, I18n.format("gui.cancel"), true, true, btn -> close());
|
||||||
|
|
||||||
amountField = new TextFieldWidget(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6, font.FONT_HEIGHT, "");
|
amountField = new TextFieldWidget(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6, font.FONT_HEIGHT, "");
|
||||||
amountField.setEnableBackgroundDrawing(false);
|
amountField.setEnableBackgroundDrawing(false);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
|
|||||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||||
import com.raoulvdberge.refinedstorage.integration.craftingtweaks.CraftingTweaksIntegration;
|
import com.raoulvdberge.refinedstorage.integration.craftingtweaks.CraftingTweaksIntegration;
|
||||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||||
import com.raoulvdberge.refinedstorage.screen.grid.InputConfigurationScreen;
|
import com.raoulvdberge.refinedstorage.screen.grid.AlternativesScreen;
|
||||||
import com.raoulvdberge.refinedstorage.screen.widget.CheckBoxWidget;
|
import com.raoulvdberge.refinedstorage.screen.widget.CheckBoxWidget;
|
||||||
import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.SideButton;
|
import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.SideButton;
|
||||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
@@ -176,21 +176,28 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
|||||||
|
|
||||||
if (valid && slot instanceof FilterSlot && slot.isEnabled() && ((FilterSlot) slot).isSizeAllowed()) {
|
if (valid && slot instanceof FilterSlot && slot.isEnabled() && ((FilterSlot) slot).isSizeAllowed()) {
|
||||||
if (!slot.getStack().isEmpty()) {
|
if (!slot.getStack().isEmpty()) {
|
||||||
if (((FilterSlot) slot).isInputConfigurationAllowed() && hasControlDown()) {
|
if (((FilterSlot) slot).isAlternativesAllowed() && hasControlDown()) {
|
||||||
minecraft.displayGuiScreen(new InputConfigurationScreen(
|
minecraft.displayGuiScreen(new AlternativesScreen(
|
||||||
this,
|
this,
|
||||||
minecraft.player,
|
minecraft.player,
|
||||||
new TranslationTextComponent("gui.refinedstorage.input_configuration"),
|
new TranslationTextComponent("gui.refinedstorage.alternatives"),
|
||||||
slot.getStack(),
|
slot.getStack(),
|
||||||
slot.getSlotIndex()
|
slot.getSlotIndex()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
minecraft.displayGuiScreen(new AmountScreen(
|
minecraft.displayGuiScreen(new ItemAmountScreen(
|
||||||
this,
|
this,
|
||||||
minecraft.player,
|
minecraft.player,
|
||||||
slot.slotNumber,
|
slot.slotNumber,
|
||||||
slot.getStack(),
|
slot.getStack(),
|
||||||
slot.getSlotStackLimit()
|
slot.getSlotStackLimit(),
|
||||||
|
parent -> new AlternativesScreen(
|
||||||
|
parent,
|
||||||
|
minecraft.player,
|
||||||
|
new TranslationTextComponent("gui.refinedstorage.alternatives"),
|
||||||
|
slot.getStack(),
|
||||||
|
slot.getSlotIndex()
|
||||||
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,11 +205,11 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
|||||||
FluidStack stack = ((FluidFilterSlot) slot).getFluidInventory().getFluid(slot.getSlotIndex());
|
FluidStack stack = ((FluidFilterSlot) slot).getFluidInventory().getFluid(slot.getSlotIndex());
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
if (((FluidFilterSlot) slot).isInputConfigurationAllowed() && hasControlDown()) {
|
if (((FluidFilterSlot) slot).isAlternativesAllowed() && hasControlDown()) {
|
||||||
minecraft.displayGuiScreen(new InputConfigurationScreen(
|
minecraft.displayGuiScreen(new AlternativesScreen(
|
||||||
this,
|
this,
|
||||||
minecraft.player,
|
minecraft.player,
|
||||||
new TranslationTextComponent("gui.refinedstorage.input_configuration"),
|
new TranslationTextComponent("gui.refinedstorage.alternatives"),
|
||||||
stack,
|
stack,
|
||||||
slot.getSlotIndex()
|
slot.getSlotIndex()
|
||||||
));
|
));
|
||||||
@@ -212,7 +219,14 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
|||||||
minecraft.player,
|
minecraft.player,
|
||||||
slot.slotNumber,
|
slot.slotNumber,
|
||||||
stack,
|
stack,
|
||||||
((FluidFilterSlot) slot).getFluidInventory().getMaxAmount()
|
((FluidFilterSlot) slot).getFluidInventory().getMaxAmount(),
|
||||||
|
parent -> new AlternativesScreen(
|
||||||
|
this,
|
||||||
|
minecraft.player,
|
||||||
|
new TranslationTextComponent("gui.refinedstorage.alternatives"),
|
||||||
|
stack,
|
||||||
|
slot.getSlotIndex()
|
||||||
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,22 +4,56 @@ import com.raoulvdberge.refinedstorage.RS;
|
|||||||
import com.raoulvdberge.refinedstorage.container.FluidAmountContainer;
|
import com.raoulvdberge.refinedstorage.container.FluidAmountContainer;
|
||||||
import com.raoulvdberge.refinedstorage.network.SetFluidFilterSlotMessage;
|
import com.raoulvdberge.refinedstorage.network.SetFluidFilterSlotMessage;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
// TODO here too
|
||||||
public class FluidAmountScreen extends AmountSpecifyingScreen<FluidAmountContainer> {
|
public class FluidAmountScreen extends AmountSpecifyingScreen<FluidAmountContainer> {
|
||||||
private int containerSlot;
|
private int containerSlot;
|
||||||
private FluidStack stack;
|
private FluidStack stack;
|
||||||
private int maxAmount;
|
private int maxAmount;
|
||||||
|
@Nullable
|
||||||
|
private Function<Screen, Screen> alternativesScreenFactory;
|
||||||
|
|
||||||
public FluidAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, FluidStack stack, int maxAmount) {
|
public FluidAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, FluidStack stack, int maxAmount, @Nullable Function<Screen, Screen> alternativesScreenFactory) {
|
||||||
super(parent, new FluidAmountContainer(player, stack), 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.fluid_amount"));
|
super(parent, new FluidAmountContainer(player, stack), alternativesScreenFactory != null ? 194 : 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.fluid_amount"));
|
||||||
|
|
||||||
this.containerSlot = containerSlot;
|
this.containerSlot = containerSlot;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.maxAmount = maxAmount;
|
this.maxAmount = maxAmount;
|
||||||
|
this.alternativesScreenFactory = alternativesScreenFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getOkCancelButtonWidth() {
|
||||||
|
return alternativesScreenFactory != null ? 75 : super.getOkCancelButtonWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPostInit(int x, int y) {
|
||||||
|
super.onPostInit(x, y);
|
||||||
|
|
||||||
|
if (alternativesScreenFactory != null) {
|
||||||
|
addButton(x + 114, cancelButton.y + 24, getOkCancelButtonWidth(), 20, I18n.format("gui.refinedstorage.alternatives"), true, true, btn -> {
|
||||||
|
minecraft.displayGuiScreen(alternativesScreenFactory.apply(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Pair<Integer, Integer> getOkCancelPos() {
|
||||||
|
if (alternativesScreenFactory == null) {
|
||||||
|
return super.getOkCancelPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Pair.of(114, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -44,7 +78,7 @@ public class FluidAmountScreen extends AmountSpecifyingScreen<FluidAmountContain
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTexture() {
|
protected String getTexture() {
|
||||||
return "gui/crafting_settings.png";
|
return alternativesScreenFactory != null ? "gui/amount_specifying_wide.png" : "gui/amount_specifying.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.screen;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.AmountContainer;
|
||||||
|
import com.raoulvdberge.refinedstorage.network.SetFilterSlotMessage;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class ItemAmountScreen extends AmountSpecifyingScreen<AmountContainer> {
|
||||||
|
private int containerSlot;
|
||||||
|
private ItemStack stack;
|
||||||
|
private int maxAmount;
|
||||||
|
@Nullable
|
||||||
|
private Function<Screen, Screen> alternativesScreenFactory;
|
||||||
|
|
||||||
|
public ItemAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, ItemStack stack, int maxAmount, @Nullable Function<Screen, Screen> alternativesScreenFactory) {
|
||||||
|
super(parent, new AmountContainer(player, stack), alternativesScreenFactory != null ? 194 : 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.item_amount"));
|
||||||
|
|
||||||
|
this.containerSlot = containerSlot;
|
||||||
|
this.stack = stack;
|
||||||
|
this.maxAmount = maxAmount;
|
||||||
|
this.alternativesScreenFactory = alternativesScreenFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getOkCancelButtonWidth() {
|
||||||
|
return alternativesScreenFactory != null ? 75 : super.getOkCancelButtonWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPostInit(int x, int y) {
|
||||||
|
super.onPostInit(x, y);
|
||||||
|
|
||||||
|
if (alternativesScreenFactory != null) {
|
||||||
|
addButton(x + 114, cancelButton.y + 24, getOkCancelButtonWidth(), 20, I18n.format("gui.refinedstorage.alternatives"), true, true, btn -> {
|
||||||
|
minecraft.displayGuiScreen(alternativesScreenFactory.apply(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Pair<Integer, Integer> getOkCancelPos() {
|
||||||
|
if (alternativesScreenFactory == null) {
|
||||||
|
return super.getOkCancelPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Pair.of(114, 22);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDefaultAmount() {
|
||||||
|
return stack.getCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canAmountGoNegative() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getMaxAmount() {
|
||||||
|
return maxAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getOkButtonText() {
|
||||||
|
return I18n.format("misc.refinedstorage.set");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTexture() {
|
||||||
|
return alternativesScreenFactory != null ? "gui/amount_specifying_wide.png" : "gui/amount_specifying.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int[] getIncrements() {
|
||||||
|
return new int[]{
|
||||||
|
1, 10, 64,
|
||||||
|
-1, -10, -64
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onOkButtonPressed(boolean shiftDown) {
|
||||||
|
try {
|
||||||
|
int amount = Integer.parseInt(amountField.getText());
|
||||||
|
|
||||||
|
RS.NETWORK_HANDLER.sendToServer(new SetFilterSlotMessage(containerSlot, ItemHandlerHelper.copyStackWithSize(stack, amount)));
|
||||||
|
|
||||||
|
close();
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.raoulvdberge.refinedstorage.screen.grid;
|
package com.raoulvdberge.refinedstorage.screen.grid;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.container.InputConfigurationContainer;
|
import com.raoulvdberge.refinedstorage.container.AlternativesContainer;
|
||||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||||
import com.raoulvdberge.refinedstorage.screen.widget.CheckBoxWidget;
|
import com.raoulvdberge.refinedstorage.screen.widget.CheckBoxWidget;
|
||||||
@@ -31,7 +31,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class InputConfigurationScreen extends BaseScreen {
|
public class AlternativesScreen extends BaseScreen {
|
||||||
private final Screen parent;
|
private final Screen parent;
|
||||||
private final ScrollbarWidget scrollbar;
|
private final ScrollbarWidget scrollbar;
|
||||||
|
|
||||||
@@ -42,14 +42,14 @@ public class InputConfigurationScreen extends BaseScreen {
|
|||||||
private ItemStack item;
|
private ItemStack item;
|
||||||
private FluidStack fluid;
|
private FluidStack fluid;
|
||||||
|
|
||||||
private InputConfigurationScreen(Screen parent, PlayerEntity player, ITextComponent title) {
|
private AlternativesScreen(Screen parent, PlayerEntity player, ITextComponent title) {
|
||||||
super(new InputConfigurationContainer(player), 175, 143, null, title);
|
super(new AlternativesContainer(player), 175, 143, null, title);
|
||||||
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.scrollbar = new ScrollbarWidget(this, 155, 20, 12, 89);
|
this.scrollbar = new ScrollbarWidget(this, 155, 20, 12, 89);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputConfigurationScreen(Screen parent, PlayerEntity player, ITextComponent title, ItemStack item, int slot) {
|
public AlternativesScreen(Screen parent, PlayerEntity player, ITextComponent title, ItemStack item, int slot) {
|
||||||
this(parent, player, title);
|
this(parent, player, title);
|
||||||
|
|
||||||
this.type = IType.ITEMS;
|
this.type = IType.ITEMS;
|
||||||
@@ -58,7 +58,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
|||||||
this.fluid = null;
|
this.fluid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputConfigurationScreen(Screen parent, PlayerEntity player, ITextComponent title, FluidStack fluid, int slot) {
|
public AlternativesScreen(Screen parent, PlayerEntity player, ITextComponent title, FluidStack fluid, int slot) {
|
||||||
this(parent, player, title);
|
this(parent, player, title);
|
||||||
|
|
||||||
this.type = IType.FLUIDS;
|
this.type = IType.FLUIDS;
|
||||||
@@ -69,9 +69,6 @@ public class InputConfigurationScreen extends BaseScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostInit(int x, int y) {
|
public void onPostInit(int x, int y) {
|
||||||
Button apply = addButton(x + 7, y + 114, 50, 20, I18n.format("gui.refinedstorage.input_configuration.apply"), true, true, btn -> apply());
|
|
||||||
addButton(x + apply.getWidth() + 7 + 4, y + 114, 50, 20, I18n.format("gui.cancel"), true, true, btn -> close());
|
|
||||||
|
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
@@ -135,6 +132,9 @@ public class InputConfigurationScreen extends BaseScreen {
|
|||||||
yy += 18;
|
yy += 18;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button apply = addButton(x + 7, y + 114, 50, 20, I18n.format("gui.refinedstorage.alternatives.apply"), lines.size() > 1, true, btn -> apply());
|
||||||
|
addButton(x + apply.getWidth() + 7 + 4, y + 114, 50, 20, I18n.format("gui.cancel"), true, true, btn -> close());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -153,7 +153,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||||
bindTexture(RS.ID, "gui/input_configuration.png");
|
bindTexture(RS.ID, "gui/alternatives.png");
|
||||||
|
|
||||||
blit(x, y, 0, 0, xSize, ySize);
|
blit(x, y, 0, 0, xSize, ySize);
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
|||||||
public void renderTooltip(int x, int y, int mx, int my) {
|
public void renderTooltip(int x, int y, int mx, int my) {
|
||||||
for (ItemStack item : items) {
|
for (ItemStack item : items) {
|
||||||
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
||||||
InputConfigurationScreen.this.renderTooltip(item, mx, my, RenderUtils.getTooltipFromItem(item));
|
AlternativesScreen.this.renderTooltip(item, mx, my, RenderUtils.getTooltipFromItem(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
x += 17;
|
x += 17;
|
||||||
@@ -375,7 +375,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
|||||||
public void renderTooltip(int x, int y, int mx, int my) {
|
public void renderTooltip(int x, int y, int mx, int my) {
|
||||||
for (FluidStack fluid : fluids) {
|
for (FluidStack fluid : fluids) {
|
||||||
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
if (RenderUtils.inBounds(x + 3, y, 16, 16, mx, my)) {
|
||||||
InputConfigurationScreen.this.renderTooltip(mx, my, fluid.getDisplayName().getFormattedText());
|
AlternativesScreen.this.renderTooltip(mx, my, fluid.getDisplayName().getFormattedText());
|
||||||
}
|
}
|
||||||
|
|
||||||
x += 17;
|
x += 17;
|
||||||
@@ -28,7 +28,7 @@ public class CraftingSettingsScreen extends AmountSpecifyingScreen<CraftingSetti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTexture() {
|
protected String getTexture() {
|
||||||
return "gui/crafting_settings.png";
|
return "gui/amount_specifying.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -84,8 +84,8 @@
|
|||||||
"gui.refinedstorage.security_manager.permission.5.tooltip": "Ability to change security options",
|
"gui.refinedstorage.security_manager.permission.5.tooltip": "Ability to change security options",
|
||||||
"gui.refinedstorage.storage_monitor": "Storage Monitor",
|
"gui.refinedstorage.storage_monitor": "Storage Monitor",
|
||||||
"gui.refinedstorage.crafter_manager": "Crafter Manager",
|
"gui.refinedstorage.crafter_manager": "Crafter Manager",
|
||||||
"gui.refinedstorage.input_configuration": "Input configuration",
|
"gui.refinedstorage.alternatives": "Alternatives",
|
||||||
"gui.refinedstorage.input_configuration.apply": "Apply",
|
"gui.refinedstorage.alternatives.apply": "Apply",
|
||||||
"misc.refinedstorage.energy_stored": "%d / %d FE",
|
"misc.refinedstorage.energy_stored": "%d / %d FE",
|
||||||
"misc.refinedstorage.energy_usage": "Usage: %d FE/t",
|
"misc.refinedstorage.energy_usage": "Usage: %d FE/t",
|
||||||
"misc.refinedstorage.energy_usage_minimal": "%d FE/t",
|
"misc.refinedstorage.energy_usage_minimal": "%d FE/t",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Reference in New Issue
Block a user