Class ChoiceAttribute
- Namespace
- Nautilus.Options.Attributes
- Assembly
- Nautilus.dll
Attribute used to signify the decorated member should be represented in the mod's options menu as a
ModChoiceOption<T>. Works for either int index-based, string-based, or
Enum-based members.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)]
public sealed class ChoiceAttribute : ModOptionAttribute, _Attribute
- Inheritance
-
ChoiceAttribute
- Implements
- Inherited Members
- Extension Methods
Examples
using Nautilus.Json;
using Nautilus.Options;
public enum CustomChoice { One, Two, Three }
[Menu("My Options Menu")]
public class Config : ConfigFile
{
[Choice("My index-based choice", "One", "Two", "Three")]
public int MyIndexBasedChoice;
[Choice]
public CustomChoice MyEnumBasedChoice;
}
Remarks
Enum choices can also be parsed from their values by merely omitting the ChoiceAttribute.
Constructors
ChoiceAttribute()
Attribute used to signify the decorated member should be represented in the mod's options menu as a
ModChoiceOption<T>. Works for either int index-based, string-based, or
Enum-based members.
public ChoiceAttribute()
ChoiceAttribute(string, params string[])
Attribute used to signify the decorated member should be represented in the mod's options menu as a
ModChoiceOption<T>. Works for either int index-based, string-based, or
Enum-based members.
public ChoiceAttribute(string label = null, params string[] options)
Parameters
label
string- The label for the choice. If none is set, the name of the member will be used.
options
string[]- The list of options for the user to choose from.
Remarks
Enum choices can also be parsed from their values by merely omitting the
options
.ChoiceAttribute(string[])
Attribute used to signify the decorated member should be represented in the mod's options menu as a
ModChoiceOption<T>. Works for either int index-based, string-based, or
Enum-based members.
public ChoiceAttribute(string[] options)
Parameters
options
string[]- The list of options for the user to choose from.
Remarks
Enum choices can also be parsed from their values by merely omitting the
options
.Properties
Options
The list of options that will be displayed.
public string[] Options { get; set; }
Property Value
- string[]