aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-07 10:28:28 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-07 10:28:28 +0200
commit95a2caffdddadb487c164a7cc498f54ed4a27955 (patch)
treefade10daea20a9be557fc9ee23ec7229d3fbad7b /src/main/java/cc/polyfrost/oneconfig
parent1e58db410a03088ab793b24fa999311c792f2337 (diff)
downloadOneConfig-95a2caffdddadb487c164a7cc498f54ed4a27955.tar.gz
OneConfig-95a2caffdddadb487c164a7cc498f54ed4a27955.tar.bz2
OneConfig-95a2caffdddadb487c164a7cc498f54ed4a27955.zip
fix slider arrows
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java4
2 files changed, 7 insertions, 3 deletions
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 00dbd9f..adbfb8d 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
@@ -23,7 +23,7 @@ public class ConfigSlider extends BasicOption {
this.min = min;
this.max = max;
this.step = step;
- inputField = new NumberInputField(84, 24, 0, min, max, step);
+ inputField = new NumberInputField(84, 24, 0, min, max, step == 0 ? 1 : step);
}
@Override
@@ -35,11 +35,11 @@ public class ConfigSlider extends BasicOption {
if (dragging) {
xCoordinate = (int) MathUtils.clamp(InputUtils.mouseX(), x + 352, x + 864);
value = MathUtils.map(xCoordinate, x + 352, x + 864, min, max);
- } else if (inputField.isToggled()) {
+ } else if (inputField.isToggled() || inputField.arrowsClicked()) {
value = inputField.getCurrentValue();
xCoordinate = (int) MathUtils.map(value, min, max, x + 352, x + 864);
}
- if (dragging && InputUtils.isClicked() || inputField.isToggled()) {
+ if (dragging && InputUtils.isClicked() || inputField.isToggled() || inputField.arrowsClicked()) {
dragging = false;
if (step > 0) {
xCoordinate = getStepCoordinate(xCoordinate, x);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java
index 1eefe74..5475a55 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java
@@ -117,4 +117,8 @@ public class NumberInputField extends TextInputField {
public void setMin(float min) {
this.min = min;
}
+
+ public boolean arrowsClicked() {
+ return upArrow.isClicked() || downArrow.isClicked();
+ }
}