diff --git a/src/main/java/org/saturnclient/ui2/components/Sidebar.java b/src/main/java/org/saturnclient/ui2/components/Sidebar.java index 36b9492..aa47d99 100644 --- a/src/main/java/org/saturnclient/ui2/components/Sidebar.java +++ b/src/main/java/org/saturnclient/ui2/components/Sidebar.java @@ -1,9 +1,8 @@ package org.saturnclient.ui2.components; import org.saturnclient.saturnclient.SaturnClient; -import org.saturnclient.saturnclient.config.Property; import org.saturnclient.saturnclient.config.SaturnClientConfig; -import org.saturnclient.saturnclient.config.ThemeManager; +import org.saturnclient.saturnclient.config.Theme; import org.saturnclient.ui2.resources.Textures; import org.saturnclient.ui2.Element; import org.saturnclient.ui2.ElementContext; @@ -18,19 +17,6 @@ import net.minecraft.client.render.RenderLayer; import net.minecraft.util.Identifier; public class Sidebar extends Element { - private static ThemeManager theme = new ThemeManager("SideBar", "hovering"); - 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)); - private static Property iconRadius = theme.property("icon-radius", Property.integer(10)); - private static Property padding = theme.property("padding", Property.integer(10)); - - static { - theme.propertyStateDefault("hovering", "icon-bg", -7643914); - } - public static class SidebarComponent { Runnable onClick; boolean end; @@ -45,7 +31,7 @@ public class Sidebar extends Element { Runnable onClose; SidebarComponent[] components = { - new Sidebar.SidebarComponent(Textures.MODS_TAB, () -> { + new Sidebar.SidebarComponent(Textures.MODS_TAB, () -> { SaturnClient.client.setScreen(new ModMenu()); }, false), new Sidebar.SidebarComponent(Textures.SETTINGS, () -> { @@ -79,36 +65,33 @@ public class Sidebar extends Element { int bottomRow = 0; int gap = 5; // 5px gap between icons - int sp = 30 - padding.value + gap; - int s = 30 - (padding.value * 2); - int s2 = s + padding.value; + int padding = 10; + int sp = 30 - padding + gap; + int s = 30 - (padding * 2); + int s2 = s + padding; renderScope.setRenderLayer(RenderLayer::getGuiTextured); - renderScope.drawRoundedRectangle(0, 0, width, height, cornerRadius.value, bgColor.value); + renderScope.drawRoundedRectangle(0, 0, width, height, Theme.BG_RADIUS.value, Theme.BACKGROUND.value); int i = 0; for (SidebarComponent component : components) { if (component.end) { int y = (height - (sp * bottomRow)) - (s * 2); - if (ctx.isHovering(0, y - (padding.value / 2), s2, s2) || active == i) { - theme.setState("hovering"); - } else { - theme.setState(null); + if (ctx.isHovering(0, y - (padding / 2), s2, s2) || active == i) { } - renderScope.drawRoundedRectangle(padding.value / 2, y - (padding.value / 2), s + padding.value, s + padding.value, iconRadius.value, iconBg.value); - renderScope.drawTexture(component.sprite, padding.value, y, 0, 0, s, s, iconFg.value); + renderScope.drawRoundedRectangle(padding / 2, y - (padding / 2), s + padding, + s + padding, Theme.WIDGET_RADIUS.value, Theme.PRIMARY.value); + renderScope.drawTexture(component.sprite, padding, y, 0, 0, s, s, Theme.PRIMARY_FG.value); bottomRow += 1; } else { - int y = padding.value + (sp * topRow); - if (ctx.isHovering(0, y - (padding.value / 2), s2, s2) || active == i) { - theme.setState("hovering"); - } else { - theme.setState(null); + int y = padding + (sp * topRow); + if (ctx.isHovering(0, y - (padding / 2), s2, s2) || active == i) { } - renderScope.drawRoundedRectangle(padding.value / 2, y - (padding.value / 2), s + padding.value, s + padding.value, iconRadius.value, iconBg.value); - renderScope.drawTexture(component.sprite, padding.value, y, 0, 0, s, s, iconFg.value); + renderScope.drawRoundedRectangle(padding / 2, y - (padding / 2), s + padding, + s + padding, Theme.WIDGET_RADIUS.value, Theme.PRIMARY.value); + renderScope.drawTexture(component.sprite, padding, y, 0, 0, s, s, Theme.PRIMARY_FG.value); topRow += 1; } @@ -122,21 +105,22 @@ public class Sidebar extends Element { int bottomRow = 0; int gap = 5; // same 5px gap here - int sp = 30 - padding.value + gap; - int s = 30 - (padding.value * 2); - int s2 = s + padding.value; + int padding = 10; + int sp = 30 - padding + gap; + int s = 30 - (padding * 2); + int s2 = s + padding; for (SidebarComponent component : components) { if (component.end) { int y = (height - (sp * bottomRow)) - (s * 2); - if (Utils.isHovering(mouseX - (padding.value / 2), mouseY - (y - (padding.value / 2)), s2, s2, scale)) { + if (Utils.isHovering(mouseX - (padding / 2), mouseY - (y - (padding / 2)), s2, s2, scale)) { component.onClick.run(); break; } bottomRow += 1; } else { - int y = padding.value + (sp * topRow); - if (Utils.isHovering(mouseX - (padding.value / 2), mouseY - (y - (padding.value / 2)), s2, s2, scale)) { + int y = padding + (sp * topRow); + if (Utils.isHovering(mouseX - (padding / 2), mouseY - (y - (padding / 2)), s2, s2, scale)) { component.onClick.run(); break; }