diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-29 15:26:36 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-29 15:26:36 +0700 |
commit | 98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315 (patch) | |
tree | a26d876b223229a35d05ef93c81a429ea1d877cd /src/main/java/cc | |
parent | ce370c8e2768383b57212fccd4018f92f88b8847 (diff) | |
download | OneConfig-98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315.tar.gz OneConfig-98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315.tar.bz2 OneConfig-98eedb30ac2f4e6ab9b0b1b04127e4afdcba0315.zip |
kotlin dsl
RenderManager reorganization
fix build error in CommandHelper
Diffstat (limited to 'src/main/java/cc')
29 files changed, 391 insertions, 335 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java index 1efa8ef..9bde547 100644 --- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java @@ -54,7 +54,7 @@ public class OneConfig { EventManager.INSTANCE.register(HypixelUtils.INSTANCE); RenderManager.setupAndDraw((vg) -> { RenderManager.drawRoundedRect(vg, -100, -100, 50, 50, -1, 12f); - RenderManager.drawString(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.MEDIUM); RenderManager.drawImage(vg, Images.HUE_GRADIENT, -100, -100, 50, 50); }); } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java index cdd9c51..399282e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/data/OptionSubcategory.java @@ -43,7 +43,7 @@ public class OptionSubcategory { if (filteredOptions.size() == 0 && filteredTop.size() == 0 && filteredBottom.size() == 0) return 0; int optionY = y; if (!name.equals("")) { - RenderManager.drawString(vg, name, x, y + 12, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 12, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); optionY += 36; } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 5194f83..75e6750 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -93,8 +93,8 @@ public class OneConfigGui extends UScreen { RenderManager.drawLine(vg, x + 224, y, x + 222, y + 800, 1, OneConfigConfig.GRAY_700); 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); + RenderManager.drawText(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.BOLD); // added half line height to center text + RenderManager.drawText(vg, "ALPHA - By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.REGULAR); textInputField.draw(vg, x + 1020, y + 16); sideBar.draw(vg, x, y); @@ -159,7 +159,7 @@ public class OneConfigGui extends UScreen { int color = OneConfigConfig.WHITE_60; if (i == parents.size() - 1) color = OneConfigConfig.WHITE_95; else if (hovered && !Mouse.isButtonDown(0)) color = OneConfigConfig.WHITE_80; - RenderManager.drawString(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.SEMIBOLD); + RenderManager.drawText(vg, title, breadcrumbX, y + 38, color, 24f, Fonts.SEMIBOLD); if (i != 0) RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, breadcrumbX - 28, y + 25, 24, 24, color); if (hovered && InputUtils.isClicked()) openPage(parents.get(i)); @@ -168,7 +168,7 @@ public class OneConfigGui extends UScreen { long end = System.nanoTime() - start; String s = (" draw: " + end / 1000000f + "ms"); - RenderManager.drawString(vg, s, x + 1170, y + 790, OneConfigConfig.GRAY_300, 10f, Fonts.MEDIUM); + RenderManager.drawText(vg, s, x + 1170, y + 790, OneConfigConfig.GRAY_300, 10f, Fonts.MEDIUM); if (currentColorSelector != null) { currentColorSelector.draw(vg); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index 51e5a66..a17076b 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -58,11 +58,11 @@ public class SideBar { if (i >= 562) i += 44; else i += 36; if (i == 144) { - RenderManager.drawString(vg, "MOD CONFIG", x + 16, y + 266, OneConfigConfig.WHITE_80, 12f, Fonts.SEMIBOLD); + RenderManager.drawText(vg, "MOD CONFIG", x + 16, y + 266, OneConfigConfig.WHITE_80, 12f, Fonts.SEMIBOLD); i = 180; } if (i == 324) { - RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 446, OneConfigConfig.WHITE_80, 12f, Fonts.SEMIBOLD); + RenderManager.drawText(vg, "PERSONALIZATION", x + 16, y + 446, OneConfigConfig.WHITE_80, 12f, Fonts.SEMIBOLD); i = 360; } if (i == 504) { 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 a84c290..f97cde2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java @@ -101,7 +101,7 @@ public class BasicButton extends BasicElement { contentWidth += iconSize + xSpacing; } if (text != null) { - RenderManager.drawString(vg, text, middle - contentWidth / 2 + (icon1 == null ? 0 : iconSize + xSpacing), middleYText, textColor, fontSize, Fonts.MEDIUM); + RenderManager.drawText(vg, text, middle - contentWidth / 2 + (icon1 == null ? 0 : iconSize + xSpacing), middleYText, textColor, fontSize, Fonts.MEDIUM); } if (icon1 != null) { RenderManager.drawSvg(vg, icon1, middle - contentWidth / 2, middleYIcon, iconSize, iconSize); @@ -114,7 +114,7 @@ public class BasicButton extends BasicElement { } if (alignment == ALIGNMENT_JUSTIFIED) { if (text != null) { - RenderManager.drawString(vg, text, middle - contentWidth / 2, middleYText, textColor, fontSize, Fonts.MEDIUM); + RenderManager.drawText(vg, text, middle - contentWidth / 2, middleYText, textColor, fontSize, Fonts.MEDIUM); } if (icon1 != null) { RenderManager.drawSvg(vg, icon1, x + xSpacing, middleYIcon, iconSize, iconSize); @@ -132,7 +132,7 @@ public class BasicButton extends BasicElement { contentWidth += iconSize + xSpacing; } if (text != null) { - RenderManager.drawString(vg, text, x + contentWidth, middleYText, textColor, fontSize, Fonts.MEDIUM); + RenderManager.drawText(vg, text, x + contentWidth, middleYText, textColor, fontSize, Fonts.MEDIUM); contentWidth += RenderManager.getTextWidth(vg, text, fontSize, Fonts.MEDIUM) + xSpacing; } if (icon2 != null) { @@ -150,7 +150,7 @@ public class BasicButton extends BasicElement { } if (text != null) { contentWidth -= RenderManager.getTextWidth(vg, text, fontSize, Fonts.MEDIUM); - RenderManager.drawString(vg, text, x + contentWidth, middleYText, textColor, fontSize, Fonts.MEDIUM); + RenderManager.drawText(vg, text, x + contentWidth, middleYText, textColor, fontSize, Fonts.MEDIUM); contentWidth -= xSpacing; } if (icon1 != null) { 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 c734ccb..6c8845c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -105,7 +105,7 @@ public class ColorSelector { int height = 768; RenderManager.drawHollowRoundRect(vg, x - 3, y - 3, width + 4, height + 4, new Color(204, 204, 204, 77).getRGB(), 20f, 2f); 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); + RenderManager.drawText(vg, "Color Selector", x + 16, y + 32, OneConfigConfig.WHITE_90, 18f, Fonts.SEMIBOLD); if (!closeBtn.isHovered()) RenderManager.setAlpha(vg, 0.8f); closeBtn.draw(vg, x + 368, y + 16); RenderManager.drawSvg(vg, SVGs.X_CIRCLE, x + 368, y + 16, 32, 32, closeBtn.isHovered() ? OneConfigConfig.ERROR_600 : -1); @@ -172,17 +172,17 @@ public class ColorSelector { } percentMove = MathUtils.easeOut(percentMove, mode, 100f); - RenderManager.drawString(vg, "HSB Box", x + 55, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); - RenderManager.drawString(vg, "Color Wheel", x + 172.5f, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); - RenderManager.drawString(vg, "Chroma", x + 313, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "HSB Box", x + 55, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Color Wheel", x + 172.5f, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Chroma", x + 313, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); - RenderManager.drawString(vg, "Saturation", x + 224, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Saturation", x + 224, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); saturationInput.draw(vg, x + 312, y + 544); - RenderManager.drawString(vg, "Brightness", x + 16, y + 599, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Brightness", x + 16, y + 599, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); brightnessInput.draw(vg, x + 104, y + 584); - RenderManager.drawString(vg, "Alpha (%)", x + 224, y + 599, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Alpha (%)", x + 224, y + 599, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); alphaInput.draw(vg, x + 312, y + 584); - RenderManager.drawString(vg, color.getDataBit() == -1 ? "Hex (RGB):" : "Color Code:", x + 16, y + 641, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, color.getDataBit() == -1 ? "Hex (RGB):" : "Color Code:", x + 16, y + 641, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); hexInput.draw(vg, x + 104, y + 624); copyBtn.draw(vg, x + 204, y + 624); @@ -218,14 +218,14 @@ public class ColorSelector { if (mode == 0) { topSlider.setColor(color); topSlider.draw(vg, x + 16, y + 424); - RenderManager.drawString(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); hueInput.draw(vg, x + 104, y + 544); } if (mode == 2) { speedSlider.draw(vg, x + 60, y + 424); - RenderManager.drawString(vg, "SLOW", x + 16, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR); - RenderManager.drawString(vg, "FAST", x + 370, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR); - RenderManager.drawString(vg, "Speed (s)", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "SLOW", x + 16, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR); + RenderManager.drawText(vg, "FAST", x + 370, y + 429, OneConfigConfig.WHITE_80, 12f, Fonts.REGULAR); + RenderManager.drawText(vg, "Speed (s)", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); hueInput.draw(vg, x + 104, y + 544); if (!speedSlider.isDragging()) { color.setChromaSpeed((int) Math.abs(speedSlider.getValue() - 29)); @@ -262,7 +262,7 @@ public class ColorSelector { color.setHSBA(dragging ? angle : color.getHue(), saturation, (int) (topSlider.getValue() / 360 * 100), (int) ((bottomSlider.getValue() / 100f) * 255)); topSlider.setGradient(OneConfigConfig.BLACK, color.getRGBMax(true)); topSlider.setImage(null); - RenderManager.drawString(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Hue", x + 16, y + 560, OneConfigConfig.WHITE_80, 12f, Fonts.MEDIUM); hueInput.draw(vg, x + 104, y + 544); topSlider.draw(vg, x + 16, y + 424); break; 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 cc8c54d..d3326a5 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -53,7 +53,7 @@ public class ModCard extends BasicElement { favoriteHitbox.currentColor = ColorUtils.getColor(favoriteHitbox.currentColor, favoriteHitbox.colorPalette, favoriteHitbox.hovered, favoriteHitbox.clicked); RenderManager.drawRoundedRectVaried(vg, x + 212, y + 87, 32, 32, favoriteHitbox.currentColor, 0f, 0f, 12f, 0f); favorite = favoriteHitbox.isToggled(); - RenderManager.drawString(vg, modData.name, x + 12, y + 103, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, modData.name, x + 12, y + 103, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); if (favorite) { RenderManager.drawSvg(vg, SVGs.HEART_FILL, x + 220, y + 95, 16, 16); } else { 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 3ad7f51..a10e3a0 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 @@ -28,7 +28,7 @@ public class ConfigButton extends BasicOption { public void draw(long vg, int x, int y) { button.disable(!isEnabled()); if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); - RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); button.draw(vg, x + (size == 1 ? 352 : 736), y); RenderManager.setAlpha(vg, 1f); } 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 f8c34e1..f7e0f90 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 @@ -45,7 +45,7 @@ public class ConfigCheckbox extends BasicOption { 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 } - RenderManager.drawString(vg, name, x + 32, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x + 32, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 50f)); if (percentOn != 0 && percentOn != 1f) { RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, ColorUtils.setAlpha(OneConfigConfig.PRIMARY_500, (int) (percentOn * 255)), 6f); 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 5ecaa9e..0d420e8 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 @@ -35,7 +35,7 @@ public class ConfigColorElement extends BasicOption { } catch (IllegalAccessException e) { return; } - RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); if (!hexField.isToggled()) hexField.setInput("#" + color.getHex()); hexField.setErrored(false); if (hexField.isToggled()) { 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 a36a829..9024516 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 @@ -26,7 +26,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f @Override public void draw(long vg, int x, int y) { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); - RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); boolean hovered; if (size == 1) hovered = InputUtils.isAreaHovered(x + 224, y, 256, 32) && isEnabled(); @@ -50,12 +50,12 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); if (size == 1) { 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.drawText(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, OneConfigConfig.PRIMARY_600, 8); 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.drawText(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.PRIMARY_600, 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); } @@ -80,7 +80,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); if (size == 1) { 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.drawText(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, OneConfigConfig.PRIMARY_600, 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 452, y + 4, 24, 24); @@ -107,12 +107,12 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f InputUtils.blockClicks(false); } - RenderManager.drawString(vg, option, x + 240, optionY + 18, color, 14, Fonts.MEDIUM); + RenderManager.drawText(vg, option, x + 240, optionY + 18, color, 14, Fonts.MEDIUM); optionY += 32; } } 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.drawText(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); if (hovered && Mouse.isButtonDown(0)) RenderManager.setAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.PRIMARY_600, 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); @@ -131,7 +131,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f color = OneConfigConfig.WHITE; } - RenderManager.drawString(vg, option, x + 368, optionY + 18, color, 14, Fonts.MEDIUM); + RenderManager.drawText(vg, option, x + 368, optionY + 18, color, 14, Fonts.MEDIUM); if (optionHovered && InputUtils.isClicked(true)) { try { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java index f8aa0d6..76601f7 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java @@ -35,15 +35,15 @@ public class ConfigDualOption extends BasicOption { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); boolean hoveredLeft = InputUtils.isAreaHovered(x + 226, y, 128, 32) && isEnabled(); boolean hoveredRight = InputUtils.isAreaHovered(x + 354, y, 128, 32) && isEnabled(); - RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 226, y, 256, 32, OneConfigConfig.GRAY_600, 12f); int x1 = (int) (x + 228 + (percentMove * 128)); RenderManager.drawRoundedRect(vg, x1, y + 2, 124, 28, OneConfigConfig.PRIMARY_600, 10f); if (!hoveredLeft && isEnabled()) RenderManager.setAlpha(vg, 0.8f); - RenderManager.drawString(vg, left, x + 290 - RenderManager.getTextWidth(vg, left, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, left, x + 290 - RenderManager.getTextWidth(vg, left, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); if (isEnabled()) RenderManager.setAlpha(vg, 1f); if (!hoveredRight && isEnabled()) RenderManager.setAlpha(vg, 0.8f); - RenderManager.drawString(vg, right, x + 418 - RenderManager.getTextWidth(vg, right, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); + RenderManager.drawText(vg, right, x + 418 - RenderManager.getTextWidth(vg, right, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); RenderManager.setAlpha(vg, 1); if ((hoveredLeft && toggled || hoveredRight && !toggled) && InputUtils.isClicked()) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java index c7c7ea9..445424e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java @@ -18,7 +18,7 @@ public class ConfigHeader extends BasicOption { @Override public void draw(long vg, int x, int y) { Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 480 : 992, 32); - RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); ScissorManager.resetScissor(vg, scissor); } 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 6564e9e..6a6c4f2 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 @@ -22,7 +22,7 @@ public class ConfigInfo extends BasicOption { public void draw(long vg, int x, int y) { Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 448 : 960, 32); RenderManager.drawInfo(vg, type, x, y + 4, 24); - RenderManager.drawString(vg, name, x + 32, y + 18, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM); + RenderManager.drawText(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 cb90165..78ef0b3 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 @@ -26,7 +26,7 @@ public class ConfigKeyBind extends BasicOption { @Override public void draw(long vg, int x, int y) { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); - RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); OneKeyBind keyBind = getKeyBind(); String text = keyBind.getDisplay(); button.disable(!isEnabled()); 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 61729b9..ec13566 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 @@ -36,9 +36,9 @@ public class ConfigPageButton extends BasicOption { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x - 16, y, 1024, height, backgroundColor, 20); - RenderManager.drawString(vg, name, x + 10, y + 32, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); + RenderManager.drawText(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.drawText(vg, name, x + 10, y + 70, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM); RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, x + 981f, y + (description.equals("") ? 20f : 36f), 13, 22); if (clicked) OneConfigGui.INSTANCE.openPage(new ModConfigPage(page)); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java index e5b3d90..08761fb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java @@ -67,7 +67,7 @@ public class ConfigSlider extends BasicOption { } if (!inputField.isToggled()) inputField.setCurrentValue(value); - RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 352, y + 13, 512, 6, OneConfigConfig.GRAY_300, 4f); RenderManager.drawRoundedRect(vg, x + 352, y + 13, xCoordinate - x - 352, 6, OneConfigConfig.PRIMARY_500, 4f); if (step > 0) { 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 f802680..61c0dd5 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 @@ -35,7 +35,7 @@ public class ConfigSwitch extends BasicOption { if (percentOn != 0) RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, ColorUtils.setAlpha(colorEnabled, (int) (255 * percentOn)), 12f); RenderManager.drawRoundedRect(vg, x2, y + 7, 18, 18, OneConfigConfig.WHITE, 9f); - RenderManager.drawString(vg, name, x + 50, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x + 50, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); if (InputUtils.isAreaClicked(x, y, 42, 32) && isEnabled()) { toggled = !toggled; 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 4fa57b8..966a85e 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 @@ -27,7 +27,7 @@ public class ConfigTextBox extends BasicOption { public void draw(long vg, int x, int y) { if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); textField.disable(!isEnabled()); - RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM); try { String value = (String) get(); 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 f11a3fd..ce048c9 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 @@ -39,15 +39,15 @@ public class ConfigUniSelector extends BasicOption { } if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f); String option = options[selected] + " " + (selected + 1) + "/" + options.length; - RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); Scissor scissor = ScissorManager.scissor(vg, x + 256, y, 192, 32); if (previous == -1) { - RenderManager.drawString(vg, option, x + 352 - RenderManager.getTextWidth(vg, option, 14f, Fonts.MEDIUM) / 2f, y + 15, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, option, x + 352 - RenderManager.getTextWidth(vg, option, 14f, Fonts.MEDIUM) / 2f, y + 15, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); } else { String prevOption = options[previous] + " " + (previous + 1) + "/" + options.length; - RenderManager.drawString(vg, selected < previous ? prevOption : option, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? prevOption : option, 14f, Fonts.MEDIUM) / 2f + 192 * percentMove, y + 15, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); - RenderManager.drawString(vg, selected < previous ? option : prevOption, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? option : prevOption, 14f, Fonts.MEDIUM) / 2f - 192 * (1 - percentMove), y + 15, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, selected < previous ? prevOption : option, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? prevOption : option, 14f, Fonts.MEDIUM) / 2f + 192 * percentMove, y + 15, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, selected < previous ? option : prevOption, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? option : prevOption, 14f, Fonts.MEDIUM) / 2f - 192 * (1 - percentMove), y + 15, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); } ScissorManager.resetScissor(vg, scissor); 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 a7dbf62..ff82879 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 @@ -127,18 +127,18 @@ public class TextInputField extends BasicElement { float width; StringBuilder s = new StringBuilder(); if (multiLine) { - wrappedText = TextUtils.wrapText(vg, input, this.width - 24, 14f, Fonts.REGULAR); + wrappedText = TextUtils.wrapText(vg, input, this.width - 24, 14f, Fonts.REGULAR.font); lines = wrappedText.size(); if (!toggled) caretPos = wrappedText.get(wrappedText.size() - 1).length(); int caretLine = (int) MathUtils.clamp(getCaretLine(caretPos), 0, wrappedText.size() - 1); - width = RenderManager.getTextWidth(vg, wrappedText.get(caretLine).substring(0, getLineCaret(caretPos, caretLine)), 14f, Fonts.REGULAR); + width = RenderManager.getTextWidth(vg, wrappedText.get(caretLine).substring(0, getLineCaret(caretPos, caretLine)), 14f, Fonts.REGULAR.font); } else if (!password) { - width = RenderManager.getTextWidth(vg, input.substring(0, caretPos), 14f, Fonts.REGULAR); + width = RenderManager.getTextWidth(vg, input.substring(0, caretPos), 14f, Fonts.REGULAR.font); } else { for (int i = 0; i < input.length(); i++) { s.append("*"); } - width = RenderManager.getTextWidth(vg, s.substring(0, caretPos), 14f, Fonts.REGULAR); + width = RenderManager.getTextWidth(vg, s.substring(0, caretPos), 14f, Fonts.REGULAR.font); } if (hovered) { while (Mouse.next()) { @@ -222,11 +222,11 @@ public class TextInputField extends BasicElement { if (input.equals("")) { if (multiLine) { - RenderManager.drawString(vg, defaultText, x + 12, y + 16, color, 14f, Fonts.REGULAR); + RenderManager.drawText(vg, defaultText, x + 12, y + 16, color, 14f, Fonts.REGULAR); } else if (!centered) { - RenderManager.drawString(vg, defaultText, x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR); + RenderManager.drawText(vg, defaultText, x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR); } else { - RenderManager.drawString(vg, defaultText, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.REGULAR); + RenderManager.drawText(vg, defaultText, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.REGULAR); } } @@ -234,16 +234,16 @@ public class TextInputField extends BasicElement { if (multiLine) { int textY = y + 20; for (String line : wrappedText) { - RenderManager.drawString(vg, line, x + 12, textY, color, 14f, Fonts.REGULAR); + RenderManager.drawText(vg, line, x + 12, textY, color, 14f, Fonts.REGULAR); textY += 24; } } else if (!centered) { - RenderManager.drawString(vg, input, x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR); + RenderManager.drawText(vg, input, x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR); } else { - RenderManager.drawString(vg, input, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.REGULAR); + RenderManager.drawText(vg, input, x + this.width / 2f - halfTextWidth, y + height / 2f + 1, color, 14f, Fonts.REGULAR); } } else { - RenderManager.drawString(vg, s.toString(), x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR); + RenderManager.drawText(vg, s.toString(), x + 12, y + height / 2f + 1, color, 14f, Fonts.REGULAR); } ScissorManager.resetScissor(vg, scissor); } catch ( diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java index e41cc9e..0bb94aa 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java @@ -12,28 +12,28 @@ public class CreditsPage extends Page { @Override public void draw(long vg, int x, int y) { RenderManager.drawSvg(vg, SVGs.ONECONFIG, x + 20f, y + 20f, 96, 96); - RenderManager.drawString(vg, "OneConfig", x + 130, y + 46, -1, 42, Fonts.BOLD); - RenderManager.drawString(vg, "ALPHA - By Polyfrost", x + 132, y + 76, -1, 18, Fonts.MEDIUM); - RenderManager.drawString(vg, "v0.1", x + 132, y + 96, -1, 18, Fonts.MEDIUM); - - RenderManager.drawString(vg, "Development Team", x + 20, y + 180, -1, 24, Fonts.SEMIBOLD); - RenderManager.drawString(vg, " - MoonTidez - Founder and lead designer", x + 20, y + 205, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - DeDiamondPro - Config backend, GUI frontend, HUD", x + 20, y + 220, -1, 12, Fonts.REGULAR); // +15/line - RenderManager.drawString(vg, " - nextdaydelivery - GUI frontend, Render Manager, Utilities", x + 20, y + 235, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - Wyvest - Gradle, Render Manager, VCAL, Utilities", x + 20, y + 250, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - Ethan - Utilities", x + 20, y + 265, -1, 12, Fonts.REGULAR); - - RenderManager.drawString(vg, "Libraries", x + 20, y + 318, -1, 24, Fonts.SEMIBOLD); - RenderManager.drawString(vg, " - LWJGLTwoPointFive (DJTheRedstoner) - LWJGL3 loading hack", x + 20, y + 340, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - #getResourceAsStream (SpinyOwl) - IO Utility", x + 20, y + 355, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - NanoVG (memononen) - NanoVG Library", x + 20, y + 370, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - UniversalCraft (Sk1er LLC) - Multiversioning bindings", x + 20, y + 385, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - Easing Functions (jesusgollonet)", x + 20, y + 400, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - Quiltflower (Quilt Team) - Gradle decompiler", x + 20, y + 415, -1, 12, Fonts.REGULAR); - RenderManager.drawString(vg, " - Seraph (Scherso) - Locraw and Multithreading utilities", x + 20, y + 430, -1, 12, Fonts.REGULAR); - - RenderManager.drawString(vg, "Terms Of Service & Licensing", x + 20, y + 517, -1, 24, Fonts.SEMIBOLD); - RenderManager.drawString(vg, " - License Summary goes here", x + 20, y + 540, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, "OneConfig", x + 130, y + 46, -1, 42, Fonts.BOLD); + RenderManager.drawText(vg, "ALPHA - By Polyfrost", x + 132, y + 76, -1, 18, Fonts.MEDIUM); + RenderManager.drawText(vg, "v0.1", x + 132, y + 96, -1, 18, Fonts.MEDIUM); + + RenderManager.drawText(vg, "Development Team", x + 20, y + 180, -1, 24, Fonts.SEMIBOLD); + RenderManager.drawText(vg, " - MoonTidez - Founder and lead designer", x + 20, y + 205, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - DeDiamondPro - Config backend, GUI frontend, HUD", x + 20, y + 220, -1, 12, Fonts.REGULAR); // +15/line + RenderManager.drawText(vg, " - nextdaydelivery - GUI frontend, Render Manager, Utilities", x + 20, y + 235, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - Wyvest - Gradle, Render Manager, VCAL, Utilities", x + 20, y + 250, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - Ethan - Utilities", x + 20, y + 265, -1, 12, Fonts.REGULAR); + + RenderManager.drawText(vg, "Libraries", x + 20, y + 318, -1, 24, Fonts.SEMIBOLD); + RenderManager.drawText(vg, " - LWJGLTwoPointFive (DJTheRedstoner) - LWJGL3 loading hack", x + 20, y + 340, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - #getResourceAsStream (SpinyOwl) - IO Utility", x + 20, y + 355, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - NanoVG (memononen) - NanoVG Library", x + 20, y + 370, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - UniversalCraft (Sk1er LLC) - Multiversioning bindings", x + 20, y + 385, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - Easing Functions (jesusgollonet)", x + 20, y + 400, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - Quiltflower (Quilt Team) - Gradle decompiler", x + 20, y + 415, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - Seraph (Scherso) - Locraw and Multithreading utilities", x + 20, y + 430, -1, 12, Fonts.REGULAR); + + RenderManager.drawText(vg, "Terms Of Service & Licensing", x + 20, y + 517, -1, 24, Fonts.SEMIBOLD); + RenderManager.drawText(vg, " - License Summary goes here", x + 20, y + 540, -1, 12, Fonts.REGULAR); RenderManager.drawImage(vg, "https://i.insider.com/602ee9ced3ad27001837f2ac?width=700", x + 600, y + 20, 350, 263); 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 5892273..fd6e8fe 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/HomePage.java @@ -42,10 +42,10 @@ public class HomePage extends Page { public void draw(long vg, int x, int y) { RenderManager.drawRoundedRect(vg, x, y, 184, 36, -1, 12f); - RenderManager.drawString(vg, "This is a cool string to test pages", x + 32, y + 72, -1, 36f, Fonts.BOLD); + RenderManager.drawText(vg, "This is a cool string to test pages", x + 32, y + 72, -1, 36f, Fonts.BOLD); RenderManager.drawRoundedRect(vg, x + 350, y + 310, 300, 200, OneConfigConfig.PRIMARY_600, 14f); RenderManager.drawSvg(vg, SVGs.INFO_CIRCLE, x + 20, y + 604, 24, 24); - RenderManager.drawString(vg, "Info", x + 52, y + 618, OneConfigConfig.WHITE_90, 24f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Info", x + 52, y + 618, OneConfigConfig.WHITE_90, 24f, Fonts.MEDIUM); RenderManager.drawRoundedRect(vg, x + 16, y + 644, 1024, 64, OneConfigConfig.GRAY_700, 20f); RenderManager.drawURL(vg, "https://www.youtube.com/watch?v=dQw4w9WgXcQ", x + 100, y + 205, 24, Fonts.MEDIUM); 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 1f17c7d..67a1124 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -58,7 +58,7 @@ public class ModsPage extends Page { } size = iY + 119; if (iX == x + 16 && iY == y + 72) { - RenderManager.drawString(vg, "Looks like there is nothing here. Try another category?", x + 16, y + 72, OneConfigConfig.WHITE_60, 14f, Fonts.MEDIUM); + RenderManager.drawText(vg, "Looks like there is nothing here. Try another category?", x + 16, y + 72, OneConfigConfig.WHITE_60, 14f, Fonts.MEDIUM); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java index 2215499..f366648 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java @@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.libs.universal.UGraphics; import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import cc.polyfrost.oneconfig.libs.universal.UResolution; +import cc.polyfrost.oneconfig.lwjgl.font.Font; import cc.polyfrost.oneconfig.lwjgl.font.FontManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.ImageLoader; @@ -15,7 +16,8 @@ import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.NetworkUtils; import net.minecraft.client.gui.Gui; import net.minecraft.client.shader.Framebuffer; -import org.lwjgl.nanovg.*; +import org.lwjgl.nanovg.NVGColor; +import org.lwjgl.nanovg.NVGPaint; import org.lwjgl.opengl.GL11; import java.util.function.LongConsumer; @@ -28,19 +30,19 @@ import static org.lwjgl.nanovg.NanoVGGL2.nvgCreate; * Handles NanoVG rendering and wraps it in a more convenient interface. */ public final class RenderManager { - private RenderManager() { - - } + private static long vg = -1; //nanovg - private static long vg = -1; + private RenderManager() { + + } /** * Sets up rendering, calls the consumer with the NanoVG context, and then cleans up. * - * @see RenderManager#setupAndDraw(boolean, LongConsumer) * @param consumer The consumer to call. + * @see RenderManager#setupAndDraw(boolean, LongConsumer) */ public static void setupAndDraw(LongConsumer consumer) { setupAndDraw(false, consumer); @@ -50,7 +52,7 @@ public final class RenderManager { * Sets up rendering, calls the consumer with the NanoVG context, and then cleans up. * * @param mcScaling Whether to render with Minecraft's scaling. - * @param consumer The consumer to call. + * @param consumer The consumer to call. */ public static void setupAndDraw(boolean mcScaling, LongConsumer consumer) { if (vg == -1) { @@ -85,12 +87,12 @@ public final class RenderManager { /** * Draws a rectangle with the given parameters. * - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param width The width. + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param width The width. * @param height The height. - * @param color The color. + * @param color The color. */ public static void drawRectangle(long vg, float x, float y, float width, float height, int color) { // TODO make everything use this one day if (OneConfigConfig.ROUNDED_CORNERS) { @@ -101,72 +103,99 @@ public final class RenderManager { } /** - * Draws a rounded gradient rectangle with the given parameters. + * Draws a rectangle with the given parameters. * - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param width The width. + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param width The width. * @param height The height. - * @param color The first color of the gradient. - * @param color2 The second color of the gradient. - * @param radius The corner radius. + * @param color The color. */ - public static void drawGradientRoundedRect(long vg, float x, float y, float width, float height, int color, int color2, float radius) { - NVGPaint bg = NVGPaint.create(); + public static void drawRect(long vg, float x, float y, float width, float height, int color) { nvgBeginPath(vg); - nvgRoundedRect(vg, x, y, width, height, radius); + nvgRect(vg, x, y, width, height); NVGColor nvgColor = color(vg, color); - NVGColor nvgColor2 = color(vg, color2); - nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x + width, y, nvgColor, nvgColor2, bg)); nvgFill(vg); nvgColor.free(); - nvgColor2.free(); } /** - * Draw a HSB box + * Draws a rounded rectangle with the given parameters. * - * @param vg The NanoVG context. - * @param x The x coordinate. - * @param y The y coordinate - * @param width The width. + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param width The width. * @param height The height. - * @param colorTarget Hue color + * @param color The color. + * @param radius The radius. */ - public static void drawHSBBox(long vg, float x, float y, float width, float height, int colorTarget) { - drawRoundedRect(vg, x, y, width, height, colorTarget, 8f); - - NVGPaint bg = NVGPaint.create(); + public static void drawRoundedRect(long vg, float x, float y, float width, float height, int color, float radius) { nvgBeginPath(vg); - nvgRoundedRect(vg, x, y, width, height, 8f); - NVGColor nvgColor = color(vg, -1); - NVGColor nvgColor2 = color(vg, OneConfigConfig.TRANSPARENT); - nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x + width, y, nvgColor, nvgColor2, bg)); + nvgRoundedRect(vg, x, y, width, height, radius); + color(vg, color); + NVGColor nvgColor = color(vg, color); nvgFill(vg); nvgColor.free(); - nvgColor2.free(); + } - NVGPaint bg2 = NVGPaint.create(); + /** + * Draw a rounded rectangle where every corner has a different radius + * + * @param vg The NanoVG context + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param height The height. + * @param color The color. + * @param radiusTL Top left corner radius. + * @param radiusTR Top right corner radius. + * @param radiusBR Bottom right corner radius. + * @param radiusBL Bottom left corner radius + */ + public static void drawRoundedRectVaried(long vg, float x, float y, float width, float height, int color, float radiusTL, float radiusTR, float radiusBR, float radiusBL) { nvgBeginPath(vg); - nvgRoundedRect(vg, x, y, width, height, 8f); - NVGColor nvgColor3 = color(vg, OneConfigConfig.TRANSPARENT); - NVGColor nvgColor4 = color(vg, OneConfigConfig.BLACK); - nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x, y + height, nvgColor3, nvgColor4, bg2)); + nvgRoundedRectVarying(vg, x, y, width, height, radiusTL, radiusTR, radiusBR, radiusBL); + color(vg, color); + NVGColor nvgColor = color(vg, color); nvgFill(vg); - nvgColor3.free(); - nvgColor4.free(); + nvgColor.free(); + } + + /** + * Draws a hollow rounded rectangle with the given parameters. + * + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param height The height. + * @param color The color. + * @param radius The radius. + * @param thickness The thickness. + */ + public static void drawHollowRoundRect(long vg, float x, float y, float width, float height, int color, float radius, float thickness) { + nvgBeginPath(vg); + nvgRoundedRect(vg, x + thickness, y + thickness, width - thickness, height - thickness, radius); + nvgStrokeWidth(vg, thickness + 0.5f); + nvgPathWinding(vg, NVG_HOLE); + color(vg, color); + NVGColor nvgColor = color(vg, color); + nvgStrokeColor(vg, nvgColor); + nvgStroke(vg); + nvgColor.free(); } /** * Draws a gradient rectangle with the given parameters. * - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param width The width. + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param width The width. * @param height The height. - * @param color The first color of the gradient. + * @param color The first color of the gradient. * @param color2 The second color of the gradient. */ public static void drawGradientRect(long vg, float x, float y, float width, float height, int color, int color2) { @@ -183,125 +212,154 @@ public final class RenderManager { } /** - * Draws a rectangle with the given parameters. + * Draws a rounded gradient rectangle with the given parameters. * - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param width The width. + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param width The width. * @param height The height. - * @param color The color. + * @param color The first color of the gradient. + * @param color2 The second color of the gradient. + * @param radius The corner radius. */ - public static void drawRect(long vg, float x, float y, float width, float height, int color) { + public static void drawGradientRoundedRect(long vg, float x, float y, float width, float height, int color, int color2, float radius) { + NVGPaint bg = NVGPaint.create(); nvgBeginPath(vg); - nvgRect(vg, x, y, width, height); + nvgRoundedRect(vg, x, y, width, height, radius); NVGColor nvgColor = color(vg, color); + NVGColor nvgColor2 = color(vg, color2); + nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x + width, y, nvgColor, nvgColor2, bg)); nvgFill(vg); nvgColor.free(); + nvgColor2.free(); } /** - * Draws a rounded rectangle with the given parameters. + * Draw a HSB box * - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. - * @param color The color. - * @param radius The radius. + * @param vg The NanoVG context. + * @param x The x coordinate. + * @param y The y coordinate + * @param width The width. + * @param height The height. + * @param colorTarget Hue color */ - public static void drawRoundedRect(long vg, float x, float y, float width, float height, int color, float radius) { + public static void drawHSBBox(long vg, float x, float y, float width, float height, int colorTarget) { + drawRoundedRect(vg, x, y, width, height, colorTarget, 8f); + + NVGPaint bg = NVGPaint.create(); nvgBeginPath(vg); - nvgRoundedRect(vg, x, y, width, height, radius); - color(vg, color); - NVGColor nvgColor = color(vg, color); + nvgRoundedRect(vg, x, y, width, height, 8f); + NVGColor nvgColor = color(vg, -1); + NVGColor nvgColor2 = color(vg, OneConfigConfig.TRANSPARENT); + nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x + width, y, nvgColor, nvgColor2, bg)); nvgFill(vg); nvgColor.free(); + nvgColor2.free(); + + NVGPaint bg2 = NVGPaint.create(); + nvgBeginPath(vg); + nvgRoundedRect(vg, x, y, width, height, 8f); + NVGColor nvgColor3 = color(vg, OneConfigConfig.TRANSPARENT); + NVGColor nvgColor4 = color(vg, OneConfigConfig.BLACK); + nvgFillPaint(vg, nvgLinearGradient(vg, x, y, x, y + height, nvgColor3, nvgColor4, bg2)); + nvgFill(vg); + nvgColor3.free(); + nvgColor4.free(); } /** - * Draw a rounded rectangle where every corner has a different radius + * Draws a circle with the given parameters. * - * @param vg The NanoVG context - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. - * @param color The color. - * @param radiusTL Top left corner radius. - * @param radiusTR Top right corner radius. - * @param radiusBR Bottom right corner radius. - * @param radiusBL Bottom left corner radius + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param radius The radius. + * @param color The color. */ - public static void drawRoundedRectVaried(long vg, float x, float y, float width, float height, int color, float radiusTL, float radiusTR, float radiusBR, float radiusBL) { + public static void drawCircle(long vg, float x, float y, float radius, int color) { nvgBeginPath(vg); - nvgRoundedRectVarying(vg, x, y, width, height, radiusTL, radiusTR, radiusBR, radiusBL); - color(vg, color); + nvgCircle(vg, x, y, radius); NVGColor nvgColor = color(vg, color); nvgFill(vg); nvgColor.free(); } /** - * Draws a hollow rounded rectangle with the given parameters. + * Draws a String with the given parameters. * - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. + * @param vg The NanoVG context. + * @param text The text. + * @param x The x position. + * @param y The y position. * @param color The color. - * @param radius The radius. - * @param thickness The thickness. + * @param size The size. + * @param font The font. + * @see cc.polyfrost.oneconfig.lwjgl.font.Font */ - public static void drawHollowRoundRect(long vg, float x, float y, float width, float height, int color, float radius, float thickness) { - nvgBeginPath(vg); - nvgRoundedRect(vg, x + thickness, y + thickness, width - thickness, height - thickness, radius); - nvgStrokeWidth(vg, thickness + 0.5f); - nvgPathWinding(vg, NVG_HOLE); - color(vg, color); - NVGColor nvgColor = color(vg, color); - nvgStrokeColor(vg, nvgColor); - nvgStroke(vg); - nvgColor.free(); + public static void drawText(long vg, String text, float x, float y, int color, float size, Fonts font) { + drawText(vg, text, x, y, color, size, font.font); } /** - * Draws a circle with the given parameters. - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param radius The radius. + * Draws a String with the given parameters. + * + * @param vg The NanoVG context. + * @param text The text. + * @param x The x position. + * @param y The y position. * @param color The color. + * @param size The size. + * @param font The font. + * @see cc.polyfrost.oneconfig.lwjgl.font.Font */ - public static void drawCircle(long vg, float x, float y, float radius, int color) { + public static void drawText(long vg, String text, float x, float y, int color, float size, Font font) { nvgBeginPath(vg); - nvgCircle(vg, x, y, radius); + nvgFontSize(vg, size); + nvgFontFace(vg, font.getName()); + nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); NVGColor nvgColor = color(vg, color); + nvgText(vg, x, y, text); nvgFill(vg); nvgColor.free(); } /** - * Draws a String with the given parameters. - * @param vg The NanoVG context. - * @param text The text. - * @param x The x position. - * @param y The y position. + * Draws a String wrapped at the given width, with the given parameters. + * + * @param vg The NanoVG context. + * @param text The text. + * @param x The x position. + * @param y The y position. + * @param width The width. * @param color The color. - * @param size The size. - * @param font The font. + * @param size The size. + * @param font The font. + */ + public static void drawWrappedString(long vg, String text, float x, float y, float width, int color, float size, Fonts font) { + drawWrappedString(vg, text, x, y, width, color, size, font.font); + } + + /** + * Draws a String wrapped at the given width, with the given parameters. * - * @see cc.polyfrost.oneconfig.lwjgl.font.Font + * @param vg The NanoVG context. + * @param text The text. + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param color The color. + * @param size The size. + * @param font The font. */ - public static void drawString(long vg, String text, float x, float y, int color, float size, Fonts font) { + public static void drawWrappedString(long vg, String text, float x, float y, float width, int color, float size, Font font) { nvgBeginPath(vg); nvgFontSize(vg, size); - nvgFontFace(vg, font.font.getName()); + nvgFontFace(vg, font.getName()); nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); NVGColor nvgColor = color(vg, color); - nvgText(vg, x, y, text); + nvgTextBox(vg, x, y, width, text); nvgFill(vg); nvgColor.free(); } @@ -311,11 +369,23 @@ public final class RenderManager { * * <p><b>This does NOT scale to Minecraft's GUI scale!</b></p> * - * @see RenderManager#drawString(long, String, float, float, int, float, Fonts) + * @see RenderManager#drawText(long, String, float, float, int, float, Font) * @see InputUtils#isAreaClicked(int, int, int, int) */ public static void drawURL(long vg, String url, float x, float y, float size, Fonts font) { - drawString(vg, url, x, y, OneConfigConfig.PRIMARY_500, size, font); + drawURL(vg, url, x, y, size, font.font); + } + + /** + * Draw a formatted URL (a string in blue with an underline) that when clicked, opens the given text. + * + * <p><b>This does NOT scale to Minecraft's GUI scale!</b></p> + * + * @see RenderManager#drawText(long, String, float, float, int, float, Font) + * @see InputUtils#isAreaClicked(int, int, int, int) + */ + public static void drawURL(long vg, String url, float x, float y, float size, Font font) { + drawText(vg, url, x, y, OneConfigConfig.PRIMARY_500, size, font); float length = getTextWidth(vg, url, size, font); drawRectangle(vg, x, y + size / 2, length, 1, OneConfigConfig.PRIMARY_500); if (InputUtils.isAreaClicked((int) (x - 2), (int) (y - 1), (int) (length + 4), (int) (size / 2 + 3))) { @@ -324,36 +394,14 @@ public final class RenderManager { } /** - * Draws a String wrapped at the given width, with the given parameters. - * @param vg The NanoVG context. - * @param text The text. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param color The color. - * @param size The size. - * @param font The font. - */ - public static void drawWrappedString(long vg, String text, float x, float y, float width, int color, float size, Fonts font) { - nvgBeginPath(vg); - nvgFontSize(vg, size); - nvgFontFace(vg, font.font.getName()); - nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); - NVGColor nvgColor = color(vg, color); - nvgTextBox(vg, x, y, width, text); - nvgFill(vg); - nvgColor.free(); - } - - /** * Draws an image with the provided file path. - * @param vg The NanoVG context. - * @param filePath The file path. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. * + * @param vg The NanoVG context. + * @param filePath The file path. + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param height The height. * @see RenderManager#drawImage(long, String, float, float, float, float, int) */ public static void drawImage(long vg, String filePath, float x, float y, float width, float height) { @@ -371,13 +419,14 @@ public final class RenderManager { /** * Draws an image with the provided file path. - * @param vg The NanoVG context. + * + * @param vg The NanoVG context. * @param filePath The file path. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. - * @param color The color. + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param height The height. + * @param color The color. */ public static void drawImage(long vg, String filePath, float x, float y, float width, float height, int color) { if (ImageLoader.INSTANCE.loadImage(vg, filePath)) { @@ -394,14 +443,33 @@ public final class RenderManager { } /** + * Draws an image with the provided file path and parameters. + * + * @see RenderManager#drawImage(long, String, float, float, float, float) + */ + public static void drawImage(long vg, Images filePath, float x, float y, float width, float height) { + drawImage(vg, filePath.filePath, x, y, width, height); + } + + /** + * Draws an image with the provided file path and parameters. + * + * @see RenderManager#drawImage(long, String, float, float, float, float, int) + */ + public static void drawImage(long vg, Images filePath, float x, float y, float width, float height, int color) { + drawImage(vg, filePath.filePath, x, y, width, height, color); + } + + /** * Draws a rounded image with the provided file path and parameters. - * @param vg The NanoVG context. + * + * @param vg The NanoVG context. * @param filePath The file path. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. - * @param radius The radius. + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param height The height. + * @param radius The radius. */ public static void drawRoundImage(long vg, String filePath, float x, float y, float width, float height, float radius) { if (ImageLoader.INSTANCE.loadImage(vg, filePath)) { @@ -425,46 +493,34 @@ public final class RenderManager { drawRoundImage(vg, filePath.filePath, x, y, width, height, radius); } - /** - * Draws an image with the provided file path and parameters. - * - * @see RenderManager#drawImage(long, String, float, float, float, float) - */ - public static void drawImage(long vg, Images filePath, float x, float y, float width, float height) { - drawImage(vg, filePath.filePath, x, y, width, height); - } - - /** - * Draws an image with the provided file path and parameters. - * - * @see RenderManager#drawImage(long, String, float, float, float, float, int) - */ - public static void drawImage(long vg, Images filePath, float x, float y, float width, float height, int color) { - drawImage(vg, filePath.filePath, x, y, width, height, color); + public static float getTextWidth(long vg, String text, float fontSize, Fonts font) { + return getTextWidth(vg, text, fontSize, font.font); } /** * Get the width of the provided String. - * @param vg The NanoVG context. - * @param text The text. + * + * @param vg The NanoVG context. + * @param text The text. * @param fontSize The font size. - * @param font The font. + * @param font The font. * @return The width of the text. */ - public static float getTextWidth(long vg, String text, float fontSize, Fonts font) { + public static float getTextWidth(long vg, String text, float fontSize, Font font) { float[] bounds = new float[4]; nvgFontSize(vg, fontSize); - nvgFontFace(vg, font.font.getName()); + nvgFontFace(vg, font.getName()); return nvgTextBounds(vg, 0, 0, text, bounds); } /** * Draws a line with the provided parameters. - * @param vg The NanoVG context. - * @param x The x position. - * @param y The y position. - * @param endX The end x position. - * @param endY The end y position. + * + * @param vg The NanoVG context. + * @param x The x position. + * @param y The y position. + * @param endX The end x position. + * @param endY The end y position. * @param width The width. * @param color The color. */ @@ -484,43 +540,27 @@ public final class RenderManager { * * <a href="https://github.com/SpinyOwl/legui/blob/develop/LICENSE">Adapted from legui under MIT license</a> * - * @param vg The NanoVG context. - * @param x The x coordinate. - * @param y The y coordinate. - * @param w The width. - * @param h The height. - * @param blur The blur (feather). - * @param spread The spread. + * @param vg The NanoVG context. + * @param x The x coordinate. + * @param y The y coordinate. + * @param w The width. + * @param h The height. + * @param blur The blur (feather). + * @param spread The spread. * @param cornerRadius The radius of the corner */ public static void drawDropShadow(long vg, float x, float y, float w, float h, float blur, float spread, float cornerRadius) { - try ( - NVGPaint shadowPaint = NVGPaint.calloc(); // allocating memory to pass color to nanovg wrapper - NVGColor firstColor = NVGColor.calloc(); // allocating memory to pass color to nanovg wrapper - NVGColor secondColor = NVGColor.calloc() // allocating memory to pass color to nanovg wrapper + try (NVGPaint shadowPaint = NVGPaint.calloc(); // allocating memory to pass color to nanovg wrapper + NVGColor firstColor = NVGColor.calloc(); // allocating memory to pass color to nanovg wrapper + NVGColor secondColor = NVGColor.calloc() // allocating memory to pass color to nanovg wrapper ) { - fillNvgColorWithRGBA(0, 0, 0, 0.5f, firstColor); // filling allocated memory - fillNvgColorWithRGBA(0, 0, 0, 0, secondColor); // filling allocated memory + fillNVGColorWithRGBA(0, 0, 0, 0.5f, firstColor); // filling allocated memory + fillNVGColorWithRGBA(0, 0, 0, 0, secondColor); // filling allocated memory // creating gradient and put it to shadowPaint - nvgBoxGradient(vg, - x - spread, - y - spread, - w + 2 * spread, - h + 2 * spread, - cornerRadius + spread, - blur, - firstColor, - secondColor, - shadowPaint); + nvgBoxGradient(vg, x - spread, y - spread, w + 2 * spread, h + 2 * spread, cornerRadius + spread, blur, firstColor, secondColor, shadowPaint); nvgBeginPath(vg); - nvgRoundedRect(vg, - x - spread - blur, - y - spread - blur, - w + 2 * spread + 2 * blur, - h + 2 * spread + 2 * blur, - cornerRadius + spread - ); + nvgRoundedRect(vg, x - spread - blur, y - spread - blur, w + 2 * spread + 2 * blur, h + 2 * spread + 2 * blur, cornerRadius + spread); nvgRoundedRect(vg, x, y, w, h, cornerRadius); nvgPathWinding(vg, NVG_HOLE); nvgFillPaint(vg, shadowPaint); @@ -530,13 +570,14 @@ public final class RenderManager { /** * Fills the provided {@link NVGColor} with the provided RGBA values. - * @param r The red value. - * @param g The green value. - * @param b The blue value. - * @param a The alpha value. + * + * @param r The red value. + * @param g The green value. + * @param b The blue value. + * @param a The alpha value. * @param color The {@link NVGColor} to fill. */ - public static void fillNvgColorWithRGBA(float r, float g, float b, float a, NVGColor color) { + public static void fillNVGColorWithRGBA(float r, float g, float b, float a, NVGColor color) { color.r(r); color.g(g); color.b(b); @@ -546,7 +587,7 @@ public final class RenderManager { /** * Create a {@link NVGColor} from the provided RGBA values. * - * @param vg The NanoVG context. + * @param vg The NanoVG context. * @param color The color. * @return The {@link NVGColor} created. */ @@ -559,9 +600,10 @@ public final class RenderManager { /** * Scales all rendering by the provided scale. + * * @param vg The NanoVG context. - * @param x The x scale. - * @param y The y scale. + * @param x The x scale. + * @param y The y scale. */ public static void scale(long vg, float x, float y) { nvgScale(vg, x, y); @@ -570,7 +612,7 @@ public final class RenderManager { /** * Sets the global alpha value to render with. * - * @param vg The NanoVG context. + * @param vg The NanoVG context. * @param alpha The alpha value. */ public static void setAlpha(long vg, float alpha) { @@ -580,12 +622,12 @@ public final class RenderManager { /** * Draws a SVG with the provided file path and parameters. * - * @param vg The NanoVG context. + * @param vg The NanoVG context. * @param filePath The file path. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param height The height. */ public static void drawSvg(long vg, String filePath, float x, float y, float width, float height) { float w = width; @@ -609,13 +651,13 @@ public final class RenderManager { /** * Draws a SVG with the provided file path and parameters. * - * @param vg The NanoVG context. + * @param vg The NanoVG context. * @param filePath The file path. - * @param x The x position. - * @param y The y position. - * @param width The width. - * @param height The height. - * @param color The color. + * @param x The x position. + * @param y The y position. + * @param width The width. + * @param height The height. + * @param color The color. */ public static void drawSvg(long vg, String filePath, float x, float y, float width, float height, int color) { float w = width; @@ -658,10 +700,10 @@ public final class RenderManager { /** * Draw a circle with an info icon inside of it * - * @param vg The NanoVG context. + * @param vg The NanoVG context. * @param type The icon type. - * @param x The x position. - * @param y The y position. + * @param x The x position. + * @param y The y position. * @param size The diameter. */ public static void drawInfo(long vg, InfoType type, float x, float y, float size) { diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java index 614d138..f6ad3f5 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java @@ -18,10 +18,10 @@ public class TestNanoVGGui_Test extends UScreen { RenderManager.setupAndDraw((vg) -> { RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); - RenderManager.drawString(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); + RenderManager.drawText(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB()); RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB()); - RenderManager.drawString(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); + RenderManager.drawText(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); }); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java index 19d399f..79634da 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java @@ -4,7 +4,7 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; public final class MathUtils { public static float clamp(float number) { - return number < 0f ? 0f : Math.min(number, 1f); + return clamp(number, 0, 1); } public static float clamp(float number, float min, float max) { diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java index f9f0fbd..4fa5125 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/TextUtils.java @@ -1,6 +1,7 @@ package cc.polyfrost.oneconfig.utils; import cc.polyfrost.oneconfig.lwjgl.RenderManager; +import cc.polyfrost.oneconfig.lwjgl.font.Font; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import java.util.ArrayList; @@ -20,6 +21,19 @@ public final class TextUtils { * @return The array of lines. */ public static ArrayList<String> wrapText(long vg, String text, float maxWidth, float fontSize, Fonts font) { + return wrapText(vg, text, maxWidth, fontSize, font.font); + } + + /** + * Wraps a string into an array of lines. + * @param vg The NanoVG context. + * @param text The text to wrap. + * @param maxWidth The maximum width of each line. + * @param fontSize The font size. + * @param font The font to use. + * @return The array of lines. + */ + public static ArrayList<String> wrapText(long vg, String text, float maxWidth, float fontSize, Font font) { ArrayList<String> wrappedText = new ArrayList<>(); text += " "; int prevIndex = 0; diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java index bc57fc2..3e7b7ea 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/commands/CommandHelper.java @@ -10,7 +10,7 @@ package cc.polyfrost.oneconfig.utils.commands; public abstract class CommandHelper { public CommandHelper() { - CommandManager.registerCommand(this); + CommandManager.INSTANCE.registerCommand(this); } public void preload() { |