pub struct GameViewModel<M: SettingsManager> { /* private fields */ }
Expand description

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

Implementations§

source§

impl<M: SettingsManager> GameViewModel<M>

source

pub fn new(settings_manager: M) -> Self

Create a GameViewModel with a settings manager.

source

pub fn open_game<'a>( &'a mut self, paths: &'a [impl AsRef<Path>], frontend_type: FrontendType ) -> impl Future<Output = Result<()>> + Stream<Item = OpenGameStatus> + 'a

Open the game with paths and frontend type.

source

pub fn context(&self) -> &Context

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

source

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

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<M> !RefUnwindSafe for GameViewModel<M>

§

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

§

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

§

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

§

impl<M> !UnwindSafe for GameViewModel<M>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

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

§

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