Skip to content

Commit 0dcbab4

Browse files
committed
Implement Replace for Il2CppString
1 parent 9b17b1f commit 0dcbab4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/system/string.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ fn system_string_copy(string: &Il2CppString, method_info: OptionalMethod) -> &'_
4242
#[crate::from_offset("System", "String", "Clone")]
4343
fn system_string_clone(this: &Il2CppString, method_info: OptionalMethod) -> &'_ mut Il2CppString;
4444

45+
// #[crate::from_offset("System", "String", "Replace")]
46+
#[skyline::from_offset(0x3773720)]
47+
fn system_string_replace_str(this: &mut Il2CppString, old_value: &Il2CppString, new_value: &Il2CppString, method_info: OptionalMethod) -> &'static mut Il2CppString;
48+
4549
#[crate::from_offset("System", "String", "Contains")]
4650
fn system_string_contains(this: &Il2CppString, value: &Il2CppString, method_info: OptionalMethod) -> bool;
4751

@@ -107,6 +111,10 @@ impl Il2CppString {
107111
unsafe { system_string_contains(self, value.into(), None) }
108112
}
109113

114+
pub fn replace<'a>(&mut self, old_value: impl Into<&'a Il2CppString>, new_value: impl Into<&'a Il2CppString>) -> &'_ mut Il2CppString {
115+
unsafe { system_string_replace_str(self, old_value.into(), new_value.into(), None) }
116+
}
117+
110118
/// Provides a new instance of the Il2CppString, separate from the original.
111119
pub fn clone(&self) -> &'_ Il2CppString {
112120
// Yes.

0 commit comments

Comments
 (0)