-
Notifications
You must be signed in to change notification settings - Fork 1
Selection

Adding a ModOptionSelection object to your menu displays a Dropdown which expands to a list of items when clicked which can be selected.
ModOptionSelection myDropdown = new ModOptionSelection("mySetting", "Option Label");ModOptionSelection initialization requires only an identifier, label but can be initialized with additional arguments choices, defaultSelection and the standard enabled. You will then want to add options using its methods, and can then add it to ModOptions.
The choices argument is of type ModSelectionOptionChoices which has its own section at the end of this document. If it is left as default an empty ModSelectionOptionChoices will be assigned to ModOptionSelection.Choices to which choices can be added. If you prefer to set up the choices before initializing the ModOptionSelection it can be created, added to, then passed into the initializer.
The defaultSelection argument allows for the selection of a choice at initialization. The index must be in the range of the choices argument.
To read which dropdown value is selected check the string Selection which returns the identifier or int SelectionIndex property. The event ValueChanged is triggered every time the selection is changed through either Selection or SelectionIndex properties, except on initialization.
The mod can manually change the state of the checkbox by writing to the Selection or SelectionIndex properties. If the identifier string does exist the list or the index is out of range an exception will be thrown.
To add hover text for the selected option simply assign a string dictionary to the hoverTextDictionary property.
myDropdown.hoverTextDictionary = new Dictionary<string, string>
{
{ "choiceId1", "Hover Text Goes Here" },
{ "choiceId2", "Hover text for Always Off" }
};
// or
myDropdown.hoverTextDictionary = new Dictionary<string, string>();
myDropdown.hoverTextDictionary.Add("Identifier", "Hover Text");public ModOptionSelection(string identifier, string labelText, ModSelectionOptionChoices choices = null, int defaultSelection = 0, bool enabled = true);public ModSelectionOptionChoices Choices { get; }
public int SelectionIndex { get; set; }
public string Selection { get; set; }
public Dictionary<String, String> hoverTextDictionary { get; set; }public delegate void ModOptionSelectionHandler(string ComponentIdentifier, string selectionIdentifier);
public event ModOptionSelectionHandler ValueChanged;public new string this[int key];
public string this[string identifier];
public void Insert(int index, string identifier, string label);
public void Add(string identifier, string label);
public void Remove(string identifier);
public bool Contains(string identifier);
public int IndexOf(string identifier);
public string IdentifierOf(int index);
public string LabelOf(int index);
public string LabelOf(string identifier);
public int IndexOfLabel(string label);
public string IdentifierOfLabel(string label);public List<string> Identifiers { get; }
public List<string> Labels { get; }