dao::options::Toggle

struct

A checkbox in a plugin’s section.

get runs each time the screen opens. set runs when the player clicks the box, and returns the option’s value after the click: wanted to accept the change, or the old value to refuse it. The box shows whatever set returns. Both run on the game thread (dao/Frame.h), so they may call script commands. A change takes effect at the click; the screen’s Cancel then gives set back the value the option had as the screen opened, and OK keeps the change.

Declared in dao/Options.h.

Fields

Field Type  
defaultValue std::optional<bool> = std::nullopt The value the screen’s Restore Defaults gives it, through set, as a click would; none to leave it as it is.
get std::function<bool()> returns the option’s value; required
label std::wstring the text beside the box
name std::wstring The option’s name: letters and digits, starting with a letter. Prefix it with the plugin’s name, for example “TurnBasedCombat”, so that it cannot clash with another plugin’s.
set std::function<bool(bool wanted)> applies a click and returns the new value; required
tooltip std::wstring the text shown when the mouse is over the box