Localize singleplayer server name in char selection

This commit is contained in:
coffee-compiler 2024-07-27 22:03:31 +00:00 committed by Marcel
parent 127c0ce0aa
commit a263d8d88a
2 changed files with 11 additions and 4 deletions

View File

@ -41,6 +41,8 @@ const BANLIST_FILENAME: &str = "banlist.ron";
const SERVER_DESCRIPTION_FILENAME: &str = "description.ron";
const ADMINS_FILENAME: &str = "admins.ron";
pub const SINGLEPLAYER_SERVER_NAME: &str = "Singleplayer";
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub enum ServerBattleMode {
Global(BattleMode),
@ -308,7 +310,7 @@ impl Settings {
} else {
DEFAULT_WORLD_SEED
},
server_name: "Singleplayer".to_owned(),
server_name: SINGLEPLAYER_SERVER_NAME.to_owned(),
max_players: 100,
max_view_distance: None,
client_timeout: Duration::from_secs(180),

View File

@ -41,6 +41,7 @@ use iced::{
button, scrollable, slider, text_input, Align, Button, Color, Column, Container,
HorizontalAlignment, Length, Row, Scrollable, Slider, Space, Text, TextInput,
};
use server::settings::SINGLEPLAYER_SERVER_NAME;
use std::sync::Arc;
use vek::{Rgba, Vec2};
@ -535,11 +536,15 @@ impl Controls {
*info_content = None;
}
let server_name = if client.server_info().name == SINGLEPLAYER_SERVER_NAME {
&i18n.get_msg("common-singleplayer").to_string()
} else {
&client.server_info().name
};
let server = Container::new(
Column::with_children(vec![
Text::new(&client.server_info().name)
.size(fonts.cyri.scale(25))
.into(),
Text::new(server_name).size(fonts.cyri.scale(25)).into(),
// TODO: show additional server info here
Space::new(Length::Fill, Length::Units(25)).into(),
])