aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-11-23 03:34:12 +1100
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-11-23 03:34:12 +1100
commit089bac89c5435eb7e5cf80e7602da953a65f5b1a (patch)
treeea6aea2afc38f6ef02884f0c3babdc5ed86058bb /src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
parent07403ec86c53f67b94d988b4c01a0afc2fdb2810 (diff)
downloadnotenoughupdates-089bac89c5435eb7e5cf80e7602da953a65f5b1a.tar.gz
notenoughupdates-089bac89c5435eb7e5cf80e7602da953a65f5b1a.tar.bz2
notenoughupdates-089bac89c5435eb7e5cf80e7602da953a65f5b1a.zip
1.7
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index e2faa5aa..667128b9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -479,9 +479,40 @@ public class Utils {
}
public static void drawStringF(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- GL11.glTranslatef(x, y, 0);
- fr.drawString(str, 0, 0, colour, shadow);
- GL11.glTranslatef(-x, -y, 0);
+ fr.drawString(str, x, y, colour, shadow);
+ }
+
+ public static int getCharVertLen(char c) {
+ if("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
+ return 5;
+ } else {
+ return 7;
+ }
+ }
+
+ public static float getVerticalHeight(String str) {
+ str = cleanColour(str);
+ float height = 0;
+ for(int i=0; i<str.length(); i++) {
+ char c = str.charAt(i);
+ int charHeight = getCharVertLen(c);
+ height += charHeight + 1.5f;
+ }
+ return height;
+ }
+
+ public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
+ String format = FontRenderer.getFormatFromString(str);
+ str = cleanColour(str);
+ for(int i=0; i<str.length(); i++) {
+ char c = str.charAt(i);
+
+ int charHeight = getCharVertLen(c);
+ int charWidth = fr.getCharWidth(c);
+ fr.drawString(format+c, x+(5-charWidth)/2f, y-7+charHeight, colour, shadow);
+
+ y += charHeight + 1.5f;
+ }
}
public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {