From b5fdad973f499b6e26a885dba89e66ea2c29bde3 Mon Sep 17 00:00:00 2001 From: isXander Date: Mon, 24 Jul 2023 15:56:59 +0100 Subject: Add tick method to ImageRenderer --- common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java | 2 ++ .../main/java/dev/isxander/yacl3/gui/OptionDescriptionWidget.java | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'common/src/main/java/dev/isxander/yacl3/gui') 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>> CACHE = new ConcurrentHashMap<>(); static CompletableFuture> getOrMakeAsync(ResourceLocation id, Supplier> 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) { -- cgit