diff options
author | isXander <xandersmith2008@gmail.com> | 2023-05-21 12:41:45 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-05-21 12:41:45 +0100 |
commit | 21afea0da3956f2d8cca81a54fa9820152e0c077 (patch) | |
tree | e5944f94a5f85d3fcbe048da633e62f5357fe835 /common/src/main/java/dev/isxander/yacl/api | |
parent | e51af159ba3eba5ebda976bea1c1957cddeee7c6 (diff) | |
download | YetAnotherConfigLib-21afea0da3956f2d8cca81a54fa9820152e0c077.tar.gz YetAnotherConfigLib-21afea0da3956f2d8cca81a54fa9820152e0c077.tar.bz2 YetAnotherConfigLib-21afea0da3956f2d8cca81a54fa9820152e0c077.zip |
Start overhauling UI
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl/api')
-rw-r--r-- | common/src/main/java/dev/isxander/yacl/api/Option.java | 9 | ||||
-rw-r--r-- | common/src/main/java/dev/isxander/yacl/api/OptionDescription.java | 39 |
2 files changed, 48 insertions, 0 deletions
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<T> { */ @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<T> { */ Builder<T> name(@NotNull Component name); + Builder<T> description(@NotNull OptionDescription description); + + Builder<T> description(@NotNull Function<T, OptionDescription> 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<T> tooltip(@NotNull Function<T, Component> tooltipGetter); /** @@ -150,6 +158,7 @@ public interface Option<T> { * * @param tooltips text lines - merged with a new-line on {@link Builder#build()}. */ + @Deprecated Builder<T> 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<Optional<ImageRenderer>> 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(); + } +} |