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
impl StringsFileTextProvider
Sourcepub fn from_yarn_project(yarn_project: &YarnProject) -> Self
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
impl Clone for StringsFileTextProvider
Source§fn clone(&self) -> StringsFileTextProvider
fn clone(&self) -> StringsFileTextProvider
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StringsFileTextProvider
impl Debug for StringsFileTextProvider
Source§impl TextProvider for StringsFileTextProvider
impl TextProvider for StringsFileTextProvider
Source§fn clone_shallow(&self) -> Box<dyn UnderlyingTextProvider>
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])
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>
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>)
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>
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
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
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
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
impl TextProvider for StringsFileTextProvider
Source§fn set_base_string_table(&mut self, string_table: HashMap<LineId, StringInfo>)
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>,
)
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>)
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>>
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§
impl Freeze for StringsFileTextProvider
impl !RefUnwindSafe for StringsFileTextProvider
impl Send for StringsFileTextProvider
impl Sync for StringsFileTextProvider
impl Unpin for StringsFileTextProvider
impl !UnwindSafe for StringsFileTextProvider
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
Attempts to downcast this to
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
Attempts to downcast this to
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
Attempts to downcast this to
T behind Arc pointerSource§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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
impl<T> DowncastSend for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.