StringsFileTextProvider

Struct StringsFileTextProvider 

Source
pub struct StringsFileTextProvider { /* private fields */ }
Expand description

The default TextProvider used by a DialogueRunner unless overridden with DialogueRunnerBuilder::with_text_provider. If the DialogueRunner’s language is the base language, i.e. the one the Yarn files are written in, this will send the lines as they appear in the Yarn file. If DialogueRunner::set_language or DialogueRunner::set_text_language were used to set the language to a language supported by a translation in the Localizations, this loads the strings file for that translation from the disk at the specified path. If this fails, the base language is used as a fallback.

Implementations§

Source§

impl StringsFileTextProvider

Source

pub fn from_yarn_project(yarn_project: &YarnProject) -> Self

Create a new text provider from a Yarn project. This will be done for you when using YarnProject::create_dialogue_runner or YarnProject::build_dialogue_runner.

Trait Implementations§

Source§

impl Clone for StringsFileTextProvider

Source§

fn clone(&self) -> StringsFileTextProvider

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StringsFileTextProvider

Source§

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

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

impl TextProvider for StringsFileTextProvider

Source§

fn clone_shallow(&self) -> Box<dyn UnderlyingTextProvider>

Creates a shallow clone of this text provider, i.e. a clone that shares the same underlying provider and will thus be perfectly in sync with the original instance.
Source§

fn accept_line_hints(&mut self, _line_ids: &[LineId])

Passes the LineIds that this TextProvider should soon provide text for. These are the LineIds that are contained in the current node and are not required to be actually reached.
Source§

fn get_text(&self, id: &LineId) -> Option<String>

Returns the text for the given LineId. Will only be called if TextProvider::are_lines_available returns true.
Source§

fn set_language(&mut self, language: Option<Language>)

Sets the current language. If None is passed, the base language will be used.
Source§

fn get_language(&self) -> Option<Language>

Returns the current language. If None is returned, the base language is used.
Source§

fn are_lines_available(&self) -> bool

Returns whether the text for all lines announced by TextProvider::accept_line_hints are available, i.e. have been loaded and are ready to be used.
Source§

fn as_any(&self) -> &dyn Any

Gets the TextProvider as a trait object. This allows retrieving the concrete type by downcasting, using the downcast_ref method available through the Any trait.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Gets the TextProvider as a mutable trait object. This allows retrieving the concrete type by downcasting, using the downcast_mut method available through the Any trait.
Source§

impl TextProvider for StringsFileTextProvider

Source§

fn set_base_string_table(&mut self, string_table: HashMap<LineId, StringInfo>)

Stores a string table containing the base language strings, i.e. the strings found in the Yarn files themselves.
Source§

fn extend_base_string_table( &mut self, string_table: HashMap<LineId, StringInfo>, )

Extends the string table set by TextProvider::set_base_string_table with additional strings.
Source§

fn take_fetched_assets(&mut self, asset: Box<dyn Any>)

Stores the assets fetched by TextProvider::fetch_assets. This functionality is split into two functions because TextProvider::take_fetched_assets is mutable, so we lose access to the World when calling it since it contains this very TextProvider.
Source§

fn fetch_assets(&self, world: &World) -> Option<Box<dyn Any + 'static>>

Fetches any necessary assets. The returned value is then passed to TextProvider::take_fetched_assets. This functionality is split into two functions because TextProvider::take_fetched_assets is mutable, so we lose access to the World when calling it since it contains this very TextProvider.

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> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
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, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

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

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

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

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

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

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

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

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

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of this value.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

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

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,