fix: switch locale dosn't update encoding correctly

This commit is contained in:
poly000 2024-03-27 00:12:17 +08:00
parent 0de0a25103
commit 0c6aa5288a
No known key found for this signature in database
1 changed files with 11 additions and 3 deletions

View File

@ -586,10 +586,18 @@ impl SharedGameState {
pub fn update_locale(&mut self, ctx: &mut Context) {
if let Some(locale) = SharedGameState::get_locale(&self.constants, &self.settings.locale) {
self.loc = locale;
if (self.loc.code == "jp" || self.loc.code == "en") && self.constants.is_base() {
self.constants.textscript.encoding = TextScriptEncoding::ShiftJIS
if let Some(encoding) = self.loc.encoding.as_ref() {
self.constants.textscript.encoding = TextScriptEncoding::from(encoding.as_str())
} else {
self.constants.textscript.encoding = TextScriptEncoding::UTF8
if (self.loc.code == "jp" || self.loc.code == "en") && self.constants.is_base() {
self.constants.textscript.encoding = TextScriptEncoding::ShiftJIS
} else {
self.constants.textscript.encoding = TextScriptEncoding::UTF8
}
}
if let Some(state_encoding) = self.loc.stage_encoding.as_ref() {
self.constants.stage_encoding = Some(state_encoding.as_str().into());
}
}