diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-03 17:38:50 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-03 17:38:50 +0200 |
commit | b798930b21b89b81be05a31281f768667a6dd7f3 (patch) | |
tree | 8611e7a51f65910da99b22034f078c23b13f8546 /src/main/java/io/polyfrost/oneconfig/gui | |
parent | e5ef86b9b3fd0f5e687416acc667f368444e4459 (diff) | |
download | OneConfig-b798930b21b89b81be05a31281f768667a6dd7f3.tar.gz OneConfig-b798930b21b89b81be05a31281f768667a6dd7f3.tar.bz2 OneConfig-b798930b21b89b81be05a31281f768667a6dd7f3.zip |
multiple scissors system
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui')
3 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java index 1b6123e..3377f19 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java @@ -7,6 +7,8 @@ import io.polyfrost.oneconfig.gui.elements.TextInputField; import io.polyfrost.oneconfig.gui.pages.HomePage; import io.polyfrost.oneconfig.gui.pages.Page; import io.polyfrost.oneconfig.lwjgl.RenderManager; +import io.polyfrost.oneconfig.lwjgl.Scissor; +import io.polyfrost.oneconfig.lwjgl.ScissorManager; import io.polyfrost.oneconfig.lwjgl.font.Fonts; import io.polyfrost.oneconfig.lwjgl.image.Images; import io.polyfrost.oneconfig.utils.InputUtils; @@ -115,7 +117,7 @@ public class OneConfigGui extends GuiScreen { } } - nvgScissor(vg, x + 224, y + 72, 1056, 728); + Scissor scissor = ScissorManager.scissor(vg, x + 224, y + 72, 1056, 728); if (prevPage != null) { pageProgress = MathUtils.easeInOutCirc(50, pageProgress, 832 - pageProgress, 220); prevPage.draw(vg, (int) (x - pageProgress), y + 72); @@ -128,7 +130,7 @@ public class OneConfigGui extends GuiScreen { } else { currentPage.draw(vg, (int) (x - pageProgress), y + 72); } - nvgResetScissor(vg); + ScissorManager.resetScissor(vg, scissor); if (currentColorSelector != null) { currentColorSelector.draw(vg); } diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java index 04e5676..1e33008 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java @@ -2,6 +2,8 @@ package io.polyfrost.oneconfig.gui.elements; import io.polyfrost.oneconfig.config.OneConfigConfig; import io.polyfrost.oneconfig.lwjgl.RenderManager; +import io.polyfrost.oneconfig.lwjgl.Scissor; +import io.polyfrost.oneconfig.lwjgl.ScissorManager; import io.polyfrost.oneconfig.lwjgl.font.Fonts; import io.polyfrost.oneconfig.utils.InputUtils; import net.minecraft.client.gui.GuiScreen; @@ -84,6 +86,7 @@ public class TextInputField extends BasicElement { this.y = y; this.vg = vg; try { + Scissor scissor = ScissorManager.scissor(vg, x, y, width, height); int colorOutline = errored ? OneConfigConfig.ERROR_700 : OneConfigConfig.GRAY_700; RenderManager.drawHollowRoundRect(vg, x, y, width, height, colorOutline, 12f, 2f); super.update(x, y); @@ -179,6 +182,7 @@ public class TextInputField extends BasicElement { } else { RenderManager.drawString(vg, s.toString(), x + 12, y + height / 2f + 1, color, 14f, Fonts.INTER_REGULAR); } + ScissorManager.resetScissor(vg, scissor); } catch (Exception e) { e.printStackTrace(); } @@ -334,9 +338,6 @@ public class TextInputField extends BasicElement { if (!Character.isDefined(c)) return; if (GuiScreen.isCtrlKeyDown()) return; if (ChatAllowedCharacters.isAllowedCharacter(c)) { - if (getTextWidth(vg, input) + 22 > width) { // over typing is banned - return; - } if (selectedText != null) { if (caretPos > prevCaret) { input = input.substring(0, prevCaret) + input.substring(prevCaret, caretPos); diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java index 9e3a4a4..ff7616e 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java @@ -3,6 +3,8 @@ package io.polyfrost.oneconfig.gui.elements.config; import io.polyfrost.oneconfig.config.OneConfigConfig; import io.polyfrost.oneconfig.config.interfaces.BasicOption; import io.polyfrost.oneconfig.lwjgl.RenderManager; +import io.polyfrost.oneconfig.lwjgl.Scissor; +import io.polyfrost.oneconfig.lwjgl.ScissorManager; import io.polyfrost.oneconfig.lwjgl.font.Fonts; import io.polyfrost.oneconfig.lwjgl.image.Images; import io.polyfrost.oneconfig.utils.InputUtils; @@ -36,16 +38,15 @@ public class ConfigUniSelector extends BasicOption { String option = options[selected] + " " + (selected + 1) + "/" + options.length; RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.INTER_MEDIUM); + Scissor scissor = ScissorManager.scissor(vg, x + 256, y, 192, 32); if (previous == -1) { RenderManager.drawString(vg, option, x + 352 - RenderManager.getTextWidth(vg, option, 12f, Fonts.INTER_MEDIUM) / 2f, y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM); } else { String prevOption = options[previous] + " " + (previous + 1) + "/" + options.length; - NanoVG.nvgScissor(vg, x + 256, y, 192, 32); RenderManager.drawString(vg, selected < previous ? prevOption : option, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? prevOption : option, 12f, Fonts.INTER_MEDIUM) / 2f + 192 * percentMove, y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM); RenderManager.drawString(vg, selected < previous ? option : prevOption, x + 352 - RenderManager.getTextWidth(vg, selected < previous ? option : prevOption, 12f, Fonts.INTER_MEDIUM) / 2f - 192 * (1 - percentMove), y + 15, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_MEDIUM); - - NanoVG.nvgResetScissor(vg); } + ScissorManager.resetScissor(vg, scissor); // actual coordinates: 240, 7 NanoVG.nvgTranslate(vg, x + 248, y + 21); |