From 442f48a6e28196910e92f460d3d677e3e47cbfc0 Mon Sep 17 00:00:00 2001 From: Kevin <92656833+kevinthegreat1@users.noreply.github.com> Date: Sat, 18 Nov 2023 04:07:39 -0500 Subject: Add Enum Dropdown Controller (#117) --- .../src/main/java/dev/isxander/yacl3/test/ConfigTest.java | 3 +++ .../src/main/java/dev/isxander/yacl3/test/GuiTest.java | 11 +++++++++++ 2 files changed, 14 insertions(+) (limited to 'test-common/src/main/java/dev/isxander') 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 a61a112..a8f49b0 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,7 @@ 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.ChatFormatting; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -51,6 +52,8 @@ public class ConfigTest { public String stringSuggestions = ""; @SerialEntry public Item item = Items.OAK_LOG; + @SerialEntry + public ChatFormatting formattingOption = ChatFormatting.RED; @SerialEntry public List 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 a20312e..ec16e2e 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 @@ -14,6 +14,7 @@ import dev.isxander.yacl3.gui.controllers.string.number.DoubleFieldController; import dev.isxander.yacl3.gui.controllers.string.number.FloatFieldController; import dev.isxander.yacl3.gui.controllers.string.number.IntegerFieldController; import dev.isxander.yacl3.gui.controllers.string.number.LongFieldController; +import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.GraphicsStatus; import net.minecraft.client.Minecraft; @@ -24,6 +25,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; +import org.apache.commons.lang3.StringUtils; import java.awt.Color; import java.nio.file.Path; @@ -268,6 +270,15 @@ public class GuiTest { ) .controller(ItemControllerBuilder::create) .build()) + .option(Option.createBuilder() + .name(Component.literal("Enum Dropdown")) + .binding( + defaults.formattingOption, + () -> config.formattingOption, + (value) -> config.formattingOption = value + ) + .controller(option -> EnumDropdownControllerBuilder.create(option).formatValue(formatting -> Component.literal(StringUtils.capitalize(formatting.getName()).replaceAll("_", " ")))) + .build()) .build()) .group(OptionGroup.createBuilder() .name(Component.literal("Options that aren't really options")) -- cgit