aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-04-16 01:55:58 +0900
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-04-16 01:55:58 +0900
commitfff43b4d2a89ae50aa1d315fc4dad65055e654be (patch)
tree1868409a8282572894cafe73dd97bbf0009bbb7e /src/main/java/io/polyfrost/oneconfig
parent30df3e578cef533cacedf737449bbd35d4ea5d11 (diff)
downloadOneConfig-fff43b4d2a89ae50aa1d315fc4dad65055e654be.tar.gz
OneConfig-fff43b4d2a89ae50aa1d315fc4dad65055e654be.tar.bz2
OneConfig-fff43b4d2a89ae50aa1d315fc4dad65055e654be.zip
misc things
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java4
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/NanoVGUtils.java20
-rw-r--r--src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java5
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);
});
}
}