diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-06-01 17:37:49 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-06-01 17:37:49 +0100 |
commit | e48cd4479f832cdd341ab0a289d1b4a88ab21a3c (patch) | |
tree | 01f38d4575287612f1720b6f1f294ea91d15e617 /src/main | |
parent | d109fac644fb9be7424f35fa24eb0ad32331e799 (diff) | |
download | OneConfig-e48cd4479f832cdd341ab0a289d1b4a88ab21a3c.tar.gz OneConfig-e48cd4479f832cdd341ab0a289d1b4a88ab21a3c.tar.bz2 OneConfig-e48cd4479f832cdd341ab0a289d1b4a88ab21a3c.zip |
OC-53 should be done but had to push + color utils changed again
Diffstat (limited to 'src/main')
21 files changed, 238 insertions, 174 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 6c37229..a78ab12 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -5,7 +5,6 @@ import cc.polyfrost.oneconfig.config.core.OneColor; import cc.polyfrost.oneconfig.gui.elements.BasicElement; import cc.polyfrost.oneconfig.gui.elements.ColorSelector; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; -import cc.polyfrost.oneconfig.gui.pages.HomePage; import cc.polyfrost.oneconfig.gui.pages.ModsPage; import cc.polyfrost.oneconfig.gui.pages.Page; import cc.polyfrost.oneconfig.libs.universal.*; @@ -13,6 +12,7 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; import org.jetbrains.annotations.NotNull; @@ -30,8 +30,8 @@ public class OneConfigGui extends UScreen { private final TextInputField textInputField = new TextInputField(248, 40, "Search...", false, false, SVGs.MAGNIFYING_GLASS_BOLD); private final ArrayList<Page> previousPages = new ArrayList<>(); private final ArrayList<Page> nextPages = new ArrayList<>(); - private final BasicElement backArrow = new BasicElement(40, 40, -1, false); - private final BasicElement forwardArrow = new BasicElement(40, 40, -1, false); + private final BasicElement backArrow = new BasicElement(40, 40, new ColorPalette(OneConfigConfig.GRAY_700, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_500_80), true); + private final BasicElement forwardArrow = new BasicElement(40, 40, new ColorPalette(OneConfigConfig.GRAY_700, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_500_80), true); private final ArrayList<Page> parents = new ArrayList<>(); public ColorSelector currentColorSelector; public boolean mouseDown; @@ -100,7 +100,7 @@ public class OneConfigGui extends UScreen { textInputField.draw(vg, x + 1020, y + 16); sideBar.draw(vg, x, y); backArrow.draw(vg, x + 240, y + 16); - forwardArrow.draw(vg, x + 280, y + 16); + forwardArrow.draw(vg, x + 288, y + 16); if (previousPages.size() == 0) { backArrow.disable(true); @@ -109,7 +109,7 @@ public class OneConfigGui extends UScreen { backArrow.disable(false); if (!backArrow.isHovered() || Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); } - RenderManager.drawSvg(vg, SVGs.ARROW_CIRCLE_LEFT, x + 249, y + 25, 22, 22); + RenderManager.drawSvg(vg, SVGs.CHEVRON_LEFT, x + 246, y + 22, 28, 28); RenderManager.setAlpha(vg, 1f); if (nextPages.size() == 0) { forwardArrow.disable(true); @@ -118,7 +118,7 @@ public class OneConfigGui extends UScreen { forwardArrow.disable(false); if (!forwardArrow.isHovered() || Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); } - RenderManager.drawSvg(vg, SVGs.ARROW_CIRCLE_RIGHT, x + 289, y + 25, 22, 22); + RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, x + 294, y + 22, 28, 28); RenderManager.setAlpha(vg, 1f); if (backArrow.isClicked() && previousPages.size() > 0) { @@ -152,13 +152,13 @@ public class OneConfigGui extends UScreen { } ScissorManager.clearScissors(vg); - float breadcrumbX = x + 336; + float breadcrumbX = x + 352; for (int i = 0; i < parents.size(); i++) { String title = parents.get(i).getTitle(); float width = RenderManager.getTextWidth(vg, title, 24f, Fonts.SEMIBOLD); boolean hovered = InputUtils.isAreaHovered((int) breadcrumbX, y + 24, (int) width, 36); int color = OneConfigConfig.WHITE_60; - if (i == parents.size() - 1) color = OneConfigConfig.WHITE_95; + if (i == parents.size() - 1) color = OneConfigConfig.WHITE; else if (hovered && !Mouse.isButtonDown(0)) color = OneConfigConfig.WHITE_80; RenderManager.drawText(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.SEMIBOLD); if (i != 0) diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index c9699f7..f4da715 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -8,27 +8,27 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.GuiUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import java.util.ArrayList; import static cc.polyfrost.oneconfig.gui.elements.BasicButton.ALIGNMENT_LEFT; import static cc.polyfrost.oneconfig.gui.elements.BasicButton.SIZE_36; -import static cc.polyfrost.oneconfig.utils.ColorUtils.*; public class SideBar { private final ArrayList<BasicButton> buttons = new ArrayList<BasicButton>() {{ - add(new BasicButton(192, SIZE_36, "Credits", SVGs.COPYRIGHT_FILL, null, ALIGNMENT_LEFT, TERTIARY)); - add(new BasicButton(192, SIZE_36, "Global Search", SVGs.MAGNIFYING_GLASS_BOLD, null, ALIGNMENT_LEFT, TERTIARY)); - add(new BasicButton(192, SIZE_36, "Mods", SVGs.FADERS_HORIZONTAL_BOLD, null, ALIGNMENT_LEFT, PRIMARY)); - add(new BasicButton(192, SIZE_36, "Profiles", SVGs.USER_SWITCH_FILL, null, ALIGNMENT_LEFT, TERTIARY)); - add(new BasicButton(192, SIZE_36, "Performance", SVGs.GAUGE_FILL, null, ALIGNMENT_LEFT, TERTIARY)); - add(new BasicButton(192, SIZE_36, "Updates", SVGs.ARROWS_CLOCKWISE_BOLD, null, ALIGNMENT_LEFT, TERTIARY)); - add(new BasicButton(192, SIZE_36, "Themes", SVGs.PAINT_BRUSH_BROAD_FILL, null, ALIGNMENT_LEFT, TERTIARY)); - add(new BasicButton(192, SIZE_36, "Screenshots", SVGs.APERTURE_FILL, null, ALIGNMENT_LEFT, TERTIARY)); - add(new BasicButton(192, SIZE_36, "Preferences", SVGs.GEAR_SIX_FILL, null, ALIGNMENT_LEFT, TERTIARY)); + add(new BasicButton(192, SIZE_36, "Credits", SVGs.COPYRIGHT_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(192, SIZE_36, "Global Search", SVGs.MAGNIFYING_GLASS_BOLD, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(192, SIZE_36, "Mods", SVGs.FADERS_HORIZONTAL_BOLD, null, ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(192, SIZE_36, "Profiles", SVGs.USER_SWITCH_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(192, SIZE_36, "Performance", SVGs.GAUGE_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(192, SIZE_36, "Updates", SVGs.ARROWS_CLOCKWISE_BOLD, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(192, SIZE_36, "Themes", SVGs.PAINT_BRUSH_BROAD_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(192, SIZE_36, "Screenshots", SVGs.APERTURE_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(192, SIZE_36, "Preferences", SVGs.GEAR_SIX_FILL, null, ALIGNMENT_LEFT, ColorPalette.TERTIARY)); }}; - private final BasicButton HUDButton = new BasicButton(192, SIZE_36, "Edit HUD", SVGs.NOTE_PENCIL_BOLD, null, ALIGNMENT_LEFT, SECONDARY); - private final BasicButton CloseButton = new BasicButton(192, SIZE_36, "Close", SVGs.X_CIRCLE_BOLD, null, ALIGNMENT_LEFT, SECONDARY_DESTRUCTIVE); + private final BasicButton HUDButton = new BasicButton(192, SIZE_36, "Edit HUD", SVGs.NOTE_PENCIL_BOLD, null, ALIGNMENT_LEFT, ColorPalette.SECONDARY); + private final BasicButton CloseButton = new BasicButton(192, SIZE_36, "Close", SVGs.X_CIRCLE_BOLD, null, ALIGNMENT_LEFT, ColorPalette.SECONDARY_DESTRUCTIVE); public SideBar() { buttons.get(0).setClickAction(new CreditsPage()); @@ -54,10 +54,10 @@ public class SideBar { for (BasicButton button : buttons) { if (button.isClicked()) { - button.setColorPalette(PRIMARY); + button.setColorPalette(ColorPalette.PRIMARY); for (BasicButton button1 : buttons) { if (button.equals(button1)) continue; - button1.setColorPalette(TERTIARY); + button1.setColorPalette(ColorPalette.TERTIARY); } break; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java index f8edf78..8166883 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -6,7 +6,9 @@ import cc.polyfrost.oneconfig.gui.pages.Page; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; +import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Mouse; @@ -14,7 +16,7 @@ public class BasicButton extends BasicElement { protected String text; protected SVGs icon1, icon2; - private final int alignment, colorPalette; + private final int alignment; private final float fontSize, cornerRadius; private final int xSpacing, xPadding; private final int iconSize; @@ -29,15 +31,17 @@ public class BasicButton extends BasicElement { public static final int SIZE_36 = 36; public static final int SIZE_40 = 40; public static final int SIZE_48 = 48; + + public static final int CUSTOM_COLOR = -100; private boolean toggleable = false; private Page page; private Runnable runnable; - public BasicButton(int width, int size, String text, int align, int colorPalette) { + public BasicButton(int width, int size, String text, int align, @NotNull ColorPalette colorPalette) { this(width, size, text, null, null, align, colorPalette); } - public BasicButton(int width, int size, String text, SVGs icon1, SVGs icon2, int align, int colorPalette) { + public BasicButton(int width, int size, String text, SVGs icon1, SVGs icon2, int align, @NotNull ColorPalette colorPalette) { super(width, 32, colorPalette, true); if (text != null) this.text = text; if (icon1 != null) this.icon1 = icon1; @@ -54,7 +58,7 @@ public class BasicButton extends BasicElement { this.fontSize = size == SIZE_48 ? 20 : (float) (size / 2 - 4); } - public BasicButton(int width, int size, SVGs icon, int align, int colorPalette) { + public BasicButton(int width, int size, SVGs icon, int align, @NotNull ColorPalette colorPalette) { this(width, size, null, icon, null, align, colorPalette); } @@ -74,19 +78,16 @@ public class BasicButton extends BasicElement { public void draw(long vg, int x, int y) { this.x = x; this.y = y; - RenderManager.drawRoundedRect(vg, x, y, this.width, this.height, currentColor, this.cornerRadius); + RenderManager.drawRoundedRect(vg, x, y, this.width, this.height, colorPalette == ColorPalette.TERTIARY || colorPalette == ColorPalette.TERTIARY_DESTRUCTIVE ? OneConfigConfig.TRANSPARENT : currentColor, this.cornerRadius); float contentWidth = 0f; int color = -1; + if(colorPalette == ColorPalette.TERTIARY || colorPalette == ColorPalette.TERTIARY_DESTRUCTIVE) { + color = currentColor; + } final float middle = x + width / 2f; final float middleYIcon = y + height / 2f - iconSize / 2f; final float middleYText = y + height / 2f + fontSize / 8f; if (this.text != null) { - if (this.colorPalette == ColorUtils.TERTIARY) { - color = OneConfigConfig.WHITE_80; - if (hovered) color = OneConfigConfig.WHITE; - if (clicked) color = OneConfigConfig.WHITE_80; - if (page == null) color = OneConfigConfig.WHITE_50; - } contentWidth += RenderManager.getTextWidth(vg, text, fontSize, Fonts.MEDIUM); } if (alignment == ALIGNMENT_CENTER) { @@ -177,10 +178,6 @@ public class BasicButton extends BasicElement { public void update(int x, int y) { super.update(x, y); if (hoverFx) { - if (colorPalette == ColorUtils.TERTIARY) { - currentColor = OneConfigConfig.TRANSPARENT; - return; - } if (!toggleable) { currentColor = ColorUtils.getColor(currentColor, colorPalette, hovered, hovered && Mouse.isButtonDown(0)); } else { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java index 8b86827..93e2c07 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -1,27 +1,29 @@ package cc.polyfrost.oneconfig.gui.elements; import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; +import org.jetbrains.annotations.NotNull; public class BasicElement { protected int width, height; - protected int colorPalette; + protected ColorPalette colorPalette; protected int hitBoxX, hitBoxY; protected boolean hoverFx; protected boolean hovered = false; protected boolean clicked = false; protected boolean toggled = false; protected boolean disabled = false; - protected int currentColor; + public int currentColor; protected final float radius; private boolean block = false; - public BasicElement(int width, int height, int colorPalette, boolean hoverFx) { + public BasicElement(int width, int height, @NotNull ColorPalette colorPalette, boolean hoverFx) { this(width, height, colorPalette, hoverFx, 12f); } - public BasicElement(int width, int height, int colorPalette, boolean hoverFx, float radius) { + public BasicElement(int width, int height, @NotNull ColorPalette colorPalette, boolean hoverFx, float radius) { this.height = height; this.width = width; this.colorPalette = colorPalette; @@ -30,7 +32,7 @@ public class BasicElement { } public BasicElement(int width, int height, boolean hoverFx) { - this(width, height, ColorUtils.TRANSPARENT, hoverFx, 12f); + this(width, height, ColorPalette.TRANSPARENT, hoverFx, 12f); } @@ -80,7 +82,7 @@ public class BasicElement { this.height = height; } - public void setColorPalette(int colorPalette) { + public void setColorPalette(ColorPalette colorPalette) { this.colorPalette = colorPalette; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java index edd145e..8cc8165 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -11,7 +11,7 @@ import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; import cc.polyfrost.oneconfig.utils.NetworkUtils; @@ -31,11 +31,11 @@ public class ColorSelector { private final ArrayList<BasicElement> buttons = new ArrayList<>(); private final BasicElement closeBtn = new BasicElement(32, 32, false); - private final BasicButton copyBtn = new BasicButton(32, 32, SVGs.COPY, BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY); - private final BasicButton pasteBtn = new BasicButton(32, 32, SVGs.PASTE, BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY); - private final BasicButton guideBtn = new BasicButton(112, 32, "Guide", SVGs.HELP_CIRCLE, SVGs.POP_OUT, BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY); - private final BasicButton faveBtn = new BasicButton(32, 32, SVGs.HEART_OUTLINE, BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY); - private final BasicButton recentBtn = new BasicButton(32, 32, SVGs.HISTORY, BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY); + private final BasicButton copyBtn = new BasicButton(32, 32, SVGs.COPY, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); + private final BasicButton pasteBtn = new BasicButton(32, 32, SVGs.PASTE, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); + private final BasicButton guideBtn = new BasicButton(112, 32, "Guide", SVGs.HELP_CIRCLE, SVGs.POP_OUT, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); + private final BasicButton faveBtn = new BasicButton(32, 32, SVGs.HEART_OUTLINE, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); + private final BasicButton recentBtn = new BasicButton(32, 32, SVGs.HISTORY, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); private final NumberInputField hueInput = new NumberInputField(90, 32, 0, 0, 360, 1); private final NumberInputField saturationInput = new NumberInputField(90, 32, 100, 0, 100, 1); @@ -56,9 +56,9 @@ public class ColorSelector { public ColorSelector(OneColor color, int mouseX, int mouseY) { this.color = color; - buttons.add(new BasicElement(124, 28, ColorUtils.SECONDARY, true, 10f)); - buttons.add(new BasicElement(124, 28, ColorUtils.SECONDARY, true, 10f)); - buttons.add(new BasicElement(124, 28, ColorUtils.SECONDARY, true, 10f)); + buttons.add(new BasicElement(124, 28, ColorPalette.SECONDARY, true, 10f)); + buttons.add(new BasicElement(124, 28, ColorPalette.SECONDARY, true, 10f)); + buttons.add(new BasicElement(124, 28, ColorPalette.SECONDARY, true, 10f)); hueInput.setCurrentValue(color.getHue()); saturationInput.setCurrentValue(color.getSaturation()); brightnessInput.setCurrentValue(color.getBrightness()); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java index 410f98f..d5e8895 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -9,7 +9,8 @@ import cc.polyfrost.oneconfig.libs.universal.wrappers.UPlayer; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.fml.common.ModMetadata; @@ -19,7 +20,7 @@ import java.util.ArrayList; public class ModCard extends BasicElement { private final Mod modData; - private final BasicElement favoriteHitbox = new BasicElement(32, 32, ColorUtils.PRIMARY, true); + private final BasicElement favoriteHitbox = new BasicElement(32, 32, ColorPalette.PRIMARY, true); private boolean active, disabled, favorite; private int colorGray = OneConfigConfig.GRAY_600; private int colorPrimary = OneConfigConfig.PRIMARY_600; @@ -62,11 +63,11 @@ public class ModCard extends BasicElement { super.update(x, y); isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87); boolean isHoveredSecondary = InputUtils.isAreaHovered(x, y + 87, width - 32, 32) && !disabled; - colorGray = ColorUtils.getColor(colorGray, ColorUtils.SECONDARY, isHoveredMain, clicked && isHoveredMain); + colorGray = ColorUtils.getColor(colorGray, ColorPalette.SECONDARY, isHoveredMain, clicked && isHoveredMain); if (active && !disabled) { - colorPrimary = ColorUtils.getColor(colorPrimary, ColorUtils.PRIMARY, isHoveredSecondary, clicked && isHoveredSecondary); + colorPrimary = ColorUtils.getColor(colorPrimary, ColorPalette.PRIMARY, isHoveredSecondary, clicked && isHoveredSecondary); } else { - colorPrimary = ColorUtils.getColor(colorPrimary, ColorUtils.SECONDARY, isHoveredSecondary, false); + colorPrimary = ColorUtils.getColor(colorPrimary, ColorPalette.SECONDARY, isHoveredSecondary, false); } if (clicked && isHoveredMain) { if (!active) toggled = false; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java index a10e3a0..d58852f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java @@ -5,7 +5,7 @@ import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import java.lang.reflect.Field; @@ -14,13 +14,13 @@ public class ConfigButton extends BasicOption { public ConfigButton(Runnable runnable, Object parent, String name, int size, String text) { super(null, parent, name, size); - this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorUtils.PRIMARY); + this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY); this.button.setClickAction(runnable); } public ConfigButton(Field field, Object parent, String name, int size, String text) { super(field, parent, name, size); - this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorUtils.PRIMARY); + this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY); this.button.setClickAction(getRunnableFromField(field, parent)); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java index 0f1a2bb..543a8e0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java @@ -5,7 +5,8 @@ import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; @@ -40,7 +41,7 @@ public class ConfigCheckbox extends BasicOption { e.printStackTrace(); } } - color = ColorUtils.getColor(color, ColorUtils.SECONDARY, hover, false); + color = ColorUtils.getColor(color, ColorPalette.SECONDARY, hover, false); if (percentOn != 1f) { // performance RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, color, 6f); RenderManager.drawHollowRoundRect(vg, x, y + 4, 23.5f, 23.5f, OneConfigConfig.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java index 4a986d7..51d3fec 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java @@ -5,7 +5,8 @@ import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.input.Mouse; @@ -40,7 +41,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f } if (opened) return; - backgroundColor = ColorUtils.getColor(backgroundColor, ColorUtils.SECONDARY, hovered, false); + backgroundColor = ColorUtils.getColor(backgroundColor, ColorPalette.SECONDARY, hovered, false); int selected = 0; try { selected = (int) get(); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java index 78ef0b3..b10cf2c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java @@ -9,7 +9,7 @@ import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import java.lang.reflect.Field; @@ -19,7 +19,7 @@ public class ConfigKeyBind extends BasicOption { public ConfigKeyBind(Field field, Object parent, String name, int size) { super(field, parent, name, size); - button = new BasicButton(256, 32, "", SVGs.KEYSTROKE, null, BasicButton.ALIGNMENT_LEFT, ColorUtils.SECONDARY); + button = new BasicButton(256, 32, "", SVGs.KEYSTROKE, null, BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY); button.setToggleable(true); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java index ec13566..a68370a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java @@ -8,7 +8,8 @@ import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.input.Mouse; @@ -30,7 +31,7 @@ public class ConfigPageButton extends BasicOption { int height = description.equals("") ? 64 : 96; boolean hovered = InputUtils.isAreaHovered(x - 2, y, 1024, height) && isEnabled(); boolean clicked = hovered && InputUtils.isClicked(); - backgroundColor = ColorUtils.getColor(backgroundColor, ColorUtils.SECONDARY, hovered, false); + backgroundColor = ColorUtils.getColor(backgroundColor, ColorPalette.SECONDARY, hovered, false); if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java index 61c0dd5..8a0d85e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java @@ -4,7 +4,8 @@ import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; @@ -28,7 +29,7 @@ public class ConfigSwitch extends BasicOption { } int x2 = x + 3 + (int) (percentOn * 18); boolean hovered = InputUtils.isAreaHovered(x, y, 42, 32); - colorDisabled = ColorUtils.getColor(colorDisabled, ColorUtils.SECONDARY, hovered, false); + colorDisabled = ColorUtils.getColor(colorDisabled, ColorPalette.SECONDARY, hovered, false); colorEnabled = ColorUtils.smoothColor(colorEnabled, OneConfigConfig.PRIMARY_600, OneConfigConfig.PRIMARY_500, hovered, 40f); if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, colorDisabled, 12f); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java index ce048c9..698d04b 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java @@ -7,7 +7,7 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java index 925f61d..bdf3dfa 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java @@ -4,7 +4,8 @@ import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.gui.elements.BasicElement; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; +import cc.polyfrost.oneconfig.utils.color.ColorUtils; public class NumberInputField extends TextInputField { private final BasicElement upArrow = new BasicElement(12, 14, false); @@ -47,8 +48,8 @@ public class NumberInputField extends TextInputField { if (current == max) colorTop = OneConfigConfig.GRAY_500_80; if (current == min) colorBottom = OneConfigConfig.GRAY_500_80; - colorTop = ColorUtils.getColor(colorTop, ColorUtils.SECONDARY, upArrow.isHovered(), upArrow.isClicked()); - colorBottom = ColorUtils.getColor(colorBottom, ColorUtils.SECONDARY, downArrow.isHovered(), downArrow.isClicked()); + colorTop = ColorUtils.getColor(colorTop, ColorPalette.SECONDARY, upArrow.isHovered(), upArrow.isClicked()); + colorBottom = ColorUtils.getColor(colorBottom, ColorPalette.SECONDARY, downArrow.isHovered(), downArrow.isClicked()); if (upArrow.isClicked()) { current += step; if (current > max) current = max; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java index 3e15e83..bd73c1e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java @@ -1,18 +1,9 @@ package cc.polyfrost.oneconfig.gui.pages; import cc.polyfrost.oneconfig.config.OneConfigConfig; -import cc.polyfrost.oneconfig.config.core.OneColor; -import cc.polyfrost.oneconfig.gui.OneConfigGui; -import cc.polyfrost.oneconfig.gui.elements.BasicButton; -import cc.polyfrost.oneconfig.gui.elements.ColorSelector; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import cc.polyfrost.oneconfig.utils.ColorUtils; -import cc.polyfrost.oneconfig.utils.InputUtils; -import cc.polyfrost.oneconfig.utils.NetworkUtils; - -import java.awt.*; public class HomePage extends Page { /*private final BasicButton socialsBtn = new BasicButton(184, 36, "Socials", SVGs.SHARE, SVGs.POP_OUT, BasicButton.ALIGNMENT_CENTER, ColorUtils.PRIMARY); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java index 205de07..b5f2256 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java @@ -6,7 +6,7 @@ import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import java.util.ArrayList; @@ -28,7 +28,7 @@ public class ModConfigPage extends Page { } if (page.categories.size() < 2) return; for (String category : page.categories.keySet()) { - BasicButton button = new BasicButton(0, SIZE_32, category, BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY); + BasicButton button = new BasicButton(0, SIZE_32, category, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY); button.setClickAction(() -> switchCategory(category)); button.setToggleable(true); if (category.equals(selectedCategory)) button.setToggled(true); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java index cc087a3..6df01e1 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -9,7 +9,7 @@ import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.gui.elements.ModCard; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.utils.ColorUtils; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; import java.util.ArrayList; import java.util.List; @@ -25,13 +25,13 @@ public class ModsPage extends Page { for (Mod modData : OneConfig.loadedMods) { modCards.add(OneConfigConfig.favoriteMods.contains(modData.name) ? 0 : modCards.size(), new ModCard(modData, modData.config == null || modData.config.enabled, false, OneConfigConfig.favoriteMods.contains(modData.name))); } - modCategories.add(new BasicButton(64, 32, "All", BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY)); - modCategories.add(new BasicButton(80, 32, "Combat", BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY)); - modCategories.add(new BasicButton(64, 32, "HUD", BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY)); - modCategories.add(new BasicButton(104, 32, "Utility & QoL", BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY)); - modCategories.add(new BasicButton(80, 32, "Hypixel", BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY)); - modCategories.add(new BasicButton(80, 32, "Skyblock", BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY)); - modCategories.add(new BasicButton(88, 32, "3rd Party", BasicButton.ALIGNMENT_CENTER, ColorUtils.SECONDARY)); + modCategories.add(new BasicButton(64, 32, "All", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + modCategories.add(new BasicButton(80, 32, "Combat", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + modCategories.add(new BasicButton(64, 32, "HUD", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + modCategories.add(new BasicButton(104, 32, "Utility & QoL", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + modCategories.add(new BasicButton(80, 32, "Hypixel", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + modCategories.add(new BasicButton(80, 32, "Skyblock", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + modCategories.add(new BasicButton(88, 32, "3rd Party", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); modCategories.get(0).setToggled(true); int i = 0; for (BasicButton button : modCategories) { diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java new file mode 100644 index 0000000..c2a1fec --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java @@ -0,0 +1,140 @@ +package cc.polyfrost.oneconfig.utils.color; + + +import cc.polyfrost.oneconfig.config.OneConfigConfig; +import cc.polyfrost.oneconfig.config.core.OneColor; + +import java.awt.*; + +import static cc.polyfrost.oneconfig.config.OneConfigConfig.*; + +public class ColorPalette { + /** + * Always returns transparent. + */ + public static final ColorPalette TRANSPARENT = new ColorPalette(OneConfigConfig.TRANSPARENT, OneConfigConfig.TRANSPARENT, OneConfigConfig.TRANSPARENT); + /** + * <h1>Primary Color Scheme</h1> Normal: Primary 600,<br> Hover: Primary 700,<br> Clicked: Primary 700 (80%) + */ + public static final ColorPalette PRIMARY = new ColorPalette(PRIMARY_600, PRIMARY_700, PRIMARY_700_80); + /** + * <h1>Secondary Color Scheme</h1> Normal: Gray 500,<br> Hover: Gray 400,<br> Clicked: Gray 400 (80%) + */ + public static final ColorPalette SECONDARY = new ColorPalette(OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, OneConfigConfig.GRAY_400_80); + /** + * <h1>Secondary (Transparent) Color Scheme</h1> Normal: Transparent,<br> Hover: Gray rgba(229, 229, 229, 77),<br> Clicked: Gray rgba(229, 229, 229, 51) + */ + public static final ColorPalette SECONDARY_TRANSPARENT = new ColorPalette(OneConfigConfig.TRANSPARENT, new Color(229, 229, 229, 77).getRGB(), new Color(229, 229, 229, 51).getRGB()); + /** + * <h1>Tertiary Color Scheme</h1> Normal: Transparent (Text=White 90%),<br> Hover: Transparent (Text=White 100%),<br> Clicked: Transparent (Text=White 80%) + * <h2>NOTICE this returns the text colors as it is always transparent.</h2> + */ + public static final ColorPalette TERTIARY = new ColorPalette(WHITE_90, WHITE, WHITE_80); + /** + * <h1>Primary Destructive Color Scheme</h1> Normal: Error 700,<br> Hover: Error 600,<br> Clicked: Error 600 (80%) + */ + public static final ColorPalette PRIMARY_DESTRUCTIVE = new ColorPalette(ERROR_700, ERROR_600, ERROR_600_80); + /** + * <h1>Secondary Destructive Color Scheme</h1> Normal: Gray 500,<br> Hover: Error 800,<br> Clicked: Error 800 (80%) + */ + public static final ColorPalette SECONDARY_DESTRUCTIVE = new ColorPalette(OneConfigConfig.GRAY_500, ERROR_800, ERROR_800_80); + /** + * <h1>Tertiary Destructive Color Scheme</h1> Normal: Transparent (Text=White 90%),<br> Hover: Transparent (Text=Error 300),<br> Clicked: Transparent (Text=Error 300 80%) + * <h2>NOTICE this returns the text colors as it is always transparent.</h2> + */ + public static final ColorPalette TERTIARY_DESTRUCTIVE = new ColorPalette(WHITE_90, ERROR_300, ERROR_300_80); + + + + + private final int colorNormal; + private final int colorHovered; + private final int colorPressed; + private final float[] colorNormalf; + private final float[] colorHoveredf; + private final float[] colorPressedf; + + /** <h1>Create a new ColorPalette.</h1> + * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. + * <br> This method takes integers in ARGB format, like many other classes, such as {@link OneColor} and {@link Color}. + * @param colorNormal the color of the element when it is not hovered or pressed. + * @param colorHovered the color of the element when it is hovered. + * @param colorPressed the color of the element when it is pressed. + */ + public ColorPalette(int colorNormal, int colorHovered, int colorPressed) { + this.colorNormal = colorNormal; + this.colorHovered = colorHovered; + this.colorPressed = colorPressed; + this.colorNormalf = new float[]{ColorUtils.getRed(colorNormal) / 255f, ColorUtils.getGreen(colorNormal) / 255f, ColorUtils.getBlue(colorNormal) / 255f, ColorUtils.getAlpha(colorNormal) / 255f}; + this.colorHoveredf = new float[]{ColorUtils.getRed(colorHovered) / 255f, ColorUtils.getGreen(colorHovered) / 255f, ColorUtils.getBlue(colorHovered) / 255f, ColorUtils.getAlpha(colorHovered) / 255f}; + this.colorPressedf = new float[]{ColorUtils.getRed(colorPressed) / 255f, ColorUtils.getGreen(colorPressed) / 255f, ColorUtils.getBlue(colorPressed) / 255f, ColorUtils.getAlpha(colorPressed) / 255f}; + } + /** <h1>Create a new ColorPalette.</h1> + * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. + * <br> This method takes {@link OneColor} in ARGB format. + * @param colorNormal the color of the element when it is not hovered or pressed. + * @param colorHovered the color of the element when it is hovered. + * @param colorPressed the color of the element when it is pressed. + */ + public ColorPalette(OneColor colorNormal, OneColor colorHovered, OneColor colorPressed) { + this(colorNormal.getRGB(), colorHovered.getRGB(), colorPressed.getRGB()); + } + + /** <h1>Create a new ColorPalette.</h1> + * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. + * <br> This method takes {@link Color} in ARGB format. + * @param colorNormal the color of the element when it is not hovered or pressed. + * @param colorHovered the color of the element when it is hovered. + * @param colorPressed the color of the element when it is pressed. + */ + public ColorPalette(Color colorNormal, Color colorHovered, Color colorPressed) { + this(colorNormal.getRGB(), colorHovered.getRGB(), colorPressed.getRGB()); + } + + /** <h1>Create a new ColorPalette.</h1> + * This color palette is used with animations, and the elements like BasicButton, BasicElement, and more. + * <br> This method takes float arrays of the color between 0f and 1f, in [R, G, B, A] format. + * @param colorNormal the color of the element when it is not hovered or pressed. + * @param colorHovered the color of the element when it is hovered. + * @param colorPressed the color of the element when it is pressed. + */ + public ColorPalette(float[] colorNormal, float[] colorHovered, float[] colorPressed) { + this.colorNormalf = colorNormal; + this.colorHoveredf = colorHovered; + this.colorPressedf = colorPressed; + this.colorNormal = ColorUtils.getColor(colorNormal[0], colorNormal[1], colorNormal[2], colorNormal[3]); + this.colorHovered = ColorUtils.getColor(colorHovered[0], colorHovered[1], colorHovered[2], colorHovered[3]); + this.colorPressed = ColorUtils.getColor(colorPressed[0], colorPressed[1], colorPressed[2], colorPressed[3]); + } + + /** Return the color of the element when it is not hovered or pressed in ARGB format. */ + public int getNormalColor() { + return colorNormal; + } + + /** Return the color of the element when it is hovered in ARGB format. */ + public int getHoveredColor() { + return colorHovered; + } + + /** Return the color of the element when it is pressed in ARGB format. */ + public int getPressedColor() { + return colorPressed; + } + + /** Return the color of the element when it is not hovered or pressed in a float array (r,g,b,a). */ + public float[] getNormalColorf() { + return colorNormalf; + } + + /** Return the color of the element when it is hovered in a float array (r,g,b,a). */ + public float[] getHoveredColorf() { + return colorHoveredf; + } + + /** Return the color of the element when it is pressed in a float array (r,g,b,a). */ + public float[] getPressedColorf() { + return colorPressedf; + } + +} diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java index 127b200..a419766 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java @@ -1,91 +1,19 @@ -package cc.polyfrost.oneconfig.utils; +package cc.polyfrost.oneconfig.utils.color; -import cc.polyfrost.oneconfig.config.OneConfigConfig; - -import java.awt.*; +import cc.polyfrost.oneconfig.utils.MathUtils; /** * A class to help with color manipulation. */ public final class ColorUtils { - /** - * Always returns transparent. - */ - public static final int TRANSPARENT = -10; - /** - * <h1>Primary Color Scheme</h1> Normal: Primary 600,<br> Hover: Primary 700,<br> Clicked: Primary 700 (80%) - */ - public static final int PRIMARY = 1; - /** - * <h1>Secondary Color Scheme</h1> Normal: Gray 500,<br> Hover: Gray 400,<br> Clicked: Gray 400 (80%) - */ - public static final int SECONDARY = 2; - /** - * <h1>Secondary (Transparent) Color Scheme</h1> Normal: Transparent,<br> Hover: Gray rgba(229, 229, 229, 77),<br> Clicked: Gray rgba(229, 229, 229, 51) - */ - public static final int SECONDARY_TRANSPARENT = 0; - /** - * <h1>Tertiary Color Scheme</h1> Normal: Transparent (Text=White 90%),<br> Hover: Transparent (Text=White 100%),<br> Clicked: Transparent (Text=White 80%) - * <h2>NOTICE this returns the text colors as it is always transparent.</h2> - */ - public static final int TERTIARY = 3; - /** - * <h1>Primary Destructive Color Scheme</h1> Normal: Error 700,<br> Hover: Error 600,<br> Clicked: Error 600 (80%) - */ - public static final int PRIMARY_DESTRUCTIVE = -1; - /** - * <h1>Secondary Destructive Color Scheme</h1> Normal: Gray 500,<br> Hover: Error 800,<br> Clicked: Error 800 (80%) - */ - public static final int SECONDARY_DESTRUCTIVE = -2; - /** - * <h1>Tertiary Destructive Color Scheme</h1> Normal: Transparent (Text=White 90%),<br> Hover: Transparent (Text=Error 300),<br> Clicked: Transparent (Text=Error 300 80%) - * <h2>NOTICE this returns the text colors as it is always transparent.</h2> - */ - public static final int TERTIARY_DESTRUCTIVE = -3; - - public static int getColor(int currentColor, int colorPalette, boolean hover, boolean click) { + public static int getColor(int currentColor, ColorPalette colorPalette, boolean hover, boolean click) { float[] color = splitColor(currentColor); - if (colorPalette == TRANSPARENT) { - return OneConfigConfig.TRANSPARENT; - } if (click) { - switch (colorPalette) { - case PRIMARY_DESTRUCTIVE: - return OneConfigConfig.ERROR_600_80; - case SECONDARY_DESTRUCTIVE: - return OneConfigConfig.ERROR_800_80; - case TERTIARY_DESTRUCTIVE: - return OneConfigConfig.ERROR_300_80; - case TERTIARY: - return OneConfigConfig.WHITE_80; - default: - case SECONDARY: - return OneConfigConfig.GRAY_400_80; - case SECONDARY_TRANSPARENT: - return new Color(0.9f, 0.9f, 0.9f, 0.2f).getRGB(); - case PRIMARY: - return OneConfigConfig.PRIMARY_700_80; - } + return colorPalette.getPressedColor(); } - switch (colorPalette) { - case SECONDARY_TRANSPARENT: // Formally -2 - return getColorComponents(color, new float[]{0f, 0f, 0f, 0f}, new float[]{0.9f, 0.9f, 0.9f, 0.3f}, hover, 50f); - case PRIMARY: // Formally 1 - return getColorComponents(color, splitColor(OneConfigConfig.PRIMARY_700), splitColor(OneConfigConfig.PRIMARY_600), hover, 20f); - default: - case SECONDARY: // Formally 0 - return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_400), hover, 20f); - case TERTIARY: - return getColorComponents(color, splitColor(OneConfigConfig.WHITE_90), splitColor(OneConfigConfig.WHITE), hover, 20f); - case PRIMARY_DESTRUCTIVE: - return getColorComponents(color, splitColor(OneConfigConfig.ERROR_700), splitColor(OneConfigConfig.ERROR_600), hover, 20f); - case SECONDARY_DESTRUCTIVE: - return getColorComponents(color, splitColor(OneConfigConfig.ERROR_800), splitColor(OneConfigConfig.GRAY_500), !hover, 20f); - case TERTIARY_DESTRUCTIVE: - return getColorComponents(color, splitColor(OneConfigConfig.WHITE_90), splitColor(OneConfigConfig.ERROR_300), hover, 20f); - } + return getColorComponents(color, colorPalette.getNormalColorf(), colorPalette.getHoveredColorf(), hover, 20f); } /** diff --git a/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/ColorUtilsDSL.kt b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/ColorUtilsDSL.kt index fbcf32a..6e366ab 100644 --- a/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/ColorUtilsDSL.kt +++ b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/ColorUtilsDSL.kt @@ -1,7 +1,7 @@ package cc.polyfrost.oneconfig.utils.dsl import cc.polyfrost.oneconfig.config.core.OneColor -import cc.polyfrost.oneconfig.utils.ColorUtils +import cc.polyfrost.oneconfig.utils.color.ColorUtils /** * Creates a new [OneColor] from the given RGBA integer. diff --git a/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/RenderManagerDSL.kt b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/RenderManagerDSL.kt index cbdf07e..242f1a5 100644 --- a/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/RenderManagerDSL.kt +++ b/src/main/kotlin/cc/polyfrost/oneconfig/utils/dsl/RenderManagerDSL.kt @@ -5,7 +5,7 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager import cc.polyfrost.oneconfig.lwjgl.font.Font import cc.polyfrost.oneconfig.lwjgl.image.Images import cc.polyfrost.oneconfig.lwjgl.image.SVGs -import cc.polyfrost.oneconfig.utils.ColorUtils +import cc.polyfrost.oneconfig.utils.color.ColorUtils import org.lwjgl.nanovg.NVGColor /** |