diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-25 22:01:01 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 14:01:01 +0100 |
commit | 045ca00486e62c89a4da5f880f6f52016e4dd14a (patch) | |
tree | f77f40fbaed328b0d6b54a98adb49d7dd9b38229 /src/main/java/cc/polyfrost/oneconfig/gui/elements | |
parent | 8a01f36d1021159f2c49ae8083febc046a4a8502 (diff) | |
download | OneConfig-045ca00486e62c89a4da5f880f6f52016e4dd14a.tar.gz OneConfig-045ca00486e62c89a4da5f880f6f52016e4dd14a.tar.bz2 OneConfig-045ca00486e62c89a4da5f880f6f52016e4dd14a.zip |
fix: stop using internal asset classes everywhere (#69)
* fix: stop using internal asset classes everywhere
new: add wrapper classes for NanoVG rendering and rename original Image wrapper to OneImage
* I love regex
Co-authored-by: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/elements')
5 files changed, 20 insertions, 19 deletions
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 afe899d..f98371d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -1,11 +1,11 @@ package cc.polyfrost.oneconfig.gui.elements; -import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.pages.Page; +import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.renderer.RenderManager; +import cc.polyfrost.oneconfig.renderer.SVG; import cc.polyfrost.oneconfig.renderer.font.Fonts; -import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import cc.polyfrost.oneconfig.utils.color.ColorUtils; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; public class BasicButton extends BasicElement { protected String text; - protected SVGs icon1, icon2; + protected SVG icon1, icon2; private final int alignment; private final float fontSize, cornerRadius; private final float xSpacing, xPadding; @@ -31,7 +31,7 @@ public class BasicButton extends BasicElement { private Page page; private Runnable runnable; - public BasicButton(int width, int size, String text, SVGs icon1, SVGs icon2, int align, @NotNull ColorPalette colorPalette) { + public BasicButton(int width, int size, String text, SVG icon1, SVG icon2, int align, @NotNull ColorPalette colorPalette) { super(width, 32, colorPalette, true); if (text != null) this.text = text; if (icon1 != null) this.icon1 = icon1; @@ -48,7 +48,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, @NotNull ColorPalette colorPalette) { + public BasicButton(int width, int size, SVG icon, int align, @NotNull ColorPalette colorPalette) { this(width, size, null, icon, null, align, colorPalette); } @@ -156,11 +156,11 @@ public class BasicButton extends BasicElement { this.text = text; } - public void setLeftIcon(SVGs icon) { + public void setLeftIcon(SVG icon) { icon1 = icon; } - public void setRightIcon(SVGs icon) { + public void setRightIcon(SVG icon) { icon2 = icon; } 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 568567d..d32aa65 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -102,7 +102,7 @@ public class ColorSelector { recentColors.add(new ColorBox(new OneColor(0, 0, 0, 0))); } - topSlider.setImage(Images.HUE_GRADIENT); + topSlider.setImage(Images.HUE_GRADIENT.filePath); } public void draw(long vg) { @@ -183,7 +183,7 @@ public class ColorSelector { dragging = false; } bottomSlider.setGradient(Colors.TRANSPARENT, color.getRGBNoAlpha()); - RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x + 16, y + 456, 384, 16, 8f); + RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x + 16, y + 456, 384, 16, 8f); bottomSlider.draw(vg, x + 16, y + 456); if (percentMoveMain > 0.96f) { @@ -198,7 +198,7 @@ public class ColorSelector { // draw the color preview RenderManager.drawHollowRoundRect(vg, x + 15, y + 487, 384, 40, Colors.GRAY_300, 12f, 2f); - RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x + 20, y + 492, 376, 32, 8f); + RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x + 20, y + 492, 376, 32, 8f); RenderManager.drawRoundedRect(vg, x + 20, y + 492, 376, 32, color.getRGB(), 8f); inputScissor = InputUtils.blockInputArea(x - 3, y - 3, width + 6, height + 6); @@ -215,7 +215,7 @@ public class ColorSelector { case 0: case 2: //buttons.get(mode).colorAnimation.setPalette(ColorPalette.TERTIARY); - topSlider.setImage(Images.HUE_GRADIENT); + topSlider.setImage(Images.HUE_GRADIENT.filePath); RenderManager.drawHSBBox(vg, x + 16, y + 120, 384, 288, color.getRGBMax(true)); if (mode == 0) { @@ -231,7 +231,7 @@ public class ColorSelector { case 1: //buttons.get(1).colorAnimation.setPalette(ColorPalette.TERTIARY); topSlider.setImage(null); - RenderManager.drawRoundImage(vg, Images.COLOR_WHEEL, x + 64, y + 120, 288, 288, 144f); + RenderManager.drawRoundImage(vg, Images.COLOR_WHEEL.filePath, x + 64, y + 120, 288, 288, 144f); topSlider.setGradient(Colors.BLACK, color.getRGBMax(true)); topSlider.setImage(null); @@ -419,7 +419,7 @@ public class ColorSelector { private static class ColorSlider extends Slider { protected int gradColorStart, gradColorEnd; - protected Images image; + protected String image; protected int color; public ColorSlider(int length, float min, float max, float startValue) { @@ -455,7 +455,7 @@ public class ColorSelector { this.color = color; } - public void setImage(Images image) { + public void setImage(String image) { this.image = image; } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java index a3b45bf..ce6b378 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java @@ -84,7 +84,7 @@ public class ConfigColorElement extends BasicOption { element.update(x1 + 416, y); RenderManager.drawHollowRoundRect(vg, x1 + 415, y - 1, 64, 32, Colors.GRAY_300, 12f, 2f); - RenderManager.drawRoundImage(vg, Images.ALPHA_GRID, x1 + 420, y + 4, 56, 24, 8f); + RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x1 + 420, y + 4, 56, 24, 8f); RenderManager.drawRoundedRect(vg, x1 + 420, y + 4, 56, 24, color.getRGB(), 8f); if (element.isClicked() && !open) { open = true; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java index 3d9602b..4f7d0f5 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java @@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.config.elements.BasicOption; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; +import cc.polyfrost.oneconfig.renderer.SVG; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.utils.InputUtils; @@ -46,7 +47,7 @@ public class ConfigTextBox extends BasicOption { textField.draw(vg, x + (size == 1 ? 224 : 352), y); if (secure) { - SVGs icon = textField.getPassword() ? SVGs.EYE_OFF : SVGs.EYE; + final SVG icon = textField.getPassword() ? SVGs.EYE_OFF : SVGs.EYE; boolean hovered = InputUtils.isAreaHovered(x + 967, y + 7, 18, 18) && isEnabled(); int color = hovered ? Colors.WHITE : Colors.WHITE_80; if (hovered && InputUtils.isClicked()) textField.setPassword(!textField.getPassword()); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java index 3c2cb1c..1052487 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java @@ -2,10 +2,10 @@ package cc.polyfrost.oneconfig.gui.elements.text; import cc.polyfrost.oneconfig.gui.elements.BasicElement; import cc.polyfrost.oneconfig.internal.assets.Colors; -import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; +import cc.polyfrost.oneconfig.renderer.SVG; import cc.polyfrost.oneconfig.renderer.font.Fonts; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager; @@ -35,12 +35,12 @@ public class TextInputField extends BasicElement { protected boolean onlyNums = false; protected boolean errored = false; protected boolean centered = false; - protected SVGs icon; + protected SVG icon; protected ArrayList<String> wrappedText = null; private long clickTimeD1; private int lines = 1; - public TextInputField(int width, int height, String defaultText, boolean multiLine, boolean password, SVGs icon) { + public TextInputField(int width, int height, String defaultText, boolean multiLine, boolean password, SVG icon) { super(width, height, false); this.multiLine = multiLine; this.defaultText = defaultText; |