aboutsummaryrefslogtreecommitdiff
path: root/src/testmod
diff options
context:
space:
mode:
Diffstat (limited to 'src/testmod')
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
index cdaf3a1..e7fa794 100644
--- a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
+++ b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
@@ -3,13 +3,15 @@ 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 dev.isxander.yacl.gui.controllers.ActionController;
+import dev.isxander.yacl.gui.controllers.EnumController;
+import dev.isxander.yacl.gui.controllers.TickBoxController;
+import dev.isxander.yacl.gui.controllers.slider.DoubleSliderController;
+import dev.isxander.yacl.gui.controllers.slider.FloatSliderController;
+import dev.isxander.yacl.gui.controllers.slider.IntegerSliderController;
+import dev.isxander.yacl.gui.controllers.slider.LongSliderController;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.toast.SystemToast;
import net.minecraft.text.Text;
public class ModMenuIntegration implements ModMenuApi {
@@ -27,7 +29,7 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.tickbox,
(value) -> TestSettings.tickbox = value
)
- .controller(TickBoxControl::new)
+ .controller(TickBoxController::new)
.build())
.option(Option.createBuilder(int.class)
.name(Text.of("Int Slider that is cut off because the slider"))
@@ -36,7 +38,7 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.intSlider,
(value) -> TestSettings.intSlider = value
)
- .controller(opt -> new IntegerSliderControl(opt, 0, 3, 1))
+ .controller(opt -> new IntegerSliderController(opt, 0, 3, 1))
.build())
.option(Option.createBuilder(double.class)
.name(Text.of("Double Slider"))
@@ -45,7 +47,7 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.doubleSlider,
(value) -> TestSettings.doubleSlider = value
)
- .controller(opt -> new DoubleSliderControl(opt, 0, 3, 0.05))
+ .controller(opt -> new DoubleSliderController(opt, 0, 3, 0.05))
.build())
.option(Option.createBuilder(float.class)
.name(Text.of("Float Slider"))
@@ -54,7 +56,16 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.floatSlider,
(value) -> TestSettings.floatSlider = value
)
- .controller(opt -> new FloatSliderControl(opt, 0, 3, 0.1f))
+ .controller(opt -> new FloatSliderController(opt, 0, 3, 0.1f))
+ .build())
+ .option(Option.createBuilder(long.class)
+ .name(Text.of("Long Slider"))
+ .binding(
+ 0L,
+ () -> TestSettings.longSlider,
+ (value) -> TestSettings.longSlider = value
+ )
+ .controller(opt -> new LongSliderController(opt, 0, 1_000_000, 100))
.build())
.option(Option.createBuilder(TestSettings.Alphabet.class)
.name(Text.of("Enum Cycler"))
@@ -63,12 +74,12 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.enumOption,
(value) -> TestSettings.enumOption = value
)
- .controller(opt -> new EnumControl<>(opt, TestSettings.Alphabet.class))
+ .controller(opt -> new EnumController<>(opt, TestSettings.Alphabet.class))
.build())
.option(ButtonOption.createBuilder()
.name(Text.of("Button \"Option\""))
- .action(() -> System.out.println("aha!"))
- .controller(ActionControl::new)
+ .action(() -> SystemToast.add(MinecraftClient.getInstance().getToastManager(), SystemToast.Type.TUTORIAL_HINT, Text.of("Button Pressed"), Text.of("Button option was invoked!")))
+ .controller(ActionController::new)
.build())
.build())
.category(ConfigCategory.createBuilder()
@@ -80,7 +91,7 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.groupTestRoot,
value -> TestSettings.groupTestRoot = value
)
- .controller(TickBoxControl::new)
+ .controller(TickBoxController::new)
.build())
.group(OptionGroup.createBuilder()
.name(Text.of("First Group"))
@@ -91,7 +102,7 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.groupTestFirstGroup,
value -> TestSettings.groupTestFirstGroup = value
)
- .controller(TickBoxControl::new)
+ .controller(TickBoxController::new)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.of("First Group Test 2"))
@@ -100,7 +111,7 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.groupTestFirstGroup2,
value -> TestSettings.groupTestFirstGroup2 = value
)
- .controller(TickBoxControl::new)
+ .controller(TickBoxController::new)
.build())
.build())
.group(OptionGroup.createBuilder()
@@ -112,7 +123,7 @@ public class ModMenuIntegration implements ModMenuApi {
() -> TestSettings.groupTestSecondGroup,
value -> TestSettings.groupTestSecondGroup = value
)
- .controller(TickBoxControl::new)
+ .controller(TickBoxController::new)
.build())
.build())
.build())
@@ -124,6 +135,7 @@ public class ModMenuIntegration implements ModMenuApi {
private static int intSlider = 0;
private static double doubleSlider = 0;
private static float floatSlider = 0;
+ private static long longSlider = 0;
private static Alphabet enumOption = Alphabet.A;
private static boolean groupTestRoot = false;