Skip to main content

Module options

Module options 

Source
Expand description

An options screen: the player’s settings one per row, changed with the cursor’s left and right keys, and rows that do something (open a screen, ask a question). The game gives the rows (OptionRow), each a label key and a typed value: on or off (RowValue::Toggle), one of several (RowValue::Choice), a volume (RowValue::Volume), or something Confirm does (RowValue::Action). The engine’s own settings come as rows ready made (OptionRow::text_speed, OptionRow::fullscreen, OptionRow::frame_cap, the volumes, OptionRow::restore_defaults).

A change shows at once but is saved only when the player keeps it: leaving with anything changed asks whether to keep it, throw it away or stay (LeaveChoice). A row whose value isn’t a setting (OptionRow::unsaved) is kept or put back with them. A volume goes from 0 to MAX_VOLUME: left and right move its slider, Confirm opens a box to type the exact number (NumberBox). Whatever does something big asks first (Question).

The look is a skin. This module decides what the screen shows and does, and says it as plain data: an OptionsView (OptionsScreen::view). glyph::paint draws that view as glyphs, unless the game gives another painter (OptionsScreen::painted_by). Nothing here knows a cell, a colour or a position, so another look (a bought UI pack, another device’s screen) is another painter of the same view. Tests of what happened read the view or the settings; only the painters’ tests read cells.

Re-exports§

pub use view::OptionsView;
pub use view::RowView;
pub use view::ValueView;

Modules§

glyph
The glyph look of the Options screen: paints an OptionsView as a panel of text rows, in the style of the Key bindings screen. Everything about the look lives here (where things go, the box characters, the slider’s blocks, the colours); nothing here decides what the screen shows or does. Another look is another paint of the same view.
view
What the Options screen shows, as plain data: no cells, glyphs, colours or positions. The screen builds an OptionsView each frame (OptionsScreen::view) and a skin paints it (super::glyph::paint today). Swapping the look (a bought UI pack) means another painter of the same view; the screen’s logic and its tests of what happened don’t change.

Structs§

NumberBox
The box that takes a volume’s exact number. From the keyboard the digits are typed (the game’s keys do nothing meanwhile; the text box’s fixed keys finish, delete and cancel). Opened with a controller button it holds the volume, and the cursor steps it by one.
OptionRow
One row of an options screen, as the game gives it.
OptionsScreen
The options screen. Cancel closes it, asking first if anything changed.
Question
A yes/no question asked before something that can’t be taken back with one key (Ask::yes_no while it is open).

Enums§

LeaveChoice
An answer to the question asked on leaving with changes (LEAVE_QUESTION).
RowAction
What Confirm on an RowValue::Action row does.
RowValue
What a row shows beside its label, and what changes it. Build it with RowValue::toggle, choice, volume or action: kinds of row and their fields may come, and never break a game (ADR-0039).

Constants§

FRAME_CAP_ROW
Text key of the Frame rate row’s label (OptionRow::frame_cap).
FULLSCREEN_ROW
Text key of the Fullscreen row’s name (OptionRow::fullscreen).
HELP_CHANGE
Text key of the help line on a row whose value the cursor changes.
HELP_LEAVE
Text key of the help line while the question asked on leaving is open.
HELP_NUMBER_PAD
Text key of the help line while the volume box is open on a controller.
HELP_OPEN
Text key of the help line on a row that opens a screen.
HELP_QUESTION
Text key of the help line while a yes/no question is open.
HELP_VOLUME
Text key of the help line on a volume.
LEAVE_QUESTION
Text key of the question asked on leaving with changes.
NOT_SAVED_MESSAGE
Text key of the message if something couldn’t be saved.
ON_OFF
Text keys of an on/off value: off, then on.
QUESTION_ANSWERS
Text key of how a yes/no question is answered, with the keys (Ask::yes_no).
RESTORED_MESSAGE
Text key of the message once the defaults are back.
TITLE
Text key (Ctx::text) of the screen title.
VOLUME_STEP
How far the cursor’s left and right keys move a volume’s slider. Tunable.

Functions§

stepped
all’s value one step after (forward) or before current, stopping at the ends (wrap: going round instead). A value not in all steps from the first.

Type Aliases§

Paint
What paints the screen’s view: glyph::paint, or the game’s own (OptionsScreen::painted_by).
Rows
The game’s rows, as they are now: the ones ctx shows, top to bottom.