diff options
Diffstat (limited to 'test-common')
-rw-r--r-- | test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java index d287604..04b7db0 100644 --- a/test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java +++ b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java @@ -1,6 +1,12 @@ package dev.isxander.yacl3.test; +import com.google.common.collect.Lists; +import dev.isxander.yacl3.api.NameableEnum; +import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.api.controller.ControllerBuilder; +import dev.isxander.yacl3.api.controller.StringControllerBuilder; import dev.isxander.yacl3.config.v2.api.ConfigClassHandler; +import dev.isxander.yacl3.config.v2.api.ConfigField; import dev.isxander.yacl3.config.v2.api.GsonConfigSerializerBuilder; import dev.isxander.yacl3.config.v2.api.SerialEntry; import dev.isxander.yacl3.config.v2.api.autogen.*; @@ -8,6 +14,8 @@ import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import java.util.List; + public class ConfigV2Test { public static ConfigClassHandler<ConfigV2Test> INSTANCE = ConfigClassHandler.createBuilder(ConfigV2Test.class) .id(new ResourceLocation("yacl3", "config")) @@ -19,7 +27,7 @@ public class ConfigV2Test { .build(); @AutoGen(category = "test", group = "master_test") - @MasterTickBox({ "testTickBox", "testInt" }) + @MasterTickBox({ "testTickBox", "testInt", "testEnum" }) @SerialEntry(comment = "This option does this and that which is cool because this...") public boolean masterOption = true; @@ -32,6 +40,37 @@ public class ConfigV2Test { @IntSlider(min = 0, max = 10, step = 2) @SerialEntry public int testInt = 0; + @AutoGen(category = "test", group = "master_test") + @EnumCycler + @SerialEntry public Alphabet testEnum = Alphabet.A; + @AutoGen(category = "test", group = "misc") @Label private final Component testLabel = Component.literal("Test label"); + + @AutoGen(category = "test") + @ListGroup(valueFactory = TestListValueFactory.class, controllerFactory = TestListControllerFactory.class) + @SerialEntry public List<String> testList = Lists.newArrayList("A", "B"); + + public enum Alphabet implements NameableEnum { + A, B, C; + + @Override + public Component getDisplayName() { + return Component.literal(name()); + } + } + + public static class TestListValueFactory implements ListGroup.ValueFactory<String> { + @Override + public String provideNewValue() { + return ""; + } + } + + public static class TestListControllerFactory implements ListGroup.ControllerFactory<String> { + @Override + public ControllerBuilder<String> createController(ListGroup annotation, ConfigField<List<String>> field, OptionStorage storage, Option<String> option) { + return StringControllerBuilder.create(option); + } + } } |