diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java index 0a0e1fe51..ba08e3ecb 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/monitor/AutocraftingMonitorScreen.java @@ -26,7 +26,7 @@ import net.minecraft.world.entity.player.Inventory; import static com.refinedmods.refinedstorage.common.support.Sprites.ERROR; -import static com.refinedmods.refinedstorage.common.support.Sprites.ERROR_SIZE; +import static com.refinedmods.refinedstorage.common.support.Sprites.ICON_SIZE; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; @@ -295,10 +295,10 @@ && isHoveringOverItems(mouseX, mouseY)) { private static void renderItemErrorIcon(final GuiGraphics graphics, final int x, final int y) { graphics.blitSprite( ERROR, - x + 73 - ERROR_SIZE - 3, - y + (29 / 2) - (ERROR_SIZE / 2), - ERROR_SIZE, - ERROR_SIZE + x + 73 - ICON_SIZE - 3, + y + (29 / 2) - (ICON_SIZE / 2), + ICON_SIZE, + ICON_SIZE ); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativeContainerMenu.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativeContainerMenu.java index acd7bf39f..5dcb47647 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativeContainerMenu.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativeContainerMenu.java @@ -20,6 +20,7 @@ import static com.refinedmods.refinedstorage.common.autocrafting.patterngrid.AlternativesScreen.ALTERNATIVE_HEIGHT; import static com.refinedmods.refinedstorage.common.autocrafting.patterngrid.AlternativesScreen.ALTERNATIVE_ROW_HEIGHT; +import static com.refinedmods.refinedstorage.common.autocrafting.patterngrid.AlternativesScreen.RESOURCES_PER_ROW; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.getTagTranslationKey; class AlternativeContainerMenu extends AbstractResourceContainerMenu { @@ -28,7 +29,7 @@ class AlternativeContainerMenu extends AbstractResourceContainerMenu { AlternativeContainerMenu(final ResourceSlot amountSlot) { super(null, 0); - this.amountSlot = amountSlot.forAmountScreen(118, 48); + this.amountSlot = amountSlot.forAmountScreen(127, 48); final List tags = amountSlot.getResource() == null ? Collections.emptyList() : amountSlot.getResource().getTags(); @@ -62,12 +63,12 @@ private void addAlternativeSlots() { ); for (int j = 0; j < resources.size(); ++j) { resources.set(j, new ResourceAmount(alternative.getResources().get(j), 1)); - final int row = j / 8; - final int col = j % 8; + final int row = j / RESOURCES_PER_ROW; + final int col = j % RESOURCES_PER_ROW; final int slotX = x + 1 + 1 + col * 18; final int slotY = y + ALTERNATIVE_ROW_HEIGHT + (row * 18) + 1; final AlternativeSlot resourceSlot = new AlternativeSlot(resources, j, slotX, slotY); - if (j < 8) { + if (j < RESOURCES_PER_ROW) { alternative.getMainSlots().add(resourceSlot); } else { alternative.getOverflowSlots().add(resourceSlot); diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativesScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativesScreen.java index c8bd53620..77d9fbdba 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativesScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/patterngrid/AlternativesScreen.java @@ -38,6 +38,7 @@ public class AlternativesScreen extends AbstractAmountScreen { static final int ALTERNATIVE_ROW_HEIGHT = 18; static final int ALTERNATIVE_HEIGHT = ALTERNATIVE_ROW_HEIGHT * 2; + static final int RESOURCES_PER_ROW = 9; private static final ResourceLocation TEXTURE = createIdentifier("textures/gui/alternatives.png"); private static final MutableComponent TITLE = createTranslation("gui", "configure_amount"); @@ -58,8 +59,7 @@ public class AlternativesScreen extends AbstractAmountScreencreate() .withInitialAmount(slot.getDisplayAmount()) .withIncrementsTop(1, 10, 64) - .withIncrementsTopStartPosition(new Vector3f(40, 20, 0)) + .withIncrementsTopStartPosition(new Vector3f(49, 20, 0)) .withIncrementsBottom(-1, -10, -64) - .withIncrementsBottomStartPosition(new Vector3f(40, 71, 0)) - .withAmountFieldPosition(new Vector3f(38, 51, 0)) + .withIncrementsBottomStartPosition(new Vector3f(49, 71, 0)) + .withAmountFieldPosition(new Vector3f(47, 51, 0)) .withActionButtonsStartPosition(new Vector3f(7, 199, 0)) .withHorizontalActionButtons(true) .withMinAmount(1D) @@ -98,7 +98,7 @@ public class AlternativesScreen extends AbstractAmountScreen slots, final int rowOffset, final boolean visible) { for (int i = 0; i < slots.size(); i++) { - final int row = (i / 8) + rowOffset; + final int row = (i / RESOURCES_PER_ROW) + rowOffset; final AlternativeSlot resourceSlot = slots.get(i); Platform.INSTANCE.setSlotY( resourceSlot, @@ -491,9 +491,9 @@ public boolean keyPressed(final int key, final int scanCode, final int modifiers private boolean isOverAlternativesArea(final double x, final double y) { return x >= leftPos + 7 - && (x < leftPos + 7 + 161) + && (x < leftPos + 7 + 179) && y >= topPos + 121 - && (y < topPos + 121 + 88); + && (y < topPos + 121 + 74); } @Override diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java index a0a059ac0..36228f23d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/autocrafting/preview/AutocraftingPreviewScreen.java @@ -10,6 +10,7 @@ import com.refinedmods.refinedstorage.common.support.amount.AbstractAmountScreen; import com.refinedmods.refinedstorage.common.support.amount.AmountScreenConfiguration; import com.refinedmods.refinedstorage.common.support.amount.DoubleAmountOperations; +import com.refinedmods.refinedstorage.common.support.amount.IconButton; import com.refinedmods.refinedstorage.common.support.tooltip.HelpClientTooltipComponent; import com.refinedmods.refinedstorage.common.support.tooltip.SmallText; import com.refinedmods.refinedstorage.common.support.widget.CheckboxWidget; @@ -200,6 +201,12 @@ protected void init() { )); } + @Nullable + @Override + protected IconButton.Icon getConfirmButtonIcon() { + return null; + } + private void requestMaxAmount(final Button button) { button.active = false; getMenu().requestMaxAmount(); @@ -276,7 +283,9 @@ private void setPreview(@Nullable final Preview preview) { previewItemsScrollbar.setEnabled(rows > 0); confirmButton.setMessage(START); confirmButton.active = preview.type() == PreviewType.SUCCESS; - confirmButton.setError(preview.type() != PreviewType.SUCCESS); + confirmButton.setIcon(preview.type() == PreviewType.SUCCESS + ? IconButton.Icon.START + : IconButton.Icon.ERROR); confirmButton.setTooltip(preview.type() == PreviewType.MISSING_RESOURCES ? Tooltip.create(MISSING_RESOURCES) : null); @@ -603,7 +612,7 @@ private void setPending() { return; } confirmButton.active = false; - confirmButton.setError(false); + confirmButton.setIcon(null); confirmButton.setTooltip(null); confirmButton.setMessage(PENDING); } @@ -613,7 +622,7 @@ private void setStartDisabled() { return; } confirmButton.active = false; - confirmButton.setError(false); + confirmButton.setIcon(null); confirmButton.setTooltip(null); confirmButton.setMessage(START); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/Sprites.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/Sprites.java index ab0897790..a3f49e5a1 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/Sprites.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/Sprites.java @@ -11,8 +11,12 @@ public final class Sprites { public static final int LIGHT_ARROW_HEIGHT = 15; public static final ResourceLocation WARNING = createIdentifier("warning"); public static final int WARNING_SIZE = 10; - public static final int ERROR_SIZE = 12; + public static final int ICON_SIZE = 12; public static final ResourceLocation ERROR = createIdentifier("error"); + public static final ResourceLocation START = createIdentifier("start"); + public static final ResourceLocation CANCEL = createIdentifier("cancel"); + public static final ResourceLocation RESET = createIdentifier("reset"); + public static final ResourceLocation SET = createIdentifier("set"); private Sprites() { } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/AbstractAmountScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/AbstractAmountScreen.java index 4a8baab44..56b67486d 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/AbstractAmountScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/AbstractAmountScreen.java @@ -20,7 +20,7 @@ import org.joml.Vector3f; import org.lwjgl.glfw.GLFW; -import static com.refinedmods.refinedstorage.common.support.Sprites.ERROR_SIZE; +import static com.refinedmods.refinedstorage.common.support.Sprites.ICON_SIZE; import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation; public abstract class AbstractAmountScreen @@ -30,11 +30,11 @@ public abstract class AbstractAmountScreen reset()) - .pos(leftPos + x, topPos + y) - .size(width, ACTION_BUTTON_HEIGHT) - .build()); + final IconButton button = new IconButton( + leftPos + x, + topPos + y, + width, + ACTION_BUTTON_HEIGHT, + RESET_TEXT, + btn -> reset() + ); + button.setIcon(IconButton.Icon.RESET); + return addRenderableWidget(button); } private void addConfirmButton(final int x, final int y) { final int width = configuration.isHorizontalActionButtons() - ? font.width(configuration.getConfirmButtonText()) + ACTION_BUTTON_SPACING + ERROR_SIZE + ? font.width(configuration.getConfirmButtonText()) + ACTION_BUTTON_SPACING + ICON_SIZE : ACTION_BUTTON_WIDTH; - confirmButton = addRenderableWidget(new ConfirmButton( + final IconButton button = new IconButton( leftPos + x, topPos + y, width, ACTION_BUTTON_HEIGHT, configuration.getConfirmButtonText(), btn -> tryConfirmAndCloseToParent() - )); + ); + button.setIcon(getConfirmButtonIcon()); + confirmButton = addRenderableWidget(button); + } + + @Nullable + protected IconButton.Icon getConfirmButtonIcon() { + return IconButton.Icon.SET; } private Button addCancelButton(final int x, final int y) { final int width = configuration.isHorizontalActionButtons() - ? font.width(CANCEL_TEXT) + ACTION_BUTTON_SPACING + ? font.width(CANCEL_TEXT) + ACTION_BUTTON_SPACING + ICON_SIZE : ACTION_BUTTON_WIDTH; - return addRenderableWidget(Button.builder(CANCEL_TEXT, btn -> close()) - .pos(leftPos + x, topPos + y) - .size(width, ACTION_BUTTON_HEIGHT) - .build()); + final IconButton button = new IconButton( + leftPos + x, + topPos + y, + width, + ACTION_BUTTON_HEIGHT, + CANCEL_TEXT, + btn -> close() + ); + button.setIcon(IconButton.Icon.CANCEL); + return addRenderableWidget(button); } private void addAmountField() { @@ -157,7 +176,7 @@ protected void onAmountFieldChanged() { final boolean valid = getAndValidateAmount().isPresent(); if (confirmButton != null) { confirmButton.active = valid; - confirmButton.setError(!valid); + confirmButton.setIcon(valid ? getConfirmButtonIcon() : IconButton.Icon.ERROR); } else { tryConfirm(); } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/ConfirmButton.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/IconButton.java similarity index 53% rename from refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/ConfirmButton.java rename to refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/IconButton.java index 8367c9c52..861456794 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/ConfirmButton.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/IconButton.java @@ -1,22 +1,27 @@ package com.refinedmods.refinedstorage.common.support.amount; +import com.refinedmods.refinedstorage.common.support.Sprites; + +import javax.annotation.Nullable; + import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; -import static com.refinedmods.refinedstorage.common.support.Sprites.ERROR; -import static com.refinedmods.refinedstorage.common.support.Sprites.ERROR_SIZE; +import static com.refinedmods.refinedstorage.common.support.Sprites.ICON_SIZE; -public class ConfirmButton extends Button { - private boolean error; +public class IconButton extends Button { + @Nullable + private Icon icon; - public ConfirmButton(final int x, - final int y, - final int width, - final int height, - final Component message, - final OnPress onPress) { + public IconButton(final int x, + final int y, + final int width, + final int height, + final Component message, + final OnPress onPress) { super(x, y, width, height, message, onPress, DEFAULT_NARRATION); } @@ -26,8 +31,8 @@ protected void renderWidget(final GuiGraphics graphics, final int mouseY, final float partialTick) { super.renderWidget(graphics, mouseX, mouseY, partialTick); - if (error) { - graphics.blitSprite(ERROR, getX() + 4, getY() + 4, ERROR_SIZE, ERROR_SIZE); + if (icon != null) { + graphics.blitSprite(icon.sprite, getX() + 4, getY() + 4, ICON_SIZE, ICON_SIZE); } } @@ -36,13 +41,27 @@ protected void renderScrollingString(final GuiGraphics graphics, final Font font, final int width, final int color) { - final int offset = error ? (ERROR_SIZE - 6) : 0; + final int offset = icon != null ? (ICON_SIZE - 6) : 0; final int start = offset + getX() + width; final int end = offset + getX() + getWidth() - width; renderScrollingString(graphics, font, getMessage(), start, getY(), end, getY() + getHeight(), color); } - public void setError(final boolean error) { - this.error = error; + public void setIcon(@Nullable final Icon icon) { + this.icon = icon; + } + + public enum Icon { + ERROR(Sprites.ERROR), + START(Sprites.START), + CANCEL(Sprites.CANCEL), + RESET(Sprites.RESET), + SET(Sprites.SET); + + private final ResourceLocation sprite; + + Icon(final ResourceLocation sprite) { + this.sprite = sprite; + } } } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/PriorityScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/PriorityScreen.java index 76c72f713..3f2621aeb 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/PriorityScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/PriorityScreen.java @@ -38,7 +38,7 @@ public PriorityScreen(final MutableComponent title, IntegerAmountOperations.INSTANCE ); this.priorityChanged = priorityChanged; - this.imageWidth = 164; + this.imageWidth = 172; this.imageHeight = 92; } diff --git a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/ResourceAmountScreen.java b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/ResourceAmountScreen.java index 104e9584a..e2b910eb3 100644 --- a/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/ResourceAmountScreen.java +++ b/refinedstorage-common/src/main/java/com/refinedmods/refinedstorage/common/support/amount/ResourceAmountScreen.java @@ -41,7 +41,7 @@ public ResourceAmountScreen(final Screen parent, final Inventory playerInventory DoubleAmountOperations.INSTANCE ); this.slot = slot; - this.imageWidth = 172; + this.imageWidth = 180; this.imageHeight = 99; } diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/alternatives.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/alternatives.png index d979899d1..b05545e0a 100644 Binary files a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/alternatives.png and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/alternatives.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/priority.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/priority.png index 423ef87b6..b64142a47 100644 Binary files a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/priority.png and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/priority.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/resource_amount.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/resource_amount.png index 6b8b35fdd..3a4c72874 100644 Binary files a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/resource_amount.png and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/resource_amount.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/cancel.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/cancel.png new file mode 100644 index 000000000..ac98defee Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/cancel.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/reset.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/reset.png new file mode 100644 index 000000000..c4dd7b837 Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/reset.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/set.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/set.png new file mode 100644 index 000000000..985480dbd Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/set.png differ diff --git a/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/start.png b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/start.png new file mode 100644 index 000000000..5f362e5f3 Binary files /dev/null and b/refinedstorage-common/src/main/resources/assets/refinedstorage/textures/gui/sprites/start.png differ