Class SettingDef¶
Namespace: Apogee.Host
Assembly: Apogee.Host.dll
The schema of one setting: its key (dotted lower-case words, such as audio.volume or mod.coolmod.show_hints), its type, its default, and for a number its range or for a choice its
choices. The values themselves live in a
public sealed record SettingDef : IEquatable<SettingDef>
Inheritance¶
Implements¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors¶
SettingDef(string, SettingType, Value, double, double, IReadOnlyList<string>?, bool, string?, string?)¶
The schema of one setting: its key (dotted lower-case words, such as audio.volume or mod.coolmod.show_hints), its type, its default, and for a number its range or for a choice its
choices. The values themselves live in a
public SettingDef(string Key, SettingType Type, Value Default, double Min = -Infinity, double Max = Infinity, IReadOnlyList<string>? Choices = null, bool Restart = false, string? Help = null, string? Owner = null)
Parameters¶
Key string
Two or more words of a-z, 0-9 and _, joined by dots.
Type SettingType
What the setting holds.
Default Value
The value a player who never changed it has: a boolean, an integer, a float or a string, as Type says.
Min double
The lowest a number may be (a smaller one is raised to it).
Max double
The highest a number may be.
Choices IReadOnlyList<string>?
For
Restart bool
Changing it takes effect at the next start of the game, not at once (
Help string?
One line for the options menu, or null.
Owner string?
Who defined it: the id of a script's owner (base, a mod's id), or null for the engine's own.
Properties¶
Choices¶
For
public IReadOnlyList<string>? Choices { get; init; }
Property Value¶
Default¶
The value a player who never changed it has: a boolean, an integer, a float or a string, as Type says.
public Value Default { get; init; }
Property Value¶
Help¶
One line for the options menu, or null.
public string? Help { get; init; }
Property Value¶
Key¶
Two or more words of a-z, 0-9 and _, joined by dots.
public string Key { get; init; }
Property Value¶
Max¶
The highest a number may be.
public double Max { get; init; }
Property Value¶
Min¶
The lowest a number may be (a smaller one is raised to it).
public double Min { get; init; }
Property Value¶
Owner¶
Who defined it: the id of a script's owner (base, a mod's id), or null for the engine's own.
public string? Owner { get; init; }
Property Value¶
Restart¶
Changing it takes effect at the next start of the game, not at once (
public bool Restart { get; init; }
Property Value¶
Type¶
What the setting holds.
public SettingType Type { get; init; }
Property Value¶
Methods¶
Format(Value)¶
The text of a value as the file holds it, in the invariant culture.
public static string Format(Value value)
Parameters¶
value Value
Returns¶
IsValidKey(string)¶
Whether key is a valid key.
public static bool IsValidKey(string key)
Parameters¶
key string
Returns¶
OfBool(string, bool, bool, string?, string?)¶
A boolean setting.
public static SettingDef OfBool(string key, bool defaultValue, bool restart = false, string? help = null, string? owner = null)
Parameters¶
key string
defaultValue bool
restart bool
help string?
owner string?
Returns¶
OfChoice(string, string, IReadOnlyList<string>, bool, string?, string?)¶
A setting that is one of a few words.
public static SettingDef OfChoice(string key, string defaultValue, IReadOnlyList<string> choices, bool restart = false, string? help = null, string? owner = null)
Parameters¶
key string
defaultValue string
choices IReadOnlyList<string>
restart bool
help string?
owner string?
Returns¶
OfInt(string, long, double, double, bool, string?, string?)¶
A whole-number setting.
public static SettingDef OfInt(string key, long defaultValue, double min = -Infinity, double max = Infinity, bool restart = false, string? help = null, string? owner = null)
Parameters¶
key string
defaultValue long
min double
max double
restart bool
help string?
owner string?
Returns¶
OfNumber(string, double, double, double, bool, string?, string?)¶
A number setting.
public static SettingDef OfNumber(string key, double defaultValue, double min = -Infinity, double max = Infinity, bool restart = false, string? help = null, string? owner = null)
Parameters¶
key string
defaultValue double
min double
max double
restart bool
help string?
owner string?
Returns¶
OfString(string, string, bool, string?, string?)¶
A text setting.
public static SettingDef OfString(string key, string defaultValue, bool restart = false, string? help = null, string? owner = null)
Parameters¶
key string
defaultValue string
restart bool
help string?
owner string?
Returns¶
TryParse(string, out Value)¶
Reads the text of a value in the file. False when it does not read as this type (a number out of range is clamped, as
public bool TryParse(string text, out Value value)
Parameters¶
text string
value Value
Returns¶
TryParseType(string, out SettingType)¶
The type a script's name stands for.
public static bool TryParseType(string name, out SettingType type)
Parameters¶
name string
type SettingType
Returns¶
TypeName(SettingType)¶
The name scripts use for a type: bool, int, number, string, choice.
public static string TypeName(SettingType type)
Parameters¶
type SettingType