diff options
author | isXander <xandersmith2008@gmail.com> | 2023-05-25 19:36:47 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-05-25 19:36:47 +0100 |
commit | 2792276924cf5e292211bc0d43dbc4cf3eb9c181 (patch) | |
tree | d041268817a8c73ffa1f9a2a2a65f968c3be1ab6 /common/src/main/java/dev/isxander/yacl/impl | |
parent | aba5085302c6ad8eec1aa9ed25a9a86758d95d34 (diff) | |
download | YetAnotherConfigLib-2792276924cf5e292211bc0d43dbc4cf3eb9c181.tar.gz YetAnotherConfigLib-2792276924cf5e292211bc0d43dbc4cf3eb9c181.tar.bz2 YetAnotherConfigLib-2792276924cf5e292211bc0d43dbc4cf3eb9c181.zip |
removed `.name()` from description, replaced with option name. also javadoc
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl/impl')
7 files changed, 19 insertions, 18 deletions
diff --git a/common/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java b/common/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java index f0e0bdd..afb2cb5 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/ButtonOptionImpl.java @@ -217,7 +217,7 @@ public final class ButtonOptionImpl implements ButtonOption { concatenatedTooltip.append(line); } - return new ButtonOptionImpl(name, OptionDescription.createBuilder().name(name).description(concatenatedTooltip).build(), action, available, controlGetter); + return new ButtonOptionImpl(name, OptionDescription.createBuilder().description(concatenatedTooltip).build(), action, available, controlGetter); } } } diff --git a/common/src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java b/common/src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java index ed73174..e593ce4 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java @@ -111,7 +111,7 @@ public final class ConfigCategoryImpl implements ConfigCategory { Validate.notNull(name, "`name` must not be null to build `ConfigCategory`"); List<OptionGroup> combinedGroups = new ArrayList<>(); - combinedGroups.add(new OptionGroupImpl(Component.empty(), OptionDescription.createBuilder().name(Component.literal("Root")).build(), ImmutableList.copyOf(rootOptions), false, true)); + combinedGroups.add(new OptionGroupImpl(Component.empty(), OptionDescription.empty(), ImmutableList.copyOf(rootOptions), false, true)); combinedGroups.addAll(groups); Validate.notEmpty(combinedGroups, "at least one option must be added to build `ConfigCategory`"); diff --git a/common/src/main/java/dev/isxander/yacl/impl/LabelOptionImpl.java b/common/src/main/java/dev/isxander/yacl/impl/LabelOptionImpl.java index 2a7759c..a32121d 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/LabelOptionImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/LabelOptionImpl.java @@ -29,7 +29,6 @@ public final class LabelOptionImpl implements LabelOption { this.labelController = new LabelController(this); this.binding = Binding.immutable(label); this.description = OptionDescription.createBuilder() - .name(this.name) .description(this.label) .build(); } diff --git a/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java b/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java index a5536a4..c21e733 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/ListOptionImpl.java @@ -345,7 +345,7 @@ public final class ListOptionImpl<T> implements ListOption<T> { if (ensureLegacyDescriptionBuilder()) YACLConstants.LOGGER.warn("Using deprecated `tooltip` method in list option {}. Use `description` instead.", name.getString()); - description = legacyBuilder.name(name).build(); + description = legacyBuilder.build(); } return new ListOptionImpl<>(name, description, binding, initialValue, typeClass, controllerFunction, ImmutableSet.copyOf(flags), collapsed, available, listeners); diff --git a/common/src/main/java/dev/isxander/yacl/impl/OptionDescriptionImpl.java b/common/src/main/java/dev/isxander/yacl/impl/OptionDescriptionImpl.java index 5d09828..0b2853f 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/OptionDescriptionImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/OptionDescriptionImpl.java @@ -14,20 +14,13 @@ import java.nio.file.Path; import java.util.*; import java.util.concurrent.CompletableFuture; -public record OptionDescriptionImpl(Component descriptiveName, Component description, CompletableFuture<Optional<ImageRenderer>> image) implements OptionDescription { +public record OptionDescriptionImpl(Component description, CompletableFuture<Optional<ImageRenderer>> image) implements OptionDescription { public static class BuilderImpl implements Builder { - private Component name; private final List<Component> descriptionLines = new ArrayList<>(); private CompletableFuture<Optional<ImageRenderer>> image = CompletableFuture.completedFuture(Optional.empty()); private boolean imageUnset = true; @Override - public Builder name(Component name) { - this.name = name; - return this; - } - - @Override public Builder description(Component... description) { this.descriptionLines.addAll(Arrays.asList(description)); return this; @@ -45,7 +38,18 @@ public record OptionDescriptionImpl(Component descriptiveName, Component descrip Validate.isTrue(width > 0, "Width must be greater than 0!"); Validate.isTrue(height > 0, "Height must be greater than 0!"); - this.image = ImageRenderer.getOrMakeSync(image, () -> Optional.of(new ImageRenderer.TextureBacked(image, width, height))); + this.image = ImageRenderer.getOrMakeSync(image, () -> Optional.of(new ImageRenderer.TextureBacked(image, 0, 0, width, height, width, height))); + imageUnset = false; + return this; + } + + @Override + public Builder image(ResourceLocation image, float u, float v, int width, int height, int textureWidth, int textureHeight) { + Validate.isTrue(imageUnset, "Image already set!"); + Validate.isTrue(width > 0, "Width must be greater than 0!"); + Validate.isTrue(height > 0, "Height must be greater than 0!"); + + this.image = ImageRenderer.getOrMakeSync(image, () -> Optional.of(new ImageRenderer.TextureBacked(image, u, v, width, height, textureWidth, textureHeight))); imageUnset = false; return this; } @@ -120,8 +124,6 @@ public record OptionDescriptionImpl(Component descriptiveName, Component descrip @Override public OptionDescription build() { - Validate.notNull(name, "Name must be set!"); - MutableComponent concatenatedDescription = Component.empty(); Iterator<Component> iter = descriptionLines.iterator(); while (iter.hasNext()) { @@ -129,7 +131,7 @@ public record OptionDescriptionImpl(Component descriptiveName, Component descrip if (iter.hasNext()) concatenatedDescription.append("\n"); } - return new OptionDescriptionImpl(name.copy().withStyle(ChatFormatting.BOLD), concatenatedDescription, image); + return new OptionDescriptionImpl(concatenatedDescription, image); } } } diff --git a/common/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java b/common/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java index 0649f16..2db8acd 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/OptionGroupImpl.java @@ -133,7 +133,7 @@ public final class OptionGroupImpl implements OptionGroup { if (ensureLegacyDescriptionBuilder()) YACLConstants.LOGGER.warn("Using deprecated `tooltip` method in option group '{}'. Use `description` instead.", name != null ? name.getString() : "unnamed group"); - description = legacyBuilder.name(name).build(); + description = legacyBuilder.build(); } return new OptionGroupImpl(name, description, ImmutableList.copyOf(options), collapsed, false); diff --git a/common/src/main/java/dev/isxander/yacl/impl/OptionImpl.java b/common/src/main/java/dev/isxander/yacl/impl/OptionImpl.java index 98dcc23..ebb1226 100644 --- a/common/src/main/java/dev/isxander/yacl/impl/OptionImpl.java +++ b/common/src/main/java/dev/isxander/yacl/impl/OptionImpl.java @@ -312,7 +312,7 @@ public final class OptionImpl<T> implements Option<T> { return concatenatedTooltip; }; - descriptionFunction = opt -> OptionDescription.createBuilder().name(name).description(concatenatedTooltipGetter.apply(opt)).build(); + descriptionFunction = opt -> OptionDescription.createBuilder().description(concatenatedTooltipGetter.apply(opt)).build(); } return new OptionImpl<>(name, descriptionFunction, controlGetter, binding, available, ImmutableSet.copyOf(flags), typeClass, listeners); |