Description:
Default float parser.
Added In: v0.45
public class UMFConfigFloat : UMFConfigParser<float> { public float DefaultValue; public float MinValue; public float MaxValue; public int Decimals; public float VanillaValue; public bool RequiresRestart; public float[] AllowedValues; public UMFConfigFloat(float defaultValue = default(float), float minValue = default(float), float maxValue = default(float), int decimals = 1, float vanillaValue = default(float), bool requiresRestart = false, params float[] allowedValues) { DefaultValue = defaultValue; MinValue = Math.Min(minValue, maxValue); MaxValue = Math.Max(minValue, maxValue); Decimals = decimals; VanillaValue = vanillaValue; RequiresRestart = requiresRestart; AllowedValues = allowedValues; } public override float Parse(string value) { if (!float.TryParse(value, out float result)) result = DefaultValue; return result; } public override string ToString() { return DefaultValue.ToString(); } public override string Default() { return DefaultValue.ToString(); } public override string Range() { return (MaxValue != default(float) ? MinValue.ToString() + "," + MaxValue.ToString() + "," + Decimals.ToString() : null); } public override string Vanilla() { return (VanillaValue != default(float) ? VanillaValue.ToString() : null); } public override string Allowed() { return (AllowedValues.Length > 0 ? string.Join(",", AllowedValues.Select(x => x.ToString()).ToArray()) : null); } public override string Restart() { return RequiresRestart.ToString(); } }
//Coming soon
//Coming soon