diff options
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig')
3 files changed, 12 insertions, 17 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java index d0f54f7..eb830df 100644 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java +++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import static org.lwjgl.BufferUtils.createByteBuffer; import static org.lwjgl.system.MemoryUtil.memSlice; +@SuppressWarnings("RedundantCast") final class IOUtil { private IOUtil() { @@ -21,7 +22,7 @@ final class IOUtil { private static ByteBuffer resizeBuffer(ByteBuffer buffer, int newCapacity) { ByteBuffer newBuffer = createByteBuffer(newCapacity); - buffer.flip(); + ((Buffer) buffer).flip(); newBuffer.put(buffer); return newBuffer; } @@ -57,7 +58,6 @@ final class IOUtil { } } - //noinspection RedundantCast ((Buffer) buffer).flip(); return memSlice(buffer); } diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java index c9d0615..f8dcafb 100644 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java +++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java @@ -6,14 +6,13 @@ import net.minecraft.client.shader.Framebuffer; import org.lwjgl.nanovg.NVGColor; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; -import org.lwjgl.system.MemoryStack; import java.io.IOException; -import java.nio.ByteBuffer; import java.util.function.LongConsumer; import static org.lwjgl.nanovg.NanoVG.*; -import static org.lwjgl.nanovg.NanoVGGL2.*; +import static org.lwjgl.nanovg.NanoVGGL2.NVG_ANTIALIAS; +import static org.lwjgl.nanovg.NanoVGGL2.nvgCreate; public final class NanoVGUtils { private NanoVGUtils() { @@ -31,7 +30,7 @@ public final class NanoVGUtils { } if (font == -1) { try { - font = nvgCreateFontMem(vg, "custom-font", IOUtil.resourceToByteBuffer("/assets/oneconfig/font/Roboto-Regular.ttf", 150 * 1024), 0); + font = nvgCreateFontMem(vg, "custom-font", IOUtil.resourceToByteBuffer("/assets/oneconfig/font/Inter-Bold.ttf", 200 * 1024), 0); } catch (IOException e) { e.printStackTrace(); } @@ -80,15 +79,10 @@ public final class NanoVGUtils { nvgBeginPath(vg); nvgFontSize(vg, size); nvgFontFace(vg, "custom-font"); - nvgTextAlign(vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE); - try (MemoryStack stack = MemoryStack.stackPush()) { - ByteBuffer textByte = stack.ASCII(text, false); - nvgFontBlur(vg, 0); - color(vg, color); - nvgText(vg, x, y, textByte); - } catch (Exception e) { - e.printStackTrace(); - } + nvgTextAlign(vg, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE); + color(vg, color); + nvgText(vg, x, y, text); + nvgFill(vg); } public static void color(long vg, int color) { diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java index 74d6a1e..67e0a68 100644 --- a/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java +++ b/src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java @@ -10,10 +10,11 @@ public class TestNanoVGGui extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); + drawRect(0, 0, width, height, Color.BLACK.getRGB()); NanoVGUtils.setupAndDraw((vg) -> { NanoVGUtils.drawRect(vg, 0, 0, 300, 300, Color.BLUE.getRGB()); - NanoVGUtils.drawRoundedRect(vg, 305, 305, 100, 100, Color.BLACK.getRGB(), 8); - NanoVGUtils.drawString(vg, "Hello!", 500, 500, Color.BLACK.getRGB(), 50); + NanoVGUtils.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); + NanoVGUtils.drawString(vg, "Hello!", 500, 500, Color.WHITE.getRGB(), 50); }); } } |