mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Store a backlog of messages sent while the chat is hidden
This commit is contained in:
parent
b775399235
commit
debbaea83c
@ -202,7 +202,7 @@ pub enum Event {
|
||||
ResizeChat(Vec2<f64>),
|
||||
MoveChat(Vec2<f64>),
|
||||
UpdateUnread(Vec<bool>),
|
||||
CloseChat,
|
||||
DisableForceChat,
|
||||
}
|
||||
|
||||
impl<'a> Widget for Chat<'a> {
|
||||
@ -249,7 +249,7 @@ impl<'a> Widget for Chat<'a> {
|
||||
let chat_tabs = &chat_settings.chat_tabs;
|
||||
let current_chat_tab = chat_settings.chat_tab_index.and_then(|i| chat_tabs.get(i));
|
||||
|
||||
let chat_box_input_width = self.chat_size.x - CHAT_ICON_WIDTH - 7.0;
|
||||
let chat_box_input_width = self.chat_size.x - CHAT_ICON_WIDTH - 12.0;
|
||||
|
||||
// Empty old messages
|
||||
state.update(|s| {
|
||||
@ -829,7 +829,7 @@ impl<'a> Widget for Chat<'a> {
|
||||
let has_message = !state.input.message.is_empty();
|
||||
let pressed = matches!(key_press.key, Key::Return | Key::NumPadEnter);
|
||||
if pressed {
|
||||
events.push(Event::CloseChat);
|
||||
events.push(Event::DisableForceChat);
|
||||
}
|
||||
has_message && pressed
|
||||
})
|
||||
|
@ -1273,6 +1273,7 @@ pub struct Hud {
|
||||
failed_entity_pickups: HashMap<EcsEntity, CollectFailedData>,
|
||||
new_loot_messages: VecDeque<LootMessage>,
|
||||
new_messages: VecDeque<comp::ChatMsg>,
|
||||
message_backlog: VecDeque<comp::ChatMsg>,
|
||||
new_notifications: VecDeque<Notification>,
|
||||
speech_bubbles: HashMap<Uid, comp::SpeechBubble>,
|
||||
content_bubbles: Vec<(Vec3<f32>, comp::SpeechBubble)>,
|
||||
@ -1374,6 +1375,7 @@ impl Hud {
|
||||
failed_entity_pickups: HashMap::default(),
|
||||
new_loot_messages: VecDeque::new(),
|
||||
new_messages: VecDeque::new(),
|
||||
message_backlog: VecDeque::new(),
|
||||
new_notifications: VecDeque::new(),
|
||||
speech_bubbles: HashMap::new(),
|
||||
content_bubbles: Vec::new(),
|
||||
@ -3486,7 +3488,7 @@ impl Hud {
|
||||
)
|
||||
.set(self.ids.loot_scroller, ui_widgets);
|
||||
|
||||
self.new_loot_messages = VecDeque::new();
|
||||
self.new_loot_messages.clear();
|
||||
|
||||
// Don't put NPC messages in chat box.
|
||||
self.new_messages
|
||||
@ -3497,6 +3499,9 @@ impl Hud {
|
||||
// even when hovering over them
|
||||
// TODO look into parenting and then settings movable widgets to floating
|
||||
if global_state.settings.interface.toggle_chat || self.force_chat {
|
||||
for hidden in self.message_backlog.drain(..).rev() {
|
||||
self.new_messages.push_front(hidden);
|
||||
}
|
||||
for event in Chat::new(
|
||||
&mut self.new_messages,
|
||||
client,
|
||||
@ -3547,15 +3552,20 @@ impl Hud {
|
||||
chat::Event::UpdateUnread(unread) => {
|
||||
self.unread_tabs = unread;
|
||||
},
|
||||
chat::Event::CloseChat => {
|
||||
chat::Event::DisableForceChat => {
|
||||
self.force_chat = false;
|
||||
},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.message_backlog.extend(self.new_messages.drain(..));
|
||||
while self.message_backlog.len() > 100 {
|
||||
self.message_backlog.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
self.new_messages = VecDeque::new();
|
||||
self.new_notifications = VecDeque::new();
|
||||
self.new_messages.clear();
|
||||
self.new_notifications.clear();
|
||||
|
||||
// Windows
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user