diff options
author | Crendgrim <Crendgrim@users.noreply.github.com> | 2023-08-31 00:06:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 23:06:47 +0100 |
commit | 554646dbd857e2fab1be8339ce8d0231ef2dbb4c (patch) | |
tree | b55e6f1d282c18e743857bba3c9d5e4f226200ed /common/src/main/java/dev/isxander/yacl3/impl | |
parent | c11566072608683034864dbd4e0d3f5afa067537 (diff) | |
download | YetAnotherConfigLib-554646dbd857e2fab1be8339ce8d0231ef2dbb4c.tar.gz YetAnotherConfigLib-554646dbd857e2fab1be8339ce8d0231ef2dbb4c.tar.bz2 YetAnotherConfigLib-554646dbd857e2fab1be8339ce8d0231ef2dbb4c.zip |
Add dropdown controllers (#95)
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl3/impl')
2 files changed, 67 insertions, 0 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/impl/controller/DropdownStringControllerBuilderImpl.java b/common/src/main/java/dev/isxander/yacl3/impl/controller/DropdownStringControllerBuilderImpl.java new file mode 100644 index 0000000..b300a6a --- /dev/null +++ b/common/src/main/java/dev/isxander/yacl3/impl/controller/DropdownStringControllerBuilderImpl.java @@ -0,0 +1,49 @@ +package dev.isxander.yacl3.impl.controller; + +import dev.isxander.yacl3.api.Controller; +import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.api.controller.DropdownStringControllerBuilder; +import dev.isxander.yacl3.gui.controllers.dropdown.DropdownStringController; + +import java.util.Arrays; +import java.util.List; + +public class DropdownStringControllerBuilderImpl extends StringControllerBuilderImpl implements DropdownStringControllerBuilder { + private List<String> values; + private boolean allowEmptyValue = false; + private boolean allowAnyValue = false; + + public DropdownStringControllerBuilderImpl(Option<String> option) { + super(option); + } + + @Override + public DropdownStringControllerBuilder values(List<String> values) { + this.values = values; + return this; + } + + @Override + public DropdownStringControllerBuilderImpl values(String... values) { + this.values = Arrays.asList(values); + return this; + } + + @Override + public DropdownStringControllerBuilderImpl allowEmptyValue(boolean allowEmptyValue) { + this.allowEmptyValue = allowEmptyValue; + return this; + } + + @Override + public DropdownStringControllerBuilderImpl allowAnyValue(boolean allowAnyValue) { + this.allowAnyValue = allowAnyValue; + return this; + } + + @Override + public Controller<String> build() { + return new DropdownStringController(option, values, allowEmptyValue, allowAnyValue); + } + +} diff --git a/common/src/main/java/dev/isxander/yacl3/impl/controller/ItemControllerBuilderImpl.java b/common/src/main/java/dev/isxander/yacl3/impl/controller/ItemControllerBuilderImpl.java new file mode 100644 index 0000000..9a817fb --- /dev/null +++ b/common/src/main/java/dev/isxander/yacl3/impl/controller/ItemControllerBuilderImpl.java @@ -0,0 +1,18 @@ +package dev.isxander.yacl3.impl.controller; + +import dev.isxander.yacl3.api.Controller; +import dev.isxander.yacl3.api.Option; +import dev.isxander.yacl3.api.controller.ItemControllerBuilder; +import dev.isxander.yacl3.gui.controllers.dropdown.ItemController; +import net.minecraft.world.item.Item; + +public class ItemControllerBuilderImpl extends AbstractControllerBuilderImpl<Item> implements ItemControllerBuilder { + public ItemControllerBuilderImpl(Option<Item> option) { + super(option); + } + + @Override + public Controller<Item> build() { + return new ItemController(option); + } +} |