Skip to main content

Module help_keys

Module help_keys 

Source
Expand description

Help text that names keys and controller buttons. Names always come from the active Keymap, never string literals, because each layout binds actions to different keys (game ADR-0015) and the player can rebind them (game ADR-0031); and they follow the Device the player pressed last (docs/design/controls.md, Controller): keys on the keyboard, the pad’s own button names on a controller.

Generic over the game’s ActionSet (ticket 1106).

Structs§

HelpKeys
What help text names keys from: the bindings, the device whose keys or buttons to name, the two words a key’s name can be (! not mapped, arrows) and what joins a button chord’s two buttons (A+B). A game gives its screens one with the words in the player’s language (worded). Dereferences to the Keymap.

Constants§

ARROWS
The English name of the four arrow keys together: what HelpKeys::new starts with, and what tests compare with. The game shows the language file’s word. Lives here because it names keys (only input may).
CHORD_JOIN
The English of what joins a button chord’s two buttons (A+B): what HelpKeys::new starts with, and what tests compare with. The game shows the language file’s.
NOT_MAPPED
The English of HelpKeys::not_mapped: what HelpKeys::new starts with, and what tests compare with. The game shows keys.not_mapped of the language file.
SEPARATOR
Separator between the parts of a help line.

Functions§

all_key_names
Every key for action, joined with / (e.g. f/j/Enter/Space): its slots in Keymap::chords_for order, then its fixed keys (Keymap::fixed_chords_for). On a controller, every button for it (Keymap::buttons_for). HelpKeys::not_mapped if its slots are empty.
cursor_keys_name
What moves the cursor: arrows when the four cursor actions are on the arrow keys, otherwise their keys in up-left-down-right order (wasd). On a controller, D-pad/L-stick or whatever the cursor is on (Keymap::cursor_buttons_name). HelpKeys::not_mapped if any cursor action has no key. See Keymap::cursor_keys_name.
help_line
Joins key label hints with SEPARATOR, leaving out hints whose key is None (hidden by the caller, e.g. a key that does nothing here).
key_name
The name of the key for action (its Keymap::primary chord), e.g. f or Shift+Space; on a controller, of its button or button chord (Keymap::primary_button) as that pad labels it, e.g. A or A+B. HelpKeys::not_mapped if it has none.