aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-21 14:19:44 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-21 14:19:44 +0100
commit260d48126cbedb4341c5c5865bfd8e605f90955a (patch)
tree563f65d65d708f24df33759c411b0f2338c1933e /src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
parent30df910cf3b2f5b0683ce01e391c35829d8a5850 (diff)
downloadOneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.gz
OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.bz2
OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.zip
more gui things like text field and button
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
index d728670..2ed8404 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -3,6 +3,7 @@ package io.polyfrost.oneconfig.lwjgl;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.lwjgl.font.Font;
import io.polyfrost.oneconfig.lwjgl.font.FontManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.lwjgl.image.Image;
import io.polyfrost.oneconfig.lwjgl.image.ImageLoader;
import net.minecraft.client.Minecraft;
@@ -131,14 +132,11 @@ public final class RenderManager {
nvgColor.free();
}
- public static void drawString(long vg, String text, float x, float y, int color, float size, Font font) {
- drawString(vg, text, x, y, color, size, font.getName());
- }
- public static void drawString(long vg, String text, float x, float y, int color, float size, String fontName) {
+ public static void drawString(long vg, String text, float x, float y, int color, float size, Fonts font) {
nvgBeginPath(vg);
nvgFontSize(vg, size);
- nvgFontFace(vg, fontName);
+ nvgFontFace(vg, font.font.getName());
nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
NVGColor nvgColor = color(vg, color);
nvgText(vg, x, y, text);
@@ -216,6 +214,11 @@ public final class RenderManager {
}
}
+ public static float getTextWidth(long vg, String text, float fontSize) {
+ float[] bounds = new float[4];
+ return (nvgTextBounds(vg, 0, 0, text, bounds) / 12) * fontSize;
+ }
+
public static void drawLine(long vg, float x, float y, float endX, float endY, float width, int color) {
nvgBeginPath(vg);
nvgMoveTo(vg, x, y);