diff --git a/Cargo.lock b/Cargo.lock index d274d777a5..d6cde5f45c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1864,7 +1864,7 @@ checksum = "5fca6f9d679bff1322c76c9a1ad4b8553b30a94f3f75bea6936e19032c2f2ec3" dependencies = [ "glyph_brush_layout", "log", - "ordered-float", + "ordered-float 1.1.0", "rustc-hash", "rusttype 0.8.3", "twox-hash", diff --git a/assets/voxygen/i18n/PL.ron b/assets/voxygen/i18n/PL.ron index 49b4d3173d..5069802cdc 100644 --- a/assets/voxygen/i18n/PL.ron +++ b/assets/voxygen/i18n/PL.ron @@ -1,5 +1,5 @@ /// Localization for Polish / Tłumaczenia dla języka polskiego -VoxygenLocalization( +Localization( metadata: ( language_name: "Polish", language_identifier: "PL", diff --git a/assets/voxygen/i18n/de_DE.ron b/assets/voxygen/i18n/de_DE.ron index a4f8b45b09..3fdd70ba3e 100644 --- a/assets/voxygen/i18n/de_DE.ron +++ b/assets/voxygen/i18n/de_DE.ron @@ -11,7 +11,7 @@ /// `assets/voxygen/i18n` and that's it! /// Lokalisation für Deutsch/Deutschland -VoxygenLocalization( +( metadata: ( language_name: "Deutsch", language_identifier: "de_DE", diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index daab2aa0ea..5ef6d90d71 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -13,7 +13,7 @@ /// WARNING: Localization files shall be saved in UTF-8 format without BOM /// Localization for "global" English -VoxygenLocalization( +( metadata: ( language_name: "English", language_identifier: "en", diff --git a/assets/voxygen/i18n/es_ES.ron b/assets/voxygen/i18n/es_ES.ron index 5c608525df..57a2dd3356 100644 --- a/assets/voxygen/i18n/es_ES.ron +++ b/assets/voxygen/i18n/es_ES.ron @@ -12,7 +12,7 @@ /// /// Localization for Spanish (Spain) -VoxygenLocalization( +Localization( metadata: ( language_name: "Español de España", language_identifier: "es_ES", diff --git a/assets/voxygen/i18n/es_la.ron b/assets/voxygen/i18n/es_la.ron index ffdb904665..b15f416386 100644 --- a/assets/voxygen/i18n/es_la.ron +++ b/assets/voxygen/i18n/es_la.ron @@ -13,7 +13,7 @@ /// WARNING: Localization files shall be saved in UTF-8 format without BOM /// Localization for "latinoamericano" Latin-American -VoxygenLocalization( +Localization( metadata: ( language_name: "Español Latino", language_identifier: "es_la", diff --git a/assets/voxygen/i18n/fr_FR.ron b/assets/voxygen/i18n/fr_FR.ron index dac58d4d68..4749bfe9d9 100644 --- a/assets/voxygen/i18n/fr_FR.ron +++ b/assets/voxygen/i18n/fr_FR.ron @@ -1,5 +1,5 @@ /// Localization for French (France locale) -VoxygenLocalization( +( metadata: ( language_name: "Français", language_identifier: "fr_FR", diff --git a/assets/voxygen/i18n/it_IT.ron b/assets/voxygen/i18n/it_IT.ron index 74a92c6d8b..d469582d34 100644 --- a/assets/voxygen/i18n/it_IT.ron +++ b/assets/voxygen/i18n/it_IT.ron @@ -14,7 +14,7 @@ /// Localization for "global" Italian -VoxygenLocalization( +( metadata: ( language_name: "Italiano", language_identifier: "it_IT", diff --git a/assets/voxygen/i18n/nl.ron b/assets/voxygen/i18n/nl.ron index 6c46761463..ed2c33f119 100644 --- a/assets/voxygen/i18n/nl.ron +++ b/assets/voxygen/i18n/nl.ron @@ -13,7 +13,7 @@ /// WARNING: Localization files shall be saved in UTF-8 format without BOM /// Localization for "global" English -VoxygenLocalization( +( metadata: ( language_name: "Nederlands", language_identifier: "nl", diff --git a/assets/voxygen/i18n/pt_BR.ron b/assets/voxygen/i18n/pt_BR.ron index dcd188b706..6918614aca 100644 --- a/assets/voxygen/i18n/pt_BR.ron +++ b/assets/voxygen/i18n/pt_BR.ron @@ -1,5 +1,5 @@ /// Localization for Portuguese (Brazil) -VoxygenLocalization( +Localization( metadata: ( language_name: "Português Brasileiro", language_identifier: "pt_BR", diff --git a/assets/voxygen/i18n/pt_PT.ron b/assets/voxygen/i18n/pt_PT.ron index 350d69377f..55f3420d25 100644 --- a/assets/voxygen/i18n/pt_PT.ron +++ b/assets/voxygen/i18n/pt_PT.ron @@ -1,5 +1,5 @@ /// Localization for portuguese (Portugal) -VoxygenLocalization( +( metadata: ( language_name: "Português", language_identifier: "pt_PT", diff --git a/assets/voxygen/i18n/ru_RU.ron b/assets/voxygen/i18n/ru_RU.ron index 8bc8479551..1269805096 100644 --- a/assets/voxygen/i18n/ru_RU.ron +++ b/assets/voxygen/i18n/ru_RU.ron @@ -1,5 +1,5 @@ /// Localization for "global" Russian -VoxygenLocalization( +( metadata: ( language_name: "Русский", language_identifier: "ru_RU", diff --git a/assets/voxygen/i18n/sv.ron b/assets/voxygen/i18n/sv.ron index f074769680..f1198c0e93 100644 --- a/assets/voxygen/i18n/sv.ron +++ b/assets/voxygen/i18n/sv.ron @@ -11,7 +11,7 @@ /// `assets/voxygen/i18n` and that's it! /// Localization for Swedish -VoxygenLocalization( +Localization( metadata: ( language_name: "Svenska", language_identifier: "sv", diff --git a/assets/voxygen/i18n/tr_TR.ron b/assets/voxygen/i18n/tr_TR.ron index 837b0ed7dc..15cd2e32b4 100644 --- a/assets/voxygen/i18n/tr_TR.ron +++ b/assets/voxygen/i18n/tr_TR.ron @@ -13,7 +13,7 @@ /// WARNING: Localization files shall be saved in UTF-8 format without BOM /// Localization for Turkish (Turkey) -VoxygenLocalization( +( metadata: ( language_name: "Türkçe (Türkiye)", language_identifier: "tr_TR", diff --git a/assets/voxygen/i18n/zh_CN.ron b/assets/voxygen/i18n/zh_CN.ron index a19f83765a..40622d9e0c 100644 --- a/assets/voxygen/i18n/zh_CN.ron +++ b/assets/voxygen/i18n/zh_CN.ron @@ -13,7 +13,7 @@ /// 注意: 本地化文件应以 UTF-8无BOM 格式保存 /// "全局"本地化 Simplified Chinese-简体中文 -VoxygenLocalization( +Localization( metadata: ( language_name: "Simplified Chinese", language_identifier: "zh_CN", diff --git a/assets/voxygen/i18n/zh_TW.ron b/assets/voxygen/i18n/zh_TW.ron index 657b2ba0fc..4d507c1a71 100644 --- a/assets/voxygen/i18n/zh_TW.ron +++ b/assets/voxygen/i18n/zh_TW.ron @@ -1,5 +1,5 @@ /// Localization for Traditional Chinese -VoxygenLocalization( +Localization( metadata: ( language_name: "繁體中文", language_identifier: "zh_TW", diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index f1252c9f0d..0e535cca69 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -8,9 +8,9 @@ use super::{ }; use crate::{ hud::get_quality_col, - i18n::VoxygenLocalization, + i18n::Localization, ui::{ - fonts::ConrodVoxygenFonts, + fonts::Fonts, slot::{ContentSize, SlotMaker}, ImageFrame, Tooltip, TooltipManager, Tooltipable, }, @@ -90,14 +90,14 @@ pub struct Bag<'a> { client: &'a Client, imgs: &'a Imgs, item_imgs: &'a ItemImgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, slot_manager: &'a mut SlotManager, _pulse: f32, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, stats: &'a Stats, show: &'a Show, @@ -109,12 +109,12 @@ impl<'a> Bag<'a> { client: &'a Client, imgs: &'a Imgs, item_imgs: &'a ItemImgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, slot_manager: &'a mut SlotManager, pulse: f32, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, stats: &'a Stats, show: &'a Show, ) -> Self { diff --git a/voxygen/src/hud/buffs.rs b/voxygen/src/hud/buffs.rs index ad8aeed4cc..a1a5a994ca 100644 --- a/voxygen/src/hud/buffs.rs +++ b/voxygen/src/hud/buffs.rs @@ -4,8 +4,8 @@ use super::{ }; use crate::{ hud::{get_buff_info, BuffPosition}, - i18n::VoxygenLocalization, - ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, + i18n::Localization, + ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, GlobalState, }; @@ -34,12 +34,12 @@ widget_ids! { #[derive(WidgetCommon)] pub struct BuffsBar<'a> { imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, buffs: &'a Buffs, pulse: f32, global_state: &'a GlobalState, @@ -49,10 +49,10 @@ impl<'a> BuffsBar<'a> { #[allow(clippy::too_many_arguments)] // TODO: Pending review in #587 pub fn new( imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, buffs: &'a Buffs, pulse: f32, global_state: &'a GlobalState, diff --git a/voxygen/src/hud/buttons.rs b/voxygen/src/hud/buttons.rs index e98cbebf19..874a83f192 100644 --- a/voxygen/src/hud/buttons.rs +++ b/voxygen/src/hud/buttons.rs @@ -3,8 +3,8 @@ use super::{ BLACK, CRITICAL_HP_COLOR, LOW_HP_COLOR, TEXT_COLOR, }; use crate::{ - i18n::VoxygenLocalization, - ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, + i18n::Localization, + ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, window::GameInput, GlobalState, }; @@ -49,13 +49,13 @@ pub struct Buttons<'a> { client: &'a Client, show_bag: bool, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, global_state: &'a GlobalState, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, stats: &'a Stats, } @@ -65,11 +65,11 @@ impl<'a> Buttons<'a> { client: &'a Client, show_bag: bool, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, global_state: &'a GlobalState, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, stats: &'a Stats, ) -> Self { Self { diff --git a/voxygen/src/hud/chat.rs b/voxygen/src/hud/chat.rs index 36f3f7e94f..a102f92f01 100644 --- a/voxygen/src/hud/chat.rs +++ b/voxygen/src/hud/chat.rs @@ -2,7 +2,7 @@ use super::{ img_ids::Imgs, ERROR_COLOR, FACTION_COLOR, GROUP_COLOR, INFO_COLOR, KILL_COLOR, LOOT_COLOR, OFFLINE_COLOR, ONLINE_COLOR, REGION_COLOR, SAY_COLOR, TELL_COLOR, TEXT_COLOR, WORLD_COLOR, }; -use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts, GlobalState}; +use crate::{ui::fonts::Fonts, GlobalState, Localization}; use client::{cmd, Client}; use common::{ comp::{ @@ -52,7 +52,7 @@ pub struct Chat<'a> { global_state: &'a GlobalState, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -60,7 +60,7 @@ pub struct Chat<'a> { // TODO: add an option to adjust this history_max: usize, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, } impl<'a> Chat<'a> { @@ -69,8 +69,8 @@ impl<'a> Chat<'a> { client: &'a Client, global_state: &'a GlobalState, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, ) -> Self { Self { new_messages, @@ -536,12 +536,7 @@ fn do_tab_completion(cursor: usize, input: &str, word: &str) -> (String, usize) } } -fn cursor_offset_to_index( - offset: usize, - text: &str, - ui: &Ui, - fonts: &ConrodVoxygenFonts, -) -> Option { +fn cursor_offset_to_index(offset: usize, text: &str, ui: &Ui, fonts: &Fonts) -> Option { // This moves the cursor to the given offset. Conrod is a pain. // // Width and font must match that of the chat TextEdit diff --git a/voxygen/src/hud/crafting.rs b/voxygen/src/hud/crafting.rs index d9fed33b44..4bdffff9a0 100644 --- a/voxygen/src/hud/crafting.rs +++ b/voxygen/src/hud/crafting.rs @@ -5,8 +5,8 @@ use super::{ }; use crate::{ hud::get_quality_col, - i18n::VoxygenLocalization, - ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, + i18n::Localization, + ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, }; use client::{self, Client}; use common::comp::{ @@ -55,8 +55,8 @@ pub enum Event { pub struct Crafting<'a> { client: &'a Client, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, item_imgs: &'a ItemImgs, @@ -69,8 +69,8 @@ impl<'a> Crafting<'a> { pub fn new( client: &'a Client, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, item_imgs: &'a ItemImgs, diff --git a/voxygen/src/hud/esc_menu.rs b/voxygen/src/hud/esc_menu.rs index 6ce036dfe6..fb949a249f 100644 --- a/voxygen/src/hud/esc_menu.rs +++ b/voxygen/src/hud/esc_menu.rs @@ -1,5 +1,5 @@ use super::{img_ids::Imgs, settings_window::SettingsTab, TEXT_COLOR}; -use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts}; +use crate::{i18n::Localization, ui::fonts::Fonts}; use conrod_core::{ widget::{self, Button, Image}, widget_ids, Color, Labelable, Positionable, Sizeable, Widget, WidgetCommon, @@ -22,19 +22,15 @@ widget_ids! { #[derive(WidgetCommon)] pub struct EscMenu<'a> { imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, #[conrod(common_builder)] common: widget::CommonBuilder, } impl<'a> EscMenu<'a> { - pub fn new( - imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, - ) -> Self { + pub fn new(imgs: &'a Imgs, fonts: &'a Fonts, localized_strings: &'a Localization) -> Self { Self { imgs, fonts, diff --git a/voxygen/src/hud/group.rs b/voxygen/src/hud/group.rs index 6e12c18fed..595a44ab99 100644 --- a/voxygen/src/hud/group.rs +++ b/voxygen/src/hud/group.rs @@ -6,9 +6,9 @@ use super::{ use crate::{ hud::get_buff_info, - i18n::VoxygenLocalization, + i18n::Localization, settings::Settings, - ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, + ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, window::GameInput, GlobalState, }; @@ -70,8 +70,8 @@ pub struct Group<'a> { settings: &'a Settings, imgs: &'a Imgs, rot_imgs: &'a ImgsRot, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, pulse: f32, global_state: &'a GlobalState, tooltip_manager: &'a mut TooltipManager, @@ -88,8 +88,8 @@ impl<'a> Group<'a> { settings: &'a Settings, imgs: &'a Imgs, rot_imgs: &'a ImgsRot, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, pulse: f32, global_state: &'a GlobalState, tooltip_manager: &'a mut TooltipManager, diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index ae34f752d0..046ca31e29 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -3,8 +3,8 @@ use super::{ Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, }; use crate::{ - i18n::VoxygenLocalization, - ui::{fonts::ConrodVoxygenFonts, img_ids, ImageSlider}, + i18n::Localization, + ui::{fonts::Fonts, img_ids, ImageSlider}, GlobalState, }; use client::{self, Client}; @@ -41,11 +41,11 @@ pub struct Map<'a> { world_map: &'a (img_ids::Rotations, Vec2), imgs: &'a Imgs, rot_imgs: &'a ImgsRot, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, _pulse: f32, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, global_state: &'a GlobalState, } impl<'a> Map<'a> { @@ -56,9 +56,9 @@ impl<'a> Map<'a> { imgs: &'a Imgs, rot_imgs: &'a ImgsRot, world_map: &'a (img_ids::Rotations, Vec2), - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, pulse: f32, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, global_state: &'a GlobalState, ) -> Self { Self { diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index ca993285cb..d897fa3074 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -2,7 +2,7 @@ use super::{ img_ids::{Imgs, ImgsRot}, Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, }; -use crate::ui::{fonts::ConrodVoxygenFonts, img_ids}; +use crate::ui::{fonts::Fonts, img_ids}; use client::{self, Client}; use common::{comp, terrain::TerrainChunkSize, vol::RectVolSize}; use conrod_core::{ @@ -40,7 +40,7 @@ pub struct MiniMap<'a> { imgs: &'a Imgs, rot_imgs: &'a ImgsRot, world_map: &'a (img_ids::Rotations, Vec2), - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, ori: Vec3, @@ -53,7 +53,7 @@ impl<'a> MiniMap<'a> { imgs: &'a Imgs, rot_imgs: &'a ImgsRot, world_map: &'a (img_ids::Rotations, Vec2), - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, ori: Vec3, ) -> Self { Self { diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 845a15c2ea..ffc344d3ac 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -46,13 +46,13 @@ use spell::Spell; use crate::{ ecs::{comp as vcomp, comp::HpFloaterList}, hud::img_ids::ImgsRot, - i18n::{i18n_asset_key, LanguageMetadata, VoxygenLocalization}, + i18n::{i18n_asset_key, LanguageMetadata, Localization}, render::{Consts, Globals, RenderMode, Renderer}, scene::{ camera::{self, Camera}, lod, }, - ui::{fonts::ConrodVoxygenFonts, img_ids::Rotations, slot, Graphic, Ingameable, ScaleMode, Ui}, + ui::{fonts::Fonts, img_ids::Rotations, slot, Graphic, Ingameable, ScaleMode, Ui}, window::{Event as WinEvent, FullScreenSettings, GameInput}, GlobalState, }; @@ -598,7 +598,7 @@ pub struct Hud { world_map: (/* Id */ Rotations, Vec2), imgs: Imgs, item_imgs: ItemImgs, - fonts: ConrodVoxygenFonts, + fonts: Fonts, rot_imgs: ImgsRot, new_messages: VecDeque, new_notifications: VecDeque, @@ -614,7 +614,7 @@ pub struct Hud { tab_complete: Option, pulse: f32, velocity: f32, - voxygen_i18n: std::sync::Arc, + i18n: std::sync::Arc, slot_manager: slots::SlotManager, hotbar: hotbar::State, events: Vec, @@ -649,12 +649,11 @@ impl Hud { // Load item images. let item_imgs = ItemImgs::new(&mut ui, imgs.not_found); // Load language. - let voxygen_i18n = VoxygenLocalization::load_expect(&i18n_asset_key( + let i18n = Localization::load_expect(&i18n_asset_key( &global_state.settings.language.selected_language, )); // Load fonts. - let fonts = ConrodVoxygenFonts::load(&voxygen_i18n.fonts, &mut ui) - .expect("Impossible to load fonts!"); + let fonts = Fonts::load(&i18n.fonts, &mut ui).expect("Impossible to load fonts!"); // Get the server name. let server = &client.server_info.name; // Get the id, unwrap is safe because this CANNOT be None at this @@ -715,7 +714,7 @@ impl Hud { tab_complete: None, pulse: 0.0, velocity: 0.0, - voxygen_i18n, + i18n, slot_manager, hotbar: hotbar_state, events: Vec::new(), @@ -723,10 +722,10 @@ impl Hud { } } - pub fn update_language(&mut self, voxygen_i18n: std::sync::Arc) { - self.voxygen_i18n = voxygen_i18n; - self.fonts = ConrodVoxygenFonts::load(&self.voxygen_i18n.fonts, &mut self.ui) - .expect("Impossible to load fonts!"); + pub fn update_language(&mut self, i18n: std::sync::Arc) { + self.i18n = i18n; + self.fonts = + Fonts::load(&self.i18n.fonts, &mut self.ui).expect("Impossible to load fonts!"); } #[allow(clippy::assign_op_pattern)] // TODO: Pending review in #587 @@ -1256,7 +1255,7 @@ impl Hud { in_group, &global_state.settings.gameplay, self.pulse, - &self.voxygen_i18n, + &self.i18n, &self.imgs, &self.fonts, ) @@ -1459,8 +1458,8 @@ impl Hud { Intro::Show => { if self.pulse > 20.0 { self.show.want_grab = false; - let quest_headline = &self.voxygen_i18n.get("hud.temp_quest_headline"); - let quest_text = &self.voxygen_i18n.get("hud.temp_quest_text"); + let quest_headline = &self.i18n.get("hud.temp_quest_headline"); + let quest_text = &self.i18n.get("hud.temp_quest_text"); Image::new(self.imgs.quest_bg) .w_h(404.0, 858.0) .middle_of(ui_widgets.window) @@ -1497,7 +1496,7 @@ impl Hud { .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) .mid_bottom_with_margin_on(self.ids.q_text_bg, -120.0) - .label(&self.voxygen_i18n.get("common.accept")) + .label(&self.i18n.get("common.accept")) .label_font_id(self.fonts.cyri.conrod_id) .label_font_size(self.fonts.cyri.scale(22)) .label_color(TEXT_COLOR) @@ -1675,7 +1674,7 @@ impl Hud { if let Some(help_key) = global_state.settings.controls.get_binding(GameInput::Help) { Text::new( &self - .voxygen_i18n + .i18n .get("hud.press_key_to_toggle_keybindings_fmt") .replace("{key}", help_key.to_string().as_str()), ) @@ -1693,7 +1692,7 @@ impl Hud { { Text::new( &self - .voxygen_i18n + .i18n .get("hud.press_key_to_toggle_debug_info_fmt") .replace("{key}", toggle_debug_key.to_string().as_str()), ) @@ -1708,7 +1707,7 @@ impl Hud { if let Some(help_key) = global_state.settings.controls.get_binding(GameInput::Help) { Text::new( &self - .voxygen_i18n + .i18n .get("hud.press_key_to_show_keybindings_fmt") .replace("{key}", help_key.to_string().as_str()), ) @@ -1726,7 +1725,7 @@ impl Hud { { Text::new( &self - .voxygen_i18n + .i18n .get("hud.press_key_to_show_debug_info_fmt") .replace("{key}", toggle_debug_key.to_string().as_str()), ) @@ -1744,7 +1743,7 @@ impl Hud { { Text::new( &self - .voxygen_i18n + .i18n .get("hud.press_key_to_toggle_lantern_fmt") .replace("{key}", toggle_lantern_key.to_string().as_str()), ) @@ -1789,7 +1788,7 @@ impl Hud { global_state, &self.rot_imgs, tooltip_manager, - &self.voxygen_i18n, + &self.i18n, &player_stats, ) .set(self.ids.buttons, ui_widgets) @@ -1811,7 +1810,7 @@ impl Hud { &self.fonts, &self.rot_imgs, tooltip_manager, - &self.voxygen_i18n, + &self.i18n, &player_buffs, self.pulse, &global_state, @@ -1831,7 +1830,7 @@ impl Hud { &self.imgs, &self.rot_imgs, &self.fonts, - &self.voxygen_i18n, + &self.i18n, self.pulse, &global_state, tooltip_manager, @@ -1848,7 +1847,7 @@ impl Hud { } // Popup (waypoint saved and similar notifications) Popup::new( - &self.voxygen_i18n, + &self.i18n, client, &self.new_notifications, &self.fonts, @@ -1884,7 +1883,7 @@ impl Hud { tooltip_manager, &mut self.slot_manager, self.pulse, - &self.voxygen_i18n, + &self.i18n, &player_stats, &self.show, ) @@ -1951,7 +1950,7 @@ impl Hud { &self.hotbar, tooltip_manager, &mut self.slot_manager, - &self.voxygen_i18n, + &self.i18n, &self.show, ) .set(self.ids.skillbar, ui_widgets); @@ -1965,7 +1964,7 @@ impl Hud { client, &self.imgs, &self.fonts, - &self.voxygen_i18n, + &self.i18n, &self.rot_imgs, tooltip_manager, &self.item_imgs, @@ -2004,7 +2003,7 @@ impl Hud { global_state, &self.imgs, &self.fonts, - &self.voxygen_i18n, + &self.i18n, ) .and_then(self.force_chat_input.take(), |c, input| c.input(input)) .and_then(self.tab_complete.take(), |c, input| { @@ -2041,7 +2040,7 @@ impl Hud { &self.show, &self.imgs, &self.fonts, - &self.voxygen_i18n, + &self.i18n, fps as f32, ) .set(self.ids.settings_window, ui_widgets) @@ -2194,7 +2193,7 @@ impl Hud { client, &self.imgs, &self.fonts, - &self.voxygen_i18n, + &self.i18n, info.selected_entity, &self.rot_imgs, tooltip_manager, @@ -2222,14 +2221,8 @@ impl Hud { // Spellbook if self.show.spell { - match Spell::new( - &self.show, - client, - &self.imgs, - &self.fonts, - &self.voxygen_i18n, - ) - .set(self.ids.spell, ui_widgets) + match Spell::new(&self.show, client, &self.imgs, &self.fonts, &self.i18n) + .set(self.ids.spell, ui_widgets) { Some(spell::Event::Close) => { self.show.spell(false); @@ -2249,7 +2242,7 @@ impl Hud { &self.world_map, &self.fonts, self.pulse, - &self.voxygen_i18n, + &self.i18n, &global_state, ) .set(self.ids.map, ui_widgets) @@ -2268,7 +2261,7 @@ impl Hud { } if self.show.esc_menu { - match EscMenu::new(&self.imgs, &self.fonts, &self.voxygen_i18n) + match EscMenu::new(&self.imgs, &self.fonts, &self.i18n) .set(self.ids.esc_menu, ui_widgets) { Some(esc_menu::Event::OpenSettings(tab)) => { @@ -2311,7 +2304,7 @@ impl Hud { if self.show.free_look { Text::new( &self - .voxygen_i18n + .i18n .get("hud.free_look_indicator") .replace("{key}", freelook_key.to_string().as_str()), ) @@ -2322,7 +2315,7 @@ impl Hud { .set(self.ids.free_look_bg, ui_widgets); Text::new( &self - .voxygen_i18n + .i18n .get("hud.free_look_indicator") .replace("{key}", freelook_key.to_string().as_str()), ) @@ -2336,13 +2329,13 @@ impl Hud { // Auto walk indicator if self.show.auto_walk { - Text::new(&self.voxygen_i18n.get("hud.auto_walk_indicator")) + Text::new(&self.i18n.get("hud.auto_walk_indicator")) .color(TEXT_BG) .mid_top_with_margin_on(ui_widgets.window, 70.0) .font_id(self.fonts.cyri.conrod_id) .font_size(self.fonts.cyri.scale(20)) .set(self.ids.auto_walk_bg, ui_widgets); - Text::new(&self.voxygen_i18n.get("hud.auto_walk_indicator")) + Text::new(&self.i18n.get("hud.auto_walk_indicator")) .color(KILL_COLOR) .top_left_with_margins_on(self.ids.auto_walk_bg, -1.0, -1.0) .font_id(self.fonts.cyri.conrod_id) diff --git a/voxygen/src/hud/overhead.rs b/voxygen/src/hud/overhead.rs index 8d592a3501..170c6a8d29 100644 --- a/voxygen/src/hud/overhead.rs +++ b/voxygen/src/hud/overhead.rs @@ -4,9 +4,9 @@ use super::{ }; use crate::{ hud::get_buff_info, - i18n::VoxygenLocalization, + i18n::Localization, settings::GameplaySettings, - ui::{fonts::ConrodVoxygenFonts, Ingameable}, + ui::{fonts::Fonts, Ingameable}, }; use common::comp::{BuffKind, Buffs, Energy, Health, SpeechBubble, SpeechBubbleType, Stats}; use conrod_core::{ @@ -76,9 +76,9 @@ pub struct Overhead<'a> { in_group: bool, settings: &'a GameplaySettings, pulse: f32, - voxygen_i18n: &'a std::sync::Arc, + i18n: &'a Localization, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -93,9 +93,9 @@ impl<'a> Overhead<'a> { in_group: bool, settings: &'a GameplaySettings, pulse: f32, - voxygen_i18n: &'a std::sync::Arc, + i18n: &'a Localization, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, ) -> Self { Self { info, @@ -104,7 +104,7 @@ impl<'a> Overhead<'a> { in_group, settings, pulse, - voxygen_i18n, + i18n, imgs, fonts, common: widget::CommonBuilder::default(), @@ -336,7 +336,7 @@ impl<'a> Widget for Overhead<'a> { .set(state.ids.health_bar, ui); let mut txt = format!("{}/{}", health_cur_txt, health_max_txt); if health.is_dead { - txt = self.voxygen_i18n.get("hud.group.dead").to_string() + txt = self.i18n.get("hud.group.dead").to_string() }; Text::new(&txt) .mid_top_with_margin_on(state.ids.health_bar_bg, 2.0) @@ -420,8 +420,7 @@ impl<'a> Widget for Overhead<'a> { // Speech bubble if let Some(bubble) = self.bubble { let dark_mode = self.settings.speech_bubble_dark_mode; - let localizer = - |s: &str, i| -> String { self.voxygen_i18n.get_variation(&s, i).to_string() }; + let localizer = |s: &str, i| -> String { self.i18n.get_variation(&s, i).to_string() }; let bubble_contents: String = bubble.message(localizer); let (text_color, shadow_color) = bubble_color(&bubble, dark_mode); let mut text = Text::new(&bubble_contents) diff --git a/voxygen/src/hud/overitem.rs b/voxygen/src/hud/overitem.rs index f45366176e..5c20a93576 100644 --- a/voxygen/src/hud/overitem.rs +++ b/voxygen/src/hud/overitem.rs @@ -1,6 +1,6 @@ use crate::{ settings::ControlSettings, - ui::{fonts::ConrodVoxygenFonts, Ingameable}, + ui::{fonts::Fonts, Ingameable}, window::GameInput, }; use conrod_core::{ @@ -25,7 +25,7 @@ widget_ids! { pub struct Overitem<'a> { name: &'a str, distance_from_player_sqr: &'a f32, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, controls: &'a ControlSettings, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -35,7 +35,7 @@ impl<'a> Overitem<'a> { pub fn new( name: &'a str, distance_from_player_sqr: &'a f32, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, controls: &'a ControlSettings, ) -> Self { Self { diff --git a/voxygen/src/hud/popup.rs b/voxygen/src/hud/popup.rs index 2f0e33b005..b1237c53e4 100644 --- a/voxygen/src/hud/popup.rs +++ b/voxygen/src/hud/popup.rs @@ -1,5 +1,5 @@ use super::Show; -use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts}; +use crate::{i18n::Localization, ui::fonts::Fonts}; use client::{self, Client}; use common::msg::Notification; use conrod_core::{ @@ -21,10 +21,10 @@ widget_ids! { #[derive(WidgetCommon)] pub struct Popup<'a> { - voxygen_i18n: &'a std::sync::Arc, + i18n: &'a Localization, client: &'a Client, new_notifications: &'a VecDeque, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, #[conrod(common_builder)] common: widget::CommonBuilder, show: &'a Show, @@ -34,14 +34,14 @@ pub struct Popup<'a> { /// Dungeon Cleared (TODO), and Quest Completed (TODO) impl<'a> Popup<'a> { pub fn new( - voxygen_i18n: &'a std::sync::Arc, + i18n: &'a Localization, client: &'a Client, new_notifications: &'a VecDeque, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, show: &'a Show, ) -> Self { Self { - voxygen_i18n, + i18n, client, new_notifications, fonts, @@ -126,7 +126,7 @@ impl<'a> Widget for Popup<'a> { if s.infos.is_empty() { s.last_info_update = Instant::now(); } - let text = self.voxygen_i18n.get("hud.waypoint_saved"); + let text = self.i18n.get("hud.waypoint_saved"); s.infos.push_back(text.to_string()); }); }, diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index daa5148219..25f987134b 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -5,9 +5,9 @@ use super::{ }; use crate::{ hud::BuffPosition, - i18n::{list_localizations, LanguageMetadata, VoxygenLocalization}, + i18n::{list_localizations, LanguageMetadata, Localization}, render::{AaMode, CloudMode, FluidMode, LightingMode, RenderMode, ShadowMapMode, ShadowMode}, - ui::{fonts::ConrodVoxygenFonts, ImageSlider, ScaleMode, ToggleButton}, + ui::{fonts::Fonts, ImageSlider, ScaleMode, ToggleButton}, window::{FullScreenSettings, FullscreenMode, GameInput}, GlobalState, }; @@ -227,8 +227,8 @@ pub struct SettingsWindow<'a> { global_state: &'a GlobalState, show: &'a Show, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, fps: f32, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -239,8 +239,8 @@ impl<'a> SettingsWindow<'a> { global_state: &'a GlobalState, show: &'a Show, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, fps: f32, ) -> Self { Self { diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index e8afb91e18..1f8a48eda0 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -6,9 +6,9 @@ use super::{ STAMINA_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, XP_COLOR, }; use crate::{ - i18n::VoxygenLocalization, + i18n::Localization, ui::{ - fonts::ConrodVoxygenFonts, + fonts::Fonts, slot::{ContentSize, SlotMaker}, ImageFrame, Tooltip, TooltipManager, Tooltipable, }, @@ -121,7 +121,7 @@ pub struct Skillbar<'a> { global_state: &'a GlobalState, imgs: &'a Imgs, item_imgs: &'a ItemImgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, rot_imgs: &'a ImgsRot, stats: &'a Stats, health: &'a Health, @@ -133,7 +133,7 @@ pub struct Skillbar<'a> { hotbar: &'a hotbar::State, tooltip_manager: &'a mut TooltipManager, slot_manager: &'a mut slots::SlotManager, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, pulse: f32, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -146,7 +146,7 @@ impl<'a> Skillbar<'a> { global_state: &'a GlobalState, imgs: &'a Imgs, item_imgs: &'a ItemImgs, - fonts: &'a ConrodVoxygenFonts, + fonts: &'a Fonts, rot_imgs: &'a ImgsRot, stats: &'a Stats, health: &'a Health, @@ -159,7 +159,7 @@ impl<'a> Skillbar<'a> { hotbar: &'a hotbar::State, tooltip_manager: &'a mut TooltipManager, slot_manager: &'a mut slots::SlotManager, - localized_strings: &'a std::sync::Arc, + localized_strings: &'a Localization, show: &'a Show, ) -> Self { Self { diff --git a/voxygen/src/hud/social.rs b/voxygen/src/hud/social.rs index 68680a7d01..20e7641373 100644 --- a/voxygen/src/hud/social.rs +++ b/voxygen/src/hud/social.rs @@ -4,8 +4,8 @@ use super::{ }; use crate::{ - i18n::VoxygenLocalization, - ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, + i18n::Localization, + ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable}, }; use client::{self, Client}; use common::{comp::group, sync::Uid}; @@ -66,8 +66,8 @@ pub struct Social<'a> { show: &'a Show, client: &'a Client, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, selected_entity: Option<(specs::Entity, Instant)>, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, @@ -82,8 +82,8 @@ impl<'a> Social<'a> { show: &'a Show, client: &'a Client, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, selected_entity: Option<(specs::Entity, Instant)>, rot_imgs: &'a ImgsRot, tooltip_manager: &'a mut TooltipManager, diff --git a/voxygen/src/hud/spell.rs b/voxygen/src/hud/spell.rs index 4f1a3561ba..0fbf3ab91d 100644 --- a/voxygen/src/hud/spell.rs +++ b/voxygen/src/hud/spell.rs @@ -1,5 +1,5 @@ use super::{img_ids::Imgs, Show, TEXT_COLOR, UI_MAIN}; -use crate::{i18n::VoxygenLocalization, ui::fonts::ConrodVoxygenFonts}; +use crate::{i18n::Localization, ui::fonts::Fonts}; use conrod_core::{ color, widget::{self, Button, Image, Rectangle, Text}, @@ -24,8 +24,8 @@ pub struct Spell<'a> { _client: &'a Client, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -36,8 +36,8 @@ impl<'a> Spell<'a> { show: &'a Show, _client: &'a Client, imgs: &'a Imgs, - fonts: &'a ConrodVoxygenFonts, - localized_strings: &'a std::sync::Arc, + fonts: &'a Fonts, + localized_strings: &'a Localization, ) -> Self { Self { _show: show, diff --git a/voxygen/src/i18n.rs b/voxygen/src/i18n.rs index 479fef3121..13e34dc0c0 100644 --- a/voxygen/src/i18n.rs +++ b/voxygen/src/i18n.rs @@ -44,11 +44,11 @@ impl Font { } /// Store font metadata -pub type VoxygenFonts = HashMap; +pub type Fonts = HashMap; /// Store internationalization data #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct VoxygenLocalization { +pub struct Localization { /// A map storing the localized texts /// /// Localized content can be accessed using a String key. @@ -64,12 +64,12 @@ pub struct VoxygenLocalization { pub convert_utf8_to_ascii: bool, /// Font configuration is stored here - pub fonts: VoxygenFonts, + pub fonts: Fonts, pub metadata: LanguageMetadata, } -impl VoxygenLocalization { +impl Localization { /// Get a localized text from the given key /// /// If the key is not present in the localization object @@ -97,7 +97,7 @@ impl VoxygenLocalization { /// Return the missing keys compared to the reference language pub fn list_missing_entries(&self) -> (HashSet, HashSet) { let reference_localization = - VoxygenLocalization::load_expect(i18n_asset_key(REFERENCE_LANG).as_ref()); + Localization::load_expect(i18n_asset_key(REFERENCE_LANG).as_ref()); let reference_string_keys: HashSet<_> = reference_localization.string_map.keys().cloned().collect(); @@ -136,14 +136,14 @@ impl VoxygenLocalization { } } -impl Asset for VoxygenLocalization { +impl Asset for Localization { const ENDINGS: &'static [&'static str] = &["ron"]; /// Load the translations located in the input buffer and convert them - /// into a `VoxygenLocalization` object. + /// into a `Localization` object. #[allow(clippy::into_iter_on_ref)] // TODO: Pending review in #587 fn parse(buf_reader: BufReader, _specifier: &str) -> Result { - let mut asked_localization: VoxygenLocalization = + let mut asked_localization: Localization = from_reader(buf_reader).map_err(assets::Error::parse_error)?; // Update the text if UTF-8 to ASCII conversion is enabled @@ -163,10 +163,10 @@ impl Asset for VoxygenLocalization { } } -/// Load all the available languages located in the Voxygen asset directory +/// Load all the available languages located in the voxygen asset directory pub fn list_localizations() -> Vec { let voxygen_locales_assets = "voxygen.i18n.*"; - let lang_list = VoxygenLocalization::load_glob(voxygen_locales_assets).unwrap(); + let lang_list = Localization::load_glob(voxygen_locales_assets).unwrap(); lang_list.iter().map(|e| (*e).metadata.clone()).collect() } @@ -175,7 +175,7 @@ pub fn i18n_asset_key(language_id: &str) -> String { "voxygen.i18n.".to_string() #[cfg(test)] mod tests { - use super::VoxygenLocalization; + use super::Localization; use git2::Repository; use ron::de::{from_bytes, from_reader}; use std::{ @@ -248,7 +248,7 @@ mod tests { fn generate_key_version<'a>( repo: &'a git2::Repository, - localization: &VoxygenLocalization, + localization: &Localization, path: &std::path::Path, file_blob: &git2::Blob, ) -> HashMap { @@ -348,7 +348,7 @@ mod tests { ); for path in i18n_files { let f = fs::File::open(&path).expect("Failed opening file"); - let _: VoxygenLocalization = match from_reader(f) { + let _: Localization = match from_reader(f) { Ok(v) => v, Err(e) => { panic!( @@ -387,7 +387,7 @@ mod tests { // Read HEAD for the reference language file let i18n_en_blob = read_file_from_path(&repo, &head_ref, &en_i18n_path); - let loc: VoxygenLocalization = from_bytes(i18n_en_blob.content()) + let loc: Localization = from_bytes(i18n_en_blob.content()) .expect("Expect to parse reference i18n RON file, can't proceed without it"); let i18n_references: HashMap = generate_key_version(&repo, &loc, &en_i18n_path, &i18n_en_blob); @@ -406,7 +406,7 @@ mod tests { // Find the localization entry state let current_blob = read_file_from_path(&repo, &head_ref, &relfile); - let current_loc: VoxygenLocalization = match from_bytes(current_blob.content()) { + let current_loc: Localization = match from_bytes(current_blob.content()) { Ok(v) => v, Err(e) => { eprintln!( diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index ae4be0453c..f87b32d35b 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -5,7 +5,7 @@ use veloren_voxygen::{ audio::{self, AudioFrontend}, - i18n::{self, i18n_asset_key, VoxygenLocalization}, + i18n::{self, i18n_asset_key, Localization}, logging, profile::Profile, run, @@ -157,7 +157,7 @@ fn main() { let profile = Profile::load(); let mut localization_watcher = watch::ReloadIndicator::new(); - let localized_strings = VoxygenLocalization::load_watched( + let localized_strings = Localization::load_watched( &i18n_asset_key(&settings.language.selected_language), &mut localization_watcher, ) @@ -169,7 +169,7 @@ fn main() { "Impossible to load language: change to the default language (English) instead.", ); settings.language.selected_language = i18n::REFERENCE_LANG.to_owned(); - VoxygenLocalization::load_watched( + Localization::load_watched( &i18n_asset_key(&settings.language.selected_language), &mut localization_watcher, ) diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index a50dc0c604..4cf356e5f8 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -1,7 +1,7 @@ mod ui; use crate::{ - i18n::{i18n_asset_key, VoxygenLocalization}, + i18n::{i18n_asset_key, Localization}, render::Renderer, scene::simple::{self as scene, Scene}, session::SessionState, @@ -149,7 +149,7 @@ impl PlayState for CharSelectionState { } // Tick the client (currently only to keep the connection alive). - let localized_strings = VoxygenLocalization::load_expect(&i18n_asset_key( + let localized_strings = Localization::load_expect(&i18n_asset_key( &global_state.settings.language.selected_language, )); diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index 5e64c535fb..bf3ae697af 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -1,8 +1,8 @@ use crate::{ - i18n::{i18n_asset_key, VoxygenLocalization}, + i18n::{i18n_asset_key, Localization}, render::{Consts, Globals, Renderer}, ui::{ - fonts::ConrodVoxygenFonts, + fonts::Fonts, img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic, VoxelSs9Graphic}, ImageFrame, ImageSlider, Tooltip, Tooltipable, Ui, }, @@ -26,7 +26,6 @@ use conrod_core::{ widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, UiCell, Widget, }; use rand::{thread_rng, Rng}; -use std::sync::Arc; const STARTER_HAMMER: &str = "common.items.weapons.hammer.starter_hammer"; const STARTER_BOW: &str = "common.items.weapons.bow.starter_bow"; @@ -300,9 +299,9 @@ pub struct CharSelectionUi { ids: Ids, imgs: Imgs, rot_imgs: ImgsRot, - fonts: ConrodVoxygenFonts, + fonts: Fonts, info_content: InfoContent, - voxygen_i18n: Arc, + i18n: std::sync::Arc, enter: bool, pub mode: Mode, pub selected_character: usize, @@ -321,12 +320,11 @@ impl CharSelectionUi { let imgs = Imgs::load(&mut ui).expect("Failed to load images!"); let rot_imgs = ImgsRot::load(&mut ui).expect("Failed to load images!"); // Load language - let voxygen_i18n = VoxygenLocalization::load_expect(&i18n_asset_key( + let i18n = Localization::load_expect(&i18n_asset_key( &global_state.settings.language.selected_language, )); // Load fonts. - let fonts = ConrodVoxygenFonts::load(&voxygen_i18n.fonts, &mut ui) - .expect("Impossible to load fonts!"); + let fonts = Fonts::load(&i18n.fonts, &mut ui).expect("Impossible to load fonts!"); Self { ui, @@ -336,7 +334,7 @@ impl CharSelectionUi { fonts, info_content: InfoContent::LoadingCharacters, selected_character: 0, - voxygen_i18n, + i18n, mode: Mode::Select(None), enter: false, } @@ -483,7 +481,7 @@ impl CharSelectionUi { match self.info_content { InfoContent::None => unreachable!(), InfoContent::Deletion(character_index) => { - Text::new(&self.voxygen_i18n.get("char_selection.delete_permanently")) + Text::new(&self.i18n.get("char_selection.delete_permanently")) .mid_top_with_margin_on(self.ids.info_frame, 40.0) .font_size(self.fonts.cyri.scale(24)) .font_id(self.fonts.cyri.conrod_id) @@ -495,7 +493,7 @@ impl CharSelectionUi { .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) .label_y(Relative::Scalar(2.0)) - .label(&self.voxygen_i18n.get("common.no")) + .label(&self.i18n.get("common.no")) .label_font_id(self.fonts.cyri.conrod_id) .label_font_size(self.fonts.cyri.scale(18)) .label_color(TEXT_COLOR) @@ -510,7 +508,7 @@ impl CharSelectionUi { .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) .label_y(Relative::Scalar(2.0)) - .label(&self.voxygen_i18n.get("common.yes")) + .label(&self.i18n.get("common.yes")) .label_font_id(self.fonts.cyri.conrod_id) .label_font_size(self.fonts.cyri.scale(18)) .label_color(TEXT_COLOR) @@ -532,7 +530,7 @@ impl CharSelectionUi { }; }, InfoContent::LoadingCharacters => { - Text::new(&self.voxygen_i18n.get("char_selection.loading_characters")) + Text::new(&self.i18n.get("char_selection.loading_characters")) .mid_top_with_margin_on(self.ids.info_frame, 40.0) .font_size(self.fonts.cyri.scale(24)) .font_id(self.fonts.cyri.conrod_id) @@ -540,7 +538,7 @@ impl CharSelectionUi { .set(self.ids.loading_characters_text, ui_widgets); }, InfoContent::CreatingCharacter => { - Text::new(&self.voxygen_i18n.get("char_selection.creating_character")) + Text::new(&self.i18n.get("char_selection.creating_character")) .mid_top_with_margin_on(self.ids.info_frame, 40.0) .font_size(self.fonts.cyri.scale(24)) .font_id(self.fonts.cyri.conrod_id) @@ -548,7 +546,7 @@ impl CharSelectionUi { .set(self.ids.creating_character_text, ui_widgets); }, InfoContent::DeletingCharacter => { - Text::new(&self.voxygen_i18n.get("char_selection.deleting_character")) + Text::new(&self.i18n.get("char_selection.deleting_character")) .mid_top_with_margin_on(self.ids.info_frame, 40.0) .font_size(self.fonts.cyri.scale(24)) .font_id(self.fonts.cyri.conrod_id) @@ -559,7 +557,7 @@ impl CharSelectionUi { if let Some(error_message) = &client.character_list.error { Text::new(&format!( "{}: {}", - &self.voxygen_i18n.get("common.error"), + &self.i18n.get("common.error"), error_message )) .mid_top_with_margin_on(self.ids.info_frame, 40.0) @@ -574,7 +572,7 @@ impl CharSelectionUi { .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) .label_y(Relative::Scalar(2.0)) - .label(&self.voxygen_i18n.get("common.close")) + .label(&self.i18n.get("common.close")) .label_font_id(self.fonts.cyri.conrod_id) .label_font_size(self.fonts.cyri.scale(18)) .label_color(TEXT_COLOR) @@ -644,7 +642,7 @@ impl CharSelectionUi { .parent(self.ids.charlist_bg) .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) - .label(&self.voxygen_i18n.get("char_selection.change_server")) + .label(&self.i18n.get("char_selection.change_server")) .label_color(TEXT_COLOR) .label_font_id(self.fonts.cyri.conrod_id) .label_font_size(self.fonts.cyri.scale(18)) @@ -657,7 +655,7 @@ impl CharSelectionUi { // Enter World Button let character_count = client.character_list.characters.len(); - let enter_world_str = &self.voxygen_i18n.get("char_selection.enter_world"); + let enter_world_str = &self.i18n.get("char_selection.enter_world"); let enter_button = Button::image(self.imgs.button) .mid_bottom_with_margin_on(ui_widgets.window, 10.0) .w_h(250.0, 60.0) @@ -691,7 +689,7 @@ impl CharSelectionUi { .w_h(150.0, 40.0) .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) - .label(&self.voxygen_i18n.get("char_selection.logout")) + .label(&self.i18n.get("char_selection.logout")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR) .label_font_size(self.fonts.cyri.scale(20)) @@ -772,7 +770,7 @@ impl CharSelectionUi { .press_image(self.imgs.delete_button_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("char_selection.delete_permanently"), + &self.i18n.get("char_selection.delete_permanently"), "", &tooltip_human, TEXT_COLOR, @@ -791,7 +789,7 @@ impl CharSelectionUi { Text::new( &self - .voxygen_i18n + .i18n .get("char_selection.level_fmt") .replace("{level_nb}", &character_item.level.to_string()), ) @@ -801,7 +799,7 @@ impl CharSelectionUi { .color(TEXT_COLOR) .set(self.ids.character_levels[i], ui_widgets); - Text::new(&self.voxygen_i18n.get("char_selection.uncanny_valley")) + Text::new(&self.i18n.get("char_selection.uncanny_valley")) .down_from(self.ids.character_levels[i], 4.0) .font_size(self.fonts.cyri.scale(17)) .font_id(self.fonts.cyri.conrod_id) @@ -834,7 +832,7 @@ impl CharSelectionUi { .w_h(386.0, 80.0) .hover_image(self.imgs.selection_hover) .press_image(self.imgs.selection_press) - .label(&self.voxygen_i18n.get("char_selection.create_new_charater")) + .label(&self.i18n.get("char_selection.create_new_charater")) .label_color(color) .label_font_id(self.fonts.cyri.conrod_id) .image_color(color) @@ -869,7 +867,7 @@ impl CharSelectionUi { .w_h(150.0, 40.0) .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) - .label(&self.voxygen_i18n.get("common.back")) + .label(&self.i18n.get("common.back")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR) .label_font_size(self.fonts.cyri.scale(20)) @@ -893,7 +891,7 @@ impl CharSelectionUi { } else { self.imgs.button }) - .label(&self.voxygen_i18n.get("common.create")) + .label(&self.i18n.get("common.create")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(if *name != "Character Name" && *name != "" { TEXT_COLOR @@ -908,7 +906,7 @@ impl CharSelectionUi { if create_button .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("char_selection.create_info_name"), + &self.i18n.get("char_selection.create_info_name"), "", &tooltip_human, TEXT_COLOR, @@ -1081,7 +1079,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.species.human"), + &self.i18n.get("common.species.human"), "", &tooltip_human, TEXT_COLOR, @@ -1108,7 +1106,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.species.orc"), + &self.i18n.get("common.species.orc"), "", &tooltip_human, TEXT_COLOR, @@ -1134,7 +1132,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.species.dwarf"), + &self.i18n.get("common.species.dwarf"), "", &tooltip_human, TEXT_COLOR, @@ -1160,7 +1158,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.species.elf"), + &self.i18n.get("common.species.elf"), "", &tooltip_human, TEXT_COLOR, @@ -1187,7 +1185,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.species.undead"), + &self.i18n.get("common.species.undead"), "", &tooltip_human, TEXT_COLOR, @@ -1213,7 +1211,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.species.danari"), + &self.i18n.get("common.species.danari"), "", &tooltip_human, TEXT_COLOR, @@ -1239,7 +1237,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.weapons.sceptre"), + &self.i18n.get("common.weapons.sceptre"), "", &tooltip_human, TEXT_COLOR, @@ -1265,7 +1263,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.weapons.bow"), + &self.i18n.get("common.weapons.bow"), "", &tooltip_human, TEXT_COLOR, @@ -1290,7 +1288,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.weapons.staff"), + &self.i18n.get("common.weapons.staff"), "", &tooltip_human, TEXT_COLOR, @@ -1315,7 +1313,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.weapons.sword"), + &self.i18n.get("common.weapons.sword"), "", &tooltip_human, TEXT_COLOR, @@ -1341,7 +1339,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.weapons.hammer"), + &self.i18n.get("common.weapons.hammer"), "", &tooltip_human, TEXT_COLOR, @@ -1367,7 +1365,7 @@ impl CharSelectionUi { .press_image(self.imgs.icon_border_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.weapons.axe"), + &self.i18n.get("common.weapons.axe"), "", &tooltip_human, TEXT_COLOR, @@ -1385,7 +1383,7 @@ impl CharSelectionUi { .press_image(self.imgs.dice_press) .with_tooltip( tooltip_manager, - &self.voxygen_i18n.get("common.rand_appearance"), + &self.i18n.get("common.rand_appearance"), "", &tooltip_human, TEXT_COLOR, @@ -1436,7 +1434,7 @@ impl CharSelectionUi { // Hair Style if let Some(new_val) = char_slider( self.ids.creation_buttons_alignment_2, - self.voxygen_i18n.get("char_selection.hair_style"), + self.i18n.get("char_selection.hair_style"), self.ids.hairstyle_text, body.species.num_hair_styles(body.body_type) as usize - 1, body.hair_style as usize, @@ -1448,7 +1446,7 @@ impl CharSelectionUi { // Hair Color if let Some(new_val) = char_slider( self.ids.hairstyle_slider, - self.voxygen_i18n.get("char_selection.hair_color"), + self.i18n.get("char_selection.hair_color"), self.ids.haircolor_text, body.species.num_hair_colors() as usize - 1, body.hair_color as usize, @@ -1460,7 +1458,7 @@ impl CharSelectionUi { // Skin if let Some(new_val) = char_slider( self.ids.haircolor_slider, - self.voxygen_i18n.get("char_selection.skin"), + self.i18n.get("char_selection.skin"), self.ids.skin_text, body.species.num_skin_colors() as usize - 1, body.skin as usize, @@ -1472,7 +1470,7 @@ impl CharSelectionUi { // Eyebrows if let Some(new_val) = char_slider( self.ids.skin_slider, - self.voxygen_i18n.get("char_selection.eyeshape"), + self.i18n.get("char_selection.eyeshape"), self.ids.eyebrows_text, body.species.num_eyes(body.body_type) as usize - 1, body.eyes as usize, @@ -1484,7 +1482,7 @@ impl CharSelectionUi { // EyeColor if let Some(new_val) = char_slider( self.ids.eyebrows_slider, - self.voxygen_i18n.get("char_selection.eye_color"), + self.i18n.get("char_selection.eye_color"), self.ids.eyecolor_text, body.species.num_eye_colors() as usize - 1, body.eye_color as usize, @@ -1497,7 +1495,7 @@ impl CharSelectionUi { let _current_accessory = body.accessory; if let Some(new_val) = char_slider( self.ids.eyecolor_slider, - self.voxygen_i18n.get("char_selection.accessories"), + self.i18n.get("char_selection.accessories"), self.ids.accessories_text, body.species.num_accessories(body.body_type) as usize - 1, body.accessory as usize, @@ -1510,7 +1508,7 @@ impl CharSelectionUi { if body.species.num_beards(body.body_type) > 1 { if let Some(new_val) = char_slider( self.ids.accessories_slider, - self.voxygen_i18n.get("char_selection.beard"), + self.i18n.get("char_selection.beard"), self.ids.beard_text, body.species.num_beards(body.body_type) as usize - 1, body.beard as usize, @@ -1520,7 +1518,7 @@ impl CharSelectionUi { body.beard = new_val as u8; } } else { - Text::new(&self.voxygen_i18n.get("char_selection.beard")) + Text::new(&self.i18n.get("char_selection.beard")) .mid_bottom_with_margin_on(self.ids.accessories_slider, -40.0) .font_size(self.fonts.cyri.scale(18)) .font_id(self.fonts.cyri.conrod_id) @@ -1541,7 +1539,7 @@ impl CharSelectionUi { .expect("Unable to load armor!"); if let Some(new_val) = char_slider( self.ids.beard_slider, - self.voxygen_i18n.get("char_selection.chest_color"), + self.i18n.get("char_selection.chest_color"), self.ids.chest_text, armor.len() - 1, armor diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index b2d685b92d..8674aa8003 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -47,7 +47,7 @@ impl PlayState for MainMenuState { fn tick(&mut self, global_state: &mut GlobalState, events: Vec) -> PlayStateResult { span!(_guard, "tick", "::tick"); - let localized_strings = crate::i18n::VoxygenLocalization::load_expect( + let localized_strings = crate::i18n::Localization::load_expect( &crate::i18n::i18n_asset_key(&global_state.settings.language.selected_language), ); diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index 49babfc263..db29d8e19f 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -1,9 +1,9 @@ use crate::{ - i18n::{i18n_asset_key, VoxygenLocalization}, + i18n::{i18n_asset_key, Localization}, render::Renderer, ui::{ self, - fonts::ConrodVoxygenFonts, + fonts::Fonts, ice::{Element, IcedUi}, img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic}, Graphic, Ui, @@ -190,7 +190,7 @@ struct IcedState { } pub type Message = Event; impl IcedState { - pub fn view(&mut self) -> Element { + pub fn view(&mut self, i18n: &Localization) -> Element { use iced::{Align, Column, Container, Length, Row, Space, Text}; use ui::ice::{ compound_graphic::{CompoundGraphic, Graphic}, @@ -206,13 +206,30 @@ impl IcedState { Text::new("Quit"), ) .into(), */ - Text::new("Quit").size(20).into(), + Text::new(i18n.get("common.quit")).size(40).into(), ]) .width(Length::Fill) .max_width(200) .spacing(5) .padding(10); + // Quit + /*if Button::image(self.imgs.button) + .w_h(190.0, 40.0) + .bottom_left_with_margins_on(ui_widgets.window, 60.0, 30.0) + .hover_image(self.imgs.button_hover) + .press_image(self.imgs.button_press) + .label(i18n.get("common.quit")) + .label_font_id(self.fonts.cyri.conrod_id) + .label_color(TEXT_COLOR) + .label_font_size(self.fonts.cyri.scale(20)) + .label_y(Relative::Scalar(3.0)) + .set(self.ids.quit_button, ui_widgets) + .was_clicked() + { + events.push(Event::Quit); + }*/ + let buttons = Container::new(buttons) .width(Length::Fill) .height(Length::Fill) @@ -331,8 +348,8 @@ pub struct MainMenuUi { time: f32, anim_timer: f32, bg_img_id: conrod_core::image::Id, - voxygen_i18n: std::sync::Arc, - fonts: ConrodVoxygenFonts, + i18n: std::sync::Arc, + fonts: Fonts, tip_no: u16, pub show_iced: bool, } @@ -376,21 +393,22 @@ impl<'a> MainMenuUi { )); //let chosen_tip = *tips.choose(&mut rng).unwrap(); // Load language - let voxygen_i18n = VoxygenLocalization::load_expect(&i18n_asset_key( + let i18n = Localization::load_expect(&i18n_asset_key( &global_state.settings.language.selected_language, )); // Load fonts. - let fonts = ConrodVoxygenFonts::load(&voxygen_i18n.fonts, &mut ui) - .expect("Impossible to load fonts!"); + let fonts = Fonts::load(&i18n.fonts, &mut ui).expect("Impossible to load fonts!"); // TODO: newtype Font let ice_font = { use std::io::Read; let mut buf = Vec::new(); - common::assets::load_file("voxygen.font.OpenSans-Regular", &["ttf"]) - .unwrap() - .read_to_end(&mut buf) - .unwrap(); + common::assets::load_file("voxygen.font.haxrcorp_4089_cyrillic_altgr_extended", &[ + "ttf", + ]) + .unwrap() + .read_to_end(&mut buf) + .unwrap(); glyph_brush::rusttype::Font::from_bytes(buf).unwrap() }; @@ -421,7 +439,7 @@ impl<'a> MainMenuUi { anim_timer: 0.0, //show_disclaimer: global_state.settings.show_disclaimer, bg_img_id, - voxygen_i18n, + i18n, fonts, tip_no: 0, show_iced: false, @@ -438,8 +456,8 @@ impl<'a> MainMenuUi { let (ref mut ui_widgets, ref mut _tooltip_manager) = self.ui.set_widgets(); let tip_msg = format!( "{} {}", - &self.voxygen_i18n.get("main.tip"), - &self.voxygen_i18n.get_variation("loading.tips", self.tip_no), + &self.i18n.get("main.tip"), + &self.i18n.get_variation("loading.tips", self.tip_no), ); let tip_show = global_state.settings.gameplay.loading_tips; let mut rng = thread_rng(); @@ -450,7 +468,7 @@ impl<'a> MainMenuUi { const TEXT_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); //const INACTIVE: Color = Color::Rgba(0.47, 0.47, 0.47, 0.47); - let intro_text = &self.voxygen_i18n.get("main.login_process"); + let intro_text = &self.i18n.get("main.login_process"); // Tooltip /*let _tooltip = Tooltip::new({ @@ -614,9 +632,9 @@ impl<'a> MainMenuUi { .press_image(self.imgs.button_press) .label_y(Relative::Scalar(2.0)) .label(match popup_type { - PopupType::Error => self.voxygen_i18n.get("common.okay"), - PopupType::ConnectionInfo => self.voxygen_i18n.get("common.cancel"), - PopupType::AuthTrustPrompt(_) => self.voxygen_i18n.get("common.cancel"), + PopupType::Error => self.i18n.get("common.okay"), + PopupType::ConnectionInfo => self.i18n.get("common.cancel"), + PopupType::AuthTrustPrompt(_) => self.i18n.get("common.cancel"), }) .label_font_id(self.fonts.cyri.conrod_id) .label_font_size(self.fonts.cyri.scale(15)) @@ -652,7 +670,7 @@ impl<'a> MainMenuUi { { events.push(Event::AuthServerTrust(auth_server.clone(), true)); change_popup = Some(Some(PopupData { - msg: self.voxygen_i18n.get("main.connecting").into(), + msg: self.i18n.get("main.connecting").into(), popup_type: PopupType::ConnectionInfo, })); } @@ -690,13 +708,13 @@ impl<'a> MainMenuUi { .scroll_kids_vertically() .set(self.ids.disc_window, ui_widgets); - Text::new(&self.voxygen_i18n.get("common.disclaimer")) + Text::new(&self.i18n.get("common.disclaimer")) .top_left_with_margins_on(self.ids.disc_window, 30.0, 40.0) .font_size(self.fonts.cyri.scale(35)) .font_id(self.fonts.alkhemi.conrod_id) .color(TEXT_COLOR) .set(self.ids.disc_text_1, ui_widgets); - Text::new(&self.voxygen_i18n.get("main.notice")) + Text::new(&self.i18n.get("main.notice")) .top_left_with_margins_on(self.ids.disc_window, 110.0, 40.0) .font_size(self.fonts.cyri.scale(26)) .font_id(self.fonts.cyri.conrod_id) @@ -708,7 +726,7 @@ impl<'a> MainMenuUi { .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) .label_y(Relative::Scalar(2.0)) - .label(&self.voxygen_i18n.get("common.accept")) + .label(&self.i18n.get("common.accept")) .label_font_size(self.fonts.cyri.scale(22)) .label_color(TEXT_COLOR) .label_font_id(self.fonts.cyri.conrod_id) @@ -727,7 +745,7 @@ impl<'a> MainMenuUi { self.connect = true; self.connecting = Some(std::time::Instant::now()); self.popup = Some(PopupData { - msg: [self.voxygen_i18n.get("main.connecting"), "..."].concat(), + msg: [self.i18n.get("main.connecting"), "..."].concat(), popup_type: PopupType::ConnectionInfo, }); @@ -764,7 +782,7 @@ impl<'a> MainMenuUi { self.connect = true; self.connecting = Some(std::time::Instant::now()); self.popup = Some(PopupData { - msg: [self.voxygen_i18n.get(""), ""].concat(), + msg: [self.i18n.get(""), ""].concat(), popup_type: PopupType::ConnectionInfo, }); }; @@ -893,7 +911,7 @@ impl<'a> MainMenuUi { .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) .label_y(Relative::Scalar(2.0)) - .label(&self.voxygen_i18n.get("common.close")) + .label(&self.i18n.get("common.close")) .label_font_size(self.fonts.cyri.scale(20)) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR) @@ -942,7 +960,7 @@ impl<'a> MainMenuUi { .w_h(258.0*scale, 55.0*scale) .down_from(self.ids.address_bg, 20.0*scale) .align_middle_x_of(self.ids.address_bg) - .label(&self.voxygen_i18n.get("common.multiplayer")) + .label(&self.i18n.get("common.multiplayer")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR) .label_font_size(self.fonts.cyri.scale(18)) @@ -970,7 +988,7 @@ impl<'a> MainMenuUi { .w_h(258.0 * scale, 55.0 * scale) .down_from(self.ids.login_button, 20.0 * scale) .align_middle_x_of(self.ids.address_bg) - .label(&self.voxygen_i18n.get("common.singleplayer")) + .label(&self.i18n.get("common.singleplayer")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR) .label_font_size(self.fonts.cyri.scale(18)) @@ -989,7 +1007,7 @@ impl<'a> MainMenuUi { .bottom_left_with_margins_on(ui_widgets.window, 60.0 * scale, 30.0 * scale) .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) - .label(&self.voxygen_i18n.get("common.quit")) + .label(&self.i18n.get("common.quit")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR) .label_font_size(self.fonts.cyri.scale(16)) @@ -1006,7 +1024,7 @@ impl<'a> MainMenuUi { .up_from(self.ids.quit_button, 8.0*scale) //.hover_image(self.imgs.button_hover) //.press_image(self.imgs.button_press) - .label(&self.voxygen_i18n.get("common.settings")) + .label(&self.i18n.get("common.settings")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR_2) .label_font_size(self.fonts.cyri.scale(16)) @@ -1023,7 +1041,7 @@ impl<'a> MainMenuUi { .up_from(self.ids.settings_button, 8.0 * scale) .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) - .label(&self.voxygen_i18n.get("common.servers")) + .label(&self.i18n.get("common.servers")) .label_font_id(self.fonts.cyri.conrod_id) .label_color(TEXT_COLOR) .label_font_size(self.fonts.cyri.scale(16)) @@ -1079,8 +1097,10 @@ impl<'a> MainMenuUi { pub fn maintain(&mut self, global_state: &mut GlobalState, dt: Duration) -> Vec { let events = self.update_layout(global_state, dt); self.ui.maintain(global_state.window.renderer_mut(), None); - self.ice_ui - .maintain(self.ice_state.view(), global_state.window.renderer_mut()); + self.ice_ui.maintain( + self.ice_state.view(&self.i18n), + global_state.window.renderer_mut(), + ); events } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index c94d93071c..0a5f8e5503 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -2,7 +2,7 @@ use crate::{ audio::sfx::{SfxEvent, SfxEventItem}, ecs::MyEntity, hud::{DebugInfo, Event as HudEvent, Hud, HudInfo, PressBehavior}, - i18n::{i18n_asset_key, VoxygenLocalization}, + i18n::{i18n_asset_key, Localization}, key_state::KeyState, menu::char_selection::CharSelectionState, render::Renderer, @@ -46,7 +46,7 @@ pub struct SessionState { key_state: KeyState, inputs: comp::ControllerInputs, selected_block: Block, - voxygen_i18n: std::sync::Arc, + i18n: std::sync::Arc, walk_forward_dir: Vec2, walk_right_dir: Vec2, freefly_vel: Vec3, @@ -72,7 +72,7 @@ impl SessionState { .camera_mut() .set_fov_deg(global_state.settings.graphics.fov); let hud = Hud::new(global_state, &client.borrow()); - let voxygen_i18n = VoxygenLocalization::load_expect(&i18n_asset_key( + let i18n = Localization::load_expect(&i18n_asset_key( &global_state.settings.language.selected_language, )); @@ -86,7 +86,7 @@ impl SessionState { inputs: comp::ControllerInputs::default(), hud, selected_block: Block::new(BlockKind::Misc, Rgb::broadcast(255)), - voxygen_i18n, + i18n, walk_forward_dir, walk_right_dir, freefly_vel: Vec3::zero(), @@ -131,14 +131,14 @@ impl SessionState { match inv_event { InventoryUpdateEvent::CollectFailed => { self.hud.new_message(ChatMsg { - message: self.voxygen_i18n.get("hud.chat.loot_fail").to_string(), + message: self.i18n.get("hud.chat.loot_fail").to_string(), chat_type: ChatType::CommandError, }); }, InventoryUpdateEvent::Collected(item) => { self.hud.new_message(ChatMsg { message: self - .voxygen_i18n + .i18n .get("hud.chat.loot_msg") .replace("{item}", item.name()), chat_type: ChatType::Loot, @@ -150,9 +150,9 @@ impl SessionState { client::Event::Disconnect => return Ok(TickAction::Disconnect), client::Event::DisconnectionNotification(time) => { let message = match time { - 0 => String::from(self.voxygen_i18n.get("hud.chat.goodbye")), + 0 => String::from(self.i18n.get("hud.chat.goodbye")), _ => self - .voxygen_i18n + .i18n .get("hud.chat.connection_lost") .replace("{time}", time.to_string().as_str()), }; @@ -165,7 +165,7 @@ impl SessionState { client::Event::Kicked(reason) => { global_state.info_message = Some(format!( "{}: {}", - self.voxygen_i18n.get("main.login.kicked").to_string(), + self.i18n.get("main.login.kicked").to_string(), reason )); return Ok(TickAction::Disconnect); @@ -207,7 +207,7 @@ impl PlayState for SessionState { span!(_guard, "tick", "::tick"); // TODO: let mut client = self.client.borrow_mut(); // NOTE: Not strictly necessary, but useful for hotloading translation changes. - self.voxygen_i18n = VoxygenLocalization::load_expect(&i18n_asset_key( + self.i18n = Localization::load_expect(&i18n_asset_key( &global_state.settings.language.selected_language, )); @@ -673,7 +673,7 @@ impl PlayState for SessionState { Ok(TickAction::Disconnect) => return PlayStateResult::Pop, // Go to main menu Err(err) => { global_state.info_message = - Some(self.voxygen_i18n.get("common.connection_lost").to_owned()); + Some(self.i18n.get("common.connection_lost").to_owned()); error!("[session] Failed to tick the scene: {:?}", err); return PlayStateResult::Pop; @@ -752,7 +752,7 @@ impl PlayState for SessionState { // Look for changes in the localization files if global_state.localization_watcher.reloaded() { hud_events.push(HudEvent::ChangeLanguage(Box::new( - self.voxygen_i18n.metadata.clone(), + self.i18n.metadata.clone(), ))); } @@ -980,13 +980,13 @@ impl PlayState for SessionState { HudEvent::ChangeLanguage(new_language) => { global_state.settings.language.selected_language = new_language.language_identifier; - self.voxygen_i18n = VoxygenLocalization::load_watched( + self.i18n = Localization::load_watched( &i18n_asset_key(&global_state.settings.language.selected_language), &mut global_state.localization_watcher, ) .unwrap(); - self.voxygen_i18n.log_missing_entries(); - self.hud.update_language(Arc::clone(&self.voxygen_i18n)); + self.i18n.log_missing_entries(); + self.hud.update_language(Arc::clone(&self.i18n)); }, HudEvent::ChangeFullscreenMode(new_fullscreen_settings) => { global_state diff --git a/voxygen/src/ui/fonts.rs b/voxygen/src/ui/fonts.rs index 9c726eadba..05ba6d3aab 100644 --- a/voxygen/src/ui/fonts.rs +++ b/voxygen/src/ui/fonts.rs @@ -1,14 +1,14 @@ -use crate::i18n::{Font, VoxygenFonts}; +use crate::i18n; use common::assets::Asset; -pub struct ConrodVoxygenFont { - metadata: Font, +pub struct Font { + metadata: i18n::Font, pub conrod_id: conrod_core::text::font::Id, } -impl ConrodVoxygenFont { +impl Font { #[allow(clippy::needless_return)] // TODO: Pending review in #587 - pub fn new(font: &Font, ui: &mut crate::ui::Ui) -> ConrodVoxygenFont { + pub fn new(font: &i18n::Font, ui: &mut crate::ui::Ui) -> Font { return Self { metadata: font.clone(), conrod_id: ui.new_font(crate::ui::Font::load_expect(&font.asset_key)), @@ -22,14 +22,14 @@ impl ConrodVoxygenFont { macro_rules! conrod_fonts { ($([ $( $name:ident$(,)? )* ])*) => { $( - pub struct ConrodVoxygenFonts { - $(pub $name: ConrodVoxygenFont,)* + pub struct Fonts { + $(pub $name: Font,)* } - impl ConrodVoxygenFonts { - pub fn load(voxygen_fonts: &VoxygenFonts, ui: &mut crate::ui::Ui) -> Result { + impl Fonts { + pub fn load(fonts: &i18n::Fonts, ui: &mut crate::ui::Ui) -> Result { Ok(Self { - $( $name: ConrodVoxygenFont::new(voxygen_fonts.get(stringify!($name)).unwrap(), ui),)* + $( $name: Font::new(fonts.get(stringify!($name)).unwrap(), ui),)* }) } }