aboutsummaryrefslogtreecommitdiff
path: root/test-common/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'test-common/src/main/java')
-rw-r--r--test-common/src/main/java/dev/isxander/yacl3/test/AutogenConfigTest.java12
-rw-r--r--test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java8
-rw-r--r--test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java41
3 files changed, 56 insertions, 5 deletions
diff --git a/test-common/src/main/java/dev/isxander/yacl3/test/AutogenConfigTest.java b/test-common/src/main/java/dev/isxander/yacl3/test/AutogenConfigTest.java
index 828aa73..a664d91 100644
--- a/test-common/src/main/java/dev/isxander/yacl3/test/AutogenConfigTest.java
+++ b/test-common/src/main/java/dev/isxander/yacl3/test/AutogenConfigTest.java
@@ -16,6 +16,8 @@ import dev.isxander.yacl3.gui.ValueFormatters;
import dev.isxander.yacl3.platform.YACLPlatform;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.Items;
import java.awt.*;
import java.util.List;
@@ -30,7 +32,7 @@ public class AutogenConfigTest {
.build();
@AutoGen(category = "test", group = "master_test")
- @MasterTickBox({ "testTickBox", "testBoolean", "testInt", "testDouble", "testFloat", "testLong", "testIntField", "testDoubleField", "testFloatField", "testLongField", "testEnum", "testColor", "testString" })
+ @MasterTickBox({ "testTickBox", "testBoolean", "testInt", "testDouble", "testFloat", "testLong", "testIntField", "testDoubleField", "testFloatField", "testLongField", "testEnum", "testColor", "testString", "testDropdown", "testItem" })
@SerialEntry(comment = "This option disables all the other options in this group")
public boolean masterOption = true;
@@ -90,6 +92,14 @@ public class AutogenConfigTest {
@StringField
@SerialEntry public String testString = "Test string";
+ @AutoGen(category = "test", group = "master_test")
+ @Dropdown(values = {"Apple", "Banana", "Cherry", "Date"}, allowAnyValue = true)
+ @SerialEntry public String testDropdown = "Cherry";
+
+ @AutoGen(category = "test", group = "master_test")
+ @ItemField
+ @SerialEntry public Item testItem = Items.AZURE_BLUET;
+
@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/ConfigTest.java b/test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java
index fc07120..a61a112 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
@@ -4,6 +4,8 @@ import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder;
import dev.isxander.yacl3.platform.YACLPlatform;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.Items;
import java.awt.*;
import java.util.List;
@@ -43,6 +45,12 @@ public class ConfigTest {
public long longField = 5;
@SerialEntry
public Alphabet enumOption = Alphabet.A;
+ @SerialEntry
+ public String stringOptions = "Banana";
+ @SerialEntry
+ public String stringSuggestions = "";
+ @SerialEntry
+ public Item item = Items.OAK_LOG;
@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!");
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 71b57f0..c8981d4 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
@@ -1,10 +1,7 @@
package dev.isxander.yacl3.test;
import dev.isxander.yacl3.api.*;
-import dev.isxander.yacl3.api.controller.BooleanControllerBuilder;
-import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
-import dev.isxander.yacl3.api.controller.StringControllerBuilder;
-import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
+import dev.isxander.yacl3.api.controller.*;
import dev.isxander.yacl3.gui.RequireRestartScreen;
import dev.isxander.yacl3.gui.controllers.*;
import dev.isxander.yacl3.gui.controllers.cycling.EnumController;
@@ -26,6 +23,7 @@ import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.item.Item;
import java.awt.Color;
import java.nio.file.Path;
@@ -237,6 +235,41 @@ public class GuiTest {
.build())
.build())
.group(OptionGroup.createBuilder()
+ .name(Component.literal("Dropdown Controllers"))
+ .option(Option.<String>createBuilder()
+ .name(Component.literal("String Dropdown"))
+ .binding(
+ defaults.stringOptions,
+ () -> config.stringOptions,
+ (value) -> config.stringOptions = value
+ )
+ .controller(opt -> DropdownStringControllerBuilder.create(opt)
+ .values("Apple", "Banana", "Cherry", "Date")
+ )
+ .build())
+ .option(Option.<String>createBuilder()
+ .name(Component.literal("String suggestions"))
+ .binding(
+ defaults.stringSuggestions,
+ () -> config.stringSuggestions,
+ (value) -> config.stringSuggestions = value
+ )
+ .controller(opt -> DropdownStringControllerBuilder.create(opt)
+ .values("Apple", "Banana", "Cherry", "Date")
+ .allowAnyValue(true)
+ )
+ .build())
+ .option(Option.<Item>createBuilder()
+ .name(Component.literal("Item Dropdown"))
+ .binding(
+ defaults.item,
+ () -> config.item,
+ (value) -> config.item = value
+ )
+ .controller(ItemControllerBuilder::create)
+ .build())
+ .build())
+ .group(OptionGroup.createBuilder()
.name(Component.literal("Options that aren't really options"))
.option(ButtonOption.createBuilder()
.name(Component.literal("Button \"Option\""))