From 6254bbc42d0611f8eaee97b6d4c7710d082c6826 Mon Sep 17 00:00:00 2001 From: MoonTidez <79183852+MoonTidez@users.noreply.github.com> Date: Sun, 15 May 2022 19:50:30 +0400 Subject: SVG + asset reorganization (#10) * Assets reorganization * forgot 4 pixels in alpha grid oops * Updated huegradient.png Reduces file size by only use 1px height instead of 720px while maintaining quality * we do a little renaming * new assets mapping * moon I hate you * e * moon is weird * make it compile * temp * part png rendering * svgs * fix some positionings and stuff Co-authored-by: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> --- .../java/cc/polyfrost/oneconfig/OneConfig.java | 2 +- .../cc/polyfrost/oneconfig/gui/OneConfigGui.java | 11 +- .../java/cc/polyfrost/oneconfig/gui/SideBar.java | 31 ++--- .../oneconfig/gui/elements/BasicButton.java | 23 ++-- .../oneconfig/gui/elements/ColorSelector.java | 15 +-- .../polyfrost/oneconfig/gui/elements/ModCard.java | 7 +- .../gui/elements/config/ConfigCheckbox.java | 7 +- .../gui/elements/config/ConfigColorElement.java | 2 +- .../gui/elements/config/ConfigDropdown.java | 13 +- .../oneconfig/gui/elements/config/ConfigInfo.java | 13 +- .../gui/elements/config/ConfigKeyBind.java | 3 +- .../gui/elements/config/ConfigPageButton.java | 3 +- .../gui/elements/config/ConfigTextBox.java | 3 +- .../gui/elements/config/ConfigUniSelector.java | 9 +- .../gui/elements/text/NumberInputField.java | 13 +- .../cc/polyfrost/oneconfig/gui/pages/HomePage.java | 3 +- .../cc/polyfrost/oneconfig/gui/pages/ModsPage.java | 3 +- .../polyfrost/oneconfig/lwjgl/RenderManager.java | 100 ++++++++++++++-- .../cc/polyfrost/oneconfig/lwjgl/image/Image.java | 21 ---- .../oneconfig/lwjgl/image/ImageLoader.java | 84 ++++++++++++- .../cc/polyfrost/oneconfig/lwjgl/image/Images.java | 55 +-------- .../cc/polyfrost/oneconfig/lwjgl/image/SVGs.java | 132 +++++++++++++++++++++ .../cc/polyfrost/oneconfig/utils/ColorUtils.java | 4 + 23 files changed, 396 insertions(+), 161 deletions(-) delete mode 100644 src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Image.java create mode 100644 src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java (limited to 'src/main/java/cc') diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java index 2dfca40..3661c42 100644 --- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java @@ -57,7 +57,7 @@ public class OneConfig { RenderManager.setupAndDraw((vg) -> { RenderManager.drawRoundedRect(vg, -100, -100, 50, 50, -1, 12f); RenderManager.drawString(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.MEDIUM); - RenderManager.drawImage(vg, Images.LOGO, -100, -100, 50, 50); + RenderManager.drawImage(vg, Images.HUE_GRADIENT, -100, -100, 50, 50); }); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index db32c92..97e03a6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -10,6 +10,7 @@ import cc.polyfrost.oneconfig.lwjgl.OneColor; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; 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.InputUtils; @@ -84,7 +85,7 @@ public class OneConfigGui extends UScreen { RenderManager.drawLine(vg, x + 224, y + 72, x + 1280, y + 72, 1, OneConfigConfig.GRAY_700); RenderManager.drawLine(vg, x + 224, y, x + 222, y + 800, 1, OneConfigConfig.GRAY_700); - RenderManager.drawImage(vg, Images.LOGO, x + 19, y + 19, 42, 42); + RenderManager.drawSvg(vg, SVGs.ONECONFIG, x + 19, y + 19, 42, 42); RenderManager.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.BOLD); // added half line height to center text RenderManager.drawString(vg, "ALPHA - By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.REGULAR); @@ -104,7 +105,7 @@ public class OneConfigGui extends UScreen { backArrow.disable(false); if (!backArrow.isHovered() || Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); } - RenderManager.drawImage(vg, Images.CIRCLE_ARROW, x + 271, y + 25, -22, 22); + RenderManager.drawSvg(vg, SVGs.ARROW_CIRCLE_LEFT, x + 249, y + 25, 22, 22); NanoVG.nvgGlobalAlpha(vg, 1f); if (nextPages.size() == 0) { forwardArrow.disable(true); @@ -113,7 +114,7 @@ public class OneConfigGui extends UScreen { forwardArrow.disable(false); if (!forwardArrow.isHovered() || Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); } - RenderManager.drawImage(vg, Images.CIRCLE_ARROW, x + 289, y + 25, 22, 22); + RenderManager.drawSvg(vg, SVGs.ARROW_CIRCLE_RIGHT, x + 289, y + 25, 22, 22); NanoVG.nvgGlobalAlpha(vg, 1f); if (backArrow.isClicked() && previousPages.size() > 0) { @@ -157,9 +158,7 @@ public class OneConfigGui extends UScreen { else if (hovered && !Mouse.isButtonDown(0)) color = OneConfigConfig.WHITE_80; RenderManager.drawString(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.SEMIBOLD); if (i != 0) - RenderManager.drawImage(vg, Images.CHEVRON_ARROW, breadcrumbX - 22, y + 26, 13, 22, color); - if (hovered && i != parents.size() - 1) - RenderManager.drawLine(vg, breadcrumbX, y + 48, breadcrumbX + width, y + 48, 2, color); + RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, breadcrumbX - 28, y + 25, 24, 24, color); if (hovered && InputUtils.isClicked()) openPage(parents.get(i)); breadcrumbX += width + 32; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index 85d88f9..fcbf647 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -7,6 +7,7 @@ import cc.polyfrost.oneconfig.gui.pages.ModsPage; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.MathUtils; import gg.essential.universal.UScreen; @@ -19,24 +20,24 @@ public class SideBar { private float targetY = 0, currentY = 0; public SideBar() { - btnList.add(new BasicButton(192, 36, "Dashboard", Images.DASHBOARD, null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage())); - btnList.add(new BasicButton(192, 36, "Global Search", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Screenshots", Images.SCREENSHOT, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Preferences", Images.PREFERENCES, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Mods", Images.MODS, null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage())); - btnList.add(new BasicButton(192, 36, "Performance", Images.PERFORMANCE, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Profiles", Images.PROFILES, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Updates", Images.UPDATES, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Themes Library", Images.THEMES, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Themes Browser", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Packs Library", Images.MOD_BOX, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Packs Browser", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT)); - btnList.add(new BasicButton(192, 36, "Close", Images.CLOSE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> UScreen.displayScreen(null))); - btnList.add(new BasicButton(192, 36, "Minimize", Images.MINIMIZE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> { + btnList.add(new BasicButton(192, 36, "Dashboard", SVGs.DASHBOARD, null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage())); + btnList.add(new BasicButton(192, 36, "Global Search", SVGs.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Screenshots", SVGs.IMAGE, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Preferences", SVGs.SETTINGS, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Mods", SVGs.MODS, null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage())); + btnList.add(new BasicButton(192, 36, "Performance", SVGs.PERFORMANCE, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Profiles", SVGs.PROFILES, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Updates", SVGs.UPDATE, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Themes Library", SVGs.THEME, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Themes Browser", SVGs.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Packs Library", SVGs.BOX, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Packs Browser", SVGs.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT)); + btnList.add(new BasicButton(192, 36, "Close", SVGs.X_CIRCLE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> UScreen.displayScreen(null))); + btnList.add(new BasicButton(192, 36, "Minimize", SVGs.MINIMISE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> { OneConfigGui.instanceToRestore = OneConfigGui.INSTANCE; UScreen.displayScreen(null); })); - btnList.add(new BasicButton(192, 36, "Edit HUD", Images.HUD, null, 0, BasicButton.ALIGNMENT_LEFT, () -> UScreen.displayScreen(new HudGui()))); + btnList.add(new BasicButton(192, 36, "Edit HUD", SVGs.HUD, null, 0, BasicButton.ALIGNMENT_LEFT, () -> UScreen.displayScreen(new HudGui()))); } public void draw(long vg, int x, int y) { 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 f705d0b..2b2f590 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -6,6 +6,7 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,7 +14,7 @@ import org.jetbrains.annotations.Nullable; public class BasicButton extends BasicElement { protected String text; - protected Images fileNameLeftIco, fileNameRightIco; + protected SVGs fileNameLeftIco, fileNameRightIco; private final int thisAlignment; private final float fontSize; private final int colorPalette; @@ -35,7 +36,7 @@ public class BasicButton extends BasicElement { * @param colorPalette color palette to use. see {@link ColorUtils} for more info. Can support color palette of -2, which is larger font and icons. Also supports -3, which is just the text changing color. * @param alignment alignment of the button. ALIGNMENT_LEFT or ALIGNMENT_CENTER. */ - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment) { + public BasicButton(int width, int height, @NotNull String text, @Nullable SVGs fileNameLeftIco, @Nullable SVGs fileNameRightIco, int colorPalette, int alignment) { super(width, height, colorPalette, true); this.text = text; if (fileNameLeftIco != null) this.fileNameLeftIco = fileNameLeftIco; @@ -51,22 +52,22 @@ public class BasicButton extends BasicElement { } } - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, Page page) { + public BasicButton(int width, int height, @NotNull String text, @Nullable SVGs fileNameLeftIco, @Nullable SVGs fileNameRightIco, int colorPalette, int alignment, Page page) { this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment); this.page = page; } - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, boolean toggleable) { + public BasicButton(int width, int height, @NotNull String text, @Nullable SVGs fileNameLeftIco, @Nullable SVGs fileNameRightIco, int colorPalette, int alignment, boolean toggleable) { this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment); this.toggleable = toggleable; } - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, Runnable runnable) { + public BasicButton(int width, int height, @NotNull String text, @Nullable SVGs fileNameLeftIco, @Nullable SVGs fileNameRightIco, int colorPalette, int alignment, Runnable runnable) { this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment); this.runnable = runnable; } - public BasicButton(int width, int height, @NotNull String text, @Nullable Images fileNameLeftIco, @Nullable Images fileNameRightIco, int colorPalette, int alignment, boolean toggleable, Runnable runnable) { + public BasicButton(int width, int height, @NotNull String text, @Nullable SVGs fileNameLeftIco, @Nullable SVGs fileNameRightIco, int colorPalette, int alignment, boolean toggleable, Runnable runnable) { this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment, runnable); this.toggleable = toggleable; } @@ -99,22 +100,22 @@ public class BasicButton extends BasicElement { else RenderManager.drawString(vg, text, middle - contentWidth / 2 + (fileNameLeftIco != null ? 28 : 0), y + ((float) height / 2) + 1, textColor, fontSize, Fonts.MEDIUM); if (fileNameLeftIco != null) { - if (alignIconLeft) RenderManager.drawImage(vg, fileNameLeftIco, x + 12, y + height / 2f - 10, 20, 20); - else RenderManager.drawImage(vg, fileNameLeftIco, middle - contentWidth / 2, y + 8, 20, 20); + if (alignIconLeft) RenderManager.drawSvg(vg, fileNameLeftIco, x + 12, y + height / 2f - 10, 20, 20); + else RenderManager.drawSvg(vg, fileNameLeftIco, middle - contentWidth / 2, y + 8, 20, 20); } if (fileNameRightIco != null) { - RenderManager.drawImage(vg, fileNameRightIco, middle + contentWidth / 2 - (fileNameLeftIco != null ? 20 : 24), y + 8, 20, 20); + RenderManager.drawSvg(vg, fileNameRightIco, middle + contentWidth / 2 - (fileNameLeftIco != null ? 20 : 24), y + 8, 20, 20); } } if (thisAlignment == ALIGNMENT_LEFT) { if (fileNameLeftIco != null) { - RenderManager.drawImage(vg, fileNameLeftIco, x + 12, y + 8, 20, 20, textColor); + RenderManager.drawSvg(vg, fileNameLeftIco, x + 12, y + 8, 20, 20, textColor); RenderManager.drawString(vg, text, x + 40, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.MEDIUM); } else { RenderManager.drawString(vg, text, x + 12, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.MEDIUM); } if (fileNameRightIco != null) { - RenderManager.drawImage(vg, fileNameRightIco, x + width - 28, y + 8, 20, 20); + RenderManager.drawSvg(vg, fileNameRightIco, x + width - 28, y + 8, 20, 20); } } this.update(x, y); 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 c309191..faef4ef 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -8,6 +8,7 @@ import cc.polyfrost.oneconfig.lwjgl.OneColor; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; import org.lwjgl.input.Mouse; @@ -77,7 +78,7 @@ public class ColorSelector { RenderManager.drawRoundedRect(vg, x, y, width, height, OneConfigConfig.GRAY_800, 20f); RenderManager.drawString(vg, "Color Selector", x + 16, y + 32, OneConfigConfig.WHITE_90, 18f, Fonts.SEMIBOLD); closeBtn.draw(vg, x + 368, y + 16); - RenderManager.drawImage(vg, Images.CLOSE_COLOR, x + 369, y + 17, 32, 32); + RenderManager.drawSvg(vg, SVGs.X_CIRCLE, x + 369, y + 17, 32, 32); if (closeBtn.isClicked()) { OneConfigGui.INSTANCE.closeColorSelector(); } @@ -144,12 +145,12 @@ public class ColorSelector { copyBtn.draw(vg, x + 204, y + 624); pasteBtn.draw(vg, x + 244, y + 624); - RenderManager.drawImage(vg, Images.COPY, x + 211, y + 631, 18, 18); - RenderManager.drawImage(vg, Images.PASTE, x + 251, y + 631, 18, 18); + RenderManager.drawSvg(vg, SVGs.COPY, x + 211, y + 631, 18, 18); + RenderManager.drawSvg(vg, SVGs.PASTE, x + 251, y + 631, 18, 18); guideBtn.draw(vg, x + 288, y + 624); - RenderManager.drawImage(vg, Images.HELP, x + 301, y + 631, 18, 18); - RenderManager.drawImage(vg, Images.LAUNCH, x + 369, y + 631, 18, 18); + RenderManager.drawSvg(vg, SVGs.HELP_CIRCLE, x + 301, y + 631, 18, 18); + RenderManager.drawSvg(vg, SVGs.POP_OUT, x + 369, y + 631, 18, 18); boolean drag; @@ -214,7 +215,7 @@ public class ColorSelector { break; } bottomSlider.setGradient(OneConfigConfig.TRANSPARENT_25, color.getRGBNoAlpha()); - RenderManager.drawImage(vg, Images.COLOR_BASE_LONG, x + 16, y + 456, 384, 16); + RenderManager.drawImage(vg, Images.ALPHA_GRID, x + 16, y + 456, 384, 16); bottomSlider.draw(vg, x + 16, y + 456); RenderManager.drawRoundedRect(vg, mouseX - 6, mouseY - 6, 12, 12, OneConfigConfig.WHITE, 12f); @@ -265,7 +266,7 @@ public class ColorSelector { // draw the color preview RenderManager.drawHollowRoundRect(vg, x + 15, y + 487, 384, 40, OneConfigConfig.GRAY_300, 12f, 2f); - RenderManager.drawImage(vg, Images.COLOR_BASE_LARGE, x + 20, y + 492, 376, 32); + RenderManager.drawImage(vg, Images.ALPHA_GRID, x + 20, y + 492, 376, 32); RenderManager.drawRoundedRect(vg, x + 20, y + 492, 376, 32, color.getRGB(), 8f); } 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 9af35f1..4942f9f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -9,6 +9,7 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import gg.essential.universal.wrappers.UPlayer; @@ -50,7 +51,7 @@ public class ModCard extends BasicElement { if (iconPath != null) { RenderManager.drawImage(vg, iconPath, x, y, width, 87); } else { - RenderManager.drawImage(vg, Images.MOD_BOX, x + 98, y + 19, 48, 48); + RenderManager.drawSvg(vg, SVGs.BOX, x + 98, y + 19, 48, 48); } favoriteHitbox.update(x + 212, y + 87); favoriteHitbox.currentColor = ColorUtils.getColor(favoriteHitbox.currentColor, favoriteHitbox.colorPalette, favoriteHitbox.hovered, favoriteHitbox.clicked); @@ -58,9 +59,9 @@ public class ModCard extends BasicElement { favorite = favoriteHitbox.isToggled(); RenderManager.drawString(vg, modData.name, x + 12, y + 103, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); if (favorite) { - RenderManager.drawImage(vg, Images.FAVORITE, x + 220, y + 95, 16, 16); + RenderManager.drawSvg(vg, SVGs.HEART_FILL, x + 220, y + 95, 16, 16); } else { - RenderManager.drawImage(vg, Images.FAVORITE_OFF, x + 220, y + 95, 16, 16); + RenderManager.drawSvg(vg, SVGs.HEART_OUTLINE, x + 220, y + 95, 16, 16); } super.update(x, y); isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87); 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 8a30d71..4553739 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,6 +5,7 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; @@ -49,9 +50,11 @@ public class ConfigCheckbox extends BasicOption { RenderManager.drawString(vg, name, x + 32, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 5f)); if (percentOn != 0 && percentOn != 1f) { - RenderManager.drawImage(vg, Images.CHECKMARK, x, y + 4, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB()); + RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, ColorUtils.setAlpha(OneConfigConfig.BLUE_500, (int) (percentOn * 255)), 6f); + RenderManager.drawSvg(vg, SVGs.CHECKBOX_TICK, x, y + 4, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB()); } else if (percentOn != 0) { - RenderManager.drawImage(vg, Images.CHECKMARK, x, y + 4, 24, 24); + RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, OneConfigConfig.BLUE_500, 6f); + RenderManager.drawSvg(vg, SVGs.CHECKBOX_TICK, x, y + 4, 24, 24); } NanoVG.nvgGlobalAlpha(vg, 1f); } 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 aed367f..6cf60e0 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 @@ -78,7 +78,7 @@ public class ConfigColorElement extends BasicOption { element.update(x + 432, y); RenderManager.drawRoundedRect(vg, x + 432, y, 64, 32, OneConfigConfig.GRAY_300, 12f); - RenderManager.drawImage(vg, Images.COLOR_BASE, x + 948, y + 4, 56, 24, color.getRGB()); + RenderManager.drawImage(vg, Images.ALPHA_GRID, x + 948, y + 4, 56, 24, color.getRGB()); if (element.isClicked() && !element.isToggled()) { OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(new OneColor(40, 30, 20), InputUtils.mouseX(), InputUtils.mouseY())); } 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 c2cb0cf..199e0f0 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,6 +5,7 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.input.Mouse; @@ -53,14 +54,12 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor, 12); RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 459, y + 8, 10, 6); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 459, y + 24, 10, -6); + RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 452, y + 4, 24, 24); } else { RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor, 12); RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 971, y + 8, 10, 6); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 971, y + 24, 10, -6); + RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); } NanoVG.nvgGlobalAlpha(vg, 1f); } @@ -114,8 +113,7 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 459, y + 8, 10, 6); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 459, y + 24, 10, -6); + RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 452, y + 4, 24, 24); } else { RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor, 12); RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); @@ -149,8 +147,7 @@ public class ConfigDropdown extends BasicOption { // TODO: chose where dividers if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 971, y + 8, 10, 6); - RenderManager.drawImage(vg, Images.DROPDOWN_ARROW, x + 971, y + 24, 10, -6); + RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); } NanoVG.nvgGlobalAlpha(vg, 1f); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java index 2e29328..68ebf37 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java @@ -6,28 +6,29 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import java.lang.reflect.Field; public class ConfigInfo extends BasicOption { - private Images image; + private SVGs image; public ConfigInfo(Field field, Object parent, String name, int size, InfoType type) { super(field, parent, name, size); switch (type) { case INFO: - image = Images.INFO; + image = SVGs.INFO_CIRCLE; break; case SUCCESS: - image = Images.SUCCESS; + image = SVGs.CHECK_CIRCLE; break; case WARNING: - image = Images.WARNING; + image = SVGs.WARNING; break; case ERROR: - image = Images.ERROR; + image = SVGs.ERROR; break; } } @@ -35,7 +36,7 @@ public class ConfigInfo extends BasicOption { @Override public void draw(long vg, int x, int y) { Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 448 : 960, 32); - RenderManager.drawImage(vg, image, x, y + 4, 24, 24); + RenderManager.drawSvg(vg, image, x, y + 4, 24, 24); RenderManager.drawString(vg, name, x + 32, y + 18, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM); ScissorManager.resetScissor(vg, scissor); } 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 01a2bd2..5b3efae 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 @@ -8,6 +8,7 @@ import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import gg.essential.universal.UKeyboard; import org.lwjgl.nanovg.NanoVG; @@ -19,7 +20,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, "", Images.KEYSTROKE, null, 0, BasicButton.ALIGNMENT_CENTER, true); + button = new BasicButton(256, 32, "", SVGs.KEYSTROKE, null, 0, BasicButton.ALIGNMENT_CENTER, true); button.alignIconLeft(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 3288123..81cd946 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,6 +8,7 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.input.Mouse; @@ -40,7 +41,7 @@ public class ConfigPageButton extends BasicOption { RenderManager.drawString(vg, name, x + 10, y + 32, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); if (!description.equals("")) RenderManager.drawString(vg, name, x + 10, y + 70, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM); - RenderManager.drawImage(vg, Images.CHEVRON_ARROW, x + 981f, y + (description.equals("") ? 20f : 36f), 13, 22); + RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, x + 981f, y + (description.equals("") ? 20f : 36f), 13, 22); if (clicked) OneConfigGui.INSTANCE.openPage(new ModConfigPage(page)); NanoVG.nvgGlobalAlpha(vg, 1f); 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 3aa4050..d420f01 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 @@ -5,6 +5,7 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; import org.lwjgl.nanovg.NanoVG; @@ -39,7 +40,7 @@ public class ConfigTextBox extends BasicOption { textField.draw(vg, x + (size == 1 && hasHalfSize() ? 224 : 352), y); if (secure) - RenderManager.drawImage(vg, Images.HIDE_EYE, x + 967, y + 7, 18, 18, new Color(196, 196, 196).getRGB()); + RenderManager.drawSvg(vg, SVGs.EYE, x + 967, y + 7, 18, 18, new Color(196, 196, 196).getRGB()); if (secure && InputUtils.isAreaClicked(x + 967, y + 7, 18, 18)) textField.setPassword(!textField.getPassword()); NanoVG.nvgGlobalAlpha(vg, 1f); } 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 a9b0ab1..e8927fd 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 @@ -3,6 +3,7 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.lwjgl.RenderManager; +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.lwjgl.font.Fonts; @@ -49,10 +50,10 @@ public class ConfigUniSelector extends BasicOption { } ScissorManager.resetScissor(vg, scissor); - RenderManager.drawImage(vg, Images.CHEVRON_ARROW, x + 248, y + 7, -8, 14, OneConfigConfig.BLUE_400); - RenderManager.drawImage(vg, Images.CHEVRON_ARROW, x + 456, y + 7, 8, 14, OneConfigConfig.BLUE_400); + RenderManager.drawSvg(vg, SVGs.CHEVRON_LEFT, x + 231, y + 7, 18, 18, OneConfigConfig.BLUE_400); + RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, x + 455, y + 7, 18, 18, OneConfigConfig.BLUE_400); - if (InputUtils.isAreaClicked(x + 235, y + 5, 18, 18) && selected > 0 && isEnabled()) { + if (InputUtils.isAreaClicked(x + 231, y + 7, 18, 18) && selected > 0 && isEnabled()) { previous = selected; selected -= 1; try { @@ -60,7 +61,7 @@ public class ConfigUniSelector extends BasicOption { } catch (IllegalAccessException ignored) { } percentMove = selected < previous ? 0f : 1f; - } else if (InputUtils.isAreaClicked(x + 451, y + 5, 18, 18) && selected < options.length - 1 && isEnabled()) { + } else if (InputUtils.isAreaClicked(x + 455, y + 7, 18, 18) && selected < options.length - 1 && isEnabled()) { previous = selected; selected += 1; try { 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 655900a..0660efe 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,6 +4,7 @@ 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.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import org.lwjgl.nanovg.NanoVG; @@ -29,6 +30,8 @@ public class NumberInputField extends TextInputField { public void draw(long vg, int x, int y) { super.errored = false; RenderManager.drawRoundedRect(vg, x + width + 4, y, 12, 28, OneConfigConfig.GRAY_500, 6f); + upArrow.disable(disabled); + downArrow.disable(disabled); upArrow.update(x + width + 4, y); downArrow.update(x + width + 4, y + 14); try { @@ -58,20 +61,20 @@ public class NumberInputField extends TextInputField { if (current < min) current = min; setCurrentValue(current); } - if (current >= max) { + if (current >= max && !disabled) { NanoVG.nvgGlobalAlpha(vg, 0.3f); upArrow.disable(true); } RenderManager.drawRoundedRectVaried(vg, x + width + 4, y, 12, 14, colorTop, 6f, 6f, 0f, 0f); - RenderManager.drawImage(vg, Images.UP_ARROW, x + width + 5, y + 2, 10, 10); - if (current >= max) NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.drawSvg(vg, SVGs.CHEVRON_UP, x + width + 5, y + 2, 10, 10); + if (current >= max && !disabled) NanoVG.nvgGlobalAlpha(vg, 1f); - if (current <= min) { + if (current <= min && !disabled) { NanoVG.nvgGlobalAlpha(vg, 0.3f); downArrow.disable(true); } RenderManager.drawRoundedRectVaried(vg, x + width + 4, y + 14, 12, 14, colorBottom, 0f, 0f, 6f, 6f); - RenderManager.drawImage(vg, Images.UP_ARROW, x + width + 5, y + 25, 10, -10); + RenderManager.drawSvg(vg, SVGs.CHEVRON_DOWN, x + width + 5, y + 15, 10, 10); NanoVG.nvgGlobalAlpha(vg, 1f); try { 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 dd73183..a65f227 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java @@ -8,12 +8,13 @@ import cc.polyfrost.oneconfig.lwjgl.OneColor; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.InputUtils; import java.awt.*; public class HomePage extends Page { - private final BasicButton btn = new BasicButton(184, 36, "Socials", Images.SHARE, Images.LAUNCH, 1, BasicButton.ALIGNMENT_CENTER); + private final BasicButton btn = new BasicButton(184, 36, "Socials", SVGs.SHARE, SVGs.POP_OUT, 1, BasicButton.ALIGNMENT_CENTER); public HomePage() { super("Home Dashboard"); 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 2b3dfd7..1d2dfac 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -90,7 +90,8 @@ public class ModsPage extends Page { @Override public int getMaxScrollHeight() { - return size; + //return size; + return 3298046; } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java index 4276865..a2da805 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java @@ -1,18 +1,18 @@ package cc.polyfrost.oneconfig.lwjgl; import cc.polyfrost.oneconfig.config.OneConfigConfig; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.font.FontManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Image; import cc.polyfrost.oneconfig.lwjgl.image.ImageLoader; import cc.polyfrost.oneconfig.lwjgl.image.Images; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import gg.essential.universal.UGraphics; import gg.essential.universal.UMinecraft; import gg.essential.universal.UResolution; import net.minecraft.client.gui.Gui; import net.minecraft.client.shader.Framebuffer; -import org.lwjgl.nanovg.NVGColor; -import org.lwjgl.nanovg.NVGPaint; +import org.lwjgl.nanovg.*; import org.lwjgl.opengl.GL11; import java.util.function.LongConsumer; @@ -203,10 +203,9 @@ public final class RenderManager { public static void drawImage(long vg, String filePath, float x, float y, float width, float height) { if (ImageLoader.INSTANCE.loadImage(vg, filePath)) { NVGPaint imagePaint = NVGPaint.calloc(); - cc.polyfrost.oneconfig.lwjgl.image.Image image = ImageLoader.INSTANCE.getImage(filePath); + int image = ImageLoader.INSTANCE.getImage(filePath); nvgBeginPath(vg); - - nvgImagePattern(vg, x, y, width, height, 0, image.getReference(), 1, imagePaint); + nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint); nvgRect(vg, x, y, width, height); nvgFillPaint(vg, imagePaint); nvgFill(vg); @@ -217,9 +216,9 @@ public final class RenderManager { public static void drawImage(long vg, String filePath, float x, float y, float width, float height, int color) { if (ImageLoader.INSTANCE.loadImage(vg, filePath)) { NVGPaint imagePaint = NVGPaint.calloc(); - Image image = ImageLoader.INSTANCE.getImage(filePath); + int image = ImageLoader.INSTANCE.getImage(filePath); nvgBeginPath(vg); - nvgImagePattern(vg, x, y, width, height, 0, image.getReference(), 1, imagePaint); + nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint); nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), imagePaint.innerColor()); nvgRect(vg, x, y, width, height); nvgFillPaint(vg, imagePaint); @@ -231,15 +230,14 @@ public final class RenderManager { public static void drawRoundImage(long vg, String filePath, float x, float y, float width, float height, float radius) { if (ImageLoader.INSTANCE.loadImage(vg, filePath)) { NVGPaint imagePaint = NVGPaint.calloc(); - cc.polyfrost.oneconfig.lwjgl.image.Image image = ImageLoader.INSTANCE.getImage(filePath); + int image = ImageLoader.INSTANCE.getImage(filePath); nvgBeginPath(vg); - nvgImagePattern(vg, x, y, width, height, 0, image.getReference(), 1, imagePaint); + nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint); nvgRoundedRect(vg, x, y, width, height, radius); nvgFillPaint(vg, imagePaint); nvgFill(vg); imagePaint.free(); } - } public static void drawRoundImage(long vg, Images filePath, float x, float y, float width, float height, float radius) { @@ -299,6 +297,86 @@ public final class RenderManager { return nvgColor; } + public static void drawSvg(long vg, String filePath, float x, float y, float width, float height) { + float w = width; + float h = height; + if (OneConfigGui.INSTANCE != null) { + w *= OneConfigGui.INSTANCE.getScaleFactor(); + h *= OneConfigGui.INSTANCE.getScaleFactor(); + } + if (ImageLoader.INSTANCE.loadSVG(vg, filePath, w, h)) { + NVGPaint imagePaint = NVGPaint.calloc(); + int image = ImageLoader.INSTANCE.getSVG(filePath, w, h); + nvgBeginPath(vg); + nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint); + nvgRect(vg, x, y, width, height); + nvgFillPaint(vg, imagePaint); + nvgFill(vg); + imagePaint.free(); + } + } + + public static void drawSvg(long vg, String filePath, float x, float y, float width, float height, int color) { + float w = width; + float h = height; + if (OneConfigGui.INSTANCE != null) { + w *= OneConfigGui.INSTANCE.getScaleFactor(); + h *= OneConfigGui.INSTANCE.getScaleFactor(); + } + if (ImageLoader.INSTANCE.loadSVG(vg, filePath, w, h)) { + NVGPaint imagePaint = NVGPaint.calloc(); + int image = ImageLoader.INSTANCE.getSVG(filePath, w, h); + nvgBeginPath(vg); + nvgImagePattern(vg, x, y, width, height, 0, image, 1, imagePaint); + nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), imagePaint.innerColor()); + nvgRect(vg, x, y, width, height); + nvgFillPaint(vg, imagePaint); + nvgFill(vg); + imagePaint.free(); + } + } + + public static void drawSvg(long vg, SVGs svg, float x, float y, float width, float height) { + drawSvg(vg, svg.filePath, x, y, width, height); + } + + public static void drawSvg(long vg, SVGs svg, float x, float y, float width, float height, int color) { + drawSvg(vg, svg.filePath, x, y, width, height, color); + } + + /*public static void drawSvg(long vg, String filename) { + if (ImageLoader.INSTANCE.loadSVGImage(filename)) { + try { + NSVGImage image = ImageLoader.INSTANCE.getSVG(filename); + NSVGShape shape = image.shapes(); + NSVGPath path = shape.paths(); + while (shape.address() != 0) { + while (path.address() != 0) { + nvgBeginPath(vg); + nvgFillColor(vg, color(vg, new Color(255, 255, 255).getRGB())); + nvgStrokeColor(vg, color(vg, new Color(255, 255, 255).getRGB())); + nvgStrokeWidth(vg, shape.strokeWidth()); + FloatBuffer points = path.pts(); + nvgMoveTo(vg, points.get(), points.get()); + while (points.remaining() >= 6){ + nvgBezierTo(vg, points.get(), points.get(), points.get(), points.get(), points.get(), points.get()); + } + if (path.closed() == 1) { + nvgLineTo(vg, points.get(0), points.get(1)); + } + nvgStroke(vg); + nvgClosePath(vg); + path = path.next(); + } + shape = shape.next(); + } + path.free(); + shape.free(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }*/ // gl diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Image.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Image.java deleted file mode 100644 index 2e63154..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Image.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.polyfrost.oneconfig.lwjgl.image; - -import java.nio.ByteBuffer; - -public class Image { - private final int reference; - private final ByteBuffer buffer; - - public Image(int reference, ByteBuffer buffer) { - this.reference = reference; - this.buffer = buffer; - } - - public ByteBuffer getBuffer() { - return buffer; - } - - public int getReference() { - return reference; - } -} diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java index 479104c..128ae48 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java @@ -1,14 +1,21 @@ package cc.polyfrost.oneconfig.lwjgl.image; import cc.polyfrost.oneconfig.utils.IOUtils; +import org.lwjgl.nanovg.NSVGImage; +import org.lwjgl.nanovg.NanoSVG; import org.lwjgl.nanovg.NanoVG; import org.lwjgl.stb.STBImage; +import org.lwjgl.system.MemoryUtil; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.util.HashMap; public class ImageLoader { - private final HashMap imageHashMap = new HashMap<>(); + private final HashMap imageHashMap = new HashMap<>(); + private final HashMap SVGHashMap = new HashMap<>(); public static ImageLoader INSTANCE = new ImageLoader(); public boolean loadImage(long vg, String fileName) { @@ -27,19 +34,86 @@ public class ImageLoader { return false; } - imageHashMap.put(fileName, new Image(NanoVG.nvgCreateImageRGBA(vg, width[0], height[0], NanoVG.NVG_IMAGE_REPEATX | NanoVG.NVG_IMAGE_REPEATY | NanoVG.NVG_IMAGE_GENERATE_MIPMAPS, buffer), buffer)); + imageHashMap.put(fileName, NanoVG.nvgCreateImageRGBA(vg, width[0], height[0], NanoVG.NVG_IMAGE_REPEATX | NanoVG.NVG_IMAGE_REPEATY | NanoVG.NVG_IMAGE_GENERATE_MIPMAPS, buffer)); return true; } return true; } + public boolean loadSVG(long vg, String fileName, float SVGWidth, float SVGHeight) { + String name = fileName + "-" + SVGWidth + "-" + SVGHeight; + if (!SVGHashMap.containsKey(name)) { + try { + InputStream inputStream = this.getClass().getResourceAsStream(fileName); + if (inputStream == null) return false; + StringBuilder resultStringBuilder = new StringBuilder(); + try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { + String line; + while ((line = br.readLine()) != null) { + resultStringBuilder.append(line); + } + } + CharSequence s = resultStringBuilder.toString(); + NSVGImage svg = NanoSVG.nsvgParse(s, "px", 96f); + if (svg == null) return false; + long rasterizer = NanoSVG.nsvgCreateRasterizer(); - public void removeImage(String fileName) { - imageHashMap.remove(fileName); + int w = (int) svg.width(); + int h = (int) svg.height(); + float scale = Math.max(SVGWidth / w, SVGHeight / h); + w = (int) (w * scale); + h = (int) (h * scale); + + ByteBuffer image = MemoryUtil.memAlloc(w * h * 4); + NanoSVG.nsvgRasterize(rasterizer, svg, 0, 0, scale, image, w, h, w * 4); + + NanoSVG.nsvgDeleteRasterizer(rasterizer); + NanoSVG.nsvgDelete(svg); + + SVGHashMap.put(name, NanoVG.nvgCreateImageRGBA(vg, w, h, NanoVG.NVG_IMAGE_REPEATX | NanoVG.NVG_IMAGE_REPEATY | NanoVG.NVG_IMAGE_GENERATE_MIPMAPS, image)); + return true; + } catch (Exception e) { + System.err.println("Failed to parse SVG file"); + e.printStackTrace(); + return false; + } + } + return true; } - public Image getImage(String fileName) { + public int getImage(String fileName) { return imageHashMap.get(fileName); } + public void removeImage(long vg, String fileName) { + NanoVG.nvgDeleteImage(vg, imageHashMap.get(fileName)); + imageHashMap.remove(fileName); + } + + public void clearImages(long vg) { + HashMap temp = new HashMap<>(imageHashMap); + for (String image : temp.keySet()) { + NanoVG.nvgDeleteImage(vg, imageHashMap.get(image)); + imageHashMap.remove(image); + } + } + + public int getSVG( String fileName, float width, float height) { + String name = fileName + "-" + width + "-" + height; + return SVGHashMap.get(name); + } + + public void removeSVG(long vg, String fileName, float width, float height) { + String name = fileName + "-" + width + "-" + height; + NanoVG.nvgDeleteImage(vg, imageHashMap.get(name)); + SVGHashMap.remove(name); + } + + public void clearSVGs(long vg) { + HashMap temp = new HashMap<>(SVGHashMap); + for (String image : temp.keySet()) { + NanoVG.nvgDeleteImage(vg, SVGHashMap.get(image)); + SVGHashMap.remove(image); + } + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java index 97ed221..55aa8f0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java @@ -1,59 +1,14 @@ package cc.polyfrost.oneconfig.lwjgl.image; public enum Images { - CHEVRON_ARROW("/assets/oneconfig/icons/chevron.png"), - DROPDOWN_ARROW("/assets/oneconfig/icons/dropdown_arrow.png"), - UP_ARROW("/assets/oneconfig/icons/up_arrow.png"), - CIRCLE_ARROW("/assets/oneconfig/icons/circle_arrow.png"), - - CHECKMARK("/assets/oneconfig/icons/checkmark.png"), - FAVORITE("/assets/oneconfig/icons/favorite_active.png"), - FAVORITE_OFF("/assets/oneconfig/icons/favorite_inactive.png"), - HIDE_EYE("/assets/oneconfig/icons/hide_eye.png"), - HIDE_EYE_OFF("/assets/oneconfig/icons/hide_eye_off.png"), - KEYSTROKE("/assets/oneconfig/icons/keystroke.png"), - - COLOR_BASE("/assets/oneconfig/colorui/color_base.png"), - COLOR_BASE_LONG("/assets/oneconfig/colorui/color_base_long.png"), - COLOR_BASE_LARGE("/assets/oneconfig/colorui/color_base_large.png"), - COLOR_WHEEL("/assets/oneconfig/colorui/color_wheel.png"), - HUE_GRADIENT("/assets/oneconfig/colorui/hue_gradient.png"), - CLOSE_COLOR("/assets/oneconfig/colorui/close_color.png"), - - INFO("/assets/oneconfig/icons/info.png"), - SUCCESS("/assets/oneconfig/icons/success.png"), - WARNING("/assets/oneconfig/icons/warning.png"), - ERROR("/assets/oneconfig/icons/error.png"), - - SHARE("/assets/oneconfig/icons/share.png"), - LAUNCH("/assets/oneconfig/icons/launch.png"), - SEARCH("/assets/oneconfig/icons/search.png"), - MINIMIZE("/assets/oneconfig/icons/minimize.png"), - CLOSE("/assets/oneconfig/icons/close.png"), - HELP("/assets/oneconfig/icons/help.png"), - COPY("/assets/oneconfig/icons/copy.png"), - PASTE("/assets/oneconfig/icons/paste.png"), - - LOGO("/assets/oneconfig/icons/logo.png"), - - HUD("/assets/oneconfig/icons/hud.png"), - HUD_SETTINGS("/assets/oneconfig/icons/settings.png"), - - MOD_BOX("/assets/oneconfig/icons/mod_box.png"), - MODS("/assets/oneconfig/icons/mods.png"), - PERFORMANCE("/assets/oneconfig/icons/performance.png"), - - DASHBOARD("/assets/oneconfig/icons/dashboard.png"), - PREFERENCES("/assets/oneconfig/icons/preferences.png"), - PROFILES("/assets/oneconfig/icons/profiles.png"), - SCREENSHOT("/assets/oneconfig/icons/screenshot.png"), - THEMES("/assets/oneconfig/icons/themes.png"), - UPDATES("/assets/oneconfig/icons/updates.png"), - ; + HUE_GRADIENT("/assets/oneconfig/colorui/huegradient.png"), + COLOR_WHEEL("/assets/oneconfig/colorui/colorwheel.png"), + HSB_GRADIENT("/assets/oneconfig/colorui/hsbgradient.png"), + ALPHA_GRID("/assets/oneconfig/colorui/alphagrid.png"); public final String filePath; Images(String filePath) { this.filePath = filePath; } -} +} \ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java new file mode 100644 index 0000000..1b8744f --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java @@ -0,0 +1,132 @@ +package cc.polyfrost.oneconfig.lwjgl.image; + +public enum SVGs { + ALIGN_H_CENTER("/assets/oneconfig/icons/AlignHCenter.svg"), + ALIGN_H_LEFT("/assets/oneconfig/icons/AlignHLeft.svg"), + ALIGN_H_RIGHT("/assets/oneconfig/icons/AlignHRight.svg"), + ALIGN_V_BOTTOM("/assets/oneconfig/icons/AlignVBottom.svg"), + ALIGN_V_MIDDLE("/assets/oneconfig/icons/AlignVMiddle.svg"), + ALIGN_V_TOP("/assets/oneconfig/icons/AlignVTop.svg"), + ARROW_CIRCLE_DOWN("/assets/oneconfig/icons/ArrowCircleDown.svg"), + ARROW_CIRCLE_LEFT("/assets/oneconfig/icons/ArrowCircleLeft.svg"), + ARROW_CIRCLE_RIGHT("/assets/oneconfig/icons/ArrowCircleRight.svg"), + ARROW_CIRCLE_UP("/assets/oneconfig/icons/ArrowCircleUp.svg"), + ARROW_DOWN("/assets/oneconfig/icons/ArrowDown.svg"), + ARROW_LEFT("/assets/oneconfig/icons/ArrowLeft.svg"), + ARROW_RIGHT("/assets/oneconfig/icons/ArrowRight.svg"), + ARROW_UP("/assets/oneconfig/icons/ArrowUp.svg"), + AUDIO_PAUSE("/assets/oneconfig/icons/AudioPause.svg"), + AUDIO_PLAY("/assets/oneconfig/icons/AudioPlay.svg"), + AUDIO_PREVIOUS("/assets/oneconfig/icons/AudioPrevious.svg"), + AUDIO_SKIP("/assets/oneconfig/icons/AudioSkip.svg"), + BELL("/assets/oneconfig/icons/Bell.svg"), + BELL_OFF("/assets/oneconfig/icons/BellOff.svg"), + BOX("/assets/oneconfig/icons/Box.svg"), + CAMERA("/assets/oneconfig/icons/Camera.svg"), + CART("/assets/oneconfig/icons/Cart.svg"), + CASH("/assets/oneconfig/icons/Cash.svg"), + CASH_DOLLAR("/assets/oneconfig/icons/CashDollar.svg"), + CHECKBOX_MIXED("/assets/oneconfig/icons/CheckboxMixed.svg"), + CHECKBOX_TICK("/assets/oneconfig/icons/CheckboxTick.svg"), + CHECK_CIRCLE("/assets/oneconfig/icons/CheckCircle.svg"), + CHEVRON_DOWN("/assets/oneconfig/icons/ChevronDown.svg"), + CHEVRON_LEFT("/assets/oneconfig/icons/ChevronLeft.svg"), + CHEVRON_RIGHT("/assets/oneconfig/icons/ChevronRight.svg"), + CHEVRON_UP("/assets/oneconfig/icons/ChevronUp.svg"), + CLOCK("/assets/oneconfig/icons/Clock.svg"), + CODE("/assets/oneconfig/icons/Code.svg"), + COMBO_BOX_UP("/assets/oneconfig/icons/ComboBoxUp.svg"), + COMBO_BOX_DOWN("/assets/oneconfig/icons/ComboBoxDown.svg"), + CONTENT("/assets/oneconfig/icons/Content.svg"), + COPY("/assets/oneconfig/icons/Copy.svg"), + CREDIT_CARD("/assets/oneconfig/icons/CreditCard.svg"), + CREDIT_CARD_ADD("/assets/oneconfig/icons/CreditCardAdd.svg"), + CUBE("/assets/oneconfig/icons/Cube.svg"), + DASHBOARD("/assets/oneconfig/icons/Dashboard.svg"), + DELETE("/assets/oneconfig/icons/Delete.svg"), + DOLLAR("/assets/oneconfig/icons/Dollar.svg"), + DOLLAR_CIRCLE("/assets/oneconfig/icons/DollarCircle.svg"), + DROPDOWN_LIST("/assets/oneconfig/icons/DropdownList.svg"), // TODO: old usage is DROPDOWN_ARROW, needs some work from developer side + EARTH("/assets/oneconfig/icons/Earth.svg"), + EDIT("/assets/oneconfig/icons/Edit.svg"), + ERROR("/assets/oneconfig/icons/Error.svg"), + EXPORT("/assets/oneconfig/icons/Export.svg"), + EYE("/assets/oneconfig/icons/Eye.svg"), + EYE_OFF("/assets/oneconfig/icons/EyeOff.svg"), + FABRIC_LOADER("/assets/oneconfig/icons/FabricLoader.svg"), + FILE("/assets/oneconfig/icons/File.svg"), + FILTER("/assets/oneconfig/icons/Filter.svg"), + FOLDER("/assets/oneconfig/icons/Folder.svg"), + FORGE_LOADER("/assets/oneconfig/icons/ForgeLoader.svg"), + HAMBURGER("/assets/oneconfig/icons/Hamburger.svg"), + HEART_BROKEN("/assets/oneconfig/icons/HeartBroken.svg"), + HEART_FILL("/assets/oneconfig/icons/HeartFill.svg"), + HEART_OUTLINE("/assets/oneconfig/icons/HeartOutline.svg"), + HELP_CIRCLE("/assets/oneconfig/icons/HelpCircle.svg"), + HISTORY("/assets/oneconfig/icons/History.svg"), + HOME("/assets/oneconfig/icons/Home.svg"), + HUD("/assets/oneconfig/icons/HUD.svg"), + HUD_SETTINGS("/assets/oneconfig/icons/HUDSettings.svg"), + IMAGE("/assets/oneconfig/icons/Image.svg"), + INFO_CIRCLE("/assets/oneconfig/icons/InfoCircle.svg"), + ITEM_LINK_BROKE("/assets/oneconfig/icons/ItemLinkBroke.svg"), + ITEM_LINKED("/assets/oneconfig/icons/ItemLinked.svg"), + KEYSTROKE("/assets/oneconfig/icons/Keystroke.svg"), + LAUNCH_PROFILES("/assets/oneconfig/icons/LaunchProfiles.svg"), + LINK_DIAGONAL("/assets/oneconfig/icons/LinkDiagonal.svg"), + LINK_HORIZONTAL("/assets/oneconfig/icons/LinkHorizontal.svg"), + LOCATION_POINT("/assets/oneconfig/icons/LocationPoint.svg"), + MAXIMISE("/assets/oneconfig/icons/Maximise.svg"), + MIC("/assets/oneconfig/icons/Mic.svg"), + MIC_OFF("/assets/oneconfig/icons/MicOff.svg"), + MICROSOFT_ICON("/assets/oneconfig/icons/MicrosoftIcon.svg"), + MINIMISE("/assets/oneconfig/icons/Minimise.svg"), + MINUS_CIRCLE("/assets/oneconfig/icons/MinusCircle.svg"), + MODS("/assets/oneconfig/icons/Mods.svg"), + MOVE("/assets/oneconfig/icons/Move.svg"), + NAVIGATION("/assets/oneconfig/icons/Navigation.svg"), + ONECONFIG("/assets/oneconfig/icons/OneConfig.svg"), + ONECONFIG_OFF("/assets/oneconfig/icons/OneConfigOff.svg"), + PASTE("/assets/oneconfig/icons/Paste.svg"), + PERFORMANCE("/assets/oneconfig/icons/Performance.svg"), + PLUS_CIRCLE("/assets/oneconfig/icons/PlusCircle.svg"), + POP_OUT("/assets/oneconfig/icons/PopOut.svg"), + PROFILES("/assets/oneconfig/icons/Profiles.svg"), + RESET("/assets/oneconfig/icons/Reset.svg"), + SAVE("/assets/oneconfig/icons/Save.svg"), + SEARCH("/assets/oneconfig/icons/Search.svg"), + SEND("/assets/oneconfig/icons/Send.svg"), + SETTINGS("/assets/oneconfig/icons/Settings.svg"), + SHAPE_CIRCLE("/assets/oneconfig/icons/ShapeCircle.svg"), + SHAPE_DOT("/assets/oneconfig/icons/ShapeDot.svg"), + SHAPE_HEXAGON("/assets/oneconfig/icons/ShapeHexagon.svg"), + SHAPE_SQUARE("/assets/oneconfig/icons/ShapeSquare.svg"), + SHAPE_TRIANGLE("/assets/oneconfig/icons/ShapeTriangle.svg"), + SHARE("/assets/oneconfig/icons/Share.svg"), + SHOPPING_BAG("/assets/oneconfig/icons/ShoppingBag.svg"), + SPACING("/assets/oneconfig/icons/Spacing.svg"), + THEME("/assets/oneconfig/icons/Theme.svg"), + THUMBS_DOWN("/assets/oneconfig/icons/ThumbsDown.svg"), + THUMBS_UP("/assets/oneconfig/icons/ThumbsUp.svg"), + UPDATE("/assets/oneconfig/icons/Update.svg"), + VOLUME_HIGH("/assets/oneconfig/icons/VolumeHigh.svg"), + VOLUME_MEDIUM("/assets/oneconfig/icons/VolumeMedium.svg"), + VOLUME_LOW("/assets/oneconfig/icons/VolumeLow.svg"), + VOLUME_NONE("/assets/oneconfig/icons/VolumeNone.svg"), + VOLUME_MUTE("/assets/oneconfig/icons/VolumeMute.svg"), + VOLUME_OFF("/assets/oneconfig/icons/VolumeOff.svg"), + VOLUME_MINUS("/assets/oneconfig/icons/VolumeMinus.svg"), + VOLUME_PLUS("/assets/oneconfig/icons/VolumePlus.svg"), + WARNING("/assets/oneconfig/icons/Warning.svg"), + WEBSITE("/assets/oneconfig/icons/Website.svg"), + X_CIRCLE("/assets/oneconfig/icons/XCircle.svg"), + X_CROSS("/assets/oneconfig/icons/XCross.svg"), + ZOOM_IN("/assets/oneconfig/icons/ZoomIn.svg"), + ZOOM_OUT("/assets/oneconfig/icons/ZoomOut.svg"); + + public final String filePath; + + SVGs(String filePath) { + this.filePath = filePath; + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java index d17d716..aa37005 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java @@ -84,4 +84,8 @@ public class ColorUtils { } return current; } + + public static int setAlpha(int color, int alpha) { + return ( alpha << 24 ) | ( color & 0x00ffffff ); + } } -- cgit