aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/elements/config
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-08-17 17:43:23 +0200
committerGitHub <noreply@github.com>2022-08-17 17:43:23 +0200
commit97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f (patch)
tree2bccc96007025fbccf1758ac66d4665a97d6c315 /src/main/java/cc/polyfrost/oneconfig/gui/elements/config
parente18629af6aee276b0be6cec473e4099cca9100f1 (diff)
downloadOneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.tar.gz
OneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.tar.bz2
OneConfig-97f788ecd4be15b1556ee1f3d8bd057bdf06bf5f.zip
Input revamp (#93)
* hud fix * api * things * stuff
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/elements/config')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java36
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java10
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java10
12 files changed, 62 insertions, 58 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
index d7c4103..fdd0c2f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
@@ -32,6 +32,7 @@ import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.lang.reflect.Field;
@@ -90,11 +91,11 @@ public class ConfigButton extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
button.disable(!isEnabled());
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
RenderManager.drawText(vg, name, x, y + 17, Colors.WHITE, 14f, Fonts.MEDIUM);
- button.draw(vg, x + (size == 1 ? 352 : 736), y);
+ button.draw(vg, x + (size == 1 ? 352 : 736), y, inputHandler);
RenderManager.setAlpha(vg, 1f);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
index 491eaf4..9cc60c9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
@@ -37,7 +37,7 @@ import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import cc.polyfrost.oneconfig.utils.color.ColorUtils;
@@ -58,7 +58,7 @@ public class ConfigCheckbox extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
boolean toggled = false;
try {
@@ -66,9 +66,9 @@ public class ConfigCheckbox extends BasicOption {
if (animation == null) animation = new DummyAnimation(toggled ? 1 : 0);
} catch (IllegalAccessException ignored) {
}
- boolean hover = InputUtils.isAreaHovered(x, y + 4, 24, 24);
+ boolean hover = inputHandler.isAreaHovered(x, y + 4, 24, 24);
- boolean clicked = InputUtils.isClicked() && hover;
+ boolean clicked = inputHandler.isClicked() && hover;
if (clicked && isEnabled()) {
toggled = !toggled;
animation = new EaseInOutQuad(100, 0, 1, !toggled);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
index 39b88a6..39780a1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
@@ -37,7 +37,7 @@ import cc.polyfrost.oneconfig.gui.elements.text.TextInputField;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.internal.assets.Images;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import java.lang.reflect.Field;
@@ -62,7 +62,7 @@ public class ConfigColorElement extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
if(OneConfigGui.INSTANCE == null) return;
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
hexField.disable(!isEnabled());
@@ -86,7 +86,7 @@ public class ConfigColorElement extends BasicOption {
hexField.setErrored(true);
}
}
- hexField.draw(vg, x1 + 224, y);
+ hexField.draw(vg, x1 + 224, y, inputHandler);
if (!alphaField.isToggled()) alphaField.setInput(Math.round(color.getAlpha() / 2.55f) + "%");
alphaField.setErrored(false);
@@ -106,15 +106,15 @@ public class ConfigColorElement extends BasicOption {
alphaField.setErrored(true);
}
}
- alphaField.draw(vg, x1 + 336, y);
+ alphaField.draw(vg, x1 + 336, y, inputHandler);
- element.update(x1 + 416, y);
+ element.update(x1 + 416, y, inputHandler);
RenderManager.drawHollowRoundRect(vg, x1 + 415, y - 1, 64, 32, Colors.GRAY_300, 12f, 2f);
RenderManager.drawRoundImage(vg, Images.ALPHA_GRID.filePath, x1 + 420, y + 4, 56, 24, 8f);
RenderManager.drawRoundedRect(vg, x1 + 420, y + 4, 56, 24, color.getRGB(), 8f);
if (element.isClicked() && !open) {
open = true;
- OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY(), allowAlpha));
+ OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, inputHandler.mouseX(), inputHandler.mouseY(), allowAlpha, inputHandler));
}
if (OneConfigGui.INSTANCE.currentColorSelector == null) open = false;
else if (open) color = (OneConfigGui.INSTANCE.getColor());
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
index 24e0a9b..2660266 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java
@@ -35,7 +35,7 @@ import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.renderer.scissor.Scissor;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.awt.*;
@@ -60,21 +60,21 @@ public class ConfigDropdown extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
RenderManager.drawText(vg, name, x, y + 16, Colors.WHITE_90, 14f, Fonts.MEDIUM);
boolean hovered;
- if (size == 1) hovered = InputUtils.isAreaHovered(x + 224, y, 256, 32) && isEnabled();
- else hovered = InputUtils.isAreaHovered(x + 352, y, 640, 32) && isEnabled();
+ if (size == 1) hovered = inputHandler.isAreaHovered(x + 224, y, 256, 32) && isEnabled();
+ else hovered = inputHandler.isAreaHovered(x + 352, y, 640, 32) && isEnabled();
- if (hovered && InputUtils.isClicked() || opened && InputUtils.isClicked(true) &&
- (size == 1 && !InputUtils.isAreaHovered(x + 224, y + 40, 256, options.length * 32, true) ||
- size == 2 && !InputUtils.isAreaHovered(x + 352, y + 40, 640, options.length * 32, true))) {
+ if (hovered && inputHandler.isClicked() || opened && inputHandler.isClicked(true) &&
+ (size == 1 && !inputHandler.isAreaHovered(x + 224, y + 40, 256, options.length * 32, true) ||
+ size == 2 && !inputHandler.isAreaHovered(x + 352, y + 40, 640, options.length * 32, true))) {
opened = !opened;
backgroundColor.setPalette(opened ? ColorPalette.PRIMARY : ColorPalette.SECONDARY);
- if (opened) inputScissor = InputUtils.blockAllInput();
- else if (inputScissor != null) InputUtils.stopBlock(inputScissor);
+ if (opened) inputScissor = inputHandler.blockAllInput();
+ else if (inputScissor != null) inputHandler.stopBlock(inputScissor);
}
if (opened) return;
@@ -100,12 +100,12 @@ public class ConfigDropdown extends BasicOption {
}
@Override
- public void drawLast(long vg, int x, int y) {
+ public void drawLast(long vg, int x, int y, InputHandler inputHandler) {
if (!opened) return;
boolean hovered;
- if (size == 1) hovered = InputUtils.isAreaHovered(x + 224, y, 256, 32, true);
- else hovered = InputUtils.isAreaHovered(x + 352, y, 640, 32, true);
+ if (size == 1) hovered = inputHandler.isAreaHovered(x + 224, y, 256, 32, true);
+ else hovered = inputHandler.isAreaHovered(x + 352, y, 640, 32, true);
int selected = 0;
try {
@@ -127,21 +127,21 @@ public class ConfigDropdown extends BasicOption {
int optionY = y + 44;
for (String option : options) {
int color = Colors.WHITE_80;
- boolean optionHovered = InputUtils.isAreaHovered(x + 224, optionY, 252, 32, true);
+ boolean optionHovered = inputHandler.isAreaHovered(x + 224, optionY, 252, 32, true);
if (optionHovered && Platform.getMousePlatform().isButtonDown(0)) {
RenderManager.drawRoundedRect(vg, x + 228, optionY + 2, 248, 28, Colors.PRIMARY_700_80, 8);
} else if (optionHovered) {
RenderManager.drawRoundedRect(vg, x + 228, optionY + 2, 248, 28, Colors.PRIMARY_700, 8);
color = Colors.WHITE;
}
- if (optionHovered && InputUtils.isClicked(true)) {
+ if (optionHovered && inputHandler.isClicked(true)) {
try {
set(Arrays.asList(options).indexOf(option));
} catch (IllegalAccessException ignored) {
}
opened = false;
backgroundColor.setPalette(ColorPalette.SECONDARY);
- if (inputScissor != null) InputUtils.stopBlock(inputScissor);
+ if (inputScissor != null) inputHandler.stopBlock(inputScissor);
}
RenderManager.drawText(vg, option, x + 240, optionY + 18, color, 14, Fonts.MEDIUM);
@@ -160,7 +160,7 @@ public class ConfigDropdown extends BasicOption {
int optionY = y + 44;
for (String option : options) {
int color = Colors.WHITE_80;
- boolean optionHovered = InputUtils.isAreaHovered(x + 352, optionY, 640, 36, true);
+ boolean optionHovered = inputHandler.isAreaHovered(x + 352, optionY, 640, 36, true);
if (optionHovered && Platform.getMousePlatform().isButtonDown(0)) {
RenderManager.drawRoundedRect(vg, x + 356, optionY + 2, 632, 28, Colors.PRIMARY_700_80, 8);
} else if (optionHovered) {
@@ -170,14 +170,14 @@ public class ConfigDropdown extends BasicOption {
RenderManager.drawText(vg, option, x + 368, optionY + 18, color, 14, Fonts.MEDIUM);
- if (optionHovered && InputUtils.isClicked(true)) {
+ if (optionHovered && inputHandler.isClicked(true)) {
try {
set(Arrays.asList(options).indexOf(option));
} catch (IllegalAccessException ignored) {
}
opened = false;
backgroundColor.setPalette(ColorPalette.SECONDARY);
- if (inputScissor != null) InputUtils.stopBlock(inputScissor);
+ if (inputScissor != null) inputHandler.stopBlock(inputScissor);
}
optionY += 32;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
index eaea946..c8582d1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java
@@ -34,7 +34,7 @@ import cc.polyfrost.oneconfig.gui.animations.DummyAnimation;
import cc.polyfrost.oneconfig.gui.animations.EaseInOutCubic;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import java.lang.reflect.Field;
@@ -59,7 +59,7 @@ public class ConfigDualOption extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
boolean toggled = false;
try {
toggled = (boolean) get();
@@ -67,8 +67,8 @@ public class ConfigDualOption extends BasicOption {
} catch (IllegalAccessException ignored) {
}
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
- boolean hoveredLeft = InputUtils.isAreaHovered(x + 226, y, 128, 32) && isEnabled();
- boolean hoveredRight = InputUtils.isAreaHovered(x + 354, y, 128, 32) && isEnabled();
+ boolean hoveredLeft = inputHandler.isAreaHovered(x + 226, y, 128, 32) && isEnabled();
+ boolean hoveredRight = inputHandler.isAreaHovered(x + 354, y, 128, 32) && isEnabled();
RenderManager.drawText(vg, name, x, y + 16, Colors.WHITE_90, 14f, Fonts.MEDIUM);
RenderManager.drawRoundedRect(vg, x + 226, y, 256, 32, Colors.GRAY_600, 12f);
RenderManager.drawRoundedRect(vg, x + posAnimation.get(), y + 2, 124, 28, Colors.PRIMARY_600, 10f);
@@ -79,7 +79,7 @@ public class ConfigDualOption extends BasicOption {
RenderManager.drawText(vg, right, x + 418 - RenderManager.getTextWidth(vg, right, 12f, Fonts.MEDIUM) / 2, y + 17, Colors.WHITE, 12f, Fonts.MEDIUM);
RenderManager.setAlpha(vg, 1);
- if ((hoveredLeft && toggled || hoveredRight && !toggled) && InputUtils.isClicked()) {
+ if ((hoveredLeft && toggled || hoveredRight && !toggled) && inputHandler.isClicked()) {
toggled = !toggled;
posAnimation = new EaseInOutCubic(175, 228, 356, !toggled);
try {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
index 5ac87dc..45865fe 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
@@ -33,6 +33,7 @@ import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.renderer.scissor.Scissor;
import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import java.lang.reflect.Field;
@@ -48,7 +49,7 @@ public class ConfigHeader extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 480 : 992, 32);
RenderManager.drawText(vg, name, x, y + 17, Colors.WHITE_90, 24, Fonts.MEDIUM);
ScissorManager.resetScissor(vg, scissor);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
index 2760cb6..c44c50d 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
@@ -34,6 +34,7 @@ import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.renderer.scissor.Scissor;
import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import java.lang.reflect.Field;
@@ -51,7 +52,7 @@ public class ConfigInfo extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 448 : 960, 32);
RenderManager.drawInfo(vg, type, x, y + 4, 24);
RenderManager.drawText(vg, name, x + 32, y + 18, Colors.WHITE_90, 14, Fonts.MEDIUM);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
index e14da52..daa034f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
@@ -36,6 +36,7 @@ import cc.polyfrost.oneconfig.internal.assets.SVGs;
import cc.polyfrost.oneconfig.libs.universal.UKeyboard;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.lang.reflect.Field;
@@ -56,7 +57,7 @@ public class ConfigKeyBind extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
RenderManager.drawText(vg, name, x, y + 17, Colors.WHITE, 14f, Fonts.MEDIUM);
OneKeyBind keyBind = getKeyBind();
@@ -77,7 +78,7 @@ public class ConfigKeyBind extends BasicOption {
}
} else if (text.equals("")) text = "None";
button.setText(text);
- button.draw(vg, x + (size == 1 ? 224 : 736), y);
+ button.draw(vg, x + (size == 1 ? 224 : 736), y, inputHandler);
RenderManager.setAlpha(vg, 1f);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
index 4dbcd14..de10600 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java
@@ -37,7 +37,7 @@ import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.lang.reflect.Field;
@@ -60,10 +60,10 @@ public class ConfigPageButton extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
int height = description.equals("") ? 64 : 96;
- boolean hovered = InputUtils.isAreaHovered(x - 16, y, 1024, height) && isEnabled();
- boolean clicked = hovered && InputUtils.isClicked();
+ boolean hovered = inputHandler.isAreaHovered(x - 16, y, 1024, height) && isEnabled();
+ boolean clicked = hovered && inputHandler.isClicked();
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
index 7e0f0a8..4e2dda5 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java
@@ -33,7 +33,7 @@ import cc.polyfrost.oneconfig.gui.elements.text.NumberInputField;
import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.MathUtils;
import java.lang.reflect.Field;
@@ -60,24 +60,24 @@ public class ConfigSlider extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
int xCoordinate = 0;
float value = 0;
- boolean hovered = InputUtils.isAreaHovered(x + 352, y, 512, 32) && isEnabled();
+ boolean hovered = inputHandler.isAreaHovered(x + 352, y, 512, 32) && isEnabled();
inputField.disable(!isEnabled());
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
boolean isMouseDown = Platform.getMousePlatform().isButtonDown(0);
if (hovered && isMouseDown && !mouseWasDown) dragging = true;
mouseWasDown = isMouseDown;
if (dragging) {
- xCoordinate = (int) MathUtils.clamp(InputUtils.mouseX(), x + 352, x + 864);
+ xCoordinate = (int) MathUtils.clamp(inputHandler.mouseX(), x + 352, x + 864);
if (step > 0) xCoordinate = getStepCoordinate(xCoordinate, x);
value = MathUtils.map(xCoordinate, x + 352, x + 864, min, max);
} else if (inputField.isToggled() || inputField.arrowsClicked()) {
value = inputField.getCurrentValue();
xCoordinate = (int) MathUtils.clamp(MathUtils.map(value, min, max, x + 352, x + 864), x + 352, x + 864);
}
- if (dragging && InputUtils.isClicked() || inputField.isToggled() || inputField.arrowsClicked()) {
+ if (dragging && inputHandler.isClicked() || inputField.isToggled() || inputField.arrowsClicked()) {
dragging = false;
if (step > 0) {
xCoordinate = getStepCoordinate(xCoordinate, x);
@@ -110,7 +110,7 @@ public class ConfigSlider extends BasicOption {
}
if (step == 0) RenderManager.drawRoundedRect(vg, xCoordinate - 12, y + 4, 24, 24, Colors.WHITE, 12f);
else RenderManager.drawRoundedRect(vg, xCoordinate - 4, y + 4, 8, 24, Colors.WHITE, 4f);
- inputField.draw(vg, x + 892, y);
+ inputField.draw(vg, x + 892, y, inputHandler);
RenderManager.setAlpha(vg, 1f);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
index c4a52e7..9d13e3e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java
@@ -36,7 +36,7 @@ import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad;
import cc.polyfrost.oneconfig.platform.Platform;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
import java.lang.reflect.Field;
@@ -55,7 +55,7 @@ public class ConfigSwitch extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
boolean toggled = false;
try {
toggled = (boolean) get();
@@ -67,13 +67,13 @@ public class ConfigSwitch extends BasicOption {
}
float percentOn = animation.get();
int x2 = x + 3 + (int) (percentOn * 18);
- boolean hovered = InputUtils.isAreaHovered(x, y, 42, 32);
+ boolean hovered = inputHandler.isAreaHovered(x, y, 42, 32);
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, color.getColor(hovered, hovered && Platform.getMousePlatform().isButtonDown(0)), 12f);
RenderManager.drawRoundedRect(vg, x2, y + 7, 18, 18, Colors.WHITE, 9f);
RenderManager.drawText(vg, name, x + 50, y + 17, Colors.WHITE, 14f, Fonts.MEDIUM);
- if (InputUtils.isAreaClicked(x, y, 42, 32) && isEnabled()) {
+ if (inputHandler.isAreaClicked(x, y, 42, 32) && isEnabled()) {
toggled = !toggled;
animation = new EaseInOutQuad(200, 0, 1, !toggled);
color.setPalette(toggled ? ColorPalette.PRIMARY : ColorPalette.SECONDARY);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
index 8bc1e20..adb9131 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java
@@ -35,7 +35,7 @@ import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.SVG;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
-import cc.polyfrost.oneconfig.utils.InputUtils;
+import cc.polyfrost.oneconfig.utils.InputHandler;
import java.lang.reflect.Field;
@@ -57,7 +57,7 @@ public class ConfigTextBox extends BasicOption {
}
@Override
- public void draw(long vg, int x, int y) {
+ public void draw(long vg, int x, int y, InputHandler inputHandler) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
textField.disable(!isEnabled());
RenderManager.drawText(vg, name, x, y + 16, Colors.WHITE_90, 14, Fonts.MEDIUM);
@@ -70,13 +70,13 @@ public class ConfigTextBox extends BasicOption {
if (multiLine && textField.getLines() > 2) textField.setHeight(64 + 24 * (textField.getLines() - 2));
else if (multiLine) textField.setHeight(64);
- textField.draw(vg, x + (size == 1 ? 224 : 352), y);
+ textField.draw(vg, x + (size == 1 ? 224 : 352), y, inputHandler);
if (secure) {
final SVG icon = textField.getPassword() ? SVGs.EYE_OFF : SVGs.EYE;
- boolean hovered = InputUtils.isAreaHovered(x + 967, y + 7, 18, 18) && isEnabled();
+ boolean hovered = inputHandler.isAreaHovered(x + 967, y + 7, 18, 18) && isEnabled();
int color = hovered ? Colors.WHITE : Colors.WHITE_80;
- if (hovered && InputUtils.isClicked()) textField.setPassword(!textField.getPassword());
+ if (hovered && inputHandler.isClicked()) textField.setPassword(!textField.getPassword());
if (hovered && Platform.getMousePlatform().isButtonDown(0)) RenderManager.setAlpha(vg, 0.5f);
RenderManager.drawSvg(vg, icon, x + 967, y + 7, 18, 18, color);
}