Skip to main content

Module prelude

Module prelude 

Source
Expand description

What a game on the short path names (ADR-0036): shuyi-platform’s prelude, and run_game, which runs it from a plain main.

Structs§

AppInfo
Who a game is. Build it with AppInfo::new and the with_ setters: a struct literal doesn’t compile outside this crate, so a new field never breaks a game (ADR-0039).
BasicData
A game’s data on the short path: what the engine reads from the standard files, the files themselves and the game’s own part T. Its actions are A (most simply UiAction), its colours the engine’s.
BasicGame
A game on the short path: its data is a BasicData of actions A and its own part T, read from one layer of files.
Bundle
The layers a game reads its files from.
Cell
One console cell: a glyph with foreground and background colours.
ConsoleSpec
A console’s size: cols × rows cells of cell_w × cell_h logical pixels. The frame (GlyphBuffer) keeps the spec it was made with; the game picks one when it starts (game ADR-0070 §6).
ContentError
One problem found while loading or validating an asset. Build it with ContentError::new and its methods (ADR-0039).
Ctx
Resources shared by every screen: the engine’s, and the game’s in game.
FrameInput
One frame’s input as a screen sees it.
Game
Owns the screens, input state, shared context and the console buffer.
GameHooks
Where the game has a say in the frame loop. Default has none.
GlyphBuffer
A grid of Cells, row-major.
Install
What Module::install declares with.
Layer
One layer of the bundle.
Look
What a game’s frame is painted with: the font atlas and the pictures in the game’s data. A backend makes its textures from them the first time it sees them. Build it with Look::new (ADR-0039); a game that runs on a one-bit display adds Look::with_one_bit (ADR-0062).
Rect
A rectangle of cells. A non-positive w or h means empty.
Rgb
A 24-bit RGB colour. Ordered red, then green, then blue: an order for maps, not a look.
ScreenResult
A value a screen pops with (Transition::PopWith) for the screen below, which reads it back as its type in Screen::uncovered. Any 'static type will do; the two screens agree on which.
Setup
What the platform gives a game as it loads: what goes into its context (ctx). A backend with more to give (the voice manifest it read) adds it with Start::before_load.
Start
How a game starts: the card shown while it loads, the load, where its look is and its hook for the system’s events. Built with Start::new, its optional parts set by the methods named for them (ADR-0039).

Enums§

BoxStyle
Border style for GlyphBuffer::draw_box (game ADR-0012: single for panels, double for focus/modal).
Card
What the screen shows while the game’s data loads, from the first frame (a slow device takes seconds to load a game, and shows nothing until a frame is drawn). Drawn by the backend with what it has of its own, since the game’s font isn’t loaded yet.
EngineColor
The colors the engine’s own widgets ask for. A game’s ColorSet says which of its palette’s names each one is (engine_name).
Hook
A place in the frame loop where the game calls a module.
Transition
What a screen asks the stack to do after an update.
UiAction
What the generic widgets (a menu), the Key bindings screen and the debug hook react to. A game maps some of its actions onto these with ActionSet::ui; the rest are its own business.

Traits§

ActionSet
Everything a player can ask for in one game: the game’s action enum. The keymap file, the keymap, held keys and repeat, the player’s saved bindings and help text are all built on it, never on one game’s actions.
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.
Module
A piece that joins a running game: the game installs it with Game::with_module, and calls only the hooks its install declares, in install order.
Screen
One screen of a game: a title, a map, a menu overlay, …

Functions§

print_centred
Prints text centred on row y. A text wider than buf starts at column 0, cut to the buffer’s width.
run_game
Runs a game on the short path until it quits, in a window of its console at twice its size: its files become the process’s bundle, and run starts it as BasicGame::start says, with no sounds, no voices and no system keyboard. Called from a plain fn main. Under cargo shuyi run --watch the game’s files on disk are laid over the embedded ones (watched_layer).