diff options
author | xander <xander@isxander.dev> | 2022-09-23 21:01:00 +0100 |
---|---|---|
committer | xander <xander@isxander.dev> | 2022-09-23 21:01:00 +0100 |
commit | dd29c979e6092325ee064d3b8cf33816e7e93aa4 (patch) | |
tree | 3498e8be1e33f255610acf879df423ab7aa14cfa /src/main/java/dev/isxander/yacl/gui/controllers/slider | |
parent | 1946569d914b479dad2ecdcdd5170d151433b8b5 (diff) | |
download | YetAnotherConfigLib-dd29c979e6092325ee064d3b8cf33816e7e93aa4.tar.gz YetAnotherConfigLib-dd29c979e6092325ee064d3b8cf33816e7e93aa4.tar.bz2 YetAnotherConfigLib-dd29c979e6092325ee064d3b8cf33816e7e93aa4.zip |
1.5.0
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/controllers/slider')
5 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/slider/DoubleSliderController.java b/src/main/java/dev/isxander/yacl/gui/controllers/slider/DoubleSliderController.java index ed78abd..b530e8c 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/slider/DoubleSliderController.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/slider/DoubleSliderController.java @@ -46,6 +46,7 @@ public class DoubleSliderController implements ISliderController<Double> { public DoubleSliderController(Option<Double> option, double min, double max, double interval, Function<Double, Text> valueFormatter) { Validate.isTrue(max > min, "`max` cannot be smaller than `min`"); Validate.isTrue(interval > 0, "`interval` must be more than 0"); + Validate.notNull(valueFormatter, "`valueFormatter` must not be null"); this.option = option; this.min = min; diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/slider/FloatSliderController.java b/src/main/java/dev/isxander/yacl/gui/controllers/slider/FloatSliderController.java index 4297271..d7c203e 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/slider/FloatSliderController.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/slider/FloatSliderController.java @@ -46,6 +46,7 @@ public class FloatSliderController implements ISliderController<Float> { public FloatSliderController(Option<Float> option, float min, float max, float interval, Function<Float, Text> valueFormatter) { Validate.isTrue(max > min, "`max` cannot be smaller than `min`"); Validate.isTrue(interval > 0, "`interval` must be more than 0"); + Validate.notNull(valueFormatter, "`valueFormatter` must not be null"); this.option = option; this.min = min; diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/slider/IntegerSliderController.java b/src/main/java/dev/isxander/yacl/gui/controllers/slider/IntegerSliderController.java index 38efed5..a8bca7c 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/slider/IntegerSliderController.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/slider/IntegerSliderController.java @@ -43,6 +43,7 @@ public class IntegerSliderController implements ISliderController<Integer> { public IntegerSliderController(Option<Integer> option, int min, int max, int interval, Function<Integer, Text> valueFormatter) { Validate.isTrue(max > min, "`max` cannot be smaller than `min`"); Validate.isTrue(interval > 0, "`interval` must be more than 0"); + Validate.notNull(valueFormatter, "`valueFormatter` must not be null"); this.option = option; this.min = min; diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/slider/LongSliderController.java b/src/main/java/dev/isxander/yacl/gui/controllers/slider/LongSliderController.java index 67b6a0e..50559d5 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/slider/LongSliderController.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/slider/LongSliderController.java @@ -43,6 +43,7 @@ public class LongSliderController implements ISliderController<Long> { public LongSliderController(Option<Long> option, long min, long max, long interval, Function<Long, Text> valueFormatter) { Validate.isTrue(max > min, "`max` cannot be smaller than `min`"); Validate.isTrue(interval > 0, "`interval` must be more than 0"); + Validate.notNull(valueFormatter, "`valueFormatter` must not be null"); this.option = option; this.min = min; diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java b/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java index 4a0061b..913cc00 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java @@ -135,7 +135,7 @@ public class SliderControllerElement extends ControllerWidget<ISliderController< } protected void calculateInterpolation() { - interpolation = (float) ((control.pendingValue() - control.min()) * 1 / control.range()); + interpolation = MathHelper.clamp((float) ((control.pendingValue() - control.min()) * 1 / control.range()), 0f, 1f); } @Override |