Struct eos_rs::api::messages::GameStringBuilder
source · pub struct GameStringBuilder<'a> { /* private fields */ }
Expand description
Builds a string using an “enhanced sprintf”, which recognizes certain tags and replaces them with appropriate game values.
The output buffer is calculated to have a capacity of the input format string times 3
(or i32::MAX). Should that not be enough, you can use Self::output_buffer_size
to override
this.
See https://textbox.skytemple.org for a reference about message tags and a preview tool.
Implementations§
source§impl<'a> GameStringBuilder<'a>
impl<'a> GameStringBuilder<'a>
pub fn new() -> Self
sourcepub fn set_flag_unknown0(&mut self, value: u16) -> &mut Self
pub fn set_flag_unknown0(&mut self, value: u16) -> &mut Self
Sets the unknown0 value of the preprocessor flags.
sourcepub fn show_speaker(&mut self) -> &mut Self
pub fn show_speaker(&mut self) -> &mut Self
Tells the game to show the speaker in the formatted message.
Sets the speaker value of the preprocessor flags to true.
If Self::set_speaker
was not called, this will probably(…?) show the speech
bubble icon as the speaker.
sourcepub fn set_flag_unknown18(&mut self, value: u32) -> &mut Self
pub fn set_flag_unknown18(&mut self, value: u32) -> &mut Self
Sets the unknown18 value of the preprocessor flags.
sourcepub fn set_speaker(&'a mut self, speaker: u32) -> &'a mut Self
pub fn set_speaker(&'a mut self, speaker: u32) -> &'a mut Self
Sets the speaker of the message to the given entity (probably actor or monster ID…?).
To actually also show the speaker, use Self::show_speaker
.
sourcepub fn set_flag_value(&'a mut self, flag_id: usize, value: u32) -> &'a mut Self
pub fn set_flag_value(&'a mut self, flag_id: usize, value: u32) -> &'a mut Self
Sets flag values. Currently unknown what they do.
Max flag ID is 3.
sourcepub fn set_id_value(&'a mut self, id_id: usize, value: u32) -> &'a mut Self
pub fn set_id_value(&'a mut self, id_id: usize, value: u32) -> &'a mut Self
Sets an ID for a message placeholder. This is probably used by the \[name:id\]
,
\[item:id\]
etc. placeholders,
Max ID ID is 4.
sourcepub fn set_number_value(
&'a mut self,
number_id: usize,
value: i32
) -> &'a mut Self
pub fn set_number_value( &'a mut self, number_id: usize, value: i32 ) -> &'a mut Self
Sets a number for a message placeholder. This is probably used by the \[digits_c:0]
,
etc. placeholders.
Max number ID is 4.
sourcepub fn set_string(
&'a mut self,
string_id: usize,
string: &'a CString
) -> &'a mut Self
pub fn set_string( &'a mut self, string_id: usize, string: &'a CString ) -> &'a mut Self
Sets a string for message placeholders.
Replace all occurrences of \[string:<string_id>\]
with the value of the string passed in.
Max string ID is 4.
sourcepub fn output_buffer_size(&mut self, size: i32) -> &mut Self
pub fn output_buffer_size(&mut self, size: i32) -> &mut Self
Overwrites the size of the output buffer.
sourcepub fn args(&self) -> &preprocessor_args
pub fn args(&self) -> &preprocessor_args
Returns a reference to the internal args. This will panic if Self::borrow_args
was
called before.
sourcepub fn flags(&self) -> &preprocessor_flags
pub fn flags(&self) -> &preprocessor_flags
Returns a reference to the internal flags.
sourcepub fn set_flags(&mut self, flags: &preprocessor_flags) -> &mut Self
pub fn set_flags(&mut self, flags: &preprocessor_flags) -> &mut Self
Overwrite the internal flags with the specified ones.
This is useful if you want to re-use flags.
You probably want to use Self::set_flag_unknown0
, Self::show_speaker
,
Self::set_flag_unknown18
instead in most cases.
sourcepub fn borrow_args(
&'a mut self,
args: &'a mut preprocessor_args
) -> &'a mut Self
pub fn borrow_args( &'a mut self, args: &'a mut preprocessor_args ) -> &'a mut Self
Sets the internal arguments to use the arguments passed in.
This is useful if you want to re-use args.
Subsequent calls to Self::set_speaker
, Self::set_flag_value
, Self::set_id_value
,
Self::set_number_value
,Self::set_string
will manipulate the args passed in.
You probably don’t need to use this method in most cases, just use the above mentioned methods instead.
sourcepub fn build<S: AsRef<str>>(self, format: S) -> String
pub fn build<S: AsRef<str>>(self, format: S) -> String
Converts the format string to the formatted string.
Builds String from a str. The input is the format string to use.
sourcepub fn build_from_cstr<S: AsRef<CStr>>(self, format: S) -> String
pub fn build_from_cstr<S: AsRef<CStr>>(self, format: S) -> String
Converts the format string to the formatted string.
Builds String from a CStr. The input is the format string to use.
sourcepub fn build_as_cstring<S: AsRef<str>>(self, format: S) -> CString
pub fn build_as_cstring<S: AsRef<str>>(self, format: S) -> CString
Converts the format string to the formatted string.
Builds CString from a str. The input is the format string to use.
sourcepub fn build_from_cstr_as_cstring<S: AsRef<CStr>>(self, format: S) -> CString
pub fn build_from_cstr_as_cstring<S: AsRef<CStr>>(self, format: S) -> CString
Converts the format string to the formatted string.
Builds CString from a CStr. The input is the format string to use.