Skip to main content

GameSettings

Trait GameSettings 

Source
pub trait GameSettings:
    Debug
    + Clone
    + PartialEq
    + Eq
    + Default
    + 'static {
    type Theme: Debug + Copy + PartialEq + Eq + Default + 'static;

    const DEFAULT_FRAME_CAP: FrameCap = FrameCap::DEFAULT;
    const FRAME_CAP_CHOICES: &'static [FrameCap] = _;
    const BACKGROUND: Background = Background::KEEP_RUNNING;

    // Required methods
    fn to_ron(settings: &Settings<Self>) -> String;
    fn from_ron(text: &str) -> Result<Settings<Self>, String>;
}
Expand description

The settings a game adds to the engine’s, and the saved form of both: one record, so the game decides its form (and keeps the one it has always written).

Provided Associated Constants§

Source

const DEFAULT_FRAME_CAP: FrameCap = FrameCap::DEFAULT

The frame cap a new player starts with (Settings::frame_cap): 60 frames a second unless the game says otherwise (FrameCap says why).

Source

const FRAME_CAP_CHOICES: &'static [FrameCap] = _

The frame caps the options screen’s Frame rate row steps through, in order (OptionRow::frame_cap): 30, 60, 120, 144, 165 and 240 frames a second, then none, unless the game says otherwise (frame_cap::CHOICES).

Source

const BACKGROUND: Background = Background::KEEP_RUNNING

What the game does while its window has no focus (ADR-0077): it keeps running with its sound (Background::KEEP_RUNNING) unless the game says otherwise.

Required Associated Types§

Source

type Theme: Debug + Copy + PartialEq + Eq + Default + 'static

The game’s color themes, each a palette (GameData::theme_def); () for a game with one.

Required Methods§

Source

fn to_ron(settings: &Settings<Self>) -> String

The saved form of settings (RON).

Source

fn from_ron(text: &str) -> Result<Settings<Self>, String>

Reads the saved form. Text that can’t be read gives Err with why (the caller then uses the defaults); what can be repaired is.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl GameSettings for ()

No settings of the game’s own, and one palette: the engine’s settings alone, saved as one record (Settings(text_speed: Fast, …)).

Implementors§