From 5b6810a32f65fa4ae30e551e0f3d8186156dba6c Mon Sep 17 00:00:00 2001 From: Leo dev Date: Wed, 30 Apr 2025 07:52:30 -0500 Subject: [PATCH] removed borders --- .../org/saturnclient/ui2/RenderScope.java | 75 ------------------- .../java/org/saturnclient/ui2/anim/Fade.java | 6 +- .../org/saturnclient/ui2/elements/Button.java | 5 -- .../ui2/elements/TextureButton.java | 11 +-- 4 files changed, 8 insertions(+), 89 deletions(-) diff --git a/src/main/java/org/saturnclient/ui2/RenderScope.java b/src/main/java/org/saturnclient/ui2/RenderScope.java index 2ede297..ac2b2cd 100644 --- a/src/main/java/org/saturnclient/ui2/RenderScope.java +++ b/src/main/java/org/saturnclient/ui2/RenderScope.java @@ -147,81 +147,6 @@ public class RenderScope { this.matrices.pop(); } - public void drawRoundedBorderCornerTopLeft(int s, int radius, int color) { - for (double angle = Math.PI / 2; angle <= Math.PI; angle += Math.PI / 180) { - int x = (int) Math.round(radius * Math.cos(angle)); - int y = (int) Math.round(radius * Math.sin(angle)); - - int snappedX = radius + x; - int snappedY = radius - y; - - drawRect(snappedX, snappedY, s, s, color); - } - } - - - public void drawRoundedBorderCornerTopRight(int s, int radius, int color) { - for (double angle = Math.PI; angle >= Math.PI / 2; angle -= Math.PI / 180) { - int x = (int) Math.round(radius * Math.cos(angle)); - int y = (int) Math.round(radius * Math.sin(angle)); - - int snappedX = radius - x; - int snappedY = radius - y; - - drawRect(snappedX, snappedY, s, s, color); - } - } - - public void drawRoundedBorderCornerBottomLeft(int s, int radius, int color) { - for (double angle = Math.PI; angle <= Math.PI * 1.5; angle += Math.PI / 180) { - int x = (int) Math.round(radius * Math.cos(angle)); - int y = (int) Math.round(radius * Math.sin(angle)); - - int snappedX = radius + x; - int snappedY = radius - y; - - drawRect(snappedX, snappedY, s, s, color); - } - } - - public void drawRoundedBorderCornerBottomRight(int s, int radius, int color) { - for (double angle = Math.PI * 1.5; angle <= Math.PI * 2; angle += Math.PI / 180) { - int x = (int) Math.round(radius * Math.cos(angle)); - int y = (int) Math.round(radius * Math.sin(angle)); - - int snappedX = radius + x; - int snappedY = radius - y; - - drawRect(snappedX, snappedY, s, s, color); - } - } - - public void drawRoundedBorder(int width, int height, int size, int radius, int color) { - radius = Math.min(radius, Math.min(width, height)) * 20; - size *= 10; - width *= 40; - height *= 40; - - matrices.push(); - matrices.scale(0.025f, 0.025f, 1.0f); - drawRoundedBorderCornerTopLeft(size, radius, color); - - drawRect(radius, 0, width - (radius * 2), size, color); - drawRect(0, radius, size, height - (radius * 2), color); - - drawRect(radius, height - size, width - (radius * 2), size, color); - - drawRect(width - size, radius, size, height - (radius * 2), color); - - matrices.translate(width - (radius * 2) - size, 0, 0); - drawRoundedBorderCornerTopRight(size, radius, color); - matrices.translate(0, height - (radius * 2) - size, 0); - drawRoundedBorderCornerBottomRight(size, radius, color); - matrices.translate(-(width - (radius * 2) - size), 0, 0); - drawRoundedBorderCornerBottomLeft(size, radius, color); - matrices.pop(); - } - public int getScaledWindowWidth() { return SaturnClient.client.getWindow().getScaledWidth(); } diff --git a/src/main/java/org/saturnclient/ui2/anim/Fade.java b/src/main/java/org/saturnclient/ui2/anim/Fade.java index 38e870a..47dfd65 100644 --- a/src/main/java/org/saturnclient/ui2/anim/Fade.java +++ b/src/main/java/org/saturnclient/ui2/anim/Fade.java @@ -3,18 +3,20 @@ package org.saturnclient.ui2.anim; import org.saturnclient.ui2.Element; public class Fade extends Animation { + float targetOpacity; + public Fade(int duration) { super(duration); } @Override public void tick(float progress, Element element) { - element.opacity = progress; - // element.opacity += 0.1f; + element.opacity = targetOpacity * progress; } @Override public void init(Element element) { + targetOpacity = element.opacity; element.opacity = 0; } } diff --git a/src/main/java/org/saturnclient/ui2/elements/Button.java b/src/main/java/org/saturnclient/ui2/elements/Button.java index 9aa21b1..603caa0 100644 --- a/src/main/java/org/saturnclient/ui2/elements/Button.java +++ b/src/main/java/org/saturnclient/ui2/elements/Button.java @@ -13,14 +13,11 @@ public class Button extends Element { private static ThemeManager theme = new ThemeManager("Button", "hovering"); private static Property bgColor = theme.property("bg-color", new Property(0xFF000000)); private static Property fgColor = theme.property("fg-color", new Property(0xFFFFFFFF)); - private static Property borderColor = theme.property("border-color", new Property(0xFFFFFFFF)); - private static Property border = theme.property("border", new Property(1)); private static Property cornerRadius = theme.property("corner-radius", new Property(10)); private static Property bold = theme.property("fg-bold", new Property(false)); static { theme.propertyStateDefault("hovering", "fg-color", 0xFFFF0000); - theme.propertyStateDefault("hovering", "border-color", 0xFFFF0000); } private String text; @@ -43,8 +40,6 @@ public class Button extends Element { } renderScope.drawRoundedRectangle(0, 0, width, height, cornerRadius.value, bgColor.value); - renderScope.drawRoundedBorder(width, height, border.value, cornerRadius.value, borderColor.value); - renderScope.drawText(text, (width - Fonts.getWidth(text, font)) / 2, (height - Fonts.getHeight()) / 2, bold.value, fgColor.value); } diff --git a/src/main/java/org/saturnclient/ui2/elements/TextureButton.java b/src/main/java/org/saturnclient/ui2/elements/TextureButton.java index 340fb97..d03749d 100644 --- a/src/main/java/org/saturnclient/ui2/elements/TextureButton.java +++ b/src/main/java/org/saturnclient/ui2/elements/TextureButton.java @@ -13,14 +13,12 @@ public class TextureButton extends Element { private static ThemeManager theme = new ThemeManager("TextureButton", "hovering"); private static Property bgColor = theme.property("bg-color", new Property(0xFF000000)); private static Property fgColor = theme.property("fg-color", new Property(0xFFFFFFFF)); - private static Property borderColor = theme.property("border-color", new Property(0xFFFFFFFF)); - private static Property border = theme.property("border", new Property(1)); + private static Property padding = theme.property("padding", new Property(14)); private static Property cornerRadius = theme.property("corner-radius", new Property(10)); static { theme.propertyStateDefault("hovering", "fg-color", 0xFFFF0000); - theme.propertyStateDefault("hovering", "border-color", 0xFFFF0000); } Identifier sprite; @@ -40,14 +38,13 @@ public class TextureButton extends Element { } renderScope.drawRoundedRectangle(0, 0, width, height, cornerRadius.value, bgColor.value); - renderScope.drawRoundedBorder(width, height, border.value, cornerRadius.value, borderColor.value); renderScope.setRenderLayer(RenderLayer::getGuiTextured); - int texWidth = width - 4; - int texHeight = height - 4; + int texWidth = width - padding.value; + int texHeight = height - padding.value; - renderScope.drawTexture(sprite, 2, 2, 0, 0, texWidth, texHeight, fgColor.value); + renderScope.drawTexture(sprite, padding.value / 2, padding.value / 2, 0, 0, texWidth, texHeight, fgColor.value); } @Override