aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/gui/elements
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/elements')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java7
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java7
2 files changed, 8 insertions, 6 deletions
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);