From 9986f445b89fc866265dade49b8356f87199a01e Mon Sep 17 00:00:00 2001 From: nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> Date: Tue, 19 Apr 2022 17:09:13 +0100 Subject: i am so sad ive wasted an entire day and made literally no progress (plz try and fix) --- .../io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/main/java/io/polyfrost/oneconfig/lwjgl/image') diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java index 4e07215..6fbd27f 100644 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java +++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java @@ -1,12 +1,19 @@ package io.polyfrost.oneconfig.lwjgl.image; import io.polyfrost.oneconfig.lwjgl.IOUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; import org.lwjgl.nanovg.NSVGImage; import org.lwjgl.nanovg.NanoSVG; import org.lwjgl.nanovg.NanoVG; import org.lwjgl.stb.STBImage; +import org.lwjgl.system.MemoryStack; +import java.io.BufferedReader; +import java.io.InputStreamReader; import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.StandardCharsets; import java.util.HashMap; public class ImageLoader { @@ -39,9 +46,14 @@ public class ImageLoader { public boolean loadSVGImage(String fileName) { if(!NSVGImageHashMap.containsKey(fileName)) { try { - NSVGImageHashMap.put(fileName, NanoSVG.nsvgParseFromFile(fileName, "px", 96f)); + CharSequence s = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("oneconfig", fileName)).getInputStream())).readLine(); + System.out.println(s); + NSVGImage image = NanoSVG.nsvgParse(s, "px", 96f); + NSVGImageHashMap.put(fileName, image); + System.out.println("Loaded SVG: " + fileName); } catch (Exception e) { // just in case System.err.println("Failed to parse SVG file"); + e.printStackTrace(); return false; } return true; -- cgit