Skip to main content

AppConfig

Struct AppConfig 

Source
#[non_exhaustive]
pub struct AppConfig { pub window: Window, pub storage_name: &'static str, pub files: fn(&str) -> Option<&'static [u8]>, pub font_png: &'static str, pub sounds: Files<'static>, pub voices: Option<VoiceFiles>, pub text_input: Option<Box<dyn TextInput>>, pub crash: CrashReports, }
Expand description

What a game tells the macroquad backend. How it starts, loads and is painted is its Start. Build it with AppConfig::new.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§window: Window

The window.

§storage_name: &'static str

The storage’s name: the folder in the OS’s data folder on native (storage::data_dir), the prefix of every localStorage key on the web (storage::web_prefix). Changing it loses every save.

§files: fn(&str) -> Option<&'static [u8]>

The game’s embedded files by path: the images, the font atlas’s picture and a loading card’s picture are read with it. Under cargo shuyi run --watch the folder of its files on disk lies over it (watched_layer), and a picture saved there is drawn from then on.

§font_png: &'static str

The font atlas’s picture: its path for files.

§sounds: Files<'static>

The sound files the audio manifest names, and the music folder shipped beside the game (not embedded).

§voices: Option<VoiceFiles>

Where the voice clips are; None for a game without voices.

§text_input: Option<Box<dyn TextInput>>

The system’s own keyboard for text, if the game’s build has one (Steam’s on-screen keyboard is the game’s: its ticket 0903); None where the player types on keys.

§crash: CrashReports

Whether a panic writes a crash report, and the game’s version in it (crash): reports with no version until the game assigns CrashReports::new with its own, or CrashReports::off.

Implementations§

Source§

impl AppConfig

Source

pub const fn new( window: Window, storage_name: &'static str, files: fn(&str) -> Option<&'static [u8]>, font_png: &'static str, sounds: Files<'static>, ) -> Self

The config of a game with every field it must choose, with no voices and no system keyboard: a game that has them assigns voices and text_input.

Auto Trait Implementations§

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
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

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.

§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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.