From bd6f658c6c53d160c40bc3b5fdead7b7b3dd20c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Jul 2020 00:53:17 +1000 Subject: 1.8 --- .../github/moulberry/notenoughupdates/Utils.java | 57 +++++++++------------- 1 file changed, 24 insertions(+), 33 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/Utils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/Utils.java index c08adc94..f850b49d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/Utils.java @@ -112,6 +112,10 @@ public class Utils { drawTexturedRect(x, y, width, height, uMin, uMax, vMin , vMax, GL11.GL_LINEAR); } + public static String cleanColour(String in) { + return in.replaceAll("(?i)\\u00A7.", ""); + } + public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) { GlStateManager.enableTexture2D(); GlStateManager.enableBlend(); @@ -137,34 +141,6 @@ public class Utils { .tex(uMin, vMin).endVertex(); tessellator.draw(); - /*Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer - .pos(x, y + height, 0) - .tex(uMin, vMax).endVertex(); - worldrenderer - .pos(x + width, y + height, 0) - .tex(uMax, vMax).endVertex(); - worldrenderer - .pos(x + width, y, 0) - .tex(uMax, vMin).endVertex(); - worldrenderer - .pos(x, y, 0) - .tex(uMin, vMin).endVertex(); - tessellator.draw();*/ - - /*GL11.glBegin(GL11.GL_TRIANGLE_STRIP); - GL11.glTexCoord2f(uMin, vMin); - GL11.glVertex3f(x, y, 0.0F); - GL11.glTexCoord2f(uMin, vMax); - GL11.glVertex3f(x, y+height, 0.0F); - GL11.glTexCoord2f(uMax, vMin); - GL11.glVertex3f(x+width, y, 0.0F); - GL11.glTexCoord2f(uMax, vMax); - GL11.glVertex3f(x+width, y+height, 0.0F); - GL11.glEnd();*/ - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); @@ -204,7 +180,21 @@ public class Utils { drawStringScaled(str, fr, x-len/2, y-fontHeight/2, shadow, colour, factor); } + public static void drawStringCenteredYScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) { + int strLen = fr.getStringWidth(str); + float factor = len/(float)strLen; + float fontHeight = 8*factor; + + drawStringScaled(str, fr, x, y-fontHeight/2, shadow, colour, factor); + } + public static int renderStringTrimWidth(String str, FontRenderer fr, boolean shadow, int x, int y, int len, int colour, int maxLines) { + return renderStringTrimWidth(str, fr, shadow, x, y, len, colour, maxLines, 1); + } + + public static int renderStringTrimWidth(String str, FontRenderer fr, boolean shadow, int x, int y, int len, int colour, int maxLines, float scale) { + len = (int)(len/scale); + int yOff = 0; String excess; String trimmed = trimToWidth(str, len); @@ -221,26 +211,27 @@ public class Utils { int lines = 0; while((lines++