From df8663e5958fe43d0c68fde3f4d31e45b2f15da1 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 24 Dec 2022 03:48:50 +1100 Subject: Gui element scale (#485) --- .../notenoughupdates/overlays/TextOverlay.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java index 7884b2ac..2fbbe27d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java @@ -19,6 +19,7 @@ package io.github.moulberry.notenoughupdates.overlays; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -120,12 +121,15 @@ public abstract class TextOverlay { return new Vector2f(); } - protected Vector2f getPosition(int overlayWidth, int overlayHeight) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + protected Vector2f getPosition(int overlayWidth, int overlayHeight, boolean scaled) { + GlStateManager.pushMatrix(); + ScaledResolution scaledResolution; + if (!scaled) scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + else scaledResolution = Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale); int x = position.getAbsX(scaledResolution, overlayWidth); int y = position.getAbsY(scaledResolution, overlayHeight); - + GlStateManager.popMatrix(); return new Vector2f(x, y); } @@ -138,17 +142,19 @@ public abstract class TextOverlay { private void render(List strings, boolean dummy) { if (strings == null) return; - + if (!dummy) { + GlStateManager.pushMatrix(); + Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale); + } Vector2f size = getSize(strings); overlayHeight = (int) size.y; overlayWidth = (int) size.x; - Vector2f position = getPosition(overlayWidth, overlayHeight); + Vector2f position = getPosition(overlayWidth, overlayHeight, !dummy); int x = (int) position.x; int y = (int) position.y; TextOverlayStyle style = styleSupplier.get(); - if (style == TextOverlayStyle.BACKGROUND) Gui.drawRect(x, y, x + overlayWidth, y + overlayHeight, 0x80000000); GlStateManager.enableBlend(); @@ -204,5 +210,9 @@ public abstract class TextOverlay { } } } + if (!dummy) { + Utils.pushGuiScale(0); + GlStateManager.popMatrix(); + } } } -- cgit