pub struct GameViewModel<S: SettingsManager, M: RawModule + Send + Sync + 'static> { /* private fields */ }
Expand description

A view model of Ayaka. It manages all settings and provides high-level APIs.

Implementations§

source§

impl<S: SettingsManager, M: RawModule + Send + Sync + 'static> GameViewModel<S, M>

source

pub fn new(settings_manager: S) -> Self

Create a GameViewModel with a settings manager.

source

pub fn open_game<'a>( &'a mut self, context: Context<M> ) -> impl Future<Output = Result<()>> + Stream<Item = OpenGameStatus> + 'a

Open the game with context.

source

pub fn context(&self) -> &Context<M>

The [Context], should be called after Self::open_game.

source

pub fn context_mut(&mut self) -> &mut Context<M>

The [Context], should be called after Self::open_game.

source

pub fn record(&self) -> &ActionRecord

The current ActionRecord.

source

pub fn settings(&self) -> &Settings

The loaded Settings.

source

pub fn set_settings(&mut self, settings: Settings)

Set the Settings.

source

pub fn records(&self) -> &[ActionRecord]

The loaded ActionRecords.

source

pub fn global_record(&self) -> &GlobalRecord

The loaded GlobalRecord.

source

pub fn global_record_mut(&mut self) -> &mut GlobalRecord

The loaded GlobalRecord.

source

pub fn avaliable_locale(&self) -> impl Iterator<Item = &Locale>

Get the avaliable locales from paragraphs.

source

pub fn init_new(&mut self)

Start a new game. The state of the model after this call is actually invalid. You should call next_run immediately after this call, to ensure there’s content in the game, and switch to the first line of the first paragraph.

source

pub fn init_context(&mut self, record: ActionRecord)

Start a game with record.

source

pub fn init_context_by_index(&mut self, index: usize)

Start a game with the index of records.

source

pub fn next_run(&mut self) -> bool

Step to the next run.

source

pub fn next_back_run(&mut self) -> bool

Step back to the last run.

source

pub fn current_run(&self) -> Option<&RawContext>

Get the current [RawContext].

source

pub fn current_title(&self) -> Option<&String>

Get the current paragraph title.

source

pub fn current_action(&self) -> Option<Action>

Get the current action by language.

source

pub fn current_actions(&self) -> Option<(Action, Option<Action>)>

Get the current action by language and secondary language.

source

pub fn switch(&mut self, i: usize)

Choose a switch item by index.

source

pub fn save_current_to(&mut self, index: usize)

Save current ActionRecord to the records.

source

pub fn save_settings(&self) -> Result<()>

Save all settings and records.

source

pub fn current_visited(&self) -> bool

Determine if current run has been visited.

source

pub fn records_text(&self) -> impl Iterator<Item = ActionText> + '_

Get the last action text from each record.

source

pub fn current_history( &self ) -> impl DoubleEndedIterator<Item = (Action, Option<Action>)> + '_

Get the current history by language and secondary language.

Auto Trait Implementations§

§

impl<S, M> Freeze for GameViewModel<S, M>
where S: Freeze,

§

impl<S, M> !RefUnwindSafe for GameViewModel<S, M>

§

impl<S, M> Send for GameViewModel<S, M>
where S: Send,

§

impl<S, M> Sync for GameViewModel<S, M>
where S: Sync,

§

impl<S, M> Unpin for GameViewModel<S, M>
where S: Unpin,

§

impl<S, M> !UnwindSafe for GameViewModel<S, M>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,