diff options
author | isXander <xandersmith2008@gmail.com> | 2022-11-13 19:04:45 +0000 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2022-11-13 19:04:55 +0000 |
commit | 6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6 (patch) | |
tree | 3245fcd0782ff44c9f7c62f26844ab4c7510bbeb /src/main/java/dev/isxander/yacl/impl | |
parent | b9052c99778b5ad6e54e720f6f10756e8ef8cdc0 (diff) | |
download | YetAnotherConfigLib-6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6.tar.gz YetAnotherConfigLib-6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6.tar.bz2 YetAnotherConfigLib-6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6.zip |
lots of QOL and minor improvements
smooth category scrolling
individual reset buttons for all controllers
separate Dimension into Dimension and MutableDimension to prevent mods from modifying controller dimensions without invoking the hooks
made the dimension field private in AbstractWidget so people can't modify it without the method setDimension
new Option API method to check if pending value is equal to default value
add documentation to ConfigInstance
fix bug where Option#requestSetDefault and Option#forgetPendingValue implementations weren't notifying listeners
Diffstat (limited to 'src/main/java/dev/isxander/yacl/impl')
3 files changed, 23 insertions, 12 deletions
diff --git a/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java b/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java index 7d856b0..dcb9c7a 100644 --- a/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java +++ b/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java @@ -114,6 +114,11 @@ public class ButtonOptionImpl implements ButtonOption { } @Override + public boolean isPendingValueDefault() { + throw new UnsupportedOperationException(); + } + + @Override public void addListener(BiConsumer<Option<BiConsumer<YACLScreen, ButtonOption>>, BiConsumer<YACLScreen, ButtonOption>> changedListener) { } diff --git a/src/main/java/dev/isxander/yacl/impl/OptionImpl.java b/src/main/java/dev/isxander/yacl/impl/OptionImpl.java index 98a2f48..c76f115 100644 --- a/src/main/java/dev/isxander/yacl/impl/OptionImpl.java +++ b/src/main/java/dev/isxander/yacl/impl/OptionImpl.java @@ -125,12 +125,17 @@ public class OptionImpl<T> implements Option<T> { @Override public void forgetPendingValue() { - pendingValue = binding().getValue(); + requestSet(binding().getValue()); } @Override public void requestSetDefault() { - pendingValue = binding().defaultValue(); + requestSet(binding().defaultValue()); + } + + @Override + public boolean isPendingValueDefault() { + return binding().defaultValue().equals(pendingValue()); } @Override diff --git a/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java b/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java index 76a5868..6c7508d 100644 --- a/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java +++ b/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java @@ -1,8 +1,9 @@ package dev.isxander.yacl.impl.utils; import dev.isxander.yacl.api.utils.Dimension; +import dev.isxander.yacl.api.utils.MutableDimension; -public class DimensionIntegerImpl implements Dimension<Integer> { +public class DimensionIntegerImpl implements MutableDimension<Integer> { private int x, y; private int width, height; @@ -59,14 +60,14 @@ public class DimensionIntegerImpl implements Dimension<Integer> { } @Override - public Dimension<Integer> clone() { + public MutableDimension<Integer> clone() { return new DimensionIntegerImpl(x, y, width, height); } - @Override public Dimension<Integer> setX(Integer x) { this.x = x; return this; } - @Override public Dimension<Integer> setY(Integer y) { this.y = y; return this; } - @Override public Dimension<Integer> setWidth(Integer width) { this.width = width; return this; } - @Override public Dimension<Integer> setHeight(Integer height) { this.height = height; return this; } + @Override public MutableDimension<Integer> setX(Integer x) { this.x = x; return this; } + @Override public MutableDimension<Integer> setY(Integer y) { this.y = y; return this; } + @Override public MutableDimension<Integer> setWidth(Integer width) { this.width = width; return this; } + @Override public MutableDimension<Integer> setHeight(Integer height) { this.height = height; return this; } @Override public Dimension<Integer> withX(Integer x) { @@ -80,23 +81,23 @@ public class DimensionIntegerImpl implements Dimension<Integer> { @Override public Dimension<Integer> withWidth(Integer width) { - return clone().withWidth(width); + return clone().setWidth(width); } @Override public Dimension<Integer> withHeight(Integer height) { - return clone().withHeight(height); + return clone().setHeight(height); } @Override - public Dimension<Integer> move(Integer x, Integer y) { + public MutableDimension<Integer> move(Integer x, Integer y) { this.x += x; this.y += y; return this; } @Override - public Dimension<Integer> expand(Integer width, Integer height) { + public MutableDimension<Integer> expand(Integer width, Integer height) { this.width += width; this.height += height; return this; |