aboutsummaryrefslogtreecommitdiff
path: root/src/testmod/java/dev/isxander
diff options
context:
space:
mode:
authorxander <xander@isxander.dev>2022-09-01 08:57:59 +0100
committerxander <xander@isxander.dev>2022-09-01 08:57:59 +0100
commit6f8ef7daaafd71090b2c334c10eadc8dedc738d9 (patch)
treed4054a65d99070c944132be83d25e109750dc5f9 /src/testmod/java/dev/isxander
parent9d0a5e937f97c1c17d034393e01636d5241f376a (diff)
downloadYetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.tar.gz
YetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.tar.bz2
YetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.zip
GUI Implementation
Added groups Added button "option" Added test mod
Diffstat (limited to 'src/testmod/java/dev/isxander')
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java137
1 files changed, 137 insertions, 0 deletions
diff --git a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
new file mode 100644
index 0000000..f328ab4
--- /dev/null
+++ b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
@@ -0,0 +1,137 @@
+package dev.isxander.yacl.test;
+
+import com.terraformersmc.modmenu.api.ConfigScreenFactory;
+import com.terraformersmc.modmenu.api.ModMenuApi;
+import dev.isxander.yacl.api.*;
+import dev.isxander.yacl.gui.controllers.ActionControl;
+import dev.isxander.yacl.gui.controllers.EnumControl;
+import dev.isxander.yacl.gui.controllers.TickBoxControl;
+import dev.isxander.yacl.gui.controllers.slider.DoubleSliderControl;
+import dev.isxander.yacl.gui.controllers.slider.FloatSliderControl;
+import dev.isxander.yacl.gui.controllers.slider.IntegerSliderControl;
+import net.minecraft.client.gui.widget.ButtonWidget;
+import net.minecraft.text.Text;
+
+public class ModMenuIntegration implements ModMenuApi {
+ @Override
+ public ConfigScreenFactory<?> getModConfigScreenFactory() {
+ return (parent) -> YetAnotherConfigLib.createBuilder(Text.of("Test GUI"))
+ .category(ConfigCategory.createBuilder()
+ .name(Text.of("Control Examples"))
+ .option(Option.createBuilder(boolean.class)
+ .name(Text.of("Tick Box"))
+ .tooltip(Text.of("Super long tooltip that is very descriptive to show off the text wrapping features of the thingy yes whwowwoow"))
+ .binding(
+ false,
+ () -> TestSettings.tickbox,
+ (value) -> TestSettings.tickbox = value
+ )
+ .controller(TickBoxControl::new)
+ .build())
+ .option(Option.createBuilder(int.class)
+ .name(Text.of("Int Slider that is cut off because the slider"))
+ .binding(
+ 0,
+ () -> TestSettings.intSlider,
+ (value) -> TestSettings.intSlider = value
+ )
+ .controller(opt -> new IntegerSliderControl(opt, 0, 3, 1))
+ .build())
+ .option(Option.createBuilder(double.class)
+ .name(Text.of("Double Slider"))
+ .binding(
+ 0.0,
+ () -> TestSettings.doubleSlider,
+ (value) -> TestSettings.doubleSlider = value
+ )
+ .controller(opt -> new DoubleSliderControl(opt, 0, 3, 0.05))
+ .build())
+ .option(Option.createBuilder(float.class)
+ .name(Text.of("Float Slider"))
+ .binding(
+ 0f,
+ () -> TestSettings.floatSlider,
+ (value) -> TestSettings.floatSlider = value
+ )
+ .controller(opt -> new FloatSliderControl(opt, 0, 3, 0.1f))
+ .build())
+ .option(Option.createBuilder(TestSettings.Alphabet.class)
+ .name(Text.of("Enum Cycler"))
+ .binding(
+ TestSettings.Alphabet.A,
+ () -> TestSettings.enumOption,
+ (value) -> TestSettings.enumOption = value
+ )
+ .controller(opt -> new EnumControl<>(opt, TestSettings.Alphabet.class))
+ .build())
+ .option(ButtonOption.createBuilder()
+ .name(Text.of("Button \"Option\""))
+ .action(() -> System.out.println("aha!"))
+ .controller(ActionControl::new)
+ .build())
+ .build())
+ .category(ConfigCategory.createBuilder()
+ .name(Text.of("Group Test"))
+ .option(Option.createBuilder(boolean.class)
+ .name(Text.of("Root Test"))
+ .binding(
+ false,
+ () -> TestSettings.groupTestRoot,
+ value -> TestSettings.groupTestRoot = value
+ )
+ .controller(TickBoxControl::new)
+ .build())
+ .group(OptionGroup.createBuilder()
+ .name(Text.of("First Group"))
+ .option(Option.createBuilder(boolean.class)
+ .name(Text.of("First Group Test 1"))
+ .binding(
+ false,
+ () -> TestSettings.groupTestFirstGroup,
+ value -> TestSettings.groupTestFirstGroup = value
+ )
+ .controller(TickBoxControl::new)
+ .build())
+ .option(Option.createBuilder(boolean.class)
+ .name(Text.of("First Group Test 2"))
+ .binding(
+ false,
+ () -> TestSettings.groupTestFirstGroup2,
+ value -> TestSettings.groupTestFirstGroup2 = value
+ )
+ .controller(TickBoxControl::new)
+ .build())
+ .build())
+ .group(OptionGroup.createBuilder()
+ .name(Text.empty())
+ .option(Option.createBuilder(boolean.class)
+ .name(Text.of("Second Group Test"))
+ .binding(
+ false,
+ () -> TestSettings.groupTestSecondGroup,
+ value -> TestSettings.groupTestSecondGroup = value
+ )
+ .controller(TickBoxControl::new)
+ .build())
+ .build())
+ .build())
+ .build().generateScreen(parent);
+ }
+
+ private static class TestSettings {
+ private static boolean tickbox = false;
+ private static int intSlider = 0;
+ private static double doubleSlider = 0;
+ private static float floatSlider = 0;
+ private static Alphabet enumOption = Alphabet.A;
+
+ private static boolean groupTestRoot = false;
+ private static boolean groupTestFirstGroup = false;
+ private static boolean groupTestFirstGroup2 = false;
+ private static boolean groupTestSecondGroup = false;
+
+ public enum Alphabet {
+ A, B, C
+ }
+ }
+}