mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Limited total messages
Former-commit-id: 7c8e4a3f9e1d36731579300f7662a324566de6fb
This commit is contained in:
@ -17,6 +17,8 @@ widget_ids! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAX_MESSAGES: usize = 100;
|
||||||
|
|
||||||
#[derive(WidgetCommon)]
|
#[derive(WidgetCommon)]
|
||||||
pub struct Chat<'a> {
|
pub struct Chat<'a> {
|
||||||
new_messages: &'a mut VecDeque<String>,
|
new_messages: &'a mut VecDeque<String>,
|
||||||
@ -91,6 +93,13 @@ impl<'a> Widget for Chat<'a> {
|
|||||||
ui.scroll_widget(state.ids.message_box, [0.0, std::f64::MAX]);
|
ui.scroll_widget(state.ids.message_box, [0.0, std::f64::MAX]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Empty old messages
|
||||||
|
state.update(|s| {
|
||||||
|
while s.messages.len() > MAX_MESSAGES {
|
||||||
|
s.messages.pop_back();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let keyboard_capturer = ui.global_input().current.widget_capturing_keyboard;
|
let keyboard_capturer = ui.global_input().current.widget_capturing_keyboard;
|
||||||
let input_focused = keyboard_capturer == Some(state.ids.input);
|
let input_focused = keyboard_capturer == Some(state.ids.input);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user