Working UI
This commit is contained in:
@@ -4,9 +4,13 @@ import java.io.File;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.saturnclient.common.minecraft.bindings.SaturnIdentifier;
|
import org.saturnclient.common.minecraft.bindings.SaturnIdentifier;
|
||||||
|
import org.saturnclient.common.minecraft.render.IWindow;
|
||||||
|
|
||||||
public interface IMinecraftClient {
|
public interface IMinecraftClient {
|
||||||
|
|
||||||
public File getRunDirectory();
|
public File getRunDirectory();
|
||||||
|
|
||||||
public InputStream getResource(SaturnIdentifier identifier);
|
public InputStream getResource(SaturnIdentifier identifier);
|
||||||
|
|
||||||
|
public IWindow getWindow();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ public class SaturnIdentifier extends MinecraftBinding {
|
|||||||
super(MinecraftProvider.PROVIDER.createIdentifier(namespace, path));
|
super(MinecraftProvider.PROVIDER.createIdentifier(namespace, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SaturnIdentifier(Object o) {
|
||||||
|
super(o);
|
||||||
|
}
|
||||||
|
|
||||||
public static SaturnIdentifier of(String namespace, String path) {
|
public static SaturnIdentifier of(String namespace, String path) {
|
||||||
return new SaturnIdentifier(namespace, path);
|
return new SaturnIdentifier(namespace, path);
|
||||||
}
|
}
|
||||||
@@ -21,4 +25,9 @@ public class SaturnIdentifier extends MinecraftBinding {
|
|||||||
public static SaturnIdentifier ofVanilla(String path) {
|
public static SaturnIdentifier ofVanilla(String path) {
|
||||||
return new SaturnIdentifier("minecraft", path);
|
return new SaturnIdentifier("minecraft", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.inner.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.saturnclient.common.minecraft.bindings.SaturnIdentifier;
|
|||||||
import org.saturnclient.ui.Element;
|
import org.saturnclient.ui.Element;
|
||||||
import org.saturnclient.ui.ElementContext;
|
import org.saturnclient.ui.ElementContext;
|
||||||
import org.saturnclient.ui.RenderScope;
|
import org.saturnclient.ui.RenderScope;
|
||||||
|
import org.saturnclient.ui.resources.SvgTexture;
|
||||||
|
|
||||||
public class ImageTexture extends Element {
|
public class ImageTexture extends Element {
|
||||||
SaturnIdentifier sprite;
|
SaturnIdentifier sprite;
|
||||||
@@ -16,17 +17,22 @@ public class ImageTexture extends Element {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||||
// if (sprite.toString().endsWith(".svg")) {
|
if (sprite.toString().endsWith(".svg")) {
|
||||||
// IMinecraftClient client = MinecraftProvider.PROVIDER.getClient();
|
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 renderWidth = (int) (width * client.getWindow().getFramebufferWidth() / client.getWindow().getWidth());
|
int renderHeight = (int) (height * client.getWindow().getFramebufferHeight()
|
||||||
// int renderHeight = (int) (height * client.getWindow().getFramebufferHeight()
|
/ client.getWindow().getHeight());
|
||||||
// / client.getWindow().getHeight());
|
|
||||||
|
|
||||||
// sprite = SvgTexture.getSvg(client, sprite, renderWidth * 2, renderHeight * 2);
|
SaturnIdentifier pngId = SvgTexture.getSvg(client, sprite, renderWidth * 2, renderHeight * 2);
|
||||||
// }
|
|
||||||
|
|
||||||
renderScope.drawTexture(sprite, 0, 0, 0, 0, width, height);
|
this.sprite = pngId;
|
||||||
|
if (pngId == null) {
|
||||||
|
System.err.println("Failed to render SVG: " + sprite);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderScope.drawTexture(this.sprite, 0, 0, 0, 0, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.saturnclient.config.Theme;
|
|||||||
import org.saturnclient.config.manager.Property;
|
import org.saturnclient.config.manager.Property;
|
||||||
import org.saturnclient.ui.Element;
|
import org.saturnclient.ui.Element;
|
||||||
import org.saturnclient.ui.ElementContext;
|
import org.saturnclient.ui.ElementContext;
|
||||||
|
import org.saturnclient.ui.ElementRenderer;
|
||||||
import org.saturnclient.ui.RenderScope;
|
import org.saturnclient.ui.RenderScope;
|
||||||
|
|
||||||
public class Scroll extends Element {
|
public class Scroll extends Element {
|
||||||
@@ -25,7 +26,7 @@ public class Scroll extends Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Element element) {
|
public void draw(Element element) {
|
||||||
// ElementRenderer.draw(children, element);
|
ElementRenderer.INSTANCE.draw(children, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,9 +40,9 @@ public class Scroll extends Element {
|
|||||||
renderScope.getMatrixStack().push();
|
renderScope.getMatrixStack().push();
|
||||||
renderScope.getMatrixStack().translate(padding, -scroll + padding, 0);
|
renderScope.getMatrixStack().translate(padding, -scroll + padding, 0);
|
||||||
|
|
||||||
// ElementRenderer.render(children, ctx.elapsed, renderScope,
|
ElementRenderer.INSTANCE.render(children, ctx.elapsed, renderScope,
|
||||||
// ctx.mouseX - padding,
|
ctx.mouseX - padding,
|
||||||
// ctx.mouseY - padding + scroll);
|
ctx.mouseY - padding + scroll);
|
||||||
|
|
||||||
renderScope.getMatrixStack().pop();
|
renderScope.getMatrixStack().pop();
|
||||||
renderScope.disableScissor();
|
renderScope.disableScissor();
|
||||||
@@ -110,21 +111,22 @@ public class Scroll extends Element {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(int keyCode, int scanCode, int modifiers) {
|
public void keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
// ElementRenderer.keyPressed(children, keyCode, scanCode, modifiers);
|
ElementRenderer.INSTANCE.keyPressed(children, keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
// ElementRenderer.mouseClicked(children, mouseX - padding, mouseY - padding + scroll, button);
|
ElementRenderer.INSTANCE.mouseClicked(children, mouseX - padding, mouseY - padding + scroll, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
public void mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||||
// ElementRenderer.mouseDragged(children, mouseX - padding, mouseY - padding + scroll, button, deltaX, deltaY);
|
ElementRenderer.INSTANCE.mouseDragged(children, mouseX - padding, mouseY - padding + scroll, button, deltaX,
|
||||||
|
deltaY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(double mouseX, double mouseY, int button) {
|
public void mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
// ElementRenderer.mouseReleased(children, mouseX - padding, mouseY - padding + scroll, button);
|
ElementRenderer.INSTANCE.mouseReleased(children, mouseX - padding, mouseY - padding + scroll, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user