diff --git a/src/main/java/org/saturnclient/saturnclient/config/Theme.java b/src/main/java/org/saturnclient/saturnclient/config/Theme.java index 5e3ffb0..b053d95 100644 --- a/src/main/java/org/saturnclient/saturnclient/config/Theme.java +++ b/src/main/java/org/saturnclient/saturnclient/config/Theme.java @@ -5,7 +5,7 @@ public class Theme { public static Property FOREGROUND = Property.color(0x00000000); public static Property PRIMARY = Property.color(0x00000000); public static Property PRIMARY_FG = Property.color(0x00000000); - public static Property ACCENT = Property.color(0x00000000); + public static Property ACCENT = Property.color(0xFF845eee); public static Property ACCENT_FG = Property.color(0x00000000); public static Property BG_RADIUS = Property.integer(10); public static Property WIDGET_RADIUS = Property.integer(10); diff --git a/src/main/java/org/saturnclient/ui2/elements/TabMenu.java b/src/main/java/org/saturnclient/ui2/elements/TabMenu.java index e640106..b41757b 100644 --- a/src/main/java/org/saturnclient/ui2/elements/TabMenu.java +++ b/src/main/java/org/saturnclient/ui2/elements/TabMenu.java @@ -1,7 +1,6 @@ package org.saturnclient.ui2.elements; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.saturnclient.config.ThemeManager; +import org.saturnclient.saturnclient.config.Theme; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.ElementContext; import org.saturnclient.ui2.RenderScope; @@ -10,16 +9,6 @@ import org.saturnclient.ui2.Utils; import net.minecraft.util.Identifier; public class TabMenu extends Element { - private static ThemeManager theme = new ThemeManager("TabMenu", "hovering", "selected"); - private static Property bgColor = theme.property("bg-color", Property.color(0x90000000)); - private static Property iconFg = theme.property("icon-fg", Property.color(0xFFFFFFFF)); - private static Property iconBg = theme.property("icon-bg", Property.color(0x00000000)); - private static Property cornerRadius = theme.property("corner-radius", Property.integer(10)); - - static { - theme.propertyStateDefault("hovering", "icon-bg", -7643914); - } - public static class TabMenuComponent { Runnable onClick; Identifier sprite; @@ -29,7 +18,7 @@ public class TabMenu extends Element { this.sprite = sprite; } } - + TabMenuComponent[] components; public int selectedScreen = 0; @@ -42,19 +31,21 @@ public class TabMenu extends Element { @Override public void render(RenderScope renderScope, ElementContext ctx) { - renderScope.drawRoundedRectangle(0, 0, width, height, cornerRadius.value, bgColor.value); + renderScope.drawRoundedRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, Theme.PRIMARY.value); int col = 0; for (TabMenuComponent component : components) { int x = 25 * col + 5; - if (ctx.isHovering(x, 5, 20, 20) || selectedScreen == col) { - theme.setState("hovering"); + + boolean hovering = ctx.isHovering(x, 5, 20, 20) || selectedScreen == col; + + if (hovering) { + renderScope.drawRoundedRectangle(x, 5, 20, 20, Theme.WIDGET_RADIUS.value, Theme.ACCENT.value); } - renderScope.drawRoundedRectangle(x, 5, 20, 20, cornerRadius.value, iconBg.value); - renderScope.drawTexture(component.sprite, x + 5, 10, 0, 0, 10, 10, iconFg.value); + renderScope.drawTexture(component.sprite, x + 5, 10, 0, 0, 10, 10, + hovering ? Theme.ACCENT_FG.value : Theme.PRIMARY_FG.value); - theme.setState(null); col++; } } diff --git a/src/main/java/org/saturnclient/ui2/elements/Text.java b/src/main/java/org/saturnclient/ui2/elements/Text.java index 8465021..285433d 100644 --- a/src/main/java/org/saturnclient/ui2/elements/Text.java +++ b/src/main/java/org/saturnclient/ui2/elements/Text.java @@ -1,27 +1,22 @@ package org.saturnclient.ui2.elements; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.saturnclient.config.ThemeManager; +import org.saturnclient.saturnclient.config.Theme; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.ElementContext; import org.saturnclient.ui2.RenderScope; import org.saturnclient.ui2.resources.Fonts; public class Text extends Element { - private static ThemeManager theme = new ThemeManager("Text"); - private static Property fgColor = theme.property("fg-color", Property.color(0xFFFFFFFF)); - public static Property font = theme.property("font", Property.font(1)); - private String text; public Text(String text) { this.text = text; - width = Fonts.getWidth(text, font.value); + width = Fonts.getWidth(text, Theme.FONT.value); height = Fonts.getHeight(); } @Override public void render(RenderScope renderScope, ElementContext ctx) { - renderScope.drawText(this.text, 0, 0, font.value, fgColor.value); + renderScope.drawText(this.text, 0, 0, Theme.FONT.value, Theme.FOREGROUND.value); } } diff --git a/src/main/java/org/saturnclient/ui2/elements/TextureButton.java b/src/main/java/org/saturnclient/ui2/elements/TextureButton.java index d345bf3..56d8a75 100644 --- a/src/main/java/org/saturnclient/ui2/elements/TextureButton.java +++ b/src/main/java/org/saturnclient/ui2/elements/TextureButton.java @@ -1,7 +1,6 @@ package org.saturnclient.ui2.elements; -import org.saturnclient.saturnclient.config.Property; -import org.saturnclient.saturnclient.config.ThemeManager; +import org.saturnclient.saturnclient.config.Theme; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.ElementContext; import org.saturnclient.ui2.RenderScope; @@ -10,17 +9,6 @@ import net.minecraft.client.render.RenderLayer; import net.minecraft.util.Identifier; public class TextureButton extends Element { - private static ThemeManager theme = new ThemeManager("TextureButton", "hovering"); - private static Property bgColor = theme.property("bg-color", Property.color(0xFF000000)); - private static Property fgColor = theme.property("fg-color", Property.color(0xFFFFFFFF)); - private static Property padding = theme.property("padding", Property.integer(14)); - private static Property cornerRadius = theme.property("corner-radius", Property.integer(10)); - - - static { - theme.propertyStateDefault("hovering", "fg-color", 0xFF845eee); - } - Identifier sprite; private Runnable onClick; @@ -28,23 +16,19 @@ public class TextureButton extends Element { this.sprite = sprite; this.onClick = onClick; } - + @Override public void render(RenderScope renderScope, ElementContext ctx) { - if (ctx.isHovering()) { - theme.setState("hovering"); - } else { - theme.setState(null); - } + renderScope.drawRoundedRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, + ctx.isHovering() ? Theme.ACCENT.value : Theme.PRIMARY.value); - renderScope.drawRoundedRectangle(0, 0, width, height, cornerRadius.value, bgColor.value); - renderScope.setRenderLayer(RenderLayer::getGuiTextured); - int texWidth = width - padding.value; - int texHeight = height - padding.value; - - renderScope.drawTexture(sprite, padding.value / 2, padding.value / 2, 0, 0, texWidth, texHeight, fgColor.value); + int texWidth = width - Theme.PADDING.value; + int texHeight = height - Theme.PADDING.value; + + renderScope.drawTexture(sprite, Theme.PADDING.value / 2, Theme.PADDING.value / 2, 0, 0, texWidth, texHeight, + ctx.isHovering() ? Theme.ACCENT_FG.value : Theme.PRIMARY_FG.value); } @Override