diff options
author | isXander <xandersmith2008@gmail.com> | 2023-08-14 23:27:45 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-08-14 23:27:45 +0100 |
commit | b3355266572deef1a5c3e494ad162c592383e455 (patch) | |
tree | 876510a21e27d0052cb7a1501c0295a427c9dc3c /test-common/src | |
parent | d37e147dbb4db44a921533b572aed3e54b5c6a42 (diff) | |
download | YetAnotherConfigLib-b3355266572deef1a5c3e494ad162c592383e455.tar.gz YetAnotherConfigLib-b3355266572deef1a5c3e494ad162c592383e455.tar.bz2 YetAnotherConfigLib-b3355266572deef1a5c3e494ad162c592383e455.zip |
More-or-less complete API for YACL auto-gen
Diffstat (limited to 'test-common/src')
3 files changed, 75 insertions, 23 deletions
diff --git a/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java index 3a057f9..e633061 100644 --- a/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java +++ b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java @@ -1,7 +1,7 @@ package dev.isxander.yacl3.test; import dev.isxander.yacl3.config.v2.api.ConfigClassHandler; -import dev.isxander.yacl3.config.v2.api.ConfigEntry; +import dev.isxander.yacl3.config.v2.api.SerialEntry; import dev.isxander.yacl3.config.v2.api.GsonConfigSerializerBuilder; import dev.isxander.yacl3.platform.YACLPlatform; @@ -15,36 +15,50 @@ public class ConfigTest { .build()) .build(); - @ConfigEntry public boolean booleanToggle = false; - @ConfigEntry public boolean customBooleanToggle = false; - @ConfigEntry public boolean tickbox = false; - @ConfigEntry public int intSlider = 0; - @ConfigEntry public double doubleSlider = 0; - @ConfigEntry public float floatSlider = 0; - @ConfigEntry public long longSlider = 0; - @ConfigEntry public String textField = "Hello"; - @ConfigEntry public Color colorOption = Color.red; - @ConfigEntry public double doubleField = 0.5; - @ConfigEntry public float floatField = 0.5f; - @ConfigEntry public int intField = 5; - @ConfigEntry public long longField = 5; - @ConfigEntry public Alphabet enumOption = Alphabet.A; - - @ConfigEntry + @SerialEntry + public boolean booleanToggle = false; + @SerialEntry + public boolean customBooleanToggle = false; + @SerialEntry + public boolean tickbox = false; + @SerialEntry + public int intSlider = 0; + @SerialEntry + public double doubleSlider = 0; + @SerialEntry + public float floatSlider = 0; + @SerialEntry + public long longSlider = 0; + @SerialEntry + public String textField = "Hello"; + @SerialEntry + public Color colorOption = Color.red; + @SerialEntry + public double doubleField = 0.5; + @SerialEntry + public float floatField = 0.5f; + @SerialEntry + public int intField = 5; + @SerialEntry + public long longField = 5; + @SerialEntry + public Alphabet enumOption = Alphabet.A; + + @SerialEntry public List<String> stringList = List.of("This is quite cool.", "You can add multiple items!", "And it is integrated so well into Option groups!"); - @ConfigEntry + @SerialEntry public List<Integer> intList = List.of(1, 2, 3); - @ConfigEntry + @SerialEntry public boolean groupTestRoot = false; - @ConfigEntry + @SerialEntry public boolean groupTestFirstGroup = false; - @ConfigEntry + @SerialEntry public boolean groupTestFirstGroup2 = false; - @ConfigEntry + @SerialEntry public boolean groupTestSecondGroup = false; - @ConfigEntry + @SerialEntry public int scrollingSlider = 0; public enum Alphabet { 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 new file mode 100644 index 0000000..6084e23 --- /dev/null +++ b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigV2Test.java @@ -0,0 +1,34 @@ +package dev.isxander.yacl3.test; + +import dev.isxander.yacl3.config.v2.api.ConfigClassHandler; +import dev.isxander.yacl3.config.v2.api.GsonConfigSerializerBuilder; +import dev.isxander.yacl3.config.v2.api.SerialEntry; +import dev.isxander.yacl3.config.v2.api.autogen.*; +import dev.isxander.yacl3.platform.YACLPlatform; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +public class ConfigV2Test { + public static ConfigClassHandler<ConfigV2Test> INSTANCE = ConfigClassHandler.createBuilder(ConfigV2Test.class) + .id(new ResourceLocation("yacl3", "config")) + .serializer(config -> GsonConfigSerializerBuilder.create(config) + .setPath(YACLPlatform.getConfigDir().resolve("yacl-test-v2.json")) + .build()) + .autoGen(true) + .build(); + + @AutoGen(category = "test", group = "master_test") + @MasterTickBox({ "testTickBox", "testInt" }) + @SerialEntry public boolean masterOption = true; + + @AutoGen(category = "test", group = "master_test") + @TickBox + @SerialEntry public boolean testTickBox = true; + + @AutoGen(category = "test", group = "master_test") + @IntSlider(min = 0, max = 10, step = 2) + @SerialEntry public int testInt = 0; + + @AutoGen(category = "test", group = "misc") @Label + private final Component testLabel = Component.literal("Test label"); +} 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 71e5545..2eadb2a 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 @@ -42,6 +42,10 @@ public class GuiTest { .name(Component.literal("Full Test Suite")) .action((screen, opt) -> Minecraft.getInstance().setScreen(getFullTestSuite(screen))) .build()) + .option(ButtonOption.createBuilder() + .name(Component.literal("Auto-gen test")) + .action((screen, opt) -> Minecraft.getInstance().setScreen(ConfigV2Test.INSTANCE.generateGui().generateScreen(screen))) + .build()) .group(OptionGroup.createBuilder() .name(Component.literal("Wiki")) .option(ButtonOption.createBuilder() |