From 21afea0da3956f2d8cca81a54fa9820152e0c077 Mon Sep 17 00:00:00 2001 From: isXander Date: Sun, 21 May 2023 12:41:45 +0100 Subject: Start overhauling UI --- .../main/java/dev/isxander/yacl/api/Option.java | 9 +++++ .../dev/isxander/yacl/api/OptionDescription.java | 39 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 common/src/main/java/dev/isxander/yacl/api/OptionDescription.java (limited to 'common/src/main/java/dev/isxander/yacl/api') diff --git a/common/src/main/java/dev/isxander/yacl/api/Option.java b/common/src/main/java/dev/isxander/yacl/api/Option.java index a6c0311..5f66c19 100644 --- a/common/src/main/java/dev/isxander/yacl/api/Option.java +++ b/common/src/main/java/dev/isxander/yacl/api/Option.java @@ -17,10 +17,13 @@ public interface Option { */ @NotNull Component name(); + @NotNull OptionDescription description(); + /** * Tooltip (or description) of the option. * Rendered on hover. */ + @Deprecated @NotNull Component tooltip(); /** @@ -126,12 +129,17 @@ public interface Option { */ Builder name(@NotNull Component name); + Builder description(@NotNull OptionDescription description); + + Builder description(@NotNull Function descriptionFunction); + /** * Sets the tooltip to be used by the option. * No need to wrap the text yourself, the gui does this itself. * * @param tooltipGetter function to get tooltip depending on value {@link Builder#build()}. */ + @Deprecated Builder tooltip(@NotNull Function tooltipGetter); /** @@ -150,6 +158,7 @@ public interface Option { * * @param tooltips text lines - merged with a new-line on {@link Builder#build()}. */ + @Deprecated Builder tooltip(@NotNull Component... tooltips); /** diff --git a/common/src/main/java/dev/isxander/yacl/api/OptionDescription.java b/common/src/main/java/dev/isxander/yacl/api/OptionDescription.java new file mode 100644 index 0000000..3b28a65 --- /dev/null +++ b/common/src/main/java/dev/isxander/yacl/api/OptionDescription.java @@ -0,0 +1,39 @@ +package dev.isxander.yacl.api; + +import dev.isxander.yacl.gui.ImageRenderer; +import dev.isxander.yacl.impl.OptionDescriptionImpl; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +import java.nio.file.Path; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public interface OptionDescription { + Component descriptiveName(); + + Component description(); + + CompletableFuture> image(); + + static Builder createBuilder() { + return new OptionDescriptionImpl.BuilderImpl(); + } + + interface Builder { + Builder name(Component name); + + Builder description(Component description); + + Builder image(ResourceLocation image, int width, int height); + Builder image(Path path, ResourceLocation uniqueLocation); + + Builder gifImage(ResourceLocation image); + Builder gifImage(Path path, ResourceLocation uniqueLocation); + + Builder webpImage(ResourceLocation image, int frameDelayMS); + Builder webpImage(Path path, ResourceLocation uniqueLocation, int frameDelayMS); + + OptionDescription build(); + } +} -- cgit