Skip to main content

Settings

Struct Settings 

Source
pub struct Settings<S: GameSettings> {
    pub text_speed: TextSpeed,
    pub fullscreen: bool,
    pub theme: S::Theme,
    pub music_volume: u8,
    pub sound_volume: u8,
    pub voices: bool,
    pub voice_volume: u8,
    pub frame_cap: FrameCap,
    pub game: S,
    /* private fields */
}
Expand description

Everything an options screen sets: the engine’s settings and the game’s. The defaults are a new player’s.

Fields§

§text_speed: TextSpeed

How fast dialogue text is revealed.

§fullscreen: bool

Whether the game fills the screen.

§theme: S::Theme

The color theme: the palette the game draws with.

§music_volume: u8

Music volume, 0 (silent) to MAX_VOLUME.

§sound_volume: u8

Sound volume, 0 (silent) to MAX_VOLUME.

§voices: bool

Whether voice clips play (Ctx::play_voice). Turning it off stops the one playing.

§voice_volume: u8

Voice volume, 0 (silent) to MAX_VOLUME.

§frame_cap: FrameCap

The most frames a second the platform shows: the game’s GameSettings::DEFAULT_FRAME_CAP until the player picks another. Every change of it takes the next serial, which the platform reports once it has applied it; a game that wants to know when asks with Ctx::request_frame_cap.

§game: S

The game’s own settings.

Implementations§

Source§

impl<S: GameSettings> Settings<S>

Source

pub fn layout(&self) -> Option<Layout>

The layout the player picked, if they have.

Source

pub fn with_layout(self, layout: Layout) -> Self

The same settings with layout as the one picked.

Source

pub fn with_layout_of(self, other: &Self) -> Self

The same settings with other’s layout picked (or none): to compare two settings but for the layout.

Source

pub fn restored(&self) -> Self

The defaults, keeping what isn’t a preference with a default: the layout picked (an options screen’s “Restore defaults”).

Source

pub fn music_factor(&self) -> f32

The multiplier on the music’s volume, 0–1.

Source

pub fn sound_factor(&self) -> f32

The multiplier on every sound’s volume, 0–1.

Source

pub fn voice_factor(&self) -> f32

The multiplier on every voice clip’s volume, 0–1.

Source

pub fn to_ron(&self) -> String

The saved form (GameSettings::to_ron).

Source

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

Reads the saved form (GameSettings::from_ron).

Trait Implementations§

Source§

impl<S: Clone + GameSettings> Clone for Settings<S>
where S::Theme: Clone,

Source§

fn clone(&self) -> Settings<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + GameSettings> Debug for Settings<S>
where S::Theme: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: GameSettings> Default for Settings<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S: Eq + GameSettings> Eq for Settings<S>
where S::Theme: Eq,

Source§

impl<S: PartialEq + GameSettings> PartialEq for Settings<S>
where S::Theme: PartialEq,

Source§

fn eq(&self, other: &Settings<S>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<S: PartialEq + GameSettings> StructuralPartialEq for Settings<S>
where S::Theme: PartialEq,

Auto Trait Implementations§

§

impl<S> Freeze for Settings<S>
where <S as GameSettings>::Theme: Freeze, S: Freeze,

§

impl<S> RefUnwindSafe for Settings<S>

§

impl<S> Send for Settings<S>
where <S as GameSettings>::Theme: Send, S: Send,

§

impl<S> Sync for Settings<S>
where <S as GameSettings>::Theme: Sync, S: Sync,

§

impl<S> Unpin for Settings<S>
where <S as GameSettings>::Theme: Unpin, S: Unpin,

§

impl<S> UnsafeUnpin for Settings<S>

§

impl<S> UnwindSafe for Settings<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.