From 7f88ddf36ba7804211e8aae6b3723bd8f37c82c5 Mon Sep 17 00:00:00 2001 From: xander Date: Fri, 2 Sep 2022 22:04:35 +0100 Subject: implement keyboard-operation for all controllers fix crash when focusing on option list with tab add tooltip to groups check that pending values actually applied on save, if not, error in log and the save button displays an error when trying to escape with unsaved changes, save button text goes green and bold YACLConstants file to change certain behaviours, could evolve into its own settings! update icon --- .../dev/isxander/yacl/impl/OptionGroupImpl.java | 4 ++-- .../java/dev/isxander/yacl/impl/OptionImpl.java | 4 +++- .../java/dev/isxander/yacl/impl/YACLConstants.java | 23 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create 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/OptionGroupImpl.java b/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java index 73bff07..1f2d4e2 100644 --- a/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java +++ b/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java @@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList; import dev.isxander.yacl.api.Option; import dev.isxander.yacl.api.OptionGroup; import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; -public record OptionGroupImpl(@Nullable Text name, ImmutableList> options, boolean isRoot) implements OptionGroup { +public record OptionGroupImpl(@NotNull Text name, @NotNull Text tooltip, ImmutableList> options, boolean isRoot) implements OptionGroup { } diff --git a/src/main/java/dev/isxander/yacl/impl/OptionImpl.java b/src/main/java/dev/isxander/yacl/impl/OptionImpl.java index c61eaa1..176bf93 100644 --- a/src/main/java/dev/isxander/yacl/impl/OptionImpl.java +++ b/src/main/java/dev/isxander/yacl/impl/OptionImpl.java @@ -69,7 +69,9 @@ public class OptionImpl implements Option { @Override public void applyValue() { - binding().setValue(pendingValue); + if (changed()) { + binding().setValue(pendingValue); + } } @Override diff --git a/src/main/java/dev/isxander/yacl/impl/YACLConstants.java b/src/main/java/dev/isxander/yacl/impl/YACLConstants.java new file mode 100644 index 0000000..28d6a65 --- /dev/null +++ b/src/main/java/dev/isxander/yacl/impl/YACLConstants.java @@ -0,0 +1,23 @@ +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