aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxander <xander@isxander.dev>2022-09-02 10:45:53 +0100
committerxander <xander@isxander.dev>2022-09-02 10:45:53 +0100
commit7bfbbc908d53c379fa36a929282e7f20b95afde8 (patch)
tree939adcb7460f08bfb2335f94b26d114c2dd05dcf /src
parentcff8d5bad318d133ab1089524619fc15f3b15b6f (diff)
downloadYetAnotherConfigLib-7bfbbc908d53c379fa36a929282e7f20b95afde8.tar.gz
YetAnotherConfigLib-7bfbbc908d53c379fa36a929282e7f20b95afde8.tar.bz2
YetAnotherConfigLib-7bfbbc908d53c379fa36a929282e7f20b95afde8.zip
fix group validation & icon & wiki test stuff
Diffstat (limited to 'src')
-rw-r--r--src/main/java/dev/isxander/yacl/api/ConfigCategory.java3
-rw-r--r--src/main/resources/fabric.mod.json1
-rw-r--r--src/main/resources/icon.pngbin0 -> 17130 bytes
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java73
4 files changed, 76 insertions, 1 deletions
diff --git a/src/main/java/dev/isxander/yacl/api/ConfigCategory.java b/src/main/java/dev/isxander/yacl/api/ConfigCategory.java
index b6ddcc2..5aafc62 100644
--- a/src/main/java/dev/isxander/yacl/api/ConfigCategory.java
+++ b/src/main/java/dev/isxander/yacl/api/ConfigCategory.java
@@ -136,12 +136,13 @@ public interface ConfigCategory {
public ConfigCategory build() {
Validate.notNull(name, "`name` must not be null to build `ConfigCategory`");
- Validate.notEmpty(rootOptions, "`at least one option must be added to build `ConfigCategory`");
List<OptionGroup> combinedGroups = new ArrayList<>();
combinedGroups.add(new OptionGroupImpl(Text.empty(), ImmutableList.copyOf(rootOptions), true));
combinedGroups.addAll(groups);
+ Validate.notEmpty(combinedGroups, "at least one option must be added to build `ConfigCategory`");
+
MutableText concatenatedTooltip = Text.empty();
boolean first = true;
for (Text line : tooltipLines) {
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index 708c30e..0061d05 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -12,6 +12,7 @@
"issues": "https://github.com/${github}/issues",
"sources": "https://github.com/${github}"
},
+ "icon": "icon.png",
"license": "LGPL-3.0-or-later",
"environment": "client",
"entrypoints": {
diff --git a/src/main/resources/icon.png b/src/main/resources/icon.png
new file mode 100644
index 0000000..3f6dae4
--- /dev/null
+++ b/src/main/resources/icon.png
Binary files differ
diff --git a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
index d71a83b..8776c16 100644
--- a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
+++ b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
@@ -18,6 +18,10 @@ import net.minecraft.text.Text;
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
+ return getWikiButton();
+ }
+
+ private ConfigScreenFactory<?> getFullTestSuite() {
return (parent) -> YetAnotherConfigLib.createBuilder()
.title(Text.of("Test GUI"))
.category(ConfigCategory.createBuilder()
@@ -218,6 +222,71 @@ public class ModMenuIntegration implements ModMenuApi {
.build().generateScreen(parent);
}
+ private ConfigScreenFactory<?> getWikiBasic() {
+ return (parent) -> YetAnotherConfigLib.createBuilder()
+ .title(Text.of("Mod Name"))
+ .category(ConfigCategory.createBuilder()
+ .name(Text.of("My Category"))
+ .tooltip(Text.of("This displays when you hover over a category button")) // optional
+ .option(Option.createBuilder(boolean.class)
+ .name(Text.of("My Boolean Option"))
+ .tooltip(Text.of("This option displays the basic capabilities of YetAnotherConfigLib")) // optional
+ .binding(
+ true, // default
+ () -> TestSettings.booleanToggle, // getter
+ newValue -> TestSettings.booleanToggle = newValue // setter
+ )
+ .controller(BooleanController::new)
+ .build())
+ .build())
+ .save(TestSettings::save)
+ .build()
+ .generateScreen(parent);
+ }
+
+ private ConfigScreenFactory<?> getWikiGroups() {
+ return (parent) -> YetAnotherConfigLib.createBuilder()
+ .title(Text.of("Mod Name"))
+ .category(ConfigCategory.createBuilder()
+ .name(Text.of("My Category"))
+ .tooltip(Text.of("This displays when you hover over a category button")) // optional
+ .group(OptionGroup.createBuilder()
+ .name(Text.of("Option Group"))
+ .option(Option.createBuilder(boolean.class)
+ .name(Text.of("My Boolean Option"))
+ .tooltip(Text.of("This option displays the basic capabilities of YetAnotherConfigLib")) // optional
+ .binding(
+ true, // default
+ () -> TestSettings.booleanToggle, // getter
+ newValue -> TestSettings.booleanToggle = newValue // setter
+ )
+ .controller(BooleanController::new)
+ .build())
+ .build())
+ .build())
+ .save(TestSettings::save)
+ .build()
+ .generateScreen(parent);
+ }
+
+ private ConfigScreenFactory<?> getWikiButton() {
+ return (parent) -> YetAnotherConfigLib.createBuilder()
+ .title(Text.of("Mod Name"))
+ .category(ConfigCategory.createBuilder()
+ .name(Text.of("My Category"))
+ .tooltip(Text.of("This displays when you hover over a category button")) // optional
+ .option(ButtonOption.createBuilder()
+ .name(Text.of("Pressable Button"))
+ .tooltip(Text.of("This is so easy!")) // optional
+ .action(() -> {})
+ .controller(ActionController::new)
+ .build())
+ .build())
+ .save(TestSettings::save)
+ .build()
+ .generateScreen(parent);
+ }
+
private static class TestSettings {
private static boolean booleanToggle = false;
private static boolean tickbox = false;
@@ -237,5 +306,9 @@ public class ModMenuIntegration implements ModMenuApi {
public enum Alphabet {
A, B, C
}
+
+ public static void save() {
+
+ }
}
}