Add an evaluate button for equation inputs
Additionally adds translations in languages I sorta know.
This commit is contained in:
@@ -20,6 +20,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
protected EditBox amountField;
|
protected EditBox amountField;
|
||||||
protected Button okButton;
|
protected Button okButton;
|
||||||
protected Button cancelButton;
|
protected Button cancelButton;
|
||||||
|
protected Button evaluateButton;
|
||||||
|
|
||||||
protected AmountSpecifyingScreen(BaseScreen<T> parent, T container, int width, int height, Inventory playerInventory, Component title) {
|
protected AmountSpecifyingScreen(BaseScreen<T> parent, T container, int width, int height, Inventory playerInventory, Component title) {
|
||||||
super(container, width, height, playerInventory, title);
|
super(container, width, height, playerInventory, title);
|
||||||
@@ -63,22 +64,36 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Pair<Integer, Integer> getOkCancelPos() {
|
protected Pair<Integer, Integer> getOkCancelPos() {
|
||||||
return Pair.of(114, 33);
|
return Pair.of(114, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getOkCancelButtonWidth() {
|
protected int getOkCancelButtonWidth() {
|
||||||
return 50;
|
return 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getOkCancelButtonHeight() {
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Button addActionButton(Pair<Integer, Integer> absolutePos, int xOffset, int yOffset, ITextComponent text,
|
||||||
|
IPressable onPress) {
|
||||||
|
return addButton(absolutePos.getLeft() + xOffset, absolutePos.getRight() + yOffset, getOkCancelButtonWidth(),
|
||||||
|
getOkCancelButtonHeight(), text, true, true, onPress);
|
||||||
|
}
|
||||||
|
|
||||||
@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();
|
||||||
|
Pair<Integer, Integer> absolutePos = Pair.of(x + pos.getLeft(), y + pos.getRight());
|
||||||
|
|
||||||
okButton = addButton(x + pos.getLeft(), y + pos.getRight(), getOkCancelButtonWidth(), 20, getOkButtonText(), true, true, btn -> onOkButtonPressed(hasShiftDown()));
|
okButton = addActionButton(absolutePos, 0, 0, getOkButtonText(), btn -> onOkButtonPressed(hasShiftDown()));
|
||||||
cancelButton = addButton(x + pos.getLeft(), y + pos.getRight() + 24, getOkCancelButtonWidth(), 20, new TranslatableComponent("gui.cancel"), true, true, btn -> close());
|
cancelButton = addActionButton(absolutePos, 0, 24, new TranslationTextComponent("gui.cancel"), btn -> close());
|
||||||
|
evaluateButton = addActionButton(absolutePos, 0, 48, new TranslationTextComponent("misc.refinedstorage.evaluate"),
|
||||||
|
btn -> onEvaluateButtonPressed(hasShiftDown()));
|
||||||
|
|
||||||
amountField = new EditBox(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6, font.lineHeight, new TextComponent(""));
|
amountField = new TextFieldWidget(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6,
|
||||||
amountField.setBordered(false);
|
font.FONT_HEIGHT, new StringTextComponent(""));
|
||||||
|
amountField.setEnableBackgroundDrawing(false);
|
||||||
amountField.setVisible(true);
|
amountField.setVisible(true);
|
||||||
amountField.setValue(String.valueOf(getDefaultAmount()));
|
amountField.setValue(String.valueOf(getDefaultAmount()));
|
||||||
amountField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
|
amountField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
|
||||||
@@ -173,7 +188,7 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
try {
|
try {
|
||||||
int amount = parseAmount();
|
int amount = parseAmount();
|
||||||
if (isAmountInBounds(amount)) {
|
if (isAmountInBounds(amount)) {
|
||||||
onValidAmountSave(shiftDown, amount);
|
onValidAmountSaved(shiftDown, amount);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@@ -181,7 +196,16 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onValidAmountSave(boolean shiftDown, int amount) {}
|
private void onEvaluateButtonPressed(boolean shiftDown) {
|
||||||
|
try {
|
||||||
|
amountField.setText(String.valueOf(clampAmount(parseAmount())));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onValidAmountSaved(boolean shiftDown, int amount) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(int x, int y) {
|
public void tick(int x, int y) {
|
||||||
@@ -202,7 +226,6 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
|
|||||||
renderString(poseStack, 7, 7, title.getString());
|
renderString(poseStack, 7, 7, title.getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double x, double y, double delta) {
|
public boolean mouseScrolled(double x, double y, double delta) {
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class FluidAmountScreen extends AmountSpecifyingScreen<FluidAmountContain
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onValidAmountSave(boolean shiftDown, int amount) {
|
protected void onValidAmountSaved(boolean shiftDown, int amount) {
|
||||||
RS.NETWORK_HANDLER.sendToServer(new SetFluidFilterSlotMessage(containerSlot, StackUtils.copy(stack, amount)));
|
RS.NETWORK_HANDLER.sendToServer(new SetFluidFilterSlotMessage(containerSlot, StackUtils.copy(stack, amount)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class ItemAmountScreen extends AmountSpecifyingScreen<AmountContainerMenu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onValidAmountSave(boolean shiftDown, int amount) {
|
protected void onValidAmountSaved(boolean shiftDown, int amount) {
|
||||||
RS.NETWORK_HANDLER.sendToServer(new SetFilterSlotMessage(containerSlot, ItemHandlerHelper.copyStackWithSize(stack, amount)));
|
RS.NETWORK_HANDLER.sendToServer(new SetFilterSlotMessage(containerSlot, ItemHandlerHelper.copyStackWithSize(stack, amount)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@
|
|||||||
"misc.refinedstorage.start": "Start",
|
"misc.refinedstorage.start": "Start",
|
||||||
"misc.refinedstorage.clear": "Clear",
|
"misc.refinedstorage.clear": "Clear",
|
||||||
"misc.refinedstorage.set": "Set",
|
"misc.refinedstorage.set": "Set",
|
||||||
|
"misc.refinedstorage.evaluate": "Evaluate",
|
||||||
"misc.refinedstorage.cancel_all": "Cancel All",
|
"misc.refinedstorage.cancel_all": "Cancel All",
|
||||||
"misc.refinedstorage.priority": "Priority",
|
"misc.refinedstorage.priority": "Priority",
|
||||||
"misc.refinedstorage.exact": "Exact",
|
"misc.refinedstorage.exact": "Exact",
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
"misc.refinedstorage.start": "Commencer",
|
"misc.refinedstorage.start": "Commencer",
|
||||||
"misc.refinedstorage.clear": "Vider",
|
"misc.refinedstorage.clear": "Vider",
|
||||||
"misc.refinedstorage.set": "Fixer",
|
"misc.refinedstorage.set": "Fixer",
|
||||||
|
"misc.refinedstorage.evaluate": "Évaluer",
|
||||||
"misc.refinedstorage.cancel_all": "Tout annuler",
|
"misc.refinedstorage.cancel_all": "Tout annuler",
|
||||||
"misc.refinedstorage.priority": "Priorité",
|
"misc.refinedstorage.priority": "Priorité",
|
||||||
"misc.refinedstorage.processing": "En traitement",
|
"misc.refinedstorage.processing": "En traitement",
|
||||||
|
|||||||
@@ -113,6 +113,7 @@
|
|||||||
"misc.refinedstorage.start": "开始",
|
"misc.refinedstorage.start": "开始",
|
||||||
"misc.refinedstorage.clear": "清除",
|
"misc.refinedstorage.clear": "清除",
|
||||||
"misc.refinedstorage.set": "设置",
|
"misc.refinedstorage.set": "设置",
|
||||||
|
"misc.refinedstorage.evaluate": "评估",
|
||||||
"misc.refinedstorage.cancel_all": "取消所有",
|
"misc.refinedstorage.cancel_all": "取消所有",
|
||||||
"misc.refinedstorage.priority": "优先级",
|
"misc.refinedstorage.priority": "优先级",
|
||||||
"misc.refinedstorage.oredict": "矿物辞典",
|
"misc.refinedstorage.oredict": "矿物辞典",
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
"misc.refinedstorage.start": "開始",
|
"misc.refinedstorage.start": "開始",
|
||||||
"misc.refinedstorage.clear": "清除",
|
"misc.refinedstorage.clear": "清除",
|
||||||
"misc.refinedstorage.set": "設置",
|
"misc.refinedstorage.set": "設置",
|
||||||
|
"misc.refinedstorage.evaluate": "評估",
|
||||||
"misc.refinedstorage.cancel_all": "取消所有",
|
"misc.refinedstorage.cancel_all": "取消所有",
|
||||||
"misc.refinedstorage.priority": "優先級",
|
"misc.refinedstorage.priority": "優先級",
|
||||||
"misc.refinedstorage.exact": "合成模式",
|
"misc.refinedstorage.exact": "合成模式",
|
||||||
|
|||||||
Reference in New Issue
Block a user