aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/dev/isxander/yacl/gui/controllers
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-05-26 17:59:59 +0100
committerisXander <xandersmith2008@gmail.com>2023-05-26 17:59:59 +0100
commitbaf4828a710b218b2f51fd7418f01818dea38d92 (patch)
treeffcb852bf4ce837c47e5d85ffcb346810126f4c3 /common/src/main/java/dev/isxander/yacl/gui/controllers
parentc00071184f469664fe8c9cd2876c2818a80df2d9 (diff)
downloadYetAnotherConfigLib-baf4828a710b218b2f51fd7418f01818dea38d92.tar.gz
YetAnotherConfigLib-baf4828a710b218b2f51fd7418f01818dea38d92.tar.bz2
YetAnotherConfigLib-baf4828a710b218b2f51fd7418f01818dea38d92.zip
API layer for built-in controllers
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl/gui/controllers')
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/CyclingListController.java4
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/EnumController.java21
2 files changed, 4 insertions, 21 deletions
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/CyclingListController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/CyclingListController.java
index 34f2cc9..43fa766 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/CyclingListController.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/CyclingListController.java
@@ -21,7 +21,7 @@ public class CyclingListController<T> implements ICyclingController<T> {
* @param option option of which to bind the controller to
* @param values the values to cycle through
*/
- public CyclingListController(Option<T> option, Iterable<T> values) {
+ public CyclingListController(Option<T> option, Iterable<? extends T> values) {
this(option, values, value -> Component.literal(value.toString()));
}
@@ -31,7 +31,7 @@ public class CyclingListController<T> implements ICyclingController<T> {
* @param values the values to cycle through
* @param valueFormatter function of how to convert each value to a string to display
*/
- public CyclingListController(Option<T> option, Iterable<T> values, Function<T, Component> valueFormatter) {
+ public CyclingListController(Option<T> option, Iterable<? extends T> values, Function<T, Component> valueFormatter) {
this.option = option;
this.valueFormatter = valueFormatter;
this.values = ImmutableList.copyOf(values);
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/EnumController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/EnumController.java
index ebd2cb6..281f182 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/EnumController.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/cycling/EnumController.java
@@ -26,25 +26,8 @@ public class EnumController<T extends Enum<T>> extends CyclingListController<T>
};
}
- /**
- * Constructs a cycling enum controller with a default value formatter and all values being available.
- * The default value formatter first searches if the
- * enum is a {@link NameableEnum} or {@link OptionEnum} else, just uses {@link Enum#toString()}
- *
- * @param option bound option
- */
- public EnumController(Option<T> option) {
- this(option, getDefaultFormatter());
- }
-
- /**
- * Constructs a cycling enum controller with all values being available.
- *
- * @param option bound option
- * @param valueFormatter format the enum into any {@link Component}
- */
- public EnumController(Option<T> option, Function<T, Component> valueFormatter) {
- this(option, valueFormatter, option.typeClass().getEnumConstants());
+ public EnumController(Option<T> option, Class<T> enumClass) {
+ this(option, getDefaultFormatter(), enumClass.getEnumConstants());
}
/**