diff options
Diffstat (limited to 'src/testmod/java/dev/isxander/yacl')
-rw-r--r-- | src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java | 4 | ||||
-rw-r--r-- | src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java | 33 |
2 files changed, 36 insertions, 1 deletions
diff --git a/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java b/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java index c7ea46c..5d864da 100644 --- a/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java +++ b/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java @@ -5,6 +5,7 @@ import dev.isxander.yacl.config.ConfigInstance; import dev.isxander.yacl.config.GsonConfigInstance; import java.awt.*; +import java.util.List; import java.nio.file.Path; public class ExampleConfig { @@ -25,6 +26,9 @@ public class ExampleConfig { @ConfigEntry public long longField = 5; @ConfigEntry public Alphabet enumOption = Alphabet.A; + @ConfigEntry 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 public List<Integer> intList = List.of(1, 2, 3); + @ConfigEntry public boolean groupTestRoot = false; @ConfigEntry public boolean groupTestFirstGroup = false; @ConfigEntry public boolean groupTestFirstGroup2 = false; diff --git a/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java b/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java index 7295f2c..4965150 100644 --- a/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java +++ b/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java @@ -22,7 +22,8 @@ import net.minecraft.text.ClickEvent; import net.minecraft.text.HoverEvent; import net.minecraft.text.Text; -import java.awt.*; +import java.awt.Color; +import java.util.List; public class GuiTest { public static Screen getModConfigScreenFactory(Screen parent) { @@ -245,6 +246,36 @@ public class GuiTest { .build()) .build()) .build()) + .category(ConfigCategory.createBuilder() + .name(Text.of("List Test")) + .group(ListOption.createBuilder(String.class) + .name(Text.of("String List")) + .binding( + defaults.stringList, + () -> config.stringList, + val -> config.stringList = val + ) + .controller(StringController::new) + .initial("") + .build()) + .group(ListOption.createBuilder(Integer.class) + .name(Text.of("Slider List")) + .binding( + defaults.intList, + () -> config.intList, + val -> config.intList = val + ) + .controller(opt -> new IntegerSliderController(opt, 0, 10, 1)) + .initial(0) + .available(false) + .build()) + .group(ListOption.createBuilder(Text.class) + .name(Text.of("Useless Label List")) + .binding(Binding.immutable(List.of(Text.of("It's quite impressive that literally every single controller works, without problem.")))) + .controller(LabelController::new) + .initial(Text.of("Initial label")) + .build()) + .build()) .category(PlaceholderCategory.createBuilder() .name(Text.of("Placeholder Category")) .screen((client, yaclScreen) -> new RequireRestartScreen(yaclScreen)) |