aboutsummaryrefslogtreecommitdiff
path: root/test-common/src/main/java
diff options
context:
space:
mode:
authorisXander <xander@isxander.dev>2023-08-15 12:03:27 +0100
committerisXander <xander@isxander.dev>2023-08-15 12:03:27 +0100
commitad3e7955295d114ecbdaf07eb51ba26f0dc95d96 (patch)
tree6ae545dd2c96c5c99756d706fe9c5c4e1b9b18f7 /test-common/src/main/java
parent058c20324fa055bd20957006da64d1a46bce5ed6 (diff)
downloadYetAnotherConfigLib-ad3e7955295d114ecbdaf07eb51ba26f0dc95d96.tar.gz
YetAnotherConfigLib-ad3e7955295d114ecbdaf07eb51ba26f0dc95d96.tar.bz2
YetAnotherConfigLib-ad3e7955295d114ecbdaf07eb51ba26f0dc95d96.zip
Complete the controllers (except number fields)
Diffstat (limited to 'test-common/src/main/java')
-rw-r--r--test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java41
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);
+ }
+ }
}