Skip to main content

DialoguePlayer

Struct DialoguePlayer 

Source
pub struct DialoguePlayer<H: DialogueHooks> { /* private fields */ }
Expand description

Plays a scene: each advance moves to the next text box (speech or narration), applying the portrait and caption steps in between. At a reply choice it waits for choose, plays that reply’s reaction, then rejoins the scene after the choice. The @music lines passed on the way are kept for take_music. It plays the scene as it is for those present when it starts: the lines of an @if block whose character isn’t there are no part of it, read or skipped. The game’s own lines play on its stage as the scene reaches them (DialogueHooks::direct). Pure: no drawing, no clock, no sound. Cheap to clone (the scene is shared), so a copy can be kept as the scene was at a line (a dialogue log).

Implementations§

Source§

impl<H: DialogueHooks> DialoguePlayer<H>

Source

pub fn new(scene: &Scene<H::Directive>, hooks: H, present: &Present) -> Self

Starts scene as it plays for those present, at its first text box, with hooks filling its text and playing the game’s lines. A scene with nothing to say for them is finished at once.

Source

pub fn hooks(&self) -> &H

What fills the text and plays the game’s lines.

Source

pub fn stage(&self) -> &H::Stage

What the game’s lines have set so far.

Source

pub fn stage_mut(&mut self) -> &mut H::Stage

What the game’s lines have set so far, for the game to take what it has played from it.

Source

pub fn scene_id(&self) -> &str

The id of the scene being played.

Source

pub fn scene(&self) -> &Scene<H::Directive>

The scene being played: the one it was started with, as it is for those present.

Source

pub fn current(&self) -> View<'_, H::Stage>

What to show now.

Source

pub fn line(&self) -> Option<&LineId>

The id of the line in the text box (while a choice is open, of the line being answered); None once the scene is finished.

Source

pub fn reply_line(&self, option: usize) -> Option<&LineId>

The id of reply option of the open choice, if a choice is open and has it.

Source

pub fn pending_music(&self) -> Option<&MusicLine>

The music the scene has asked for and take_music hasn’t taken yet, without taking it.

Source

pub fn advance(&mut self)

Moves to the next text box, applying every portrait, caption and place step before it. After the last one the scene is finished; advancing a finished scene does nothing. While a choice is open this does nothing either: choose a reply.

Source

pub fn choose(&mut self, option: usize)

Picks reply option of the open choice: plays its reaction, then the scene after the choice. Does nothing if no choice is open or there is no such option.

Source

pub fn skip_to_choice(&mut self)

Advances until a choice is open or the scene is over (skipping a scene stops at each choice).

Source

pub fn take_music(&mut self) -> Option<MusicLine>

The music the scene has asked for since the last call: the last @music line reached, whether the lines before it were read or skipped. None if no @music line was reached since.

Source

pub fn is_choosing(&self) -> bool

Whether a reply choice is waiting for choose.

Source

pub fn is_finished(&self) -> bool

Whether every text box has been shown and advanced past.

Trait Implementations§

Source§

impl<H: Clone + DialogueHooks> Clone for DialoguePlayer<H>
where H::Directive: Clone, H::Stage: Clone,

Source§

fn clone(&self) -> DialoguePlayer<H>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<H: Debug + DialogueHooks> Debug for DialoguePlayer<H>
where H::Directive: Debug, H::Stage: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<H: Eq + DialogueHooks> Eq for DialoguePlayer<H>
where H::Directive: Eq, H::Stage: Eq,

Source§

impl<H: PartialEq + DialogueHooks> PartialEq for DialoguePlayer<H>

Source§

fn eq(&self, other: &DialoguePlayer<H>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<H: PartialEq + DialogueHooks> StructuralPartialEq for DialoguePlayer<H>

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.