aboutsummaryrefslogtreecommitdiff
path: root/src/testmod
diff options
context:
space:
mode:
authorXander <xander@isxander.dev>2022-12-11 19:31:56 +0000
committerGitHub <noreply@github.com>2022-12-11 19:31:56 +0000
commitdd65110f60aa3e32c2970863a06a7682520cce5e (patch)
tree44612c6aa85374efa639462592ae706fb93f2575 /src/testmod
parentb890c2f0eec3627e552f1c6cfc846c8a55663243 (diff)
downloadYetAnotherConfigLib-dd65110f60aa3e32c2970863a06a7682520cce5e.tar.gz
YetAnotherConfigLib-dd65110f60aa3e32c2970863a06a7682520cce5e.tar.bz2
YetAnotherConfigLib-dd65110f60aa3e32c2970863a06a7682520cce5e.zip
[Feature] Lists (#40)
Diffstat (limited to 'src/testmod')
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java4
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java33
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))