dao::options::Choice
struct
A choice of one of a few named values in a plugin’s section.
get and set work as they do for a Toggle, but with the index of a value in values in place of a bool. wanted is always a valid index. Dragging a slider across several stops calls set once for each. As the screen opens, the choice shows the last value get or set returned (the first value before either has run), then switches to what get returns. A dropdown’s list opens downward over the rows under it.
dao::options::AddSection(L"Turn-based", {}, {{
.name = L"TurnBasedSpeed",
.label = L"Turn speed",
.tooltip = L"How fast the turns play",
.values = {L"0.5x", L"1x", L"1.5x", L"2x"},
.get = [] { return SpeedIndex(); },
.set = [](std::int32_t wanted) { return SetSpeedIndex(wanted); },
}});
Declared in dao/Options.h.
Fields
| Field | Type | |
|---|---|---|
defaultValue |
std::optional<std::int32_t> = std::nullopt |
The index the screen’s Restore Defaults gives it, through set, as a change would; none to leave it as it is. |
get |
std::function<std::int32_t()> |
returns the index of the chosen value |
label |
std::wstring |
the text to the left of the slider or dropdown |
name |
std::wstring |
the option’s name, as for a Toggle |
set |
std::function<std::int32_t(std::int32_t wanted)> |
applies a change, returns the new index |
style |
ChoiceStyle = ChoiceStyle::Slider |
a slider, or a dropdown |
tooltip |
std::wstring |
the text shown under the label |
values |
std::vector<std::wstring> |
the values’ names; at least two |