Merge branch 'coffee-compiler/localize_singleplayer_server_name' into 'master'

Localize singleplayer server name in char selection

See merge request veloren/veloren!4533
This commit is contained in:
Marcel 2024-07-27 22:03:31 +00:00
commit 2746d8403e
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 SERVER_DESCRIPTION_FILENAME: &str = "description.ron";
const ADMINS_FILENAME: &str = "admins.ron"; const ADMINS_FILENAME: &str = "admins.ron";
pub const SINGLEPLAYER_SERVER_NAME: &str = "Singleplayer";
#[derive(Copy, Clone, Debug, Deserialize, Serialize)] #[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub enum ServerBattleMode { pub enum ServerBattleMode {
Global(BattleMode), Global(BattleMode),
@ -308,7 +310,7 @@ impl Settings {
} else { } else {
DEFAULT_WORLD_SEED DEFAULT_WORLD_SEED
}, },
server_name: "Singleplayer".to_owned(), server_name: SINGLEPLAYER_SERVER_NAME.to_owned(),
max_players: 100, max_players: 100,
max_view_distance: None, max_view_distance: None,
client_timeout: Duration::from_secs(180), client_timeout: Duration::from_secs(180),

View File

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