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
OptionsViewas 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 anotherpaintof the same view. - view
- What the Options screen shows, as plain data: no cells, glyphs, colours
or positions. The screen builds an
OptionsVieweach frame (OptionsScreen::view) and a skin paints it (super::glyph::painttoday). 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§
- Number
Box - 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.
- Option
Row - One row of an options screen, as the game gives it.
- Options
Screen - 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_nowhile it is open).
Enums§
- Leave
Choice - An answer to the question asked on leaving with changes
(
LEAVE_QUESTION). - RowAction
- What Confirm on an
RowValue::Actionrow does. - RowValue
- What a row shows beside its label, and what changes it. Build it with
RowValue::toggle,choice,volumeoraction: 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 beforecurrent, stopping at the ends (wrap: going round instead). A value not inallsteps 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
ctxshows, top to bottom.