This commit is contained in:
Isse 2023-01-28 03:08:20 +01:00
parent a5248bd61a
commit aefead4a31
2 changed files with 19 additions and 11 deletions

View File

@ -219,10 +219,6 @@ fn insert_alias(you: bool, info: PlayerInfo, localisation: &Localization) -> Str
(false, false) => info.player_alias,
(false, true) => localisation.get_msg(YOU).to_string(),
(true, false) => format!("{}{}", MOD_SPACING, info.player_alias),
(true, true) => format!(
"{}{}",
MOD_SPACING,
&localisation.get_msg(YOU),
),
(true, true) => format!("{}{}", MOD_SPACING, &localisation.get_msg(YOU),),
}
}

View File

@ -442,14 +442,26 @@ impl<'a> Widget for Chat<'a> {
}
})
.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);
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())
s.ids
.chat_badges
.resize(n_badges, &mut ui.widget_id_generator())
})
}
Rectangle::fill_with([CHAT_ICON_WIDTH, CHAT_BOX_HEIGHT], color::TRANSPARENT)
@ -489,10 +501,10 @@ impl<'a> Widget for Chat<'a> {
// 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);
.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;
}