From de1c8a317226b58fe03497027136eaed1adfd808 Mon Sep 17 00:00:00 2001 From: isXander Date: Mon, 19 Sep 2022 19:11:13 +0100 Subject: 1.4.0 improved tooltips `ButtonOption` now consumes itself, so you can access it when building. --- .../dev/isxander/yacl/impl/ButtonOptionImpl.java | 39 ++++++++++++---------- .../java/dev/isxander/yacl/impl/OptionImpl.java | 7 +++- .../java/dev/isxander/yacl/impl/YACLConstants.java | 23 ------------- 3 files changed, 28 insertions(+), 41 deletions(-) delete mode 100644 src/main/java/dev/isxander/yacl/impl/YACLConstants.java (limited to 'src/main/java/dev/isxander/yacl/impl') diff --git a/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java b/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java index 51c94b0..f6c8b6d 100644 --- a/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java +++ b/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java @@ -16,17 +16,17 @@ import java.util.function.Function; public class ButtonOptionImpl implements ButtonOption { private final Text name; private final Text tooltip; - private final Consumer action; - private final boolean available; - private final Controller> controller; - private final Binding> binding; + private final BiConsumer action; + private boolean available; + private final Controller> controller; + private final Binding> binding; public ButtonOptionImpl( @NotNull Text name, @Nullable Text tooltip, - @NotNull Consumer action, + @NotNull BiConsumer action, boolean available, - @NotNull Function>> controlGetter + @NotNull Function>> controlGetter ) { this.name = name; this.tooltip = tooltip; @@ -47,7 +47,7 @@ public class ButtonOptionImpl implements ButtonOption { } @Override - public Consumer action() { + public BiConsumer action() { return action; } @@ -57,17 +57,22 @@ public class ButtonOptionImpl implements ButtonOption { } @Override - public @NotNull Controller> controller() { + public void setAvailable(boolean available) { + this.available = available; + } + + @Override + public @NotNull Controller> controller() { return controller; } @Override - public @NotNull Binding> binding() { + public @NotNull Binding> binding() { return binding; } @Override - public @NotNull Class> typeClass() { + public @NotNull Class> typeClass() { throw new UnsupportedOperationException(); } @@ -87,12 +92,12 @@ public class ButtonOptionImpl implements ButtonOption { } @Override - public @NotNull Consumer pendingValue() { + public @NotNull BiConsumer pendingValue() { throw new UnsupportedOperationException(); } @Override - public void requestSet(Consumer value) { + public void requestSet(BiConsumer value) { throw new UnsupportedOperationException(); } @@ -112,23 +117,23 @@ public class ButtonOptionImpl implements ButtonOption { } @Override - public void addListener(BiConsumer>, Consumer> changedListener) { + public void addListener(BiConsumer>, BiConsumer> changedListener) { } - private static class EmptyBinderImpl implements Binding> { + private static class EmptyBinderImpl implements Binding> { @Override - public void setValue(Consumer value) { + public void setValue(BiConsumer value) { } @Override - public Consumer getValue() { + public BiConsumer getValue() { throw new UnsupportedOperationException(); } @Override - public Consumer defaultValue() { + public BiConsumer defaultValue() { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/dev/isxander/yacl/impl/OptionImpl.java b/src/main/java/dev/isxander/yacl/impl/OptionImpl.java index 1cf2a79..36cb217 100644 --- a/src/main/java/dev/isxander/yacl/impl/OptionImpl.java +++ b/src/main/java/dev/isxander/yacl/impl/OptionImpl.java @@ -22,7 +22,7 @@ public class OptionImpl implements Option { private final Function tooltipGetter; private final Controller controller; private final Binding binding; - private final boolean available; + private boolean available; private final ImmutableSet flags; @@ -79,6 +79,11 @@ public class OptionImpl implements Option { return available; } + @Override + public void setAvailable(boolean available) { + this.available = available; + } + @Override public @NotNull Class typeClass() { return typeClass; diff --git a/src/main/java/dev/isxander/yacl/impl/YACLConstants.java b/src/main/java/dev/isxander/yacl/impl/YACLConstants.java deleted file mode 100644 index 28d6a65..0000000 --- a/src/main/java/dev/isxander/yacl/impl/YACLConstants.java +++ /dev/null @@ -1,23 +0,0 @@ -package dev.isxander.yacl.impl; - -import org.jetbrains.annotations.ApiStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class YACLConstants { - /** - * Logger used by YACL - */ - @ApiStatus.Internal - public static final Logger LOGGER = LoggerFactory.getLogger("YetAnotherConfigLib"); - - /** - * Amount of ticks to hover before showing tooltips. - */ - public static final int HOVER_TICKS = 20; - - /** - * Reset hover ticks back to 0 when the mouse is moved. - */ - public static final boolean HOVER_MOUSE_RESET = true; -} -- cgit