Generate interpolator settings from InterpolatorType enum
This commit is contained in:
@@ -14,6 +14,7 @@ public enum InterpolatorType {
|
||||
CUBIC("cubic", CubicSplineInterpolator.class, CubicSplineInterpolator::new),
|
||||
LINEAR("linear", LinearInterpolator.class, LinearInterpolator::new);
|
||||
|
||||
@Getter
|
||||
private String localizationKey;
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -2,22 +2,24 @@ package com.replaymod.simplepathing;
|
||||
|
||||
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 static final Setting<Boolean> PATH_PREVIEW = make("pathpreview", "pathpreview", true);
|
||||
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> DEFAULT_INTERPOLATION =
|
||||
new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
||||
"simplepathing", "interpolator", "replaymod.gui.settings.interpolator",
|
||||
"replaymod.gui.editkeyframe.interpolator.cubic.name");
|
||||
public static final SettingsRegistry.MultipleChoiceSettingKeys<String> DEFAULT_INTERPOLATION;
|
||||
|
||||
static {
|
||||
DEFAULT_INTERPOLATION.setChoices(new ArrayList<String>() {
|
||||
{
|
||||
add("replaymod.gui.editkeyframe.interpolator.cubic.name");
|
||||
add("replaymod.gui.editkeyframe.interpolator.linear.name");
|
||||
}
|
||||
});
|
||||
String format = "replaymod.gui.editkeyframe.interpolator.%s.name";
|
||||
DEFAULT_INTERPOLATION = new SettingsRegistry.MultipleChoiceSettingKeys<>(
|
||||
"simplepathing", "interpolator", "replaymod.gui.settings.interpolator",
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user