aboutsummaryrefslogtreecommitdiff
path: root/test-common/src/main/java/dev
diff options
context:
space:
mode:
authorisXander <xander@isxander.dev>2023-08-15 17:34:52 +0100
committerisXander <xander@isxander.dev>2023-08-15 17:34:52 +0100
commita892b7e9c2f67b072cf1461241f4ba5488e41370 (patch)
tree2059baca6e44c3495cd80dd216e2838af395a9ff /test-common/src/main/java/dev
parentb55bf458cea19838170025bf891a20daa4db4516 (diff)
downloadYetAnotherConfigLib-a892b7e9c2f67b072cf1461241f4ba5488e41370.tar.gz
YetAnotherConfigLib-a892b7e9c2f67b072cf1461241f4ba5488e41370.tar.bz2
YetAnotherConfigLib-a892b7e9c2f67b072cf1461241f4ba5488e41370.zip
Complete config tests
Diffstat (limited to 'test-common/src/main/java/dev')
-rw-r--r--test-common/src/main/java/dev/isxander/yacl3/test/AutogenConfigTest.java (renamed from test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java)58
-rw-r--r--test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java4
2 files changed, 52 insertions, 10 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/AutogenConfigTest.java
index 462bef8..7a064d5 100644
--- a/test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java
+++ b/test-common/src/main/java/dev/isxander/yacl3/test/AutogenConfigTest.java
@@ -7,6 +7,8 @@ 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.autogen.Boolean;
+import dev.isxander.yacl3.config.v2.api.autogen.Label;
import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import dev.isxander.yacl3.config.v2.api.autogen.*;
@@ -14,10 +16,11 @@ import dev.isxander.yacl3.platform.YACLPlatform;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
+import java.awt.*;
import java.util.List;
-public class ConfigV2Test {
- public static ConfigClassHandler<ConfigV2Test> INSTANCE = ConfigClassHandler.createBuilder(ConfigV2Test.class)
+public class AutogenConfigTest {
+ public static ConfigClassHandler<AutogenConfigTest> INSTANCE = ConfigClassHandler.createBuilder(AutogenConfigTest.class)
.id(new ResourceLocation("yacl3", "config"))
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(YACLPlatform.getConfigDir().resolve("yacl-test-v2.json5"))
@@ -26,8 +29,8 @@ public class ConfigV2Test {
.build();
@AutoGen(category = "test", group = "master_test")
- @MasterTickBox({ "testTickBox", "testInt", "testEnum" })
- @SerialEntry(comment = "This option does this and that which is cool because this...")
+ @MasterTickBox({ "testTickBox", "testBoolean", "testInt", "testDouble", "testFloat", "testLong", "testIntField", "testDoubleField", "testFloatField", "testLongField", "testEnum", "testColor", "testString" })
+ @SerialEntry(comment = "This option disables all the other options in this group")
public boolean masterOption = true;
@AutoGen(category = "test", group = "master_test")
@@ -36,18 +39,59 @@ public class ConfigV2Test {
public boolean testTickBox = true;
@AutoGen(category = "test", group = "master_test")
+ @Boolean(formatter = Boolean.Formatter.YES_NO, colored = true)
+ @SerialEntry(comment = "This is a cool comment omg this is amazing")
+ public boolean testBoolean = true;
+
+ @AutoGen(category = "test", group = "master_test")
@IntSlider(min = 0, max = 10, step = 2)
@SerialEntry public int testInt = 0;
@AutoGen(category = "test", group = "master_test")
+ @DoubleSlider(min = 0.1, max = 10.2, step = 0.1)
+ @SerialEntry public double testDouble = 0.1;
+
+ @AutoGen(category = "test", group = "master_test")
+ @FloatSlider(min = 0.1f, max = 10.2f, step = 0.1f)
+ @SerialEntry public float testFloat = 0.1f;
+
+ @AutoGen(category = "test", group = "master_test")
+ @LongSlider(min = 0, max = 10, step = 2)
+ @SerialEntry public long testLong = 0;
+
+ @AutoGen(category = "test", group = "master_test")
+ @IntField(min = 0, max = 10)
+ @SerialEntry public int testIntField = 0;
+
+ @AutoGen(category = "test", group = "master_test")
+ @DoubleField(min = 0.1, max = 10.2)
+ @SerialEntry public double testDoubleField = 0.1;
+
+ @AutoGen(category = "test", group = "master_test")
+ @FloatField(min = 0.1f, max = 10.2f)
+ @SerialEntry public float testFloatField = 0.1f;
+
+ @AutoGen(category = "test", group = "master_test")
+ @LongField(min = 0, max = 10)
+ @SerialEntry public long testLongField = 0;
+
+ @AutoGen(category = "test", group = "master_test")
@EnumCycler
@SerialEntry public Alphabet testEnum = Alphabet.A;
+ @AutoGen(category = "test", group = "master_test")
+ @ColorField
+ @SerialEntry public Color testColor = new Color(0xFF0000FF, true);
+
+ @AutoGen(category = "test", group = "master_test")
+ @StringField
+ @SerialEntry public String testString = "Test string";
+
@AutoGen(category = "test", group = "misc") @Label
private final Component testLabel = Component.literal("Test label");
@AutoGen(category = "test")
- @ListGroup(valueFactory = TestListValueFactory.class, controllerFactory = TestListControllerFactory.class)
+ @ListGroup(valueFactory = TestListFactory.class, controllerFactory = TestListFactory.class)
@SerialEntry public List<String> testList = Lists.newArrayList("A", "B");
public enum Alphabet implements NameableEnum {
@@ -59,14 +103,12 @@ public class ConfigV2Test {
}
}
- public static class TestListValueFactory implements ListGroup.ValueFactory<String> {
+ public static class TestListFactory implements ListGroup.ValueFactory<String>, ListGroup.ControllerFactory<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, OptionAccess storage, Option<String> option) {
return StringControllerBuilder.create(option);
diff --git a/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java b/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java
index 6430c48..9c232ca 100644
--- a/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java
+++ b/test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java
@@ -45,8 +45,8 @@ public class GuiTest {
.option(ButtonOption.createBuilder()
.name(Component.literal("Auto-gen test"))
.action((screen, opt) -> {
- ConfigV2Test.INSTANCE.serializer().load();
- Minecraft.getInstance().setScreen(ConfigV2Test.INSTANCE.generateGui().generateScreen(screen));
+ AutogenConfigTest.INSTANCE.serializer().load();
+ Minecraft.getInstance().setScreen(AutogenConfigTest.INSTANCE.generateGui().generateScreen(screen));
})
.build())
.group(OptionGroup.createBuilder()