diff options
Diffstat (limited to 'src/client/java/dev/isxander/yacl/impl')
-rw-r--r-- | src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java | 113 | ||||
-rw-r--r-- | src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java | 2 |
2 files changed, 114 insertions, 1 deletions
diff --git a/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java new file mode 100644 index 0000000..314c2ad --- /dev/null +++ b/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java @@ -0,0 +1,113 @@ +package dev.isxander.yacl.impl; + +import com.google.common.collect.ImmutableSet; +import dev.isxander.yacl.api.*; +import dev.isxander.yacl.gui.controllers.LabelController; +import net.minecraft.text.Text; +import org.jetbrains.annotations.NotNull; + +import java.util.function.BiConsumer; + +public class LabelOptionImpl implements LabelOption { + private final Text label; + private final Text name = Text.literal("Label Option"); + private final Text tooltip = Text.empty(); + private final LabelController labelController; + private final Binding<Text> binding; + + public LabelOptionImpl(Text label) { + this.label = label; + this.labelController = new LabelController(this); + this.binding = Binding.immutable(label); + } + + @Override + public Text label() { + return label; + } + + @Override + public @NotNull Text name() { + return name; + } + + @Override + public @NotNull Text tooltip() { + return tooltip; + } + + @Override + public @NotNull Controller<Text> controller() { + return labelController; + } + + @Override + public @NotNull Binding<Text> binding() { + return binding; + } + + @Override + public boolean available() { + return true; + } + + @Override + public void setAvailable(boolean available) { + throw new UnsupportedOperationException("Label options cannot be disabled."); + } + + @Override + public @NotNull Class<Text> typeClass() { + return Text.class; + } + + @Override + public @NotNull ImmutableSet<OptionFlag> flags() { + return ImmutableSet.of(); + } + + @Override + public boolean changed() { + return false; + } + + @Override + public @NotNull Text pendingValue() { + return label; + } + + @Override + public void requestSet(Text value) { + + } + + @Override + public boolean applyValue() { + return false; + } + + @Override + public void forgetPendingValue() { + + } + + @Override + public void requestSetDefault() { + + } + + @Override + public boolean isPendingValueDefault() { + return true; + } + + @Override + public boolean canResetToDefault() { + return false; + } + + @Override + public void addListener(BiConsumer<Option<Text>, Text> changedListener) { + + } +} diff --git a/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java index 1924205..fb74601 100644 --- a/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java +++ b/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java @@ -93,7 +93,7 @@ public final class ListOptionImpl<T> implements ListOption<T> { } @Override - public ImmutableList<T> pendingValue() { + public @NotNull ImmutableList<T> pendingValue() { return ImmutableList.copyOf(entries.stream().map(Option::pendingValue).toList()); } |