From f9ee398a17d2a6a5a8c6ff5c79a23cc79cf3e4ea Mon Sep 17 00:00:00 2001 From: evgenkot Date: Tue, 6 Feb 2024 16:33:38 +0500 Subject: [PATCH 1/4] I18n loot_scroller user_gender --- assets/voxygen/i18n/uk/hud/chat.ftl | 45 ++++++++++++++++++++++--- voxygen/src/hud/loot_scroller.rs | 52 ++++++++++++++++++++++++++--- voxygen/src/session/mod.rs | 4 +-- 3 files changed, 91 insertions(+), 10 deletions(-) diff --git a/assets/voxygen/i18n/uk/hud/chat.ftl b/assets/voxygen/i18n/uk/hud/chat.ftl index 9a8577be0e..eb18fff5a1 100644 --- a/assets/voxygen/i18n/uk/hud/chat.ftl +++ b/assets/voxygen/i18n/uk/hud/chat.ftl @@ -163,7 +163,44 @@ hud-chat-chat_tab_hover_tooltip = Правий клік для налаштув ## HUD Pickup message -hud-loot-pickup-msg = {$actor} підняли { $amount -> - [1] { $item } - *[other] {$amount}x {$item} -} +# hud-loot-pickup-msg = {$actor} підняли { $amount -> +# [1] { $item } +# *[other] {$amount}x {$item} +# } + +# hud-loot-pickup-msg = { $user_gender -> +# [she] { $actor } підняла { $amount -> +# [1] { $item } +# *[other] { $amount }x { $item } +# } +# [he] { $actor } підняв { $amount -> +# [1] { $item } +# *[other] { $amount }x { $item } +# } +# *[other] { $actor } підняло { $amount -> +# [1] { $item } +# *[other] { $amount }x { $item } +# } +# } + +hud-loot-pickup-msg = { $is_you -> + [true] Ви підняли { $amount -> + [1] { $item } + *[other] {$amount}x {$item} + } + + *[false] { $user_gender -> + [she] { $actor } підняла { $amount -> + [1] { $item } + *[other] { $amount }x { $item } + } + [he] { $actor } підняв { $amount -> + [1] { $item } + *[other] { $amount }x { $item } + } + *[other] { $actor } підняло { $amount -> + [1] { $item } + *[other] { $amount }x { $item } + } + } +} \ No newline at end of file diff --git a/voxygen/src/hud/loot_scroller.rs b/voxygen/src/hud/loot_scroller.rs index 36893e4308..07caff6cc9 100644 --- a/voxygen/src/hud/loot_scroller.rs +++ b/voxygen/src/hud/loot_scroller.rs @@ -6,7 +6,10 @@ use super::{ }; use crate::ui::{fonts::Fonts, ImageFrame, ItemTooltip, ItemTooltipManager, ItemTooltipable}; use client::Client; -use common::comp::inventory::item::{Item, ItemDesc, ItemI18n, MaterialStatManifest, Quality}; +use common::{ + comp::inventory::item::{Item, ItemDesc, ItemI18n, MaterialStatManifest, Quality}, + uid::Uid, +}; use conrod_core::{ color, position::Dimension, @@ -105,7 +108,7 @@ impl<'a> LootScroller<'a> { pub struct LootMessage { pub item: Item, pub amount: u32, - pub taken_by: String, + pub taken_by: Uid, } pub struct State { @@ -322,7 +325,7 @@ impl<'a> Widget for LootScroller<'a> { Quality::Artifact => self.imgs.inv_slot_orange, _ => self.imgs.inv_slot_red, }; - let quality_col = get_quality_col(item); + let quality_col = get_quality_col(&item); Image::new(self.imgs.pixel) .color(Some(shade_color(quality_col.alpha(0.7)))) @@ -350,10 +353,51 @@ impl<'a> Widget for LootScroller<'a> { &item_tooltip, ) .set(state.ids.message_icons[i], ui); + + + + // let info = self.client.player_list().get(&taken_by.unwrap()).unwrap(); + // info.character.unwrap().gender; + + // let you_uid = self.client.uid().unwrap(); + + // // Based on voxygen/i18n-helpers/src/lib.rs gender_str function + // let gender_str = |uid: &Uid| { + // if let Some(pi) = info.character.as_ref().unwrap().gender{ + // match pi { + // common::comp::Gender::Feminine=> "she".to_owned(), + // common::comp::Gender::Masculine=> "he".to_owned(), + // } + // } else { + // "??".to_owned() + // } + // }; + + + // pub fn personalize_alias(&self, uid: Uid, alias: String) -> String { + // let client_uid = self.uid().expect("Client doesn't have a Uid!!!"); + + let (user_gender, actor, is_you) = match self.client.player_list().get(taken_by) { + Some(player_info) => match player_info.character.as_ref() { + Some(character_info) => (match character_info.gender { + Some(common::comp::Gender::Feminine)=> "she".to_string(), + Some(common::comp::Gender::Masculine)=> "he".to_string(), + None => "??".to_string(), + }, character_info.name.to_string(), self.client.uid().expect("Client doesn't have a Uid!!!") == *taken_by), + None => ("??".to_string(), "Someone".to_string(), false), + } + None => ("??".to_string(), "Som!!".to_string(), false), + }; + + // client_uid == uid; + // info.character.as_ref().unwrap().name.to_string() + let label = self.localized_strings.get_msg_ctx( "hud-loot-pickup-msg", &i18n::fluent_args! { - "actor" => taken_by, + "user_gender" => user_gender, + "is_you" => is_you.to_string(), + "actor" => actor, "amount" => amount, "item" => { let (name, _) = diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index c6d1e79fcd..9828f3c6fb 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -293,7 +293,7 @@ impl SessionState { self.hud.new_loot_message(LootMessage { amount: item.amount(), item, - taken_by: client.personalize_alias(uid, taker), + taken_by: uid, }); }, client::Event::InviteComplete { @@ -391,7 +391,7 @@ impl SessionState { self.hud.new_loot_message(LootMessage { amount: item.amount(), item, - taken_by: "You".to_string(), + taken_by: client.uid().expect("Client doesn't have a Uid!!!"), }); }, _ => {}, From eee330c9e936e800c869cecc16eff0743044249b Mon Sep 17 00:00:00 2001 From: evgenkot Date: Sat, 10 Feb 2024 15:34:14 +0500 Subject: [PATCH 2/4] I18n loot_scroller correct name --- assets/voxygen/i18n/en/hud/chat.ftl | 14 ++++-- assets/voxygen/i18n/ru/hud/chat.ftl | 23 ++++++++-- assets/voxygen/i18n/uk/hud/chat.ftl | 23 +--------- client/src/lib.rs | 6 +-- common/net/src/msg/server.rs | 4 +- server/src/client.rs | 2 +- server/src/events/inventory_manip.rs | 17 +++---- voxygen/src/hud/loot_scroller.rs | 67 ++++++++++++---------------- voxygen/src/session/mod.rs | 2 +- 9 files changed, 72 insertions(+), 86 deletions(-) diff --git a/assets/voxygen/i18n/en/hud/chat.ftl b/assets/voxygen/i18n/en/hud/chat.ftl index 16961d3d8a..c6b44bac0d 100644 --- a/assets/voxygen/i18n/en/hud/chat.ftl +++ b/assets/voxygen/i18n/en/hud/chat.ftl @@ -81,7 +81,13 @@ hud-chat-chat_tab_hover_tooltip = Right click for settings ## HUD Pickup message -hud-loot-pickup-msg = { $amount -> - [one] { $actor } picked up { $item } - *[other] { $actor } picked up {$amount}x {$item} -} +hud-loot-pickup-msg = { $is_you -> + [true] You picked up { $amount -> + [1] { $item } + *[other] {$amount}x {$item} + } + *[false] { $actor } picked up { $amount -> + [1] { $item } + *[other] { $amount }x { $item } + } +} \ No newline at end of file diff --git a/assets/voxygen/i18n/ru/hud/chat.ftl b/assets/voxygen/i18n/ru/hud/chat.ftl index c109f468fc..3e1b9ca1af 100644 --- a/assets/voxygen/i18n/ru/hud/chat.ftl +++ b/assets/voxygen/i18n/ru/hud/chat.ftl @@ -53,10 +53,25 @@ hud-chat-default_death_msg = { "[" }{ $name }] умер hud-chat-all = Все hud-chat-chat_tab_hover_tooltip = ПКМ для настроек -hud-loot-pickup-msg = - { $actor } подобрал { $amount -> - [one] { $item } - *[other] { $amount }x { $item } +hud-loot-pickup-msg = { $is_you -> + [true] Вы подобрали { $amount -> + [1] { $item } + *[other] {$amount}x {$item} } + *[false] { $gender -> + [she] { $actor } подобрала { $amount -> + [1] { $item } + *[other] { $amount }x { $item } + } + [he] { $actor } подобрал { $amount -> + [1] { $item } + *[other] { $amount }x { $item } + } + *[other] { $actor } подняло { $amount -> + [1] { $item } + *[other] { $amount }x { $item } + } + } +} hud-chat-goodbye = До свидания! hud-chat-connection_lost = Соединение потеряно. Выход через { $time } секунд. diff --git a/assets/voxygen/i18n/uk/hud/chat.ftl b/assets/voxygen/i18n/uk/hud/chat.ftl index eb18fff5a1..f79c7d7134 100644 --- a/assets/voxygen/i18n/uk/hud/chat.ftl +++ b/assets/voxygen/i18n/uk/hud/chat.ftl @@ -163,33 +163,12 @@ hud-chat-chat_tab_hover_tooltip = Правий клік для налаштув ## HUD Pickup message -# hud-loot-pickup-msg = {$actor} підняли { $amount -> -# [1] { $item } -# *[other] {$amount}x {$item} -# } - -# hud-loot-pickup-msg = { $user_gender -> -# [she] { $actor } підняла { $amount -> -# [1] { $item } -# *[other] { $amount }x { $item } -# } -# [he] { $actor } підняв { $amount -> -# [1] { $item } -# *[other] { $amount }x { $item } -# } -# *[other] { $actor } підняло { $amount -> -# [1] { $item } -# *[other] { $amount }x { $item } -# } -# } - hud-loot-pickup-msg = { $is_you -> [true] Ви підняли { $amount -> [1] { $item } *[other] {$amount}x {$item} } - - *[false] { $user_gender -> + *[false] { $gender -> [she] { $actor } підняла { $amount -> [1] { $item } *[other] { $amount }x { $item } diff --git a/client/src/lib.rs b/client/src/lib.rs index 4239e0b7cf..455abfe5c5 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -96,7 +96,7 @@ const PING_ROLLING_AVERAGE_SECS: usize = 10; #[derive(Debug)] pub enum Event { Chat(comp::ChatMsg), - GroupInventoryUpdate(comp::Item, String, Uid), + GroupInventoryUpdate(comp::Item, Uid), InviteComplete { target: Uid, answer: InviteAnswer, @@ -2657,8 +2657,8 @@ impl Client { kind, }); }, - ServerGeneral::GroupInventoryUpdate(item, taker, uid) => { - frontend_events.push(Event::GroupInventoryUpdate(item, taker, uid)); + ServerGeneral::GroupInventoryUpdate(item, uid) => { + frontend_events.push(Event::GroupInventoryUpdate(item, uid)); }, // Cleanup for when the client goes back to the `presence = None` ServerGeneral::ExitInGameSuccess => { diff --git a/common/net/src/msg/server.rs b/common/net/src/msg/server.rs index 3e1a5cb990..211891842c 100644 --- a/common/net/src/msg/server.rs +++ b/common/net/src/msg/server.rs @@ -162,7 +162,7 @@ pub enum ServerGeneral { /// currently pending InvitePending(Uid), /// Update the HUD of the clients in the group - GroupInventoryUpdate(comp::Item, String, Uid), + GroupInventoryUpdate(comp::Item, Uid), /// Note: this could potentially include all the failure cases such as /// inviting yourself in which case the `InvitePending` message could be /// removed and the client could consider their invite pending until @@ -330,7 +330,7 @@ impl ServerMsg { | ServerGeneral::InviteComplete { .. } | ServerGeneral::ExitInGameSuccess | ServerGeneral::InventoryUpdate(_, _) - | ServerGeneral::GroupInventoryUpdate(_, _, _) + | ServerGeneral::GroupInventoryUpdate(_, _) | ServerGeneral::TerrainChunkUpdate { .. } | ServerGeneral::TerrainBlockUpdates(_) | ServerGeneral::SetViewDistance(_) diff --git a/server/src/client.rs b/server/src/client.rs index a5852d53c1..4b28ba8c93 100644 --- a/server/src/client.rs +++ b/server/src/client.rs @@ -183,7 +183,7 @@ impl Client { | ServerGeneral::InviteComplete { .. } | ServerGeneral::ExitInGameSuccess | ServerGeneral::InventoryUpdate(_, _) - | ServerGeneral::GroupInventoryUpdate(_, _, _) + | ServerGeneral::GroupInventoryUpdate(_, _) | ServerGeneral::SetViewDistance(_) | ServerGeneral::Outcomes(_) | ServerGeneral::Knockback(_) diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index fbfc025e1e..ce7fe22120 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -269,7 +269,6 @@ impl ServerEvent for InventoryManipEvent { &data.uids, &data.groups, &data.alignments, - &data.stats, &data.entities, &data.ability_map, &data.msm, @@ -322,7 +321,6 @@ impl ServerEvent for InventoryManipEvent { &data.uids, &data.groups, &data.alignments, - &data.stats, &data.entities, &data.ability_map, &data.msm, @@ -1081,7 +1079,6 @@ fn announce_loot_to_group( uids: &ReadStorage, groups: &ReadStorage, alignments: &ReadStorage, - stats: &ReadStorage, entities: &Entities, ability_map: &AbilityMap, msm: &MaterialStatManifest, @@ -1090,14 +1087,12 @@ fn announce_loot_to_group( members(*group_id, groups, entities, alignments, uids) .filter(|(member_e, _)| member_e != &entity) .for_each(|(e, _)| { - clients.get(e).and_then(|c| { - stats.get(entity).map(|stats| { - c.send_fallible(ServerGeneral::GroupInventoryUpdate( - item.duplicate(ability_map, msm), - stats.name.to_string(), - *uid, - )) - }) + clients.get(e).map(|c| { + c.send_fallible(ServerGeneral::GroupInventoryUpdate( + item.duplicate(ability_map, msm), + *uid, + )); + Some(()) }); }); } diff --git a/voxygen/src/hud/loot_scroller.rs b/voxygen/src/hud/loot_scroller.rs index 07caff6cc9..eee3925525 100644 --- a/voxygen/src/hud/loot_scroller.rs +++ b/voxygen/src/hud/loot_scroller.rs @@ -10,6 +10,7 @@ use common::{ comp::inventory::item::{Item, ItemDesc, ItemI18n, MaterialStatManifest, Quality}, uid::Uid, }; +use common_net::sync::WorldSyncExt; use conrod_core::{ color, position::Dimension, @@ -353,51 +354,41 @@ impl<'a> Widget for LootScroller<'a> { &item_tooltip, ) .set(state.ids.message_icons[i], ui); - - - // let info = self.client.player_list().get(&taken_by.unwrap()).unwrap(); - // info.character.unwrap().gender; - - // let you_uid = self.client.uid().unwrap(); - - // // Based on voxygen/i18n-helpers/src/lib.rs gender_str function - // let gender_str = |uid: &Uid| { - // if let Some(pi) = info.character.as_ref().unwrap().gender{ - // match pi { - // common::comp::Gender::Feminine=> "she".to_owned(), - // common::comp::Gender::Masculine=> "he".to_owned(), - // } - // } else { - // "??".to_owned() - // } - // }; - - - // pub fn personalize_alias(&self, uid: Uid, alias: String) -> String { - // let client_uid = self.uid().expect("Client doesn't have a Uid!!!"); - - let (user_gender, actor, is_you) = match self.client.player_list().get(taken_by) { - Some(player_info) => match player_info.character.as_ref() { - Some(character_info) => (match character_info.gender { - Some(common::comp::Gender::Feminine)=> "she".to_string(), - Some(common::comp::Gender::Masculine)=> "he".to_string(), - None => "??".to_string(), - }, character_info.name.to_string(), self.client.uid().expect("Client doesn't have a Uid!!!") == *taken_by), - None => ("??".to_string(), "Someone".to_string(), false), - } - None => ("??".to_string(), "Som!!".to_string(), false), + let target_name = match self.client.player_list().get(taken_by) { + Some(info) => info.player_alias.clone(), + None => match self.client.state().ecs().entity_from_uid(*taken_by) { + Some(entity) => { + let stats = self.client.state().read_storage::(); + stats + .get(entity) + .map_or(format!("", *taken_by), |e| e.name.to_owned()) + }, + None => format!("", *taken_by), + }, + }; + + let (user_gender, is_you) = match self.client.player_list().get(taken_by) { + Some(player_info) => match player_info.character.as_ref() { + Some(character_info) => ( + match character_info.gender { + Some(common::comp::Gender::Feminine) => "she".to_string(), + Some(common::comp::Gender::Masculine) => "he".to_string(), + None => "??".to_string(), + }, + self.client.uid().expect("Client doesn't have a Uid!!!") == *taken_by, + ), + None => ("??".to_string(), false), + }, + None => ("??".to_string(), false), }; - - // client_uid == uid; - // info.character.as_ref().unwrap().name.to_string() let label = self.localized_strings.get_msg_ctx( "hud-loot-pickup-msg", &i18n::fluent_args! { - "user_gender" => user_gender, "is_you" => is_you.to_string(), - "actor" => actor, + "gender" => user_gender, + "actor" => target_name, "amount" => amount, "item" => { let (name, _) = diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 9828f3c6fb..8a21ee5661 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -289,7 +289,7 @@ impl SessionState { client::Event::Chat(m) => { self.hud.new_message(m); }, - client::Event::GroupInventoryUpdate(item, taker, uid) => { + client::Event::GroupInventoryUpdate(item, uid) => { self.hud.new_loot_message(LootMessage { amount: item.amount(), item, From eb4911f60d2b7e4ab28c94618d9cdb281995f6a2 Mon Sep 17 00:00:00 2001 From: evgenkot Date: Mon, 12 Feb 2024 22:01:39 +0500 Subject: [PATCH 3/4] I18n pickup-msg correction for en uk ru --- assets/voxygen/i18n/en/hud/chat.ftl | 16 +++--- assets/voxygen/i18n/ru/hud/chat.ftl | 28 +++++------ assets/voxygen/i18n/uk/hud/chat.ftl | 28 +++++------ voxygen/src/hud/loot_scroller.rs | 75 +++++++++++++++++++---------- 4 files changed, 79 insertions(+), 68 deletions(-) diff --git a/assets/voxygen/i18n/en/hud/chat.ftl b/assets/voxygen/i18n/en/hud/chat.ftl index c6b44bac0d..de2f07da1d 100644 --- a/assets/voxygen/i18n/en/hud/chat.ftl +++ b/assets/voxygen/i18n/en/hud/chat.ftl @@ -81,13 +81,11 @@ hud-chat-chat_tab_hover_tooltip = Right click for settings ## HUD Pickup message -hud-loot-pickup-msg = { $is_you -> - [true] You picked up { $amount -> - [1] { $item } - *[other] {$amount}x {$item} - } - *[false] { $actor } picked up { $amount -> - [1] { $item } - *[other] { $amount }x { $item } - } +hud-loot-pickup-msg-you = { $amount -> + [1] You picked up { $item } + *[other] You picked up {$amount}x {$item} +} +hud-loot-pickup-msg = { $amount -> + [1] { $actor } picked up { $item } + *[other] { $actor } picked up { $amount }x { $item } } \ No newline at end of file diff --git a/assets/voxygen/i18n/ru/hud/chat.ftl b/assets/voxygen/i18n/ru/hud/chat.ftl index 3e1b9ca1af..0e29307da2 100644 --- a/assets/voxygen/i18n/ru/hud/chat.ftl +++ b/assets/voxygen/i18n/ru/hud/chat.ftl @@ -53,24 +53,18 @@ hud-chat-default_death_msg = { "[" }{ $name }] умер hud-chat-all = Все hud-chat-chat_tab_hover_tooltip = ПКМ для настроек -hud-loot-pickup-msg = { $is_you -> - [true] Вы подобрали { $amount -> - [1] { $item } - *[other] {$amount}x {$item} +hud-loot-pickup-msg-you = { $amount -> + [1] Вы подобрали { $item } + *[other] Вы подобрали {$amount}x {$item} +} +hud-loot-pickup-msg = { $gender -> + [she] { $amount -> + [1] { $actor } подобрала { $item } + *[other] { $actor } подобрала { $amount }x { $item } } - *[false] { $gender -> - [she] { $actor } подобрала { $amount -> - [1] { $item } - *[other] { $amount }x { $item } - } - [he] { $actor } подобрал { $amount -> - [1] { $item } - *[other] { $amount }x { $item } - } - *[other] { $actor } подняло { $amount -> - [1] { $item } - *[other] { $amount }x { $item } - } + *[he] { $amount -> + [1] { $actor } подобрал { $item } + *[other] { $actor } подобрал { $amount }x { $item } } } hud-chat-goodbye = До свидания! diff --git a/assets/voxygen/i18n/uk/hud/chat.ftl b/assets/voxygen/i18n/uk/hud/chat.ftl index f79c7d7134..a0501f23ea 100644 --- a/assets/voxygen/i18n/uk/hud/chat.ftl +++ b/assets/voxygen/i18n/uk/hud/chat.ftl @@ -163,23 +163,17 @@ hud-chat-chat_tab_hover_tooltip = Правий клік для налаштув ## HUD Pickup message -hud-loot-pickup-msg = { $is_you -> - [true] Ви підняли { $amount -> - [1] { $item } - *[other] {$amount}x {$item} +hud-loot-pickup-msg-you = { $amount -> + [1] Ви підняли { $item } + *[other] Ви підняли {$amount}x {$item} +} +hud-loot-pickup-msg = { $gender -> + [she] { $amount -> + [1] { $actor } підняла { $item } + *[other] { $actor } підняла { $amount }x { $item } } - *[false] { $gender -> - [she] { $actor } підняла { $amount -> - [1] { $item } - *[other] { $amount }x { $item } - } - [he] { $actor } підняв { $amount -> - [1] { $item } - *[other] { $amount }x { $item } - } - *[other] { $actor } підняло { $amount -> - [1] { $item } - *[other] { $amount }x { $item } - } + *[he] { $amount -> + [1] { $actor } підняв { $item } + *[other] { $actor } підняв { $amount }x { $item } } } \ No newline at end of file diff --git a/voxygen/src/hud/loot_scroller.rs b/voxygen/src/hud/loot_scroller.rs index eee3925525..62e64b0035 100644 --- a/voxygen/src/hud/loot_scroller.rs +++ b/voxygen/src/hud/loot_scroller.rs @@ -355,18 +355,25 @@ impl<'a> Widget for LootScroller<'a> { ) .set(state.ids.message_icons[i], ui); - let target_name = match self.client.player_list().get(taken_by) { - Some(info) => info.player_alias.clone(), - None => match self.client.state().ecs().entity_from_uid(*taken_by) { - Some(entity) => { - let stats = self.client.state().read_storage::(); - stats - .get(entity) - .map_or(format!("", *taken_by), |e| e.name.to_owned()) + let target_name = self + .client + .player_list() + .get(taken_by) + .map_or_else( + || { + self.client + .state() + .ecs() + .entity_from_uid(*taken_by) + .and_then(|entity| { + let stats = + self.client.state().read_storage::(); + stats.get(entity).map(|e| e.name.clone()) + }) }, - None => format!("", *taken_by), - }, - }; + |info| Some(info.player_alias.clone()), + ) + .unwrap_or_else(|| format!("", *taken_by)); let (user_gender, is_you) = match self.client.player_list().get(taken_by) { Some(player_info) => match player_info.character.as_ref() { @@ -383,20 +390,38 @@ impl<'a> Widget for LootScroller<'a> { None => ("??".to_string(), false), }; - let label = self.localized_strings.get_msg_ctx( - "hud-loot-pickup-msg", - &i18n::fluent_args! { - "is_you" => is_you.to_string(), - "gender" => user_gender, - "actor" => target_name, - "amount" => amount, - "item" => { - let (name, _) = - util::item_text(&item, self.localized_strings, self.item_i18n); - name - }, - }, - ); + let label = match is_you { + true => { + self.localized_strings.get_msg_ctx( + "hud-loot-pickup-msg-you", + &i18n::fluent_args! { + "gender" => user_gender, + "amount" => amount, + "item" => { + let (name, _) = + util::item_text(&item, self.localized_strings, self.item_i18n); + name + }, + }, + ) + } + false => { + self.localized_strings.get_msg_ctx( + "hud-loot-pickup-msg", + &i18n::fluent_args! { + "gender" => user_gender, + "actor" => target_name, + "amount" => amount, + "item" => { + let (name, _) = + util::item_text(&item, self.localized_strings, self.item_i18n); + name + }, + }, + ) + } + }; + let label_font_size = 20; Text::new(&label) From f4ce05a6572aff4208b5f12e6a658e3b0be1e090 Mon Sep 17 00:00:00 2001 From: evgenkot Date: Tue, 13 Feb 2024 01:13:18 +0500 Subject: [PATCH 4/4] I18n move stats --- server/src/events/inventory_manip.rs | 1 - voxygen/src/hud/loot_scroller.rs | 19 +++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index ce7fe22120..86a234dccc 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -1092,7 +1092,6 @@ fn announce_loot_to_group( item.duplicate(ability_map, msm), *uid, )); - Some(()) }); }); } diff --git a/voxygen/src/hud/loot_scroller.rs b/voxygen/src/hud/loot_scroller.rs index 62e64b0035..c7189c1348 100644 --- a/voxygen/src/hud/loot_scroller.rs +++ b/voxygen/src/hud/loot_scroller.rs @@ -297,6 +297,8 @@ impl<'a> Widget for LootScroller<'a> { .set(state.ids.scrollbar, ui); } + let stats = self.client.state().read_storage::(); + while let Some(list_message) = list_messages.next(ui) { let i = list_message.i; @@ -365,11 +367,7 @@ impl<'a> Widget for LootScroller<'a> { .state() .ecs() .entity_from_uid(*taken_by) - .and_then(|entity| { - let stats = - self.client.state().read_storage::(); - stats.get(entity).map(|e| e.name.clone()) - }) + .and_then(|entity| stats.get(entity).map(|e| e.name.clone())) }, |info| Some(info.player_alias.clone()), ) @@ -390,9 +388,8 @@ impl<'a> Widget for LootScroller<'a> { None => ("??".to_string(), false), }; - let label = match is_you { - true => { - self.localized_strings.get_msg_ctx( + let label = if is_you { + self.localized_strings.get_msg_ctx( "hud-loot-pickup-msg-you", &i18n::fluent_args! { "gender" => user_gender, @@ -404,9 +401,8 @@ impl<'a> Widget for LootScroller<'a> { }, }, ) - } - false => { - self.localized_strings.get_msg_ctx( + } else { + self.localized_strings.get_msg_ctx( "hud-loot-pickup-msg", &i18n::fluent_args! { "gender" => user_gender, @@ -419,7 +415,6 @@ impl<'a> Widget for LootScroller<'a> { }, }, ) - } }; let label_font_size = 20;