feat: localize difficulty name in save menu
This commit is contained in:
parent
9c95b20f5c
commit
a5930637c8
|
@ -40,7 +40,9 @@
|
|||
"title": "Select Difficulty",
|
||||
"easy": "Easy",
|
||||
"normal": "Normal",
|
||||
"hard": "Hard"
|
||||
"hard": "Hard",
|
||||
"difficulty_name": "Difficulty: ",
|
||||
"unknown": "(unknown)"
|
||||
},
|
||||
"coop_menu": {
|
||||
"title": "Select Number of Players",
|
||||
|
|
|
@ -40,7 +40,9 @@
|
|||
"title": "難易度選択",
|
||||
"easy": "簡単",
|
||||
"normal": "普通",
|
||||
"hard": "難しい"
|
||||
"hard": "難しい",
|
||||
"difficulty_name": "難易度: ",
|
||||
"unknown": "(未知)"
|
||||
},
|
||||
"coop_menu": {
|
||||
"title": "プレイヤー数を選択",
|
||||
|
|
|
@ -17,11 +17,7 @@ impl Default for Locale {
|
|||
Locale {
|
||||
code: "en".to_owned(),
|
||||
name: "English".to_owned(),
|
||||
font: FontData {
|
||||
path: String::new(),
|
||||
scale: 1.0,
|
||||
space_offset: 0.0
|
||||
},
|
||||
font: FontData { path: String::new(), scale: 1.0, space_offset: 0.0 },
|
||||
strings: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +61,7 @@ impl Locale {
|
|||
strings
|
||||
}
|
||||
|
||||
/// if the key does not exists, return the origin key instead
|
||||
pub fn t<'a: 'b, 'b>(&'a self, key: &'b str) -> &'b str {
|
||||
if let Some(str) = self.strings.get(key) {
|
||||
str
|
||||
|
|
|
@ -7,6 +7,7 @@ use crate::framework::error::GameResult;
|
|||
use crate::framework::graphics;
|
||||
use crate::game::shared_game_state::{GameDifficulty, MenuCharacter, SharedGameState};
|
||||
use crate::graphics::font::Font;
|
||||
use crate::i18n::Locale;
|
||||
use crate::input::combined_menu_controller::CombinedMenuController;
|
||||
use crate::menu::save_select_menu::MenuSaveInfo;
|
||||
|
||||
|
@ -594,23 +595,21 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
|
|||
|
||||
graphics::draw_rect(ctx, bar_rect, Color::new(1.0, 1.0, 1.0, 1.0))?;
|
||||
}
|
||||
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
state
|
||||
.font
|
||||
.builder()
|
||||
.x(self.x as f32 - 25.0)
|
||||
.y(y)
|
||||
.shadow(true)
|
||||
.draw("<", ctx, &state.constants, &mut state.texture_set)?;
|
||||
state
|
||||
.font
|
||||
.builder()
|
||||
.x((self.x + self.width as isize) as f32 + 15.0)
|
||||
.y(y)
|
||||
.shadow(true)
|
||||
.draw(">", ctx, &state.constants, &mut state.texture_set)?;
|
||||
state.font.builder().x(self.x as f32 - 25.0).y(y).shadow(true).draw(
|
||||
"<",
|
||||
ctx,
|
||||
&state.constants,
|
||||
&mut state.texture_set,
|
||||
)?;
|
||||
state.font.builder().x((self.x + self.width as isize) as f32 + 15.0).y(y).shadow(true).draw(
|
||||
">",
|
||||
ctx,
|
||||
&state.constants,
|
||||
&mut state.texture_set,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
MenuEntry::NewSave => {
|
||||
|
@ -677,13 +676,44 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
|
|||
);
|
||||
batch.draw(ctx)?;
|
||||
} else {
|
||||
let mut difficulty_name: String = "Difficulty: ".to_owned();
|
||||
fn translate_fallback<'l: 'a, 'a>(
|
||||
loc: &'l Locale,
|
||||
key: &'a str,
|
||||
fallback: &'a str,
|
||||
) -> &'a str {
|
||||
let result = loc.t(key);
|
||||
if result == key {
|
||||
return fallback;
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
let loc = &state.loc;
|
||||
let mut difficulty_name =
|
||||
translate_fallback(loc, "menus.difficulty_menu.difficulty_name", "Difficulty: ")
|
||||
.to_owned();
|
||||
|
||||
match save.difficulty {
|
||||
0 => difficulty_name.push_str("Normal"),
|
||||
2 => difficulty_name.push_str("Easy"),
|
||||
4 => difficulty_name.push_str("Hard"),
|
||||
_ => difficulty_name.push_str("(unknown)"),
|
||||
0 => difficulty_name.push_str(translate_fallback(
|
||||
loc,
|
||||
"menus.difficulty_menu.normal",
|
||||
"Normal",
|
||||
)),
|
||||
2 => difficulty_name.push_str(translate_fallback(
|
||||
loc,
|
||||
"menus.difficulty_menu.easy",
|
||||
"Easy",
|
||||
)),
|
||||
4 => difficulty_name.push_str(translate_fallback(
|
||||
loc,
|
||||
"menus.difficulty_menu.hard",
|
||||
"Hard",
|
||||
)),
|
||||
_ => difficulty_name.push_str(translate_fallback(
|
||||
loc,
|
||||
"menus.difficulty_menu.unknown",
|
||||
"(unknown)",
|
||||
)),
|
||||
}
|
||||
|
||||
state.font.builder().position(self.x as f32 + 20.0, y + 10.0).draw(
|
||||
|
@ -770,11 +800,7 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
|
|||
state: &mut SharedGameState,
|
||||
) -> MenuSelectionResult<T> {
|
||||
// the engine does 4 times more ticks during cutscene skipping
|
||||
let max_anim_wait = if state.textscript_vm.flags.cutscene_skip() {
|
||||
32
|
||||
} else {
|
||||
8
|
||||
};
|
||||
let max_anim_wait = if state.textscript_vm.flags.cutscene_skip() { 32 } else { 8 };
|
||||
|
||||
self.anim_wait += 1;
|
||||
if self.anim_wait > max_anim_wait {
|
||||
|
|
Loading…
Reference in New Issue