diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-05-27 21:41:40 +0300 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-05-27 21:41:40 +0300 |
commit | db7d84e44b8a21c7a43b5f81f8c3b152a20b5ab4 (patch) | |
tree | 8e42528e48fba4830492ee8814f3901caf8bde46 /src/main/java/io | |
parent | 0da8b453600577aa2519b9e9427733d9bf4da99d (diff) | |
download | LibGui-db7d84e44b8a21c7a43b5f81f8c3b152a20b5ab4.tar.gz LibGui-db7d84e44b8a21c7a43b5f81f8c3b152a20b5ab4.tar.bz2 LibGui-db7d84e44b8a21c7a43b5f81f8c3b152a20b5ab4.zip |
Convert Texture to a record
Diffstat (limited to 'src/main/java/io')
4 files changed, 14 insertions, 24 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 46b5061..61fcbb8 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 @@ -150,7 +150,7 @@ public interface BackgroundPainter { * @see NinePatch.Builder */ public static BackgroundPainter createNinePatch(Texture texture, Consumer<NinePatch.Builder<Identifier>> configurator) { - TextureRegion<Identifier> region = new TextureRegion<>(texture.image, texture.u1, texture.v1, texture.u2, texture.v2); + TextureRegion<Identifier> region = new TextureRegion<>(texture.image(), texture.u1(), texture.v1(), texture.u2(), texture.v2()); var builder = NinePatch.builder(region); configurator.accept(builder); var ninePatch = builder.build(); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java index 74a5aba..30c3295 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java @@ -111,7 +111,7 @@ public class ScreenDrawing { * @since 3.0.0 */ public static void texturedRect(MatrixStack matrices, int x, int y, int width, int height, Texture texture, int color, float opacity) { - texturedRect(matrices, x, y, width, height, texture.image, texture.u1, texture.v1, texture.u2, texture.v2, color, opacity); + texturedRect(matrices, x, y, width, height, texture.image(), texture.u1(), texture.v1(), texture.u2(), texture.v2(), color, opacity); } /** diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java index 1aea8ec..1b45a5a 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java @@ -135,7 +135,7 @@ public class WBar extends WWidget { int top = y + getHeight(); top -= barSize; if (bar!=null) { - ScreenDrawing.texturedRect(matrices, left, top, getWidth(), barSize, bar.image, bar.u1, MathHelper.lerp(percent, bar.v2, bar.v1), bar.u2, bar.v2, 0xFFFFFFFF); + ScreenDrawing.texturedRect(matrices, left, top, getWidth(), barSize, bar.image(), bar.u1(), MathHelper.lerp(percent, bar.v2(), bar.v1()), bar.u2(), bar.v2(), 0xFFFFFFFF); } else { ScreenDrawing.coloredRect(matrices, left, top, getWidth(), barSize, ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f)); } @@ -143,7 +143,7 @@ public class WBar extends WWidget { } case RIGHT: { if (bar!=null) { - ScreenDrawing.texturedRect(matrices, x, y, barSize, getHeight(), bar.image, bar.u1, bar.v1, MathHelper.lerp(percent, bar.u1, bar.u2), bar.v2, 0xFFFFFFFF); + ScreenDrawing.texturedRect(matrices, x, y, barSize, getHeight(), bar.image(), bar.u1(), bar.v1(), MathHelper.lerp(percent, bar.u1(), bar.u2()), bar.v2(), 0xFFFFFFFF); } else { ScreenDrawing.coloredRect(matrices, x, y, barSize, getHeight(), ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f)); } @@ -151,7 +151,7 @@ public class WBar extends WWidget { } case DOWN: { if (bar!=null) { - ScreenDrawing.texturedRect(matrices, x, y, getWidth(), barSize, bar.image, bar.u1, bar.v1, bar.u2, MathHelper.lerp(percent, bar.v1, bar.v2), 0xFFFFFFFF); + ScreenDrawing.texturedRect(matrices, x, y, getWidth(), barSize, bar.image(), bar.u1(), bar.v1(), bar.u2(), MathHelper.lerp(percent, bar.v1(), bar.v2()), 0xFFFFFFFF); } else { ScreenDrawing.coloredRect(matrices, x, y, getWidth(), barSize, ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f)); } @@ -162,7 +162,7 @@ public class WBar extends WWidget { int top = y; left -= barSize; if (bar!=null) { - ScreenDrawing.texturedRect(matrices, left, top, barSize, getHeight(), bar.image, MathHelper.lerp(percent, bar.u2, bar.u1), bar.v1, bar.u2, bar.v2, 0xFFFFFFFF); + ScreenDrawing.texturedRect(matrices, left, top, barSize, getHeight(), bar.image(), MathHelper.lerp(percent, bar.u2(), bar.u1()), bar.v1(), bar.u2(), bar.v2(), 0xFFFFFFFF); } else { ScreenDrawing.coloredRect(matrices, left, top, barSize, getHeight(), ScreenDrawing.colorAtOpacity(0xFFFFFF, 0.5f)); } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java index 408a3cd..e1265ce 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/Texture.java @@ -7,19 +7,14 @@ import java.util.Objects; /** * Represents a texture for a widget. * + * @param image the image of this texture + * @param u1 the start U-coordinate, between 0 and 1 + * @param v1 the start V-coordinate, between 0 and 1 + * @param u2 the end U-coordinate, between 0 and 1 + * @param v2 the end V-coordinate, between 0 and 1 * @since 3.0.0 */ -public final class Texture { - /** - * The image of this texture. - */ - public final Identifier image; - - /** - * The UV coordinates of this texture, between 0 and 1. - */ - public final float u1, v1, u2, v2; - +public record Texture(Identifier image, float u1, float v1, float u2, float v2) { /** * Constructs a new texture that uses the full image. * @@ -40,13 +35,8 @@ public final class Texture { * @param v2 the bottom V coordinate * @throws NullPointerException if the image is null */ - public Texture(Identifier image, float u1, float v1, float u2, float v2) { - this.image = Objects.requireNonNull(image, "image"); - - this.u1 = u1; - this.v1 = v1; - this.u2 = u2; - this.v2 = v2; + public Texture { + Objects.requireNonNull(image, "image"); } /** |