diff options
author | isXander <xandersmith2008@gmail.com> | 2023-07-24 15:56:59 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-07-24 16:10:44 +0100 |
commit | b5fdad973f499b6e26a885dba89e66ea2c29bde3 (patch) | |
tree | 99f2635da5a63e1432e5364259d0ae71850f6da1 /common/src/main/java/dev/isxander/yacl3/gui | |
parent | 3c88f72d6319c81c71fa300f8d534d73e19f24d4 (diff) | |
download | YetAnotherConfigLib-b5fdad973f499b6e26a885dba89e66ea2c29bde3.tar.gz YetAnotherConfigLib-b5fdad973f499b6e26a885dba89e66ea2c29bde3.tar.bz2 YetAnotherConfigLib-b5fdad973f499b6e26a885dba89e66ea2c29bde3.zip |
Add tick method to ImageRenderer
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl3/gui')
-rw-r--r-- | common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java | 2 | ||||
-rw-r--r-- | common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java b/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java index 013a770..7e9b9ab 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java @@ -40,6 +40,8 @@ public interface ImageRenderer { void close(); + default void tick() {} + Map<ResourceLocation, CompletableFuture<Optional<ImageRenderer>>> CACHE = new ConcurrentHashMap<>(); static CompletableFuture<Optional<ImageRenderer>> getOrMakeAsync(ResourceLocation id, Supplier<Optional<ImageRenderer>> factory) { diff --git a/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java b/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java index 63371d6..4fb937c 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java @@ -18,6 +18,7 @@ import net.minecraft.util.Mth; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Optional; import java.util.function.Supplier; public class OptionDescriptionWidget extends AbstractWidget { @@ -148,6 +149,12 @@ public class OptionDescriptionWidget extends AbstractWidget { } public void tick() { + if (description != null) { + description.description().image() + .getNow(Optional.empty()) + .ifPresent(ImageRenderer::tick); + } + float pxPerTick = AUTO_SCROLL_SPEED / 20f * font.lineHeight; if (maxScrollAmount > 0 && currentTimeMS() - lastInteractionTime > AUTO_SCROLL_TIMER) { if (scrollingBackward) { |