From 89400264dc0fb9babb93bcdd04f97c4252dcd772 Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Wed, 1 Jul 2020 19:05:44 +0000 Subject: [PATCH] Loot ChatType, Update german translation, map zooming --- CHANGELOG.md | 1 + .../voxygen/element/icons/chat/loot_small.png | 3 + assets/voxygen/element/slider/indicator.png | 3 + assets/voxygen/element/slider/indicator.vox | 3 - .../element/slider/indicator_round.png | 3 + assets/voxygen/element/slider/track.png | 3 + assets/voxygen/element/slider/track.vox | 3 - assets/voxygen/i18n/de_DE.ron | 21 +++++- assets/voxygen/i18n/en.ron | 16 ++++- client/src/lib.rs | 1 + common/src/comp/chat.rs | 4 ++ server/src/state_ext.rs | 1 + server/src/sys/message.rs | 2 +- voxygen/src/hud/chat.rs | 5 +- voxygen/src/hud/img_ids.rs | 8 ++- voxygen/src/hud/map.rs | 71 +++++++++++++------ voxygen/src/hud/mod.rs | 22 ++++-- voxygen/src/menu/char_selection/ui.rs | 5 +- voxygen/src/session.rs | 32 ++++++--- voxygen/src/settings.rs | 2 + 20 files changed, 158 insertions(+), 51 deletions(-) create mode 100644 assets/voxygen/element/icons/chat/loot_small.png create mode 100644 assets/voxygen/element/slider/indicator.png delete mode 100644 assets/voxygen/element/slider/indicator.vox create mode 100644 assets/voxygen/element/slider/indicator_round.png create mode 100644 assets/voxygen/element/slider/track.png delete mode 100644 assets/voxygen/element/slider/track.vox diff --git a/CHANGELOG.md b/CHANGELOG.md index e30efd1c49..5f77b5fe83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added regional, local, and global chat (`/region`, `/say`, and `/world`, respectively) - Added command shortcuts for each of the above chat modes (`/g`, `/f`, `/r`, `/s`, and `/w`, respectively and `/t` for `/tell`) - Ability to wield 2 × 1h weapons and shields (Note: 1h weapons & shields are not currently avaliable, see [!1095](https://gitlab.com/veloren/veloren/-/merge_requests/1095) for more info) +- Zoomable Map ### Changed diff --git a/assets/voxygen/element/icons/chat/loot_small.png b/assets/voxygen/element/icons/chat/loot_small.png new file mode 100644 index 0000000000..626d1c031b --- /dev/null +++ b/assets/voxygen/element/icons/chat/loot_small.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fac61138c765c68b90ab9c32b51ea2f7b9ee03ee00f30d9eebc15ada54436654 +size 512 diff --git a/assets/voxygen/element/slider/indicator.png b/assets/voxygen/element/slider/indicator.png new file mode 100644 index 0000000000..6b596273ce --- /dev/null +++ b/assets/voxygen/element/slider/indicator.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb320dde662731a02be39fb7a0cdee72866bfa18f22c775d2647430d0c5cf57d +size 224 diff --git a/assets/voxygen/element/slider/indicator.vox b/assets/voxygen/element/slider/indicator.vox deleted file mode 100644 index f8c85408ee..0000000000 --- a/assets/voxygen/element/slider/indicator.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b40ff01451e8c76d84722bc078cf8b93a787ab17464faac05245d88067c5e3f7 -size 1296 diff --git a/assets/voxygen/element/slider/indicator_round.png b/assets/voxygen/element/slider/indicator_round.png new file mode 100644 index 0000000000..c724a2235f --- /dev/null +++ b/assets/voxygen/element/slider/indicator_round.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5b1aba5c864773ca7f1de94e8fd5c15f5ad3080985a49a60368ddc20622cc42 +size 181 diff --git a/assets/voxygen/element/slider/track.png b/assets/voxygen/element/slider/track.png new file mode 100644 index 0000000000..5c5c2818ce --- /dev/null +++ b/assets/voxygen/element/slider/track.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a56a82312a3940d56e6913fe6663405ce390e014f01d417be851d19aa6c2293 +size 173 diff --git a/assets/voxygen/element/slider/track.vox b/assets/voxygen/element/slider/track.vox deleted file mode 100644 index e5524f4c0f..0000000000 --- a/assets/voxygen/element/slider/track.vox +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6e8f525fbc0e6d2bccb9f4a96744493811c5e15528b89ed9c008217a185ddff9 -size 4248 diff --git a/assets/voxygen/i18n/de_DE.ron b/assets/voxygen/i18n/de_DE.ron index df54b77e7d..32e371ca31 100644 --- a/assets/voxygen/i18n/de_DE.ron +++ b/assets/voxygen/i18n/de_DE.ron @@ -138,6 +138,7 @@ eurer erstellen Charaktere gespeichert."#, "main.login.failed_sending_request": "Authentifizierung fehlgeschlagen", "main.login.invalid_character": "Ungültiger Charakter", "main.login.client_crashed": "Client abgestürzt", + "main.login.not_on_whitelist": "Ihr braucht einen Whitelist Eintrag durch den Server Admin", /// End Main screen section @@ -154,6 +155,18 @@ eurer erstellen Charaktere gespeichert."#, "hud.press_key_to_toggle_keybindings_fmt": "Drückt {key} um die Tastenbelegung zu zeigen", "hud.press_key_to_toggle_debug_info_fmt": "Drückt {key} um die Debug-Info zu zeigen", + // Chat outputs + "hud.chat.online_msg": "[{name}] ist jetzt online.", + "hud.chat.offline_msg": "{name} ist jetzt offline.", + "hud.chat.loot_msg": "Ihr erhaltet [{item}]", + "hud.chat.loot_fail": "Euer Inventar ist voll!", + "hud.chat.goodbye": "Verbindung getrennt.", + "hud.chat.connection_lost": "Verbindung unterbrochen. Trenne Verbindung in {time} sekunden.", + + // SCT outputs + "hud.sct.experience": "{amount} Erf", + "hud.sct.block": "GEBLOCKT", + /// Respawn message "hud.press_key_to_respawn": r#"Drückt {key} um am letzten Lagerfeuer wiederbelebt zu werden."#, @@ -252,12 +265,15 @@ magischen Gegenstände ergattern?"#, "hud.settings.cumulated_damage": "Addierter Schaden", "hud.settings.incoming_damage": "Erlittener Schaden", "hud.settings.cumulated_incoming_damage": "Addierter erlittener Schaden", + "hud.settings.speech_bubble": "Sprechblase", "hud.settings.speech_bubble_dark_mode": "Dunkle Sprechblasen", + "hud.settings.speech_bubble_icon": "Sprechblasen Symbole", "hud.settings.energybar_numbers": "Zahlen auf Ressourcenanzeige", "hud.settings.values": "Werte", "hud.settings.percentages": "Prozent", "hud.settings.chat": "Chat", - "hud.settings.background_transparency": "Hintergrund Kontrast", + "hud.settings.background_transparency": "Hintergrund Kontrast", + "hud.settings.chat_character_name": "Character Namen im Chat", "hud.settings.pan_sensitivity": "Schwenk Sensibilität", "hud.settings.zoom_sensitivity": "Zoom Sensibilität", @@ -265,6 +281,8 @@ magischen Gegenstände ergattern?"#, "hud.settings.invert_mouse_y_axis": "Maus Y-Achse invertieren", "hud.settings.enable_mouse_smoothing": "Kamera Glättung", "hud.settings.free_look_behavior": "Freies Umsehen", + "hud.settings.auto_walk_behavior": "Automatisches Laufen", + "hud.settings.stop_auto_walk_on_input": "Auto-Laufen bei Tastendruck stoppen", "hud.settings.view_distance": "Gelände Sichtweite", "hud.settings.sprites_view_distance": "Objekt Sichtweite", @@ -297,6 +315,7 @@ magischen Gegenstände ergattern?"#, "hud.spell": "Zauber", "hud.free_look_indicator": "Freie Sicht aktiv", + "hud.auto_walk_indicator": "Automatisches Laufen aktiv", /// End HUD section diff --git a/assets/voxygen/i18n/en.ron b/assets/voxygen/i18n/en.ron index 3c974bed87..6f339489dc 100644 --- a/assets/voxygen/i18n/en.ron +++ b/assets/voxygen/i18n/en.ron @@ -138,7 +138,7 @@ https://account.veloren.net."#, "main.login.failed_sending_request": "Request to Auth server failed", "main.login.invalid_character": "The selected character is invalid", "main.login.client_crashed": "Client crashed", - "main.login.not_on_whitelist": "You are not on the whitelist. Contact Server Owner if you want to join.", + "main.login.not_on_whitelist": "You need a Whitelist entry by an Admin to join", /// End Main screen section @@ -155,6 +155,18 @@ https://account.veloren.net."#, "hud.press_key_to_toggle_keybindings_fmt": "Press {key} to toggle keybindings", "hud.press_key_to_toggle_debug_info_fmt": "Press {key} to toggle debug info", + // Chat outputs + "hud.chat.online_msg": "[{name}] is now online.", + "hud.chat.offline_msg": "{name} went offline.", + "hud.chat.loot_msg": "You picked up [{item}]", + "hud.chat.loot_fail": "Your Inventory is full!", + "hud.chat.goodbye": "Goodbye!", + "hud.chat.connection_lost": "Connection lost. Kicking in {time} seconds.", + + // SCT outputs + "hud.sct.experience": "{amount} Exp", + "hud.sct.block": "BLOCKED", + // Respawn message "hud.press_key_to_respawn": r#"Press {key} to respawn at the last campfire you visited."#, @@ -260,7 +272,7 @@ magically infused items?"#, "hud.settings.percentages": "Percentages", "hud.settings.chat": "Chat", "hud.settings.background_transparency": "Background Transparency", - "hud.settings.chat_character_name": "Show Character Names", + "hud.settings.chat_character_name": "Character Names in chat", "hud.settings.pan_sensitivity": "Pan Sensitivity", "hud.settings.zoom_sensitivity": "Zoom Sensitivity", diff --git a/client/src/lib.rs b/client/src/lib.rs index a2fdab84b6..64a75024f3 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1045,6 +1045,7 @@ impl Client { comp::ChatType::Offline => message.to_string(), comp::ChatType::CommandError => message.to_string(), comp::ChatType::CommandInfo => message.to_string(), + comp::ChatType::Loot => message.to_string(), comp::ChatType::FactionMeta(_) => message.to_string(), comp::ChatType::GroupMeta(_) => message.to_string(), comp::ChatType::Kill => message.to_string(), diff --git a/common/src/comp/chat.rs b/common/src/comp/chat.rs index c53d85df4c..17cd3987f4 100644 --- a/common/src/comp/chat.rs +++ b/common/src/comp/chat.rs @@ -81,6 +81,8 @@ pub enum ChatType { Npc(Uid, u16), /// Anything else Meta, + // Looted items + Loot, } impl ChatType { @@ -134,6 +136,7 @@ impl ChatMsg { ChatType::Offline => SpeechBubbleType::None, ChatType::CommandInfo => SpeechBubbleType::None, ChatType::CommandError => SpeechBubbleType::None, + ChatType::Loot => SpeechBubbleType::None, ChatType::FactionMeta(_) => SpeechBubbleType::None, ChatType::GroupMeta(_) => SpeechBubbleType::None, ChatType::Kill => SpeechBubbleType::None, @@ -154,6 +157,7 @@ impl ChatMsg { ChatType::Offline => None, ChatType::CommandInfo => None, ChatType::CommandError => None, + ChatType::Loot => None, ChatType::FactionMeta(_) => None, ChatType::GroupMeta(_) => None, ChatType::Kill => None, diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 9566c083fe..ad9ca3f5e1 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -246,6 +246,7 @@ impl StateExt for State { | comp::ChatType::Offline | comp::ChatType::CommandInfo | comp::ChatType::CommandError + | comp::ChatType::Loot | comp::ChatType::Kill | comp::ChatType::Meta | comp::ChatType::World(_) => { diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index 7543bb1b02..0038449bb3 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -272,7 +272,7 @@ impl<'a> System<'a> for Sys { if !client.login_msg_sent { new_chat_msgs.push((None, ChatMsg { chat_type: ChatType::Online, - message: format!("[{}] is now online.", &player.alias), + message: format!("[{}] is now online.", &player.alias), // TODO: Localize this })); client.login_msg_sent = true; diff --git a/voxygen/src/hud/chat.rs b/voxygen/src/hud/chat.rs index 9e2cd3fc5f..675f9622d6 100644 --- a/voxygen/src/hud/chat.rs +++ b/voxygen/src/hud/chat.rs @@ -1,6 +1,6 @@ use super::{ - img_ids::Imgs, ERROR_COLOR, FACTION_COLOR, GROUP_COLOR, INFO_COLOR, KILL_COLOR, OFFLINE_COLOR, - ONLINE_COLOR, REGION_COLOR, SAY_COLOR, TELL_COLOR, TEXT_COLOR, WORLD_COLOR, + 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::{ui::fonts::ConrodVoxygenFonts, GlobalState}; use client::{cmd, Client}; @@ -479,6 +479,7 @@ fn render_chat_line(chat_type: &ChatType, imgs: &Imgs) -> (Color, conrod_core::i ChatType::Offline => (OFFLINE_COLOR, imgs.chat_offline_small), ChatType::CommandError => (ERROR_COLOR, imgs.chat_command_error_small), ChatType::CommandInfo => (INFO_COLOR, imgs.chat_command_info_small), + ChatType::Loot => (LOOT_COLOR, imgs.chat_loot_small), ChatType::GroupMeta(_) => (GROUP_COLOR, imgs.chat_group_small), ChatType::FactionMeta(_) => (FACTION_COLOR, imgs.chat_faction_small), ChatType::Kill => (KILL_COLOR, imgs.chat_kill_small), diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index f73921253b..3a47770581 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -44,8 +44,6 @@ image_ids! { settings_button_pressed: "voxygen.element.buttons.settings_button_pressed", settings_button_hover: "voxygen.element.buttons.settings_button_hover", settings_button_press: "voxygen.element.buttons.settings_button_press", - slider: "voxygen.element.slider.track", - slider_indicator: "voxygen.element.slider.indicator", esc_frame: "voxygen.element.frames.esc_menu", // Chat-Arrows @@ -95,6 +93,11 @@ image_ids! { quest_bg: "voxygen.element.misc_bg.temp_quest_bg", + // Slider + slider: "voxygen.element.slider.track", + slider_indicator: "voxygen.element.slider.indicator", + slider_indicator_small: "voxygen.element.slider.indicator_round", + // Buttons settings: "voxygen.element.buttons.settings", @@ -316,6 +319,7 @@ image_ids! { chat_command_info_small: "voxygen.element.icons.chat.command_info_small", chat_online_small: "voxygen.element.icons.chat.online_small", chat_offline_small: "voxygen.element.icons.chat.offline_small", + chat_loot_small: "voxygen.element.icons.chat.loot_small", chat_faction: "voxygen.element.icons.chat.faction", chat_group: "voxygen.element.icons.chat.group", diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index b15e24772f..b6871ff88e 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -4,12 +4,13 @@ use super::{ }; use crate::{ i18n::VoxygenLocalization, - ui::{fonts::ConrodVoxygenFonts, img_ids}, + ui::{fonts::ConrodVoxygenFonts, img_ids, ImageSlider}, + GlobalState, }; use client::{self, Client}; use common::{comp, terrain::TerrainChunkSize, vol::RectVolSize}; use conrod_core::{ - color, + color, position, widget::{self, Button, Image, Rectangle, Text}, widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; @@ -29,6 +30,7 @@ widget_ids! { grid, map_title, qlog_title, + zoom_slider, } } @@ -44,6 +46,7 @@ pub struct Map<'a> { common: widget::CommonBuilder, _pulse: f32, localized_strings: &'a std::sync::Arc, + global_state: &'a GlobalState, } impl<'a> Map<'a> { #[allow(clippy::too_many_arguments)] // TODO: Pending review in #587 @@ -56,6 +59,7 @@ impl<'a> Map<'a> { fonts: &'a ConrodVoxygenFonts, pulse: f32, localized_strings: &'a std::sync::Arc, + global_state: &'a GlobalState, ) -> Self { Self { _show: show, @@ -67,6 +71,7 @@ impl<'a> Map<'a> { common: widget::CommonBuilder::default(), _pulse: pulse, localized_strings, + global_state, } } } @@ -76,11 +81,12 @@ pub struct State { } pub enum Event { + MapZoom(f64), Close, } impl<'a> Widget for Map<'a> { - type Event = Option; + type Event = Vec; type State = State; type Style = (); @@ -96,7 +102,8 @@ impl<'a> Widget for Map<'a> { #[allow(clippy::useless_format)] // TODO: Pending review in #587 fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; - + let zoom = self.global_state.settings.gameplay.map_zoom * 0.8; + let mut events = Vec::new(); // Frame Image::new(self.imgs.map_bg) .w_h(1052.0, 886.0) @@ -154,7 +161,7 @@ impl<'a> Widget for Map<'a> { .set(state.ids.close, ui) .was_clicked() { - return Some(Event::Close); + events.push(Event::Close); } // Location Name @@ -182,11 +189,6 @@ impl<'a> Widget for Map<'a> { let (world_map, worldsize) = self.world_map; let worldsize = worldsize.map2(TerrainChunkSize::RECT_SIZE, |e, f| e as f64 * f as f64); - Image::new(world_map.none) - .mid_top_with_margin_on(state.ids.map_align, 10.0) - .w_h(760.0, 760.0) - .parent(state.ids.bg) - .set(state.ids.grid, ui); // Coordinates let player_pos = self .client @@ -195,27 +197,56 @@ impl<'a> Widget for Map<'a> { .read_storage::() .get(self.client.entity()) .map_or(Vec3::zero(), |pos| pos.0); + let w_src = worldsize.x / TerrainChunkSize::RECT_SIZE.x as f64 / zoom; + let h_src = worldsize.y / TerrainChunkSize::RECT_SIZE.y as f64 / zoom; + let rect_src = position::Rect::from_xy_dim( + [ + player_pos.x as f64 / TerrainChunkSize::RECT_SIZE.x as f64, + (worldsize.y - player_pos.y as f64) / TerrainChunkSize::RECT_SIZE.y as f64, + ], + [w_src, h_src], + ); + Image::new(world_map.none) + .mid_top_with_margin_on(state.ids.map_align, 10.0) + .w_h(760.0, 760.0) + .parent(state.ids.bg) + .source_rectangle(rect_src) + .set(state.ids.grid, ui); + + if let Some(new_val) = ImageSlider::discrete( + self.global_state.settings.gameplay.map_zoom as i32, + 1, + 30, + self.imgs.slider_indicator_small, + self.imgs.slider, + ) + .w_h(600.0, 22.0 * 2.0) + .mid_bottom_with_margin_on(state.ids.grid, -55.0) + .track_breadth(12.0 * 2.0) + .slider_length(22.0 * 2.0) + .pad_track((12.0, 12.0)) + .set(state.ids.zoom_slider, ui) + { + events.push(Event::MapZoom(new_val as f64)); + } // Cursor pos relative to playerpos and widget size // Cursor stops moving on an axis as soon as it's position exceeds the maximum - // size of the widget - let rel = Vec2::from(player_pos).map2(worldsize, |e: f32, sz: f64| { + // // size of the widget + + /*let rel = Vec2::from(player_pos).map2(worldsize, |e: f32, sz: f64| { (e as f64 / sz).clamped(0.0, 1.0) - }); - let xy = rel * 760.0; + });*/ + //let xy = rel * 760.0; let scale = 0.6; let arrow_sz = Vec2::new(32.0, 37.0) * scale; Image::new(self.rot_imgs.indicator_mmap_small.target_north) - .bottom_left_with_margins_on( - state.ids.grid, - xy.y - arrow_sz.y / 2.0, - xy.x - arrow_sz.x / 2.0, - ) + .middle_of(state.ids.grid) .w_h(arrow_sz.x, arrow_sz.y) .color(Some(UI_HIGHLIGHT_0)) .floating(true) .parent(ui.window) .set(state.ids.indicator, ui); - None + events } } diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 80fb0f4da5..602ba98fa5 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -99,6 +99,8 @@ const REGION_COLOR: Color = Color::Rgba(0.8, 1.0, 0.8, 1.0); const KILL_COLOR: Color = Color::Rgba(1.0, 0.17, 0.17, 1.0); /// Color for global messages const WORLD_COLOR: Color = Color::Rgba(0.95, 1.0, 0.95, 1.0); +/// Color for collected loot messages +const LOOT_COLOR: Color = Color::Rgba(0.69, 0.57, 1.0, 1.0); // UI Color-Theme const UI_MAIN: Color = Color::Rgba(0.61, 0.70, 0.70, 1.0); // Greenish Blue @@ -249,6 +251,7 @@ pub enum Event { ChangeMaxFPS(u32), ChangeFOV(u16), ChangeGamma(f32), + MapZoom(f64), AdjustWindowSize([u16; 2]), ToggleFullscreen, ChangeAaMode(AaMode), @@ -360,7 +363,7 @@ impl Show { fn map(&mut self, open: bool) { self.map = open; self.bag = false; - self.want_grab = true; + self.want_grab = !open; } fn social(&mut self, open: bool) { @@ -1794,7 +1797,7 @@ impl Hud { } // Map if self.show.map { - match Map::new( + for event in Map::new( &self.show, client, &self.imgs, @@ -1803,14 +1806,19 @@ impl Hud { &self.fonts, self.pulse, &self.voxygen_i18n, + &global_state, ) .set(self.ids.map, ui_widgets) { - Some(map::Event::Close) => { - self.show.map(false); - self.force_ungrab = true; - }, - None => {}, + match event { + map::Event::Close => { + self.show.map(false); + self.force_ungrab = true; + }, + map::Event::MapZoom(map_zoom) => { + events.push(Event::MapZoom(map_zoom)); + }, + } } } diff --git a/voxygen/src/menu/char_selection/ui.rs b/voxygen/src/menu/char_selection/ui.rs index 7e6d7ff201..01a8d47cd0 100644 --- a/voxygen/src/menu/char_selection/ui.rs +++ b/voxygen/src/menu/char_selection/ui.rs @@ -185,8 +185,6 @@ image_ids! { selection: "voxygen.element.frames.selection", selection_hover: "voxygen.element.frames.selection_hover", selection_press: "voxygen.element.frames.selection_press", - slider_range: "voxygen.element.slider.track", - slider_indicator: "voxygen.element.slider.indicator", // Info Window info_frame: "voxygen.element.frames.info_frame", @@ -200,6 +198,9 @@ image_ids! { name_input: "voxygen.element.misc_bg.textbox_mid", + slider_range: "voxygen.element.slider.track", + slider_indicator: "voxygen.element.slider.indicator", + // Tool Icons daggers: "voxygen.element.icons.daggers", sword: "voxygen.element.icons.sword", diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 1df6d69822..84fc0f3765 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -12,7 +12,7 @@ use crate::{ }; use client::{self, Client}; use common::{ - assets::{load_watched, watch}, + assets::{load_expect, load_watched, watch}, clock::Clock, comp, comp::{ChatMsg, ChatType, InventoryUpdateEvent, Pos, Vel, MAX_PICKUP_RANGE_SQR}, @@ -42,6 +42,7 @@ pub struct SessionState { key_state: KeyState, inputs: comp::ControllerInputs, selected_block: Block, + voxygen_i18n: std::sync::Arc, } /// Represents an active game session (i.e., the one being played). @@ -63,6 +64,9 @@ impl SessionState { .ecs_mut() .insert(MyEntity(my_entity)); } + let voxygen_i18n = load_expect::(&i18n_asset_key( + &global_state.settings.language.selected_language, + )); Self { scene, client, @@ -70,6 +74,7 @@ impl SessionState { inputs: comp::ControllerInputs::default(), hud, selected_block: Block::new(BlockKind::Normal, Rgb::broadcast(255)), + voxygen_i18n, } } } @@ -81,6 +86,9 @@ impl SessionState { let mut client = self.client.borrow_mut(); for event in client.tick(self.inputs.clone(), dt, crate::ecs::sys::add_local_systems)? { + self.voxygen_i18n = load_expect::(&i18n_asset_key( + &global_state.settings.language.selected_language, + )); match event { client::Event::Chat(m) => { self.hud.new_message(m); @@ -96,16 +104,17 @@ impl SessionState { match inv_event { InventoryUpdateEvent::CollectFailed => { self.hud.new_message(ChatMsg { - message: String::from( - "Failed to collect item. Your inventory may be full!", - ), + message: self.voxygen_i18n.get("hud.chat.loot_fail").to_string(), chat_type: ChatType::CommandError, }); }, InventoryUpdateEvent::Collected(item) => { self.hud.new_message(ChatMsg { - message: format!("Picked up {}", item.name()), - chat_type: ChatType::CommandInfo, + message: self + .voxygen_i18n + .get("hud.chat.loot_msg") + .replace("{item}", item.name().to_string().as_str()), + chat_type: ChatType::Loot, }); }, _ => {}, @@ -114,8 +123,11 @@ impl SessionState { client::Event::Disconnect => return Ok(TickAction::Disconnect), client::Event::DisconnectionNotification(time) => { let message = match time { - 0 => String::from("Goodbye!"), - _ => format!("Connection lost. Kicking in {} seconds", time), + 0 => String::from(self.voxygen_i18n.get("hud.chat.goodbye")), + _ => self + .voxygen_i18n + .get("hud.chat.connection_lost") + .replace("{time}", time.to_string().as_str()), }; self.hud.new_message(ChatMsg { @@ -805,6 +817,10 @@ impl PlayState for SessionState { .camera_mut() .compute_dependents(&*self.client.borrow().state().terrain()); }, + HudEvent::MapZoom(map_zoom) => { + global_state.settings.gameplay.map_zoom = map_zoom; + global_state.settings.save_to_file_warn(); + }, HudEvent::ChangeGamma(new_gamma) => { global_state.settings.graphics.gamma = new_gamma; global_state.settings.save_to_file_warn(); diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 3427b3a8fe..23f3eaa5fc 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -473,6 +473,7 @@ pub struct GameplaySettings { pub free_look_behavior: PressBehavior, pub auto_walk_behavior: PressBehavior, pub stop_auto_walk_on_input: bool, + pub map_zoom: f64, } impl Default for GameplaySettings { @@ -501,6 +502,7 @@ impl Default for GameplaySettings { free_look_behavior: PressBehavior::Toggle, auto_walk_behavior: PressBehavior::Toggle, stop_auto_walk_on_input: true, + map_zoom: 4.0, } } }