mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-24 02:44:17 +00:00
Fixes to notifications
This commit is contained in:
parent
243bbf470d
commit
04c84f466a
2 changed files with 26 additions and 14 deletions
|
@ -25,7 +25,7 @@ pub unsafe fn draw(root_pane: &Pane) {
|
||||||
let notification_idx = 0;
|
let notification_idx = 0;
|
||||||
|
|
||||||
let queue = &mut ui::notifications::QUEUE;
|
let queue = &mut ui::notifications::QUEUE;
|
||||||
let notification = queue.first();
|
let notification = queue.first_mut();
|
||||||
|
|
||||||
root_pane
|
root_pane
|
||||||
.find_pane_by_name_recursive(display_parent_fmt!(notification_idx))
|
.find_pane_by_name_recursive(display_parent_fmt!(notification_idx))
|
||||||
|
@ -38,6 +38,8 @@ pub unsafe fn draw(root_pane: &Pane) {
|
||||||
let notification = notification.unwrap();
|
let notification = notification.unwrap();
|
||||||
let color = notification.color;
|
let color = notification.color;
|
||||||
|
|
||||||
|
if !notification.has_drawn() {
|
||||||
|
notification.set_drawn();
|
||||||
root_pane
|
root_pane
|
||||||
.find_pane_by_name_recursive(display_header_fmt!(notification_idx))
|
.find_pane_by_name_recursive(display_header_fmt!(notification_idx))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -51,8 +53,8 @@ pub unsafe fn draw(root_pane: &Pane) {
|
||||||
text.set_text_string(¬ification.message);
|
text.set_text_string(¬ification.message);
|
||||||
text.set_default_material_colors();
|
text.set_default_material_colors();
|
||||||
text.set_color(color.r, color.g, color.b, color.a);
|
text.set_color(color.r, color.g, color.b, color.a);
|
||||||
|
}
|
||||||
|
|
||||||
let notification = queue.first_mut().unwrap();
|
|
||||||
let has_completed = notification.check_completed();
|
let has_completed = notification.check_completed();
|
||||||
if has_completed {
|
if has_completed {
|
||||||
queue.remove(0);
|
queue.remove(0);
|
||||||
|
|
|
@ -8,6 +8,7 @@ pub struct Notification {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
length: u32,
|
length: u32,
|
||||||
pub color: ResColor,
|
pub color: ResColor,
|
||||||
|
has_drawn: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Notification {
|
impl Notification {
|
||||||
|
@ -17,9 +18,18 @@ impl Notification {
|
||||||
message,
|
message,
|
||||||
length,
|
length,
|
||||||
color,
|
color,
|
||||||
|
has_drawn: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_drawn(&mut self) {
|
||||||
|
self.has_drawn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_drawn(&mut self) -> bool {
|
||||||
|
self.has_drawn
|
||||||
|
}
|
||||||
|
|
||||||
pub fn tick(&mut self) {
|
pub fn tick(&mut self) {
|
||||||
self.length -= 1;
|
self.length -= 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue