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>
impl<S: SettingsManager, M: RawModule + Send + Sync + 'static> GameViewModel<S, M>
sourcepub fn new(settings_manager: S) -> Self
pub fn new(settings_manager: S) -> Self
Create a GameViewModel
with a settings manager.
sourcepub fn open_game<'a>(
&'a mut self,
context: Context<M>,
) -> impl Future<Output = Result<()>> + Stream<Item = OpenGameStatus> + 'a
pub fn open_game<'a>( &'a mut self, context: Context<M>, ) -> impl Future<Output = Result<()>> + Stream<Item = OpenGameStatus> + 'a
Open the game with context.
sourcepub fn context(&self) -> &Context<M>
pub fn context(&self) -> &Context<M>
The [Context
], should be called after Self::open_game
.
sourcepub fn context_mut(&mut self) -> &mut Context<M>
pub fn context_mut(&mut self) -> &mut Context<M>
The [Context
], should be called after Self::open_game
.
sourcepub fn record(&self) -> &ActionRecord
pub fn record(&self) -> &ActionRecord
The current ActionRecord
.
sourcepub fn set_settings(&mut self, settings: Settings)
pub fn set_settings(&mut self, settings: Settings)
Set the Settings
.
sourcepub fn records(&self) -> &[ActionRecord]
pub fn records(&self) -> &[ActionRecord]
The loaded ActionRecord
s.
sourcepub fn global_record(&self) -> &GlobalRecord
pub fn global_record(&self) -> &GlobalRecord
The loaded GlobalRecord
.
sourcepub fn global_record_mut(&mut self) -> &mut GlobalRecord
pub fn global_record_mut(&mut self) -> &mut GlobalRecord
The loaded GlobalRecord
.
sourcepub fn avaliable_locale(&self) -> impl Iterator<Item = &Locale>
pub fn avaliable_locale(&self) -> impl Iterator<Item = &Locale>
Get the avaliable locales from paragraphs.
sourcepub fn init_new(&mut self)
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.
sourcepub fn init_context(&mut self, record: ActionRecord)
pub fn init_context(&mut self, record: ActionRecord)
Start a game with record.
sourcepub fn init_context_by_index(&mut self, index: usize)
pub fn init_context_by_index(&mut self, index: usize)
Start a game with the index of records.
sourcepub fn next_back_run(&mut self) -> bool
pub fn next_back_run(&mut self) -> bool
Step back to the last run.
sourcepub fn current_run(&self) -> Option<&RawContext>
pub fn current_run(&self) -> Option<&RawContext>
Get the current [RawContext
].
sourcepub fn current_title(&self) -> Option<&String>
pub fn current_title(&self) -> Option<&String>
Get the current paragraph title.
sourcepub fn current_action(&self) -> Option<Action>
pub fn current_action(&self) -> Option<Action>
Get the current action by language.
sourcepub fn current_actions(&self) -> Option<(Action, Option<Action>)>
pub fn current_actions(&self) -> Option<(Action, Option<Action>)>
Get the current action by language and secondary language.
sourcepub fn save_current_to(&mut self, index: usize)
pub fn save_current_to(&mut self, index: usize)
Save current ActionRecord
to the records.
sourcepub fn save_settings(&self) -> Result<()>
pub fn save_settings(&self) -> Result<()>
Save all settings and records.
sourcepub fn current_visited(&self) -> bool
pub fn current_visited(&self) -> bool
Determine if current run has been visited.
sourcepub fn records_text(&self) -> impl Iterator<Item = ActionText> + '_
pub fn records_text(&self) -> impl Iterator<Item = ActionText> + '_
Get the last action text from each record.
sourcepub fn current_history(
&self,
) -> impl DoubleEndedIterator<Item = (Action, Option<Action>)> + '_
pub fn current_history( &self, ) -> impl DoubleEndedIterator<Item = (Action, Option<Action>)> + '_
Get the current history by language and secondary language.