diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java | 35 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java | 12 | ||||
-rw-r--r-- | src/main/resources/assets/libgui/textures/widget/item_slot.png | bin | 0 -> 738 bytes |
3 files changed, 27 insertions, 20 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java index 36c6c3a..654442c 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java @@ -44,6 +44,8 @@ public interface BackgroundPainter { /** * The {@code SLOT} background painter draws item slots or slot-like widgets. + * + * <p>For {@linkplain WItemSlot item slots}, this painter uses {@link WItemSlot#SLOT_TEXTURE libgui:textures/widget/item_slot.png}. */ public static BackgroundPainter SLOT = (matrices, left, top, panel) -> { if (!(panel instanceof WItemSlot)) { @@ -53,31 +55,24 @@ public interface BackgroundPainter { for(int x = 0; x < slot.getWidth()/18; ++x) { for(int y = 0; y < slot.getHeight()/18; ++y) { int index = x + y * (slot.getWidth() / 18); - int lo = 0xB8000000; - int bg = 0x4C000000; - //this will cause a slightly discolored bottom border on vanilla backgrounds but it's necessary for color support, it shouldn't be *too* visible unless you're looking for it - int hi = 0xB8FFFFFF; + float px = 1 / 64f; if (slot.isBigSlot()) { - ScreenDrawing.drawBeveledPanel(matrices, (x * 18) + left - 4, (y * 18) + top - 4, 26, 26, - lo, bg, hi); + int sx = (x * 18) + left - 4; + int sy = (y * 18) + top - 4; + ScreenDrawing.texturedRect(matrices, sx, sy, 26, 26, WItemSlot.SLOT_TEXTURE, + 18 * px, 0, 44 * px, 26 * px, 0xFF_FFFFFF); if (slot.getFocusedSlot() == index) { - int sx = (x * 18) + left - 4; - int sy = (y * 18) + top - 4; - ScreenDrawing.coloredRect(matrices, sx, sy, 26, 1, 0xFF_FFFFA0); - ScreenDrawing.coloredRect(matrices, sx, sy + 1, 1, 26 - 1, 0xFF_FFFFA0); - ScreenDrawing.coloredRect(matrices, sx + 26 - 1, sy + 1, 1, 26 - 1, 0xFF_FFFFA0); - ScreenDrawing.coloredRect(matrices, sx + 1, sy + 26 - 1, 26 - 1, 1, 0xFF_FFFFA0); + ScreenDrawing.texturedRect(matrices, sx, sy, 26, 26, WItemSlot.SLOT_TEXTURE, + 18 * px, 26 * px, 44 * px, 52 * px, 0xFF_FFFFFF); } } else { - ScreenDrawing.drawBeveledPanel(matrices, (x * 18) + left, (y * 18) + top, 16+2, 16+2, - lo, bg, hi); + int sx = (x * 18) + left; + int sy = (y * 18) + top; + ScreenDrawing.texturedRect(matrices, sx, sy, 18, 18, WItemSlot.SLOT_TEXTURE, + 0, 0, 18 * px, 18 * px, 0xFF_FFFFFF); if (slot.getFocusedSlot() == index) { - int sx = (x * 18) + left; - int sy = (y * 18) + top; - ScreenDrawing.coloredRect(matrices, sx, sy, 18, 1, 0xFF_FFFFA0); - ScreenDrawing.coloredRect(matrices, sx, sy + 1, 1, 18 - 1, 0xFF_FFFFA0); - ScreenDrawing.coloredRect(matrices, sx + 18 - 1, sy + 1, 1, 18 - 1, 0xFF_FFFFA0); - ScreenDrawing.coloredRect(matrices, sx + 1, sy + 18 - 1, 18 - 1, 1, 0xFF_FFFFA0); + ScreenDrawing.texturedRect(matrices, sx, sy, 18, 18, WItemSlot.SLOT_TEXTURE, + 0, 26 * px, 18 * px, 44 * px, 0xFF_FFFFFF); } } } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java index fd94100..0ec0869 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java @@ -1,5 +1,7 @@ package io.github.cottonmc.cotton.gui.widget; +import io.github.cottonmc.cotton.gui.impl.LibGuiCommon; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; @@ -20,6 +22,9 @@ import io.github.cottonmc.cotton.gui.impl.VisualLogger; import io.github.cottonmc.cotton.gui.impl.client.NarrationMessages; import io.github.cottonmc.cotton.gui.widget.data.InputResult; import io.github.cottonmc.cotton.gui.widget.icon.Icon; + +import net.minecraft.util.Identifier; + import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -65,6 +70,13 @@ import java.util.function.Predicate; * </pre> */ public class WItemSlot extends WWidget { + /** + * The default texture of item slots and {@link BackgroundPainter#SLOT}. + * + * @since 6.2.0 + */ + public static final Identifier SLOT_TEXTURE = new Identifier(LibGuiCommon.MOD_ID, "textures/widget/item_slot.png"); + private static final VisualLogger LOGGER = new VisualLogger(WItemSlot.class); private final List<ValidatedSlot> peers = new ArrayList<>(); @Nullable diff --git a/src/main/resources/assets/libgui/textures/widget/item_slot.png b/src/main/resources/assets/libgui/textures/widget/item_slot.png Binary files differnew file mode 100644 index 0000000..9136344 --- /dev/null +++ b/src/main/resources/assets/libgui/textures/widget/item_slot.png |