Working UI
This commit is contained in:
@@ -8,6 +8,10 @@ public class SaturnIdentifier extends MinecraftBinding {
|
||||
super(MinecraftProvider.PROVIDER.createIdentifier(namespace, path));
|
||||
}
|
||||
|
||||
public SaturnIdentifier(Object o) {
|
||||
super(o);
|
||||
}
|
||||
|
||||
public static SaturnIdentifier of(String namespace, String path) {
|
||||
return new SaturnIdentifier(namespace, path);
|
||||
}
|
||||
@@ -21,4 +25,9 @@ public class SaturnIdentifier extends MinecraftBinding {
|
||||
public static SaturnIdentifier ofVanilla(String path) {
|
||||
return new SaturnIdentifier("minecraft", path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.inner.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,19 @@ public class ImageTexture extends Element {
|
||||
if (sprite.toString().endsWith(".svg")) {
|
||||
IMinecraftClient client = MinecraftProvider.PROVIDER.getClient();
|
||||
|
||||
// Get the actual window pixel dimensions for the image
|
||||
int renderWidth = (int) (width * client.getWindow().getFramebufferWidth() / client.getWindow().getWidth());
|
||||
int renderHeight = (int) (height * client.getWindow().getFramebufferHeight()
|
||||
/ client.getWindow().getHeight());
|
||||
|
||||
sprite = SvgTexture.getSvg(client, sprite, renderWidth * 2, renderHeight * 2);
|
||||
SaturnIdentifier pngId = SvgTexture.getSvg(client, sprite, renderWidth * 2, renderHeight * 2);
|
||||
|
||||
this.sprite = pngId;
|
||||
if (pngId == null) {
|
||||
System.err.println("Failed to render SVG: " + sprite);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
renderScope.drawTexture(sprite, 0, 0, 0, 0, width, height);
|
||||
renderScope.drawTexture(this.sprite, 0, 0, 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.joml.Matrix4f;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import org.saturnclient.common.minecraft.MinecraftProvider;
|
||||
import org.saturnclient.common.minecraft.bindings.SaturnIdentifier;
|
||||
import org.saturnclient.common.minecraft.bindings.SaturnItemStack;
|
||||
import org.saturnclient.common.minecraft.bindings.SaturnSprite;
|
||||
@@ -17,6 +18,7 @@ import org.saturnclient.common.minecraft.render.IMatrixStack;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.mixin.DrawContextAccessor;
|
||||
import org.saturnclient.ui.resources.Fonts;
|
||||
import org.saturnclient.ui.resources.SvgTexture;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.font.TextRenderer.TextLayerType;
|
||||
@@ -267,8 +269,9 @@ public class RenderScopeImpl implements RenderScope {
|
||||
float v2, int color) {
|
||||
|
||||
if (sprite.toString().endsWith(".svg")) {
|
||||
// sprite = SvgTexture.getSvg(MinecraftClient.getInstance(), sprite, (x2 - x1) *
|
||||
// 2, (y2 - y1) * 2);
|
||||
sprite = (Identifier) SvgTexture.getSvg(MinecraftProvider.PROVIDER.getClient(),
|
||||
new SaturnIdentifier(sprite),
|
||||
(x2 - x1) * 2, (y2 - y1) * 2).inner;
|
||||
}
|
||||
|
||||
if (color == 0)
|
||||
|
||||
Reference in New Issue
Block a user