aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl/impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/isxander/yacl/impl')
-rw-r--r--src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java142
-rw-r--r--src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java10
-rw-r--r--src/main/java/dev/isxander/yacl/impl/GenericBindingImpl.java35
-rw-r--r--src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java10
-rw-r--r--src/main/java/dev/isxander/yacl/impl/OptionImpl.java145
-rw-r--r--src/main/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java19
-rw-r--r--src/main/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java19
-rw-r--r--src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java115
-rw-r--r--src/main/java/dev/isxander/yacl/impl/utils/YACLConstants.java8
9 files changed, 0 insertions, 503 deletions
diff --git a/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java b/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java
deleted file mode 100644
index dcb9c7a..0000000
--- a/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package dev.isxander.yacl.impl;
-
-import com.google.common.collect.ImmutableSet;
-import dev.isxander.yacl.api.*;
-import dev.isxander.yacl.gui.YACLScreen;
-import net.minecraft.text.Text;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
-public class ButtonOptionImpl implements ButtonOption {
- private final Text name;
- private final Text tooltip;
- 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 BiConsumer<YACLScreen, ButtonOption> action,
- boolean available,
- @NotNull Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> controlGetter
- ) {
- this.name = name;
- this.tooltip = tooltip;
- this.action = action;
- this.available = available;
- 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 BiConsumer<YACLScreen, ButtonOption> action() {
- return action;
- }
-
- @Override
- public boolean available() {
- return available;
- }
-
- @Override
- public void setAvailable(boolean available) {
- this.available = available;
- }
-
- @Override
- public @NotNull Controller<BiConsumer<YACLScreen, ButtonOption>> controller() {
- return controller;
- }
-
- @Override
- public @NotNull Binding<BiConsumer<YACLScreen, ButtonOption>> binding() {
- return binding;
- }
-
- @Override
- public @NotNull Class<BiConsumer<YACLScreen, ButtonOption>> typeClass() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public @NotNull ImmutableSet<OptionFlag> flags() {
- return ImmutableSet.of();
- }
-
- @Override
- public boolean requiresRestart() {
- return false;
- }
-
- @Override
- public boolean changed() {
- return false;
- }
-
- @Override
- public @NotNull BiConsumer<YACLScreen, ButtonOption> pendingValue() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void requestSet(BiConsumer<YACLScreen, ButtonOption> value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean applyValue() {
- return false;
- }
-
- @Override
- public void forgetPendingValue() {
-
- }
-
- @Override
- public void requestSetDefault() {
-
- }
-
- @Override
- public boolean isPendingValueDefault() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addListener(BiConsumer<Option<BiConsumer<YACLScreen, ButtonOption>>, BiConsumer<YACLScreen, ButtonOption>> changedListener) {
-
- }
-
- private static class EmptyBinderImpl implements Binding<BiConsumer<YACLScreen, ButtonOption>> {
- @Override
- public void setValue(BiConsumer<YACLScreen, ButtonOption> value) {
-
- }
-
- @Override
- public BiConsumer<YACLScreen, ButtonOption> getValue() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public BiConsumer<YACLScreen, ButtonOption> defaultValue() {
- throw new UnsupportedOperationException();
- }
- }
-}
diff --git a/src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java b/src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
deleted file mode 100644
index 971fecf..0000000
--- a/src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package dev.isxander.yacl.impl;
-
-import com.google.common.collect.ImmutableList;
-import dev.isxander.yacl.api.ConfigCategory;
-import dev.isxander.yacl.api.OptionGroup;
-import net.minecraft.text.Text;
-
-public record ConfigCategoryImpl(Text name, ImmutableList<OptionGroup> groups, Text tooltip) implements ConfigCategory {
-
-}
diff --git a/src/main/java/dev/isxander/yacl/impl/GenericBindingImpl.java b/src/main/java/dev/isxander/yacl/impl/GenericBindingImpl.java
deleted file mode 100644
index 1867bb6..0000000
--- a/src/main/java/dev/isxander/yacl/impl/GenericBindingImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package dev.isxander.yacl.impl;
-
-import dev.isxander.yacl.api.Binding;
-
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
-public class GenericBindingImpl<T> implements Binding<T> {
- private final T def;
- private final Supplier<T> getter;
- private final Consumer<T> setter;
-
- public GenericBindingImpl(T def, Supplier<T> getter, Consumer<T> setting) {
- this.def = def;
- this.getter = getter;
- this.setter = setting;
- }
-
-
- @Override
- public void setValue(T value) {
- setter.accept(value);
- }
-
- @Override
- public T getValue() {
- return getter.get();
- }
-
- @Override
- public T defaultValue() {
- return def;
- }
-
-}
diff --git a/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java b/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java
deleted file mode 100644
index 58bc96b..0000000
--- a/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package dev.isxander.yacl.impl;
-
-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.NotNull;
-
-public record OptionGroupImpl(@NotNull Text name, @NotNull Text tooltip, ImmutableList<Option<?>> options, boolean collapsed, 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
deleted file mode 100644
index c76f115..0000000
--- a/src/main/java/dev/isxander/yacl/impl/OptionImpl.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package dev.isxander.yacl.impl;
-
-import com.google.common.collect.ImmutableSet;
-import dev.isxander.yacl.api.Binding;
-import dev.isxander.yacl.api.Controller;
-import dev.isxander.yacl.api.Option;
-import dev.isxander.yacl.api.OptionFlag;
-import net.minecraft.text.Text;
-import org.jetbrains.annotations.ApiStatus;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
-public class OptionImpl<T> implements Option<T> {
- private final Text name;
- private Text tooltip;
- private final Controller<T> controller;
- private final Binding<T> binding;
- private boolean available;
-
- private final ImmutableSet<OptionFlag> flags;
-
- private final Class<T> typeClass;
-
- private T pendingValue;
-
- private final List<BiConsumer<Option<T>, T>> listeners;
-
- public OptionImpl(
- @NotNull Text name,
- @Nullable Function<T, Text> tooltipGetter,
- @NotNull Function<Option<T>, Controller<T>> controlGetter,
- @NotNull Binding<T> binding,
- boolean available,
- ImmutableSet<OptionFlag> flags,
- @NotNull Class<T> typeClass,
- @NotNull Collection<BiConsumer<Option<T>, T>> listeners
- ) {
- this.name = name;
- this.binding = binding;
- this.available = available;
- this.flags = flags;
- this.typeClass = typeClass;
- this.listeners = new ArrayList<>(listeners);
- this.controller = controlGetter.apply(this);
-
- addListener((opt, pending) -> tooltip = tooltipGetter.apply(pending));
- requestSet(binding().getValue());
- }
-
- @Override
- public @NotNull Text name() {
- return name;
- }
-
- @Override
- public @NotNull Text tooltip() {
- return tooltip;
- }
-
- @Override
- public @NotNull Controller<T> controller() {
- return controller;
- }
-
- @Override
- public @NotNull Binding<T> binding() {
- return binding;
- }
-
- @Override
- public boolean available() {
- return available;
- }
-
- @Override
- public void setAvailable(boolean available) {
- this.available = available;
- }
-
- @Override
- public @NotNull Class<T> typeClass() {
- return typeClass;
- }
-
- @Override
- public @NotNull ImmutableSet<OptionFlag> flags() {
- return flags;
- }
-
- @Override
- public boolean requiresRestart() {
- return flags.contains(OptionFlag.GAME_RESTART);
- }
-
- @Override
- public boolean changed() {
- return !binding().getValue().equals(pendingValue);
- }
-
- @Override
- public @NotNull T pendingValue() {
- return pendingValue;
- }
-
- @Override
- public void requestSet(T value) {
- pendingValue = value;
- listeners.forEach(listener -> listener.accept(this, pendingValue));
- }
-
- @Override
- public boolean applyValue() {
- if (changed()) {
- binding().setValue(pendingValue);
- return true;
- }
- return false;
- }
-
- @Override
- public void forgetPendingValue() {
- requestSet(binding().getValue());
- }
-
- @Override
- public void requestSetDefault() {
- requestSet(binding().defaultValue());
- }
-
- @Override
- public boolean isPendingValueDefault() {
- return binding().defaultValue().equals(pendingValue());
- }
-
- @Override
- public void addListener(BiConsumer<Option<T>, T> changedListener) {
- this.listeners.add(changedListener);
- }
-}
diff --git a/src/main/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java b/src/main/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java
deleted file mode 100644
index a5180ad..0000000
--- a/src/main/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package dev.isxander.yacl.impl;
-
-import com.google.common.collect.ImmutableList;
-import dev.isxander.yacl.api.OptionGroup;
-import dev.isxander.yacl.api.PlaceholderCategory;
-import dev.isxander.yacl.gui.YACLScreen;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.Text;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.BiFunction;
-
-public record PlaceholderCategoryImpl(Text name, BiFunction<MinecraftClient, YACLScreen, Screen> screen, Text tooltip) implements PlaceholderCategory {
- @Override
- public @NotNull ImmutableList<OptionGroup> groups() {
- return ImmutableList.of();
- }
-}
diff --git a/src/main/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java b/src/main/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java
deleted file mode 100644
index eb23eac..0000000
--- a/src/main/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package dev.isxander.yacl.impl;
-
-import com.google.common.collect.ImmutableList;
-import dev.isxander.yacl.api.ConfigCategory;
-import dev.isxander.yacl.api.YetAnotherConfigLib;
-import dev.isxander.yacl.gui.YACLScreen;
-import dev.isxander.yacl.impl.utils.YACLConstants;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.Text;
-
-import java.util.function.Consumer;
-
-public record YetAnotherConfigLibImpl(Text title, ImmutableList<ConfigCategory> categories, Runnable saveFunction, Consumer<YACLScreen> initConsumer) implements YetAnotherConfigLib {
- @Override
- public Screen generateScreen(Screen parent) {
- YACLConstants.LOGGER.info("Generating YACL screen");
- return new YACLScreen(this, parent);
- }
-}
diff --git a/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java b/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java
deleted file mode 100644
index 6c7508d..0000000
--- a/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package dev.isxander.yacl.impl.utils;
-
-import dev.isxander.yacl.api.utils.Dimension;
-import dev.isxander.yacl.api.utils.MutableDimension;
-
-public class DimensionIntegerImpl implements MutableDimension<Integer> {
- private int x, y;
- private int width, height;
-
- public DimensionIntegerImpl(int x, int y, int width, int height) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
-
- @Override
- public Integer x() {
- return x;
- }
-
- @Override
- public Integer y() {
- return y;
- }
-
- @Override
- public Integer width() {
- return width;
- }
-
- @Override
- public Integer height() {
- return height;
- }
-
- @Override
- public Integer xLimit() {
- return x + width;
- }
-
- @Override
- public Integer yLimit() {
- return y + height;
- }
-
- @Override
- public Integer centerX() {
- return x + width / 2;
- }
-
- @Override
- public Integer centerY() {
- return y + height / 2;
- }
-
- @Override
- public boolean isPointInside(Integer x, Integer y) {
- return x >= x() && x <= xLimit() && y >= y() && y <= yLimit();
- }
-
- @Override
- public MutableDimension<Integer> clone() {
- return new DimensionIntegerImpl(x, y, width, height);
- }
-
- @Override public MutableDimension<Integer> setX(Integer x) { this.x = x; return this; }
- @Override public MutableDimension<Integer> setY(Integer y) { this.y = y; return this; }
- @Override public MutableDimension<Integer> setWidth(Integer width) { this.width = width; return this; }
- @Override public MutableDimension<Integer> setHeight(Integer height) { this.height = height; return this; }
-
- @Override
- public Dimension<Integer> withX(Integer x) {
- return clone().setX(x);
- }
-
- @Override
- public Dimension<Integer> withY(Integer y) {
- return clone().setY(y);
- }
-
- @Override
- public Dimension<Integer> withWidth(Integer width) {
- return clone().setWidth(width);
- }
-
- @Override
- public Dimension<Integer> withHeight(Integer height) {
- return clone().setHeight(height);
- }
-
- @Override
- public MutableDimension<Integer> move(Integer x, Integer y) {
- this.x += x;
- this.y += y;
- return this;
- }
-
- @Override
- public MutableDimension<Integer> expand(Integer width, Integer height) {
- this.width += width;
- this.height += height;
- return this;
- }
-
- @Override
- public Dimension<Integer> moved(Integer x, Integer y) {
- return clone().move(x, y);
- }
-
- @Override
- public Dimension<Integer> expanded(Integer width, Integer height) {
- return clone().expand(width, height);
- }
-}
diff --git a/src/main/java/dev/isxander/yacl/impl/utils/YACLConstants.java b/src/main/java/dev/isxander/yacl/impl/utils/YACLConstants.java
deleted file mode 100644
index 3d382d4..0000000
--- a/src/main/java/dev/isxander/yacl/impl/utils/YACLConstants.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package dev.isxander.yacl.impl.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class YACLConstants {
- public static final Logger LOGGER = LoggerFactory.getLogger("YetAnotherConfigLib");
-}