diff --git a/src/main/java/dev/isxander/yacl3/gui/controllers/ListEntryWidget.java b/src/main/java/dev/isxander/yacl3/gui/controllers/ListEntryWidget.java index 10ae4572..a87b7452 100644 --- a/src/main/java/dev/isxander/yacl3/gui/controllers/ListEntryWidget.java +++ b/src/main/java/dev/isxander/yacl3/gui/controllers/ListEntryWidget.java @@ -25,7 +25,7 @@ public class ListEntryWidget extends AbstractWidget implements ContainerEventHan private final String optionNameString; - private GuiEventListener focused; + @Nullable private GuiEventListener focused; private boolean dragging; public ListEntryWidget(YACLScreen screen, ListOptionEntry listOptionEntry, AbstractWidget entryWidget) { @@ -87,7 +87,7 @@ protected void updateButtonStates() { @Override public void unfocus() { - entryWidget.unfocus(); + setFocused(null); } @Override @@ -123,7 +123,15 @@ public GuiEventListener getFocused() { @Override public void setFocused(@Nullable GuiEventListener focused) { - this.focused = focused; + if (this.focused != focused) { + if (this.focused != null) + this.focused.setFocused(false); + + if (focused != null) + focused.setFocused(true); + + this.focused = focused; + } } //? if >=1.21.11 { diff --git a/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java b/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java index 372e3369..ef76ab0a 100644 --- a/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java +++ b/src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java @@ -29,7 +29,7 @@ public DynamicTextureImage(NativeImage image, Identifier location, boolean textu RenderSystem.assertOnRenderThread(); this.image = image; - this.texture = new DynamicTexture(/*? if >=1.21.11 >>*/ /*location::toString,*/ image); + this.texture = new DynamicTexture(/*? if >=1.21.11 >>*/location::toString, image); // TODO 1.21.11 //? if <1.21.11 //this.texture.setFilter(textureFiltering, false); diff --git a/src/testmod/java/dev/isxander/yacl3/test/ConfigTest.java b/src/testmod/java/dev/isxander/yacl3/test/ConfigTest.java index 9c5f8d6e..852cad99 100644 --- a/src/testmod/java/dev/isxander/yacl3/test/ConfigTest.java +++ b/src/testmod/java/dev/isxander/yacl3/test/ConfigTest.java @@ -65,6 +65,8 @@ public class ConfigTest { @SerialEntry public ChatFormatting formattingOption = ChatFormatting.RED; + @SerialEntry + public List colorList = List.of(Color.red, Color.green, Color.blue); @SerialEntry public List stringList = List.of("This is quite cool.", "You can add multiple items!", "And it is integrated so well into Option groups!"); @SerialEntry diff --git a/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java b/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java index 2859f3a1..d22e2933 100644 --- a/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java +++ b/src/testmod/java/dev/isxander/yacl3/test/GuiTest.java @@ -90,7 +90,13 @@ private static Screen getFullTestSuite(Screen parent) { .append(Component.literal("b").withStyle(style -> style.withHoverEvent(createTextHoverEvent(Component.literal("b"))))) .append(Component.literal("c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c").withStyle(style -> style.withHoverEvent(createTextHoverEvent(Component.literal("c"))))) .append(Component.literal("e").withStyle(style -> style.withHoverEvent(createTextHoverEvent(Component.literal("e"))))) - .append(Component.literal("click me").withStyle(style -> style.withClickEvent(new ClickEvent.OpenUrl(URI.create("https://isxander.dev"))))) + .append(Component.literal("click me").withStyle(style -> style.withClickEvent( + //? if >=1.21.5 { + new ClickEvent.OpenUrl(URI.create("https://isxander.dev")) + //?} else { + /*new ClickEvent(ClickEvent.Action.OPEN_URL, "https://isxander.dev") + *///?} + ))) ) .webpImage(imageSample("sample1.webp")) .build()) @@ -324,6 +330,16 @@ private static Screen getFullTestSuite(Screen parent) { .build()) .category(ConfigCategory.createBuilder() .name(Component.literal("List Test")) + .group(ListOption.createBuilder() + .name(Component.literal("Color List")) + .binding( + defaults.colorList, + () -> config.colorList, + val -> config.colorList = val + ) + .controller(ColorControllerBuilder::create) + .initial(Color.white) + .build()) .group(ListOption.createBuilder() .name(Component.literal("String List")) .binding(