mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'tygyh/Extract-get-duration-image-from-update' into 'master'
Extract 'get_duration_image' function from 'update' See merge request veloren/veloren!2407
This commit is contained in:
commit
f255f01ac0
@ -12,6 +12,7 @@ use crate::{
|
|||||||
use common::comp::{BuffKind, Buffs, Energy, Health};
|
use common::comp::{BuffKind, Buffs, Energy, Health};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
|
image::Id,
|
||||||
widget::{self, Button, Image, Rectangle, Text},
|
widget::{self, Button, Image, Rectangle, Text},
|
||||||
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
@ -230,17 +231,7 @@ impl<'a> Widget for BuffsBar<'a> {
|
|||||||
let click_to_remove = format!("<{}>", &localized_strings.get("buff.remove"));
|
let click_to_remove = format!("<{}>", &localized_strings.get("buff.remove"));
|
||||||
let desc = format!("{}\n\n{}\n\n{}", desc_txt, remaining_time, click_to_remove);
|
let desc = format!("{}\n\n{}\n\n{}", desc_txt, remaining_time, click_to_remove);
|
||||||
// Timer overlay
|
// Timer overlay
|
||||||
if Button::image(match duration_percentage as u64 {
|
if Button::image(self.get_duration_image(duration_percentage))
|
||||||
875..=1000 => self.imgs.nothing, // 8/8
|
|
||||||
750..=874 => self.imgs.buff_0, // 7/8
|
|
||||||
625..=749 => self.imgs.buff_1, // 6/8
|
|
||||||
500..=624 => self.imgs.buff_2, // 5/8
|
|
||||||
375..=499 => self.imgs.buff_3, // 4/8
|
|
||||||
250..=374 => self.imgs.buff_4, //3/8
|
|
||||||
125..=249 => self.imgs.buff_5, // 2/8
|
|
||||||
0..=124 => self.imgs.buff_6, // 1/8
|
|
||||||
_ => self.imgs.nothing,
|
|
||||||
})
|
|
||||||
.w_h(40.0, 40.0)
|
.w_h(40.0, 40.0)
|
||||||
.middle_of(*id)
|
.middle_of(*id)
|
||||||
.with_tooltip(
|
.with_tooltip(
|
||||||
@ -310,17 +301,7 @@ impl<'a> Widget for BuffsBar<'a> {
|
|||||||
let desc_txt = hud::get_buff_desc(debuff.kind, debuff.data, localized_strings);
|
let desc_txt = hud::get_buff_desc(debuff.kind, debuff.data, localized_strings);
|
||||||
let remaining_time = hud::get_buff_time(*debuff);
|
let remaining_time = hud::get_buff_time(*debuff);
|
||||||
let desc = format!("{}\n\n{}", desc_txt, remaining_time);
|
let desc = format!("{}\n\n{}", desc_txt, remaining_time);
|
||||||
Image::new(match duration_percentage as u64 {
|
Image::new(self.get_duration_image(duration_percentage))
|
||||||
875..=1000 => self.imgs.nothing, // 8/8
|
|
||||||
750..=874 => self.imgs.buff_0, // 7/8
|
|
||||||
625..=749 => self.imgs.buff_1, // 6/8
|
|
||||||
500..=624 => self.imgs.buff_2, // 5/8
|
|
||||||
375..=499 => self.imgs.buff_3, // 4/8
|
|
||||||
250..=374 => self.imgs.buff_4, //3/8
|
|
||||||
125..=249 => self.imgs.buff_5, // 2/8
|
|
||||||
0..=124 => self.imgs.buff_6, // 1/8
|
|
||||||
_ => self.imgs.nothing,
|
|
||||||
})
|
|
||||||
.w_h(40.0, 40.0)
|
.w_h(40.0, 40.0)
|
||||||
.middle_of(*id)
|
.middle_of(*id)
|
||||||
.with_tooltip(
|
.with_tooltip(
|
||||||
@ -412,17 +393,7 @@ impl<'a> Widget for BuffsBar<'a> {
|
|||||||
desc_txt.to_string()
|
desc_txt.to_string()
|
||||||
};
|
};
|
||||||
// Timer overlay
|
// Timer overlay
|
||||||
if Button::image(match duration_percentage as u64 {
|
if Button::image(self.get_duration_image(duration_percentage))
|
||||||
875..=1000 => self.imgs.nothing, // 8/8
|
|
||||||
750..=874 => self.imgs.buff_0, // 7/8
|
|
||||||
625..=749 => self.imgs.buff_1, // 6/8
|
|
||||||
500..=624 => self.imgs.buff_2, // 5/8
|
|
||||||
375..=499 => self.imgs.buff_3, // 4/8
|
|
||||||
250..=374 => self.imgs.buff_4, // 3/8
|
|
||||||
125..=249 => self.imgs.buff_5, // 2/8
|
|
||||||
0..=124 => self.imgs.buff_6, // 1/8
|
|
||||||
_ => self.imgs.nothing,
|
|
||||||
})
|
|
||||||
.w_h(40.0, 40.0)
|
.w_h(40.0, 40.0)
|
||||||
.middle_of(*id)
|
.middle_of(*id)
|
||||||
.with_tooltip(
|
.with_tooltip(
|
||||||
@ -453,3 +424,19 @@ impl<'a> Widget for BuffsBar<'a> {
|
|||||||
event
|
event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> BuffsBar<'a> {
|
||||||
|
fn get_duration_image(&self, duration_percentage: u32) -> Id {
|
||||||
|
match duration_percentage as u64 {
|
||||||
|
875..=1000 => self.imgs.nothing, // 8/8
|
||||||
|
750..=874 => self.imgs.buff_0, // 7/8
|
||||||
|
625..=749 => self.imgs.buff_1, // 6/8
|
||||||
|
500..=624 => self.imgs.buff_2, // 5/8
|
||||||
|
375..=499 => self.imgs.buff_3, // 4/8
|
||||||
|
250..=374 => self.imgs.buff_4, // 3/8
|
||||||
|
125..=249 => self.imgs.buff_5, // 2/8
|
||||||
|
0..=124 => self.imgs.buff_6, // 1/8
|
||||||
|
_ => self.imgs.nothing,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user