diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2023-11-18 04:07:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-18 09:07:39 +0000 |
commit | 442f48a6e28196910e92f460d3d677e3e47cbfc0 (patch) | |
tree | 3e34b77b7bf9707f8553a07abe629aab837a6130 /test-common/src | |
parent | 953645023c829735663493511390948bf69714f8 (diff) | |
download | YetAnotherConfigLib-442f48a6e28196910e92f460d3d677e3e47cbfc0.tar.gz YetAnotherConfigLib-442f48a6e28196910e92f460d3d677e3e47cbfc0.tar.bz2 YetAnotherConfigLib-442f48a6e28196910e92f460d3d677e3e47cbfc0.zip |
Add Enum Dropdown Controller (#117)
Diffstat (limited to 'test-common/src')
-rw-r--r-- | test-common/src/main/java/dev/isxander/yacl3/test/ConfigTest.java | 3 | ||||
-rw-r--r-- | test-common/src/main/java/dev/isxander/yacl3/test/GuiTest.java | 11 |
2 files changed, 14 insertions, 0 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 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<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 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.<ChatFormatting>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")) |