1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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
}
}
}
|