aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl/impl
diff options
context:
space:
mode:
authorisXander <isxander@users.noreply.github.com>2022-09-19 19:11:13 +0100
committerisXander <isxander@users.noreply.github.com>2022-09-19 19:11:13 +0100
commitde1c8a317226b58fe03497027136eaed1adfd808 (patch)
tree5f97d6d91bc37f83d8de8c6f4a335d06a014cee0 /src/main/java/dev/isxander/yacl/impl
parent904e4d61b6cf84c807a99e66fc70527b01ae6fcc (diff)
downloadYetAnotherConfigLib-de1c8a317226b58fe03497027136eaed1adfd808.tar.gz
YetAnotherConfigLib-de1c8a317226b58fe03497027136eaed1adfd808.tar.bz2
YetAnotherConfigLib-de1c8a317226b58fe03497027136eaed1adfd808.zip
1.4.0
improved tooltips `ButtonOption` now consumes itself, so you can access it when building.
Diffstat (limited to 'src/main/java/dev/isxander/yacl/impl')
-rw-r--r--src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java39
-rw-r--r--src/main/java/dev/isxander/yacl/impl/OptionImpl.java7
-rw-r--r--src/main/java/dev/isxander/yacl/impl/YACLConstants.java23
3 files changed, 28 insertions, 41 deletions
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<YACLScreen> action;
- private final boolean available;
- private final Controller<Consumer<YACLScreen>> controller;
- private final Binding<Consumer<YACLScreen>> binding;
+ private final BiConsumer<YACLScreen, ButtonOption> action;
+ private boolean available;
+ private final Controller<BiConsumer<YACLScreen, ButtonOption>> controller;
+ private final Binding<BiConsumer<YACLScreen, ButtonOption>> binding;
public ButtonOptionImpl(
@NotNull Text name,
@Nullable Text tooltip,
- @NotNull Consumer<YACLScreen> action,
+ @NotNull BiConsumer<YACLScreen, ButtonOption> action,
boolean available,
- @NotNull Function<ButtonOption, Controller<Consumer<YACLScreen>>> controlGetter
+ @NotNull Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> controlGetter
) {
this.name = name;
this.tooltip = tooltip;
@@ -47,7 +47,7 @@ public class ButtonOptionImpl implements ButtonOption {
}
@Override
- public Consumer<YACLScreen> action() {
+ public BiConsumer<YACLScreen, ButtonOption> action() {
return action;
}
@@ -57,17 +57,22 @@ public class ButtonOptionImpl implements ButtonOption {
}
@Override
- public @NotNull Controller<Consumer<YACLScreen>> controller() {
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ @Override
+ public @NotNull Controller<BiConsumer<YACLScreen, ButtonOption>> controller() {
return controller;
}
@Override
- public @NotNull Binding<Consumer<YACLScreen>> binding() {
+ public @NotNull Binding<BiConsumer<YACLScreen, ButtonOption>> binding() {
return binding;
}
@Override
- public @NotNull Class<Consumer<YACLScreen>> typeClass() {
+ public @NotNull Class<BiConsumer<YACLScreen, ButtonOption>> typeClass() {
throw new UnsupportedOperationException();
}
@@ -87,12 +92,12 @@ public class ButtonOptionImpl implements ButtonOption {
}
@Override
- public @NotNull Consumer<YACLScreen> pendingValue() {
+ public @NotNull BiConsumer<YACLScreen, ButtonOption> pendingValue() {
throw new UnsupportedOperationException();
}
@Override
- public void requestSet(Consumer<YACLScreen> value) {
+ public void requestSet(BiConsumer<YACLScreen, ButtonOption> value) {
throw new UnsupportedOperationException();
}
@@ -112,23 +117,23 @@ public class ButtonOptionImpl implements ButtonOption {
}
@Override
- public void addListener(BiConsumer<Option<Consumer<YACLScreen>>, Consumer<YACLScreen>> changedListener) {
+ public void addListener(BiConsumer<Option<BiConsumer<YACLScreen, ButtonOption>>, BiConsumer<YACLScreen, ButtonOption>> changedListener) {
}
- private static class EmptyBinderImpl implements Binding<Consumer<YACLScreen>> {
+ private static class EmptyBinderImpl implements Binding<BiConsumer<YACLScreen, ButtonOption>> {
@Override
- public void setValue(Consumer<YACLScreen> value) {
+ public void setValue(BiConsumer<YACLScreen, ButtonOption> value) {
}
@Override
- public Consumer<YACLScreen> getValue() {
+ public BiConsumer<YACLScreen, ButtonOption> getValue() {
throw new UnsupportedOperationException();
}
@Override
- public Consumer<YACLScreen> defaultValue() {
+ public BiConsumer<YACLScreen, ButtonOption> 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<T> implements Option<T> {
private final Function<T, Text> tooltipGetter;
private final Controller<T> controller;
private final Binding<T> binding;
- private final boolean available;
+ private boolean available;
private final ImmutableSet<OptionFlag> flags;
@@ -80,6 +80,11 @@ public class OptionImpl<T> implements Option<T> {
}
@Override
+ public void setAvailable(boolean available) {
+ this.available = available;
+ }
+
+ @Override
public @NotNull Class<T> 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;
-}