[][src]Struct elma::state::State

pub struct State {
    pub path: Option<PathBuf>,
    pub version: u32,
    pub times: Vec<BestTimes>,
    pub players: Vec<PlayerEntry>,
    pub player_a_name: String,
    pub player_b_name: String,
    pub player_a_keys: PlayerKeys,
    pub player_b_keys: PlayerKeys,
    pub sound_enabled: bool,
    pub sound_optimization: SoundOptimization,
    pub play_mode: PlayMode,
    pub flagtag: bool,
    pub swap_bikes: bool,
    pub video_detail: VideoDetail,
    pub animated_objects: bool,
    pub animated_menus: bool,
    pub inc_screen_size_key: u32,
    pub dec_screen_size_key: u32,
    pub screenshot_key: u32,
    pub last_edited_lev_name: String,
    pub last_played_external: String,
}

State.dat struct

Fields

path: Option<PathBuf>

Path to State file.

version: u32

State file version; the only supported value is 200.

times: Vec<BestTimes>

Best times lists. state.dat has a fixed-size array of 90 of these.

players: Vec<PlayerEntry>

List of players. state.dat has a fixed-size array of 50 of these.

player_a_name: String

Name of player A, maximum 14 characters.

player_b_name: String

Name of player B, maximum 14 characters.

player_a_keys: PlayerKeys

Keys for player A.

player_b_keys: PlayerKeys

Keys for player B.

sound_enabled: bool

Whether sound is enabled.

sound_optimization: SoundOptimization

Sound optimization.

play_mode: PlayMode

Play mode.

flagtag: bool

Whether flag tag mode is enabled.

swap_bikes: bool

Whether bikes are swapped.

video_detail: VideoDetail

Video detail.

animated_objects: bool

Whether objects are animated.

animated_menus: bool

Whether menus are animated.

inc_screen_size_key: u32

Key for increasing screen size.

dec_screen_size_key: u32

Key for decreasing screen size.

screenshot_key: u32

Key for taking a screenshot.

last_edited_lev_name: String

Name of last edited level.

last_played_external: String

Name of last played external level.

Methods

impl State[src]

pub fn new() -> Self[src]

Create a new state.dat.

pub fn load<P: Into<PathBuf>>(path: P) -> Result<Self, ElmaError>[src]

Load a state.dat file.

Examples

let state = State::load("state.dat").unwrap();

pub fn from_bytes<B: AsRef<[u8]>>(buffer: B) -> Result<Self, ElmaError>[src]

Load a state.dat file from bytes.

Examples

let state = State::from_bytes(&[0,1,2]).unwrap();

pub fn to_bytes(&self) -> Result<Vec<u8>, ElmaError>[src]

Returns state.dat as a stream of bytes.

Examples

let mut state = State::load("state.dat").unwrap();
let buffer = state.to_bytes().unwrap();

pub fn save<P: Into<PathBuf>>(&mut self, path: P) -> Result<(), ElmaError>[src]

Save state.dat

Examples

let mut state = State::load("state.dat").unwrap();
state.save("newstate.dat").unwrap();

Trait Implementations

impl Default for State[src]

impl PartialEq<State> for State[src]

impl Clone for State[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for State[src]

Auto Trait Implementations

impl Send for State

impl Sync for State

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.