Generate interpolator settings from InterpolatorType enum
This commit is contained in:
@@ -14,6 +14,7 @@ public enum InterpolatorType {
|
|||||||
CUBIC("cubic", CubicSplineInterpolator.class, CubicSplineInterpolator::new),
|
CUBIC("cubic", CubicSplineInterpolator.class, CubicSplineInterpolator::new),
|
||||||
LINEAR("linear", LinearInterpolator.class, LinearInterpolator::new);
|
LINEAR("linear", LinearInterpolator.class, LinearInterpolator::new);
|
||||||
|
|
||||||
|
@Getter
|
||||||
private String localizationKey;
|
private String localizationKey;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -2,22 +2,24 @@ package com.replaymod.simplepathing;
|
|||||||
|
|
||||||
import com.replaymod.core.SettingsRegistry;
|
import com.replaymod.core.SettingsRegistry;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
||||||
public static final Setting<Boolean> PATH_PREVIEW = make("pathpreview", "pathpreview", true);
|
public static final Setting<Boolean> PATH_PREVIEW = make("pathpreview", "pathpreview", true);
|
||||||
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> DEFAULT_INTERPOLATION =
|
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> DEFAULT_INTERPOLATION;
|
||||||
new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
|
||||||
"simplepathing", "interpolator", "replaymod.gui.settings.interpolator",
|
|
||||||
"replaymod.gui.editkeyframe.interpolator.cubic.name");
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DEFAULT_INTERPOLATION.setChoices(new ArrayList<String>() {
|
String format = "replaymod.gui.editkeyframe.interpolator.%s.name";
|
||||||
{
|
DEFAULT_INTERPOLATION = new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
||||||
add("replaymod.gui.editkeyframe.interpolator.cubic.name");
|
"simplepathing", "interpolator", "replaymod.gui.settings.interpolator",
|
||||||
add("replaymod.gui.editkeyframe.interpolator.linear.name");
|
String.format(format, InterpolatorType.fromString("invalid returns default").getLocalizationKey())
|
||||||
}
|
);
|
||||||
});
|
DEFAULT_INTERPOLATION.setChoices(
|
||||||
|
Arrays.stream(InterpolatorType.values()).filter(i -> i != InterpolatorType.DEFAULT)
|
||||||
|
.map(i -> String.format(format, i.getLocalizationKey()))
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
||||||
|
|||||||
Reference in New Issue
Block a user