Skip to main content

Module ctx

Module ctx 

Source
Expand description

Ctx: what every screen shares, passed &mut to Screen::update and & to Screen::draw. The engine’s services (text by key in the player’s language, the keys and the names help text gives them, the player’s settings and profiles, sounds, music and voices, storage) and the game’s own part, Ctx::game, whose type says what the engine reads from the game’s data (GameData).

A plain struct: no service locator, no globals. A game names its own with an alias (type Ctx = shuyi_ui::Ctx<MyGame>). The engine’s services are fields; a module’s state is found by its type (Ctx::module_state), put there by its install and listed.

Structs§

Ctx
Resources shared by every screen: the engine’s, and the game’s in game.

Enums§

IdleMotion
Whether screens show their idle motion (Ctx::idle_motion).
KeyPrompt
The “press any key or button” wait (Ctx::key_prompt): browsers block sound until the player presses a key.
Keyboard
Whether the platform has a keyboard (PlatformFacts::keyboard).

Constants§

ARROWS_TEXT
The text key of the arrow keys’ name in help text (ARROWS).
CHORD_JOIN_TEXT
The text key of what joins a button chord’s two buttons in help text (A+B).
DEBUG_VIEW_KEY
Key in the computer’s Storage (not a profile’s) under which the debug view’s channels that are on are saved (DebugView::to_ron), only with debug tools on.
DEFAULT_MUSIC_SEED
Ctx::music_seed until the platform sets it.
KEYBINDINGS_KEY
Storage key under which the player’s key and controller-button bindings are saved (PlayerKeys::to_ron).
NOT_MAPPED_TEXT
The text key of what help text shows for an action with no key.
PROFILE_NUMBERED_TEXT
The text key of a profile’s name when the player hasn’t named it: Player {n}, made on a first launch.

Traits§

GameData
The game’s part of the Ctx, and what the engine reads from the game’s data through it: its actions, colors, text, keys, audio manifest and palettes, and the hooks where the game has a say.