From 177c8312ca53db56a0f90adb804867e4b6f95a16 Mon Sep 17 00:00:00 2001 From: mfishma Date: Fri, 24 Jul 2026 00:46:06 -0700 Subject: [PATCH] =?UTF-8?q?add=20custom=20font=20provider=20for=20?= =?UTF-8?q?=E2=9F=B2=20and=20update=20reset=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define the glyph for ⟲ with an 8x8 graphic to use as the reset button --- .../dev/isxander/yacl3/gui/OptionListWidget.java | 8 ++++---- .../yacl3/gui/TextScaledButtonWidget.java | 7 +------ .../resources/assets/minecraft/font/default.json | 13 +++++++++++++ .../textures/font/reset.png | Bin 0 -> 146 bytes 4 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/assets/minecraft/font/default.json create mode 100644 src/main/resources/assets/yet_another_config_lib_v3/textures/font/reset.png diff --git a/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java b/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java index 28e1131c..6c66583e 100644 --- a/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java +++ b/src/main/java/dev/isxander/yacl3/gui/OptionListWidget.java @@ -310,7 +310,7 @@ public class OptionEntry extends Entry { public final AbstractWidget widget; - private final TextScaledButtonWidget resetButton; + private final TooltipButtonWidget resetButton; private final String categoryName; private final String groupName; @@ -325,7 +325,7 @@ public OptionEntry(Option option, ConfigCategory category, OptionGroup group, this.groupName = group.name().getString().toLowerCase(); if (option.canResetToDefault() && this.widget.canReset()) { this.widget.setDimension(this.widget.getDimension().expanded(-20, 0)); - this.resetButton = new TextScaledButtonWidget(yaclScreen, widget.getDimension().xLimit(), -50, 20, 20, 2f, Component.literal("\u21BB"), button -> { + this.resetButton = new TooltipButtonWidget(yaclScreen, widget.getDimension().xLimit(), -50, 20, 20, Component.literal("\u27F2"), null, button -> { option.requestSetDefault(); }); option.addListener((opt, val) -> this.resetButton.active = !opt.isPendingValueDefault() && opt.available()); @@ -539,14 +539,14 @@ public void updateNarration(NarrationElementOutput builder) { public class ListGroupSeparatorEntry extends GroupSeparatorEntry { private final ListOption listOption; - private final TextScaledButtonWidget resetListButton; + private final TooltipButtonWidget resetListButton; private final TooltipButtonWidget addListButton; private ListGroupSeparatorEntry(ListOption group, Screen screen) { super(group, screen); this.listOption = group; - this.resetListButton = new TextScaledButtonWidget(screen, getRowRight() - 20, -50, 20, 20, 1f, Component.literal("\u21BB"), button -> { + this.resetListButton = new TooltipButtonWidget(screen, getRowRight() - 20, -50, 20, 20, Component.literal("\u27F2"), null, button -> { group.requestSetDefault(); }); group.addListener((opt, val) -> this.resetListButton.active = !opt.isPendingValueDefault() && opt.available()); diff --git a/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java b/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java index c92b16f6..52c40152 100644 --- a/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java +++ b/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java @@ -5,6 +5,7 @@ import net.minecraft.network.chat.Component; import org.jetbrains.annotations.NotNull; +@Deprecated(forRemoval = true) public class TextScaledButtonWidget extends TooltipButtonWidget { public float textScale; @@ -16,10 +17,4 @@ public TextScaledButtonWidget(Screen screen, int x, int y, int width, int height public TextScaledButtonWidget(Screen screen, int x, int y, int width, int height, float textScale, Component message, OnPress onPress) { this(screen, x, y, width, height, textScale, message, null, onPress); } - - // FIXME: i cannot figure out how to compensate a scale with a translation so for now the reset button is small fuck you - @Override - protected void extractDefaultLabel(ActiveTextCollector output) { - super.extractDefaultLabel(output); - } } diff --git a/src/main/resources/assets/minecraft/font/default.json b/src/main/resources/assets/minecraft/font/default.json new file mode 100644 index 00000000..02a2a09f --- /dev/null +++ b/src/main/resources/assets/minecraft/font/default.json @@ -0,0 +1,13 @@ +{ + "providers": [ + { + "type": "bitmap", + "file": "yet_another_config_lib_v3:font/reset.png", + "ascent": 7, + "height": 8, + "chars": [ + "\u27F2" + ] + } + ] +} diff --git a/src/main/resources/assets/yet_another_config_lib_v3/textures/font/reset.png b/src/main/resources/assets/yet_another_config_lib_v3/textures/font/reset.png new file mode 100644 index 0000000000000000000000000000000000000000..54436676a8ef31dc45e6f0a7b996bdf21999f4e4 GIT binary patch literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^93afd3?%;@)Hwm97>k44ofvPP)Tsw@I14-?iy0X7 zltGxWVyS%@P>?OaC&cyt|NlT{=%LGXK#Hj($S?Rm!_(~sUO=9>r;B4q#hm1lv@NMq jlK-%`l=f6h@-s8Y{$N??cz%T+Pzi<Dnm{r-UW|$CxMF literal 0 HcmV?d00001