package dev.isxander.yacl.impl; import dev.isxander.yacl.api.Binding; import dev.isxander.yacl.api.ButtonOption; import dev.isxander.yacl.api.Controller; import dev.isxander.yacl.gui.YACLScreen; import net.minecraft.text.Text; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; import java.util.function.Function; @ApiStatus.Internal public class ButtonOptionImpl implements ButtonOption { private final Text name; private final Text tooltip; private final Consumer action; private final Controller> controller; private final Binding> binding; public ButtonOptionImpl( @NotNull Text name, @Nullable Text tooltip, @NotNull Consumer action, @NotNull Function>> controlGetter ) { this.name = name; this.tooltip = tooltip; this.action = action; this.controller = controlGetter.apply(this); this.binding = new EmptyBinderImpl(); } @Override public @NotNull Text name() { return name; } @Override public @NotNull Text tooltip() { return tooltip; } @Override public Consumer action() { return action; } @Override public @NotNull Controller> controller() { return controller; } @Override public @NotNull Binding> binding() { return binding; } @Override public @NotNull Class> typeClass() { throw new UnsupportedOperationException(); } @Override public boolean changed() { return false; } @Override public @NotNull Consumer pendingValue() { throw new UnsupportedOperationException(); } @Override public void requestSet(Consumer value) { throw new UnsupportedOperationException(); } @Override public void applyValue() { } @Override public void forgetPendingValue() { } @Override public void requestSetDefault() { } private static class EmptyBinderImpl implements Binding> { @Override public void setValue(Consumer value) { } @Override public Consumer getValue() { throw new UnsupportedOperationException(); } @Override public Consumer defaultValue() { throw new UnsupportedOperationException(); } } }