diff options
author | xander <xander@isxander.dev> | 2022-09-01 08:57:59 +0100 |
---|---|---|
committer | xander <xander@isxander.dev> | 2022-09-01 08:57:59 +0100 |
commit | 6f8ef7daaafd71090b2c334c10eadc8dedc738d9 (patch) | |
tree | d4054a65d99070c944132be83d25e109750dc5f9 /src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java | |
parent | 9d0a5e937f97c1c17d034393e01636d5241f376a (diff) | |
download | YetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.tar.gz YetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.tar.bz2 YetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.zip |
GUI Implementation
Added groups
Added button "option"
Added test mod
Diffstat (limited to 'src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java b/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java index d7f8416..a598e27 100644 --- a/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java +++ b/src/main/java/dev/isxander/yacl/api/YetAnotherConfigLib.java @@ -1,14 +1,17 @@ package dev.isxander.yacl.api; import com.google.common.collect.ImmutableList; +import dev.isxander.yacl.gui.YACLScreen; import dev.isxander.yacl.impl.YetAnotherConfigLibImpl; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; import org.apache.commons.lang3.Validate; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; public interface YetAnotherConfigLib { @@ -16,7 +19,11 @@ public interface YetAnotherConfigLib { ImmutableList<ConfigCategory> categories(); - Screen generateScreen(); + Runnable saveFunction(); + + Consumer<YACLScreen> initConsumer(); + + Screen generateScreen(@Nullable Screen parent); static Builder createBuilder(Text title) { return new Builder(title); @@ -25,31 +32,47 @@ public interface YetAnotherConfigLib { class Builder { private Text title; private final List<ConfigCategory> categories = new ArrayList<>(); + private Runnable saveFunction = () -> {}; + private Consumer<YACLScreen> initConsumer = screen -> {}; private Builder(@NotNull Text title) { Validate.notNull(title, "`title` cannot be null"); this.title = title; } - public Builder setTitle(@NotNull Text title) { + public Builder title(@NotNull Text title) { Validate.notNull(title, "`title` cannot be null"); this.title = title; return this; } - public Builder addCategory(@NotNull ConfigCategory category) { + public Builder category(@NotNull ConfigCategory category) { Validate.notNull(category, "`category` cannot be null"); this.categories.add(category); return this; } + public Builder save(@NotNull Runnable saveFunction) { + Validate.notNull(saveFunction, "`saveFunction` cannot be null"); + + this.saveFunction = saveFunction; + return this; + } + + public Builder screenInit(@NotNull Consumer<YACLScreen> initConsumer) { + Validate.notNull(initConsumer, "`initConsumer` cannot be null"); + + this.initConsumer = initConsumer; + return this; + } + public YetAnotherConfigLib build() { Validate.notNull(title, "`title must not be null to build `YetAnotherConfigLib`"); Validate.notEmpty(categories, "`categories` must not be empty to build `YetAnotherConfigLib`"); - return new YetAnotherConfigLibImpl(title, ImmutableList.copyOf(categories)); + return new YetAnotherConfigLibImpl(title, ImmutableList.copyOf(categories), saveFunction, initConsumer); } } } |