diff options
Diffstat (limited to 'src/main')
3 files changed, 14 insertions, 7 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 240a4db..7fe7a35 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -13,6 +13,7 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Keyboard; @@ -38,6 +39,7 @@ public class OneConfigGui extends GuiScreen { private final ArrayList<Page> parents = new ArrayList<>(); private ColorSelector currentColorSelector; public boolean mouseDown; + private float scale = 1f; public OneConfigGui() { INSTANCE = this; @@ -57,7 +59,8 @@ public class OneConfigGui extends GuiScreen { currentPage = new HomePage(); parents.add(currentPage); } - //nvgScale(vg, 0.5f, 0.5f); + scale = Minecraft.getMinecraft().displayWidth / 1920f; + NanoVG.nvgScale(vg, scale, scale); if (OneConfigConfig.ROUNDED_CORNERS) { RenderManager.drawRoundedRect(vg, 544, 140, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN); RenderManager.drawRoundedRect(vg, 320, 140, 244, 800, OneConfigConfig.GRAY_900_80, OneConfigConfig.CORNER_RADIUS_WIN); @@ -220,6 +223,10 @@ public class OneConfigGui extends GuiScreen { return color; } + public float getScaleFactor() { + return scale; + } + public String getSearchValue() { return textInputField.getInput(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java index 59897c6..1199283 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java @@ -111,7 +111,7 @@ public class TextInputField extends BasicElement { while (Mouse.next()) { if (Mouse.getEventButtonState()) { if (Mouse.getEventButton() == 0) { - prevCaret = calculatePos(Mouse.getX()); + prevCaret = calculatePos(InputUtils.mouseX()); if (System.currentTimeMillis() - clickTimeD1 < 300) { onDoubleClick(); isDoubleClick = true; @@ -140,7 +140,7 @@ public class TextInputField extends BasicElement { } if (hovered) { if (Mouse.isButtonDown(0) && !isDoubleClick) { - caretPos = calculatePos(Mouse.getX()); + caretPos = calculatePos(InputUtils.mouseX()); if (caretPos > prevCaret) { if (!centered) start = x + 12 + this.getTextWidth(vg, input.substring(0, prevCaret)); else diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java index 806f6de..13b34da 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java @@ -11,8 +11,8 @@ public class InputUtils { * @return true if mouse is over region, false if not. */ public static boolean isAreaHovered(int x, int y, int width, int height) { - int mouseX = Mouse.getX(); - int mouseY = Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY()); + int mouseX = mouseX(); + int mouseY = mouseY(); return mouseX > x && mouseY > y && mouseX < x + width && mouseY < y + height; // TODO add scaling info } @@ -25,10 +25,10 @@ public class InputUtils { } public static int mouseX() { - return Mouse.getX(); + return (int) (Mouse.getX() / OneConfigGui.INSTANCE.getScaleFactor()); } public static int mouseY() { - return Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY()); + return (int) ((Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY())) / OneConfigGui.INSTANCE.getScaleFactor()); } } |