TogglesList
A screen of on/off switches with no hand-placed buttons: while the game runs it makes a row for each row of a data table, its label and a Toggle button, each remembered in the save data under its own name (SaveAs, e.g. “fire.{row}”) and starting as the table’s DefaultColumn says until the player flips it. Put it on an entity with a Layout (in an options Panel), which lines the rows up and scrolls them. Every row’s Toggle is a real one, read by scripts with Game.SaveData.GetBool like a hand-placed Toggle.
Its children that hold a Toggle are its rows: it takes them away and makes them again when the table or the list changes, and leaves its other children (a heading) alone. Each plain row is an entity named after its table row with a Text for the label and a Button with a Toggle; a Template gives rows of your own. The Scene view shows sample rows where they’ll go.
Requires: Layout (it lines up the rows)
Works with: Panel (an options screen it’s on)
Draws itself (its entity draws at Order 100 unless it has a Sprite, whose order counts).
In a network game, each machine keeps its own entity with this on it: it isn’t sent.
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
table: text = null. The table with a row for each switch, e.g. “Fires” (Assets/Tables/Fires.table). (Names a table.) (Field: a name.)hide: text = null. Rows to leave out, separated by commas, with * and ? for any letters and one, e.g. “Debug*, Test” (the names of the table’s rows). (Names row of a tables: their names, separated by commas.) (Field: a name.)labelColumn: text = null. The column holding the words to show for each row. Empty shows the row’s name. (Names a column of a table.) (Field: a name.)defaultColumn: text = null. The column (yes or no) holding whether each row starts on, until the player flips it or the game has one saved. Empty starts every row on, as a Toggle does. (Names a column of a table.) (Field: a name.)saveAs: text = “{row}”. The name each row’s switch is kept under in Game.SaveData, where “{row}” is the row’s name: “fire.{row}” keeps the Rain row’s as “fire.Rain” (read it with GetBool(“fire.Rain”, true)). Without “{row}” every row would share one name. (Plain text: the save data name for each row, with {row} for the row’s name.) (Field: text.)onText: text = “On”. What a plain row’s button says while it’s on. (Plain text: words a row’s button shows while it’s on.) (Field: text.)offText: text = “Off”. What a plain row’s button says while it’s off. (Plain text: words a row’s button shows while it’s off.) (Field: text.)
template: text = null. An entity to copy for each row instead of the plain ones, by name, e.g. “Fire Row”: a disabled one in the scene styled as you like. In each copy, “{name}” in a Text becomes the row’s label and “{row}” its name, and a Toggle with no Save As is kept under SaveAs (starting as DefaultColumn says, if it names one). (Names an entity.) (Field: an entity’s name.)font: text = null. A font for the plain rows’ words, as a Text’s Text.Font. Empty uses the built-in font. (Names a font.) (Field: a name.)textSize: a number = 0.45. How tall the plain rows’ words are, in world units. (Field: a number.)color: a color, “#RRGGBB” or “#RRGGBBAA” = “#E6E8ECFF”. The color of the plain rows’ words. (Field: a color.)buttonColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#3A3F4BFF”. The color of the plain rows’ buttons. (Field: a color.)rowHeight: a number = 0.8. How tall each plain row is, in world units; it’s as wide as the Layout has room for. (Field: a number.)buttonWidth: a number = 1.6. How wide each plain row’s button is, in world units. (Field: a number.)
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
listed: lines of text: an array of strings, or one string with line breaks. The names of the table rows it lists now, in order. Kept up to date by the game.
Scripts use it as TogglesList: its methods, events and values that aren’t saved with the scene.