enable cs+ japanese font when valid

This commit is contained in:
dawnDus 2022-04-30 11:48:47 -04:00
parent 24762a1c45
commit acad65d233
No known key found for this signature in database
GPG Key ID: 972AABDE81848F21
2 changed files with 15 additions and 5 deletions

View File

@ -15,7 +15,7 @@ use crate::i18n::Locale;
use crate::player::ControlMode;
use crate::scripting::tsc::text_script::TextScriptEncoding;
use crate::settings::Settings;
use crate::shared_game_state::{Language, Season};
use crate::shared_game_state::{FontData, Language, Season};
use crate::sound::pixtone::{Channel, Envelope, PixToneParameters, Waveform};
use crate::sound::SoundManager;
@ -1792,8 +1792,17 @@ impl EngineConstants {
}
pub fn load_locales(&mut self, ctx: &mut Context) -> GameResult {
self.locales.clear();
for language in Language::values() {
self.locales.insert(language.to_string(), Locale::new(ctx, language.to_language_code(), language.font()));
// Only Switch 1.3+ data contains an entirely valid JP font
let font =
if language == Language::Japanese && filesystem::exists_find(ctx, &self.base_paths, "/credit_jp.tsc") {
FontData::new("csfontjp.fnt".to_owned(), 0.5, 0.0)
} else {
language.font()
};
self.locales.insert(language.to_string(), Locale::new(ctx, language.to_language_code(), font));
log::info!("Loaded locale {} ({}).", language.to_string(), language.to_language_code());
}

View File

@ -107,7 +107,8 @@ impl Language {
pub fn font(self) -> FontData {
match self {
Language::English => FontData::new("csfont.fnt".to_owned(), 0.5, 0.0),
Language::Japanese => FontData::new("csfontjp.fnt".to_owned(), 0.5, 0.0),
// Use default as fallback if no proper JP font is found
Language::Japanese => FontData::new("0.fnt".to_owned(), 1.0, 0.0),
}
}
@ -282,8 +283,6 @@ impl SharedGameState {
let settings = Settings::load(ctx)?;
let mod_requirements = ModRequirements::load(ctx)?;
constants.load_locales(ctx)?;
#[cfg(not(target_os = "android"))]
if filesystem::exists(ctx, "/base/lighting.tbl") {
info!("Cave Story+ (Switch) data files detected.");
@ -321,6 +320,8 @@ impl SharedGameState {
let season = Season::current();
constants.rebuild_path_list(None, season, &settings);
constants.load_locales(ctx)?;
let active_locale = constants.locales.get(&settings.locale.to_string()).unwrap();
if constants.is_cs_plus {