Skip to main content

GameData

Trait GameData 

Source
pub trait GameData:
    Sized
    + Debug
    + 'static {
    type Action: ActionSet;
    type Colors: ColorSet;
    type Voice: ClipVariant;
    type Settings: GameSettings;

Show 15 methods // Required methods fn lang(&self) -> &Lang; fn keymap_def(&self) -> &KeymapDef<Self::Action>; fn audio_manifest(&self) -> &AudioManifest; fn palette_def(&self) -> &PaletteDef; fn console(&self) -> ConsoleSpec; // Provided methods fn theme_def( &self, theme: <Self::Settings as GameSettings>::Theme, ) -> Option<&PaletteDef> { ... } fn audio_config(&self) -> AudioConfig { ... } fn debug_lang(&self) -> Option<&str> { ... } fn key_text( &self, name: &str, keys: HelpKeys<'_, Self::Action>, ) -> Option<String> { ... } fn voice_variant(&self) -> Self::Voice { ... } fn voices(&self, _manifest: &str) -> Result<Playable<Self::Voice>, String> { ... } fn apply_settings( &mut self, _now: &Settings<Self::Settings>, _before: Option<&Settings<Self::Settings>>, ) { ... } fn blank_cell(&self, palette: &Palette) -> Cell { ... } fn keys_before_profiles(&self) -> Vec<String> { ... } fn old_layout_key(&self) -> Option<&'static str> { ... }
}
Expand description

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.

Required Associated Types§

Source

type Action: ActionSet

The game’s input actions.

Source

type Colors: ColorSet

The colors the game’s code draws with.

Source

type Voice: ClipVariant

Which of a voiced line’s clips plays.

Source

type Settings: GameSettings

The settings the game adds to the engine’s, and their saved form.

Required Methods§

Source

fn lang(&self) -> &Lang

The screen text by key, in every language.

Source

fn keymap_def(&self) -> &KeymapDef<Self::Action>

The keymap file: every layout’s default keys, the layout picker’s and the controller buttons.

Source

fn audio_manifest(&self) -> &AudioManifest

The sound and music cues.

Source

fn palette_def(&self) -> &PaletteDef

The palette the game starts with, before the settings are read.

Source

fn console(&self) -> ConsoleSpec

The console the game starts on (Ctx::console).

Provided Methods§

Source

fn theme_def( &self, theme: <Self::Settings as GameSettings>::Theme, ) -> Option<&PaletteDef>

The palette of a color theme; None keeps the palette there is. By default the game has one palette: always None.

Source

fn audio_config(&self) -> AudioConfig

Which of the game’s sound cues the engine’s widgets and screens play for a menu’s moves and choices and a cursor’s steps: by default the cues named after what they are (AudioConfig::DEFAULT).

Source

fn debug_lang(&self) -> Option<&str>

The language only a build with debug tools shows (a test pack), if the game has one: without debug tools it is English.

Source

fn key_text( &self, name: &str, keys: HelpKeys<'_, Self::Action>, ) -> Option<String>

The text of a {name} placeholder that names a key (Ctx::text_with): by default the cursor keys for {Cursor} and the key of the action called name (text::key_text); None leaves it as written.

Source

fn voice_variant(&self) -> Self::Voice

Which clip of a line plays now, where a line has several (who the player made the hero, say). By default the variant’s default: a line’s only clip.

Source

fn voices(&self, _manifest: &str) -> Result<Playable<Self::Voice>, String>

The clips that may be played, from the text of the voice manifest the platform read: those whose line still says what they say. Err says why the manifest can’t be used. By default the game has no voices, and a manifest is refused.

Source

fn apply_settings( &mut self, _now: &Settings<Self::Settings>, _before: Option<&Settings<Self::Settings>>, )

Takes what the settings say that the game draws with (a map’s look, say): before is what they were (None when they were just loaded). The engine applies the theme itself.

Source

fn blank_cell(&self, palette: &Palette) -> Cell

The cell the frame is cleared to before the screens draw: by default a blank in the engine’s text color on its panel color.

Source

fn keys_before_profiles(&self) -> Vec<String>

The Storage keys the game kept a player’s data under before it had profiles: a first launch with profiles moves them into the first one (profiles::migrate). None by default.

Source

fn old_layout_key(&self) -> Option<&'static str>

The Storage key a layout’s name was saved under before the settings held it, if the game had one: still read when the settings name none, never written.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<A, T> GameData for BasicData<A, T>
where A: ActionSet, T: Debug + 'static,