Skip to main content

shuyi_ui/
lib.rs

1//! Shuyi Engine's UI, independent of any window or platform (game ADR-0004).
2//! So far:
3//!
4//! - the [`frame`] every screen draws into (a console of glyph cells the
5//!   game sizes, pictures, a backdrop, colors by name, the text form the
6//!   snapshot tests read and the one-bit renderer);
7//! - [`input`]: a game's actions from keys and controller buttons through
8//!   a keymap, held keys and repeat, the player's saved bindings and the
9//!   names of keys in help text;
10//! - [`basic`]: [`BasicData`], a ready-made [`GameData`] read from the
11//!   files every game on the short path has;
12//! - [`screen`]s on a stack, the context they share ([`ctx`]: [`Ctx`],
13//!   with the game's part in it, [`GameData`]) and the frame loop
14//!   ([`game`]: [`Game`]), a stage's rules run in fixed steps
15//!   ([`tick`]: `TickDriver`), with the player's [`settings`] and
16//!   [`profiles`], [`storage`], [`audio`] requests and the music, and
17//!   [`text`] placeholders;
18//! - the [`frame_cap`]: the most frames a second the platform shows, the
19//!   game's default and the player's setting, asked for and confirmed by
20//!   the platform's report;
21//! - a [`module`] from outside the default engine joining a running
22//!   [`Game`]: its hooks and its state on the [`Ctx`];
23//! - a `toy` game to try things on (the `toy` feature); the test Harness
24//!   that drives a game without a window is `shuyi_platform::harness`;
25//! - the [`system_keyboard`] a text box may ask the platform for;
26//! - the [`platform_facts`]: where the game runs, which screens read
27//!   instead of a `cfg!` ([`Ctx::platform`]);
28//! - the engine's [`log`]: lines with a level, a category and a frame,
29//!   given through [`Ctx::log`];
30//! - [`perf`]: frame times and the spans a game marks
31//!   ([`Ctx::span`]), as data, in debug builds;
32//! - the float methods `core` lacks, for the `no_std` build ([`float`]);
33//! - [`ease`]: `shuyi_core`'s integer ease curves for a skin that works in
34//!   floats.
35//!
36//! - [`widgets`] screens are built from (that module lists them);
37//! - [`screens`] any game can use, with the game's rows (that module
38//!   lists them);
39//! - [`dialogue`]: a `.dlg` scene played one text box at a time;
40//! - one-time [`tips`] and which have been shown;
41//! - the developer's [`debug`] screens;
42//! - a [`hurry`] clock for something timed the player can hurry by
43//!   holding a key and finish with a press;
44//! - [`cinematic`]s: a timeline of a game's shots, each frame drawn from
45//!   the time alone;
46//! - the tactics kit's [`grid`] map: a scene of the visible tiles generic
47//!   over the game's units, the glyph and sprite skins that paint it (the
48//!   game's units by its own painter), the tile camera, the virtual
49//!   cursor, a path that follows it and how long a walk is shown.
50#![cfg_attr(not(feature = "std"), no_std)]
51
52extern crate alloc;
53
54/// What `std`'s prelude gives for free, for the `no_std` build.
55mod prelude {
56    pub use alloc::borrow::ToOwned;
57    pub use alloc::boxed::Box;
58    pub use alloc::string::{String, ToString};
59    pub use alloc::vec::Vec;
60    pub use alloc::{format, vec};
61
62    #[cfg(not(feature = "std"))]
63    pub use crate::float::{Float, Round};
64}
65
66pub mod audio;
67pub mod basic;
68pub mod cinematic;
69pub mod ctx;
70pub mod debug;
71pub mod dialogue;
72pub mod ease;
73pub mod float;
74pub mod frame;
75pub mod frame_cap;
76pub mod game;
77pub mod grid;
78pub mod hurry;
79pub mod input;
80pub mod log;
81pub mod module;
82pub mod perf;
83pub mod platform_facts;
84pub mod profiles;
85pub mod screen;
86pub mod screens;
87pub mod settings;
88pub mod storage;
89pub mod system_keyboard;
90pub mod text;
91pub mod tick;
92pub mod tips;
93#[cfg(any(test, feature = "toy"))]
94pub mod toy;
95pub mod widgets;
96
97pub use basic::BasicData;
98pub use ctx::{Ctx, GameData, IdleMotion, KeyPrompt, Keyboard};
99pub use game::{FrameOutput, Game, GameHooks, RawInputEvent, ScreenHook};
100pub use hurry::HurryClock;
101pub use platform_facts::PlatformFacts;
102pub use screen::{FrameInput, Screen, ScreenResult, ScreenStack, Transition};
103
104/// Whether this build offers the developer's tools: debug builds, and
105/// release builds with the `debug-tools` feature. Then the keys of the
106/// actions no player can rebind (a debug key) stay out of the player's
107/// reach; otherwise those keys are free to bind.
108pub const DEBUG_TOOLS: bool = cfg!(any(debug_assertions, feature = "debug-tools"));