diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-06-24 23:44:58 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-06-24 23:44:58 +0700 |
commit | f1830199d99b666f28c2b3b246f688f102adb427 (patch) | |
tree | 07fba5e7fce5e523223e8fc9da70f7783d7f15f9 /src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java | |
parent | d4463b33342ccb5ea86c2a2c9da37b9b861b6674 (diff) | |
download | OneConfig-f1830199d99b666f28c2b3b246f688f102adb427.tar.gz OneConfig-f1830199d99b666f28c2b3b246f688f102adb427.tar.bz2 OneConfig-f1830199d99b666f28c2b3b246f688f102adb427.zip |
TextHud revamp
add docs to Hud
fix config not saving when exiting prematurely
some new events
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java index d894d1e..b62d752 100644 --- a/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/renderer/RenderManager.java @@ -20,6 +20,7 @@ import org.lwjgl.nanovg.NVGPaint; import org.lwjgl.opengl.GL11; import java.util.function.LongConsumer; +import java.util.regex.Pattern; import static org.lwjgl.nanovg.NanoVG.*; import static org.lwjgl.nanovg.NanoVGGL2.NVG_ANTIALIAS; @@ -740,14 +741,68 @@ public final class RenderManager { // gl - public static void drawScaledString(String text, float x, float y, int color, boolean shadow, float scale) { + private static final Pattern regex = Pattern.compile("(?i)\\\\u00A7[0-9a-f]"); + + public static int drawBorderedText(String text, float x, float y, int color, int opacity) { + String noColors = regex.matcher(text).replaceAll("\u00A7r"); + int yes = 0; + if (opacity > 3) { + int xOff = -3; + while (xOff < 3) { + xOff++; + int yOff = -3; + while (yOff < 3) { + yOff++; + if (xOff * xOff != yOff * yOff) { + yes += + //#if MODERN==0 + UMinecraft.getFontRenderer().drawString( + noColors, (xOff / 2f) + x, (yOff / 2f) + y, (opacity) << 24, false + ); + //#else + //$$ draw( + //$$ matrix.toMC(), noColors, (xOff / 2f) + x, (yOff / 2f) + y, (opacity) shl 24 + //$$ ) + //#endif + } + } + } + } + yes += + //#if MODERN==0 + UMinecraft.getFontRenderer().drawString(text, x, y, color, false); + //#else + //$$ draw(matrix.toMC(), text, x.toFloat(), y.toFloat(), color) + //#endif + return yes; + } + + public static void drawScaledString(String text, float x, float y, int color, TextType type, float scale) { UGraphics.GL.pushMatrix(); UGraphics.GL.scale(scale, scale, 1); - UMinecraft.getFontRenderer().drawString(text, x * (1 / scale), y * (1 / scale), color, shadow); + switch (type) { + case NONE: + UMinecraft.getFontRenderer().drawString(text, x * (1 / scale), y * (1 / scale), color, false); + break; + case SHADOW: + UMinecraft.getFontRenderer().drawString(text, x * (1 / scale), y * (1 / scale), color, true); + break; + case FULL: + drawBorderedText(text, x, y, color, 100); + break; + } UGraphics.GL.popMatrix(); } public static void drawGlRect(int x, int y, int width, int height, int color) { Gui.drawRect(x, y, x + width, y + height, color); } + + public enum TextType { + NONE, SHADOW, FULL; + + public static TextType toType(int type) { + return values()[type]; + } + } } |