mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Moderator badge
This commit is contained in:
parent
0543c265c8
commit
d949348661
BIN
assets/voxygen/element/ui/chat/icons/mod_badge.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/ui/chat/icons/mod_badge.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -32,7 +32,6 @@ hud-chat-default_death_msg = [{ $name }] died
|
||||
## Utils
|
||||
hud-chat-all = All
|
||||
hud-chat-you = You
|
||||
hud-chat-mod = Mod
|
||||
hud-chat-chat_tab_hover_tooltip = Right click for settings
|
||||
hud-loot-pickup-msg = {$actor} picked up { $amount ->
|
||||
[one] { $item }
|
||||
|
@ -213,15 +213,16 @@ pub fn localize_chat_message(
|
||||
|
||||
fn insert_alias(you: bool, info: PlayerInfo, localisation: &Localization) -> String {
|
||||
const YOU: &str = "hud-chat-you";
|
||||
const MOD: &str = "hud-chat-mod";
|
||||
// Leave space for a mod badge icon.
|
||||
const MOD_SPACING: &str = " ";
|
||||
match (info.is_moderator, you) {
|
||||
(false, false) => info.player_alias,
|
||||
(false, true) => localisation.get_msg(YOU).to_string(),
|
||||
(true, false) => format!("{} - {}", &localisation.get_msg(MOD), info.player_alias),
|
||||
(true, false) => format!("{}{}", MOD_SPACING, info.player_alias),
|
||||
(true, true) => format!(
|
||||
"{} - {}",
|
||||
&localisation.get_msg(MOD),
|
||||
&localisation.get_msg(YOU)
|
||||
"{}{}",
|
||||
MOD_SPACING,
|
||||
&localisation.get_msg(YOU),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ widget_ids! {
|
||||
chat_arrow,
|
||||
chat_icon_align,
|
||||
chat_icons[],
|
||||
chat_badges[],
|
||||
|
||||
chat_tab_align,
|
||||
chat_tab_all,
|
||||
@ -440,7 +441,17 @@ impl<'a> Widget for Chat<'a> {
|
||||
true
|
||||
}
|
||||
})
|
||||
.map(|m| {
|
||||
let is_moderator = m.chat_type.uid().and_then(|uid| self.client.lookup_msg_context(&m).player_alias.get(&uid).map(|i| i.is_moderator)).unwrap_or(false);
|
||||
(is_moderator, m)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let n_badges = messages.iter().filter(|t| t.0).count();
|
||||
if state.ids.chat_badges.len() < n_badges {
|
||||
state.update(|s| {
|
||||
s.ids.chat_badges.resize(n_badges, &mut ui.widget_id_generator())
|
||||
})
|
||||
}
|
||||
Rectangle::fill_with([CHAT_ICON_WIDTH, CHAT_BOX_HEIGHT], color::TRANSPARENT)
|
||||
.top_left_with_margins_on(state.ids.message_box_bg, 0.0, 0.0)
|
||||
.crop_kids()
|
||||
@ -451,10 +462,11 @@ impl<'a> Widget for Chat<'a> {
|
||||
.scroll_kids_vertically()
|
||||
.set(state.ids.message_box, ui);
|
||||
|
||||
let mut badge_id = 0;
|
||||
while let Some(item) = items.next(ui) {
|
||||
// This would be easier if conrod used the v-metrics from rusttype.
|
||||
if item.i < messages.len() {
|
||||
let message = &messages[item.i];
|
||||
let (is_moderator, message) = &messages[item.i];
|
||||
let (color, icon) = render_chat_line(&message.chat_type, self.imgs);
|
||||
// For each ChatType needing localization get/set matching pre-formatted
|
||||
// localized string. This string will be formatted with the data
|
||||
@ -473,6 +485,18 @@ impl<'a> Widget for Chat<'a> {
|
||||
_ => 0.0,
|
||||
};
|
||||
item.set(text.h(y), ui);
|
||||
|
||||
// If the user is a moderator display a moderator icon with their alias.
|
||||
if *is_moderator {
|
||||
Image::new(self.imgs.chat_moderator_badge)
|
||||
.w_h(CHAT_ICON_WIDTH, CHAT_ICON_HEIGHT)
|
||||
.top_left_with_margins_on(item.widget_id, 2.0, 7.0)
|
||||
.parent(state.ids.message_box_bg)
|
||||
.set(state.ids.chat_badges[badge_id], ui);
|
||||
|
||||
badge_id += 1;
|
||||
}
|
||||
|
||||
let icon_id = state.ids.chat_icons[item.i];
|
||||
Image::new(icon)
|
||||
.w_h(CHAT_ICON_WIDTH, CHAT_ICON_HEIGHT)
|
||||
|
@ -674,6 +674,8 @@ image_ids! {
|
||||
chat_tell: "voxygen.element.ui.chat.icons.tell",
|
||||
chat_world: "voxygen.element.ui.chat.icons.world",
|
||||
|
||||
chat_moderator_badge: "voxygen.element.ui.chat.icons.mod_badge",
|
||||
|
||||
// Buffs
|
||||
buff_plus_0: "voxygen.element.de_buffs.buff_plus_0",
|
||||
buff_saturation_0: "voxygen.element.de_buffs.buff_saturation_0",
|
||||
|
Loading…
Reference in New Issue
Block a user