mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
decay display for groups and overhead bars
This commit is contained in:
parent
06bd7bd929
commit
345ef1ca22
BIN
assets/voxygen/element/skillbar/decayed_bg.png
(Stored with Git LFS)
BIN
assets/voxygen/element/skillbar/decayed_bg.png
(Stored with Git LFS)
Binary file not shown.
@ -2,7 +2,8 @@ use super::{
|
||||
cr_color,
|
||||
img_ids::{Imgs, ImgsRot},
|
||||
Show, BLACK, BUFF_COLOR, DEBUFF_COLOR, ERROR_COLOR, GROUP_COLOR, HP_COLOR, KILL_COLOR,
|
||||
LOW_HP_COLOR, STAMINA_COLOR, TEXT_COLOR, TEXT_COLOR_GREY, UI_HIGHLIGHT_0, UI_MAIN,
|
||||
LOW_HP_COLOR, QUALITY_EPIC, STAMINA_COLOR, TEXT_COLOR, TEXT_COLOR_GREY, UI_HIGHLIGHT_0,
|
||||
UI_MAIN,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@ -51,6 +52,7 @@ widget_ids! {
|
||||
member_panels_txt_bg[],
|
||||
member_panels_txt[],
|
||||
member_health[],
|
||||
member_health_decay[],
|
||||
member_stam[],
|
||||
buffs[],
|
||||
buff_timers[],
|
||||
@ -287,6 +289,13 @@ impl<'a> Widget for Group<'a> {
|
||||
.resize(group_size, &mut ui.widget_id_generator());
|
||||
})
|
||||
};
|
||||
if state.ids.member_health_decay.len() < group_size {
|
||||
state.update(|s| {
|
||||
s.ids
|
||||
.member_health_decay
|
||||
.resize(group_size, &mut ui.widget_id_generator());
|
||||
})
|
||||
};
|
||||
if state.ids.member_stam.len() < group_size {
|
||||
state.update(|s| {
|
||||
s.ids
|
||||
@ -395,6 +404,16 @@ impl<'a> Widget for Group<'a> {
|
||||
.color(Some(health_col))
|
||||
.top_left_with_margins_on(state.ids.member_panels_bg[i], 2.0, 2.0)
|
||||
.set(state.ids.member_health[i], ui);
|
||||
// Health Decay
|
||||
let decayed_health = 1.0 - health.maximum() as f64 / health.base_max() as f64;
|
||||
if decayed_health > 0.0 {
|
||||
let decay_bar_len = 148.0 * decayed_health * 0.5;
|
||||
Image::new(self.imgs.bar_content)
|
||||
.w_h(decay_bar_len, 22.0)
|
||||
.color(Some(QUALITY_EPIC))
|
||||
.top_right_with_margins_on(state.ids.member_panels_bg[i], 2.0, 2.0)
|
||||
.set(state.ids.member_health_decay[i], ui);
|
||||
}
|
||||
if health.is_dead {
|
||||
// Death Text
|
||||
Text::new(&self.localized_strings.get("hud.group.dead"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::{
|
||||
cr_color, img_ids::Imgs, DEFAULT_NPC, ENEMY_HP_COLOR, FACTION_COLOR, GROUP_COLOR, GROUP_MEMBER,
|
||||
HP_COLOR, LOW_HP_COLOR, REGION_COLOR, SAY_COLOR, STAMINA_COLOR, TELL_COLOR, TEXT_BG,
|
||||
TEXT_COLOR,
|
||||
HP_COLOR, LOW_HP_COLOR, QUALITY_EPIC, REGION_COLOR, SAY_COLOR, STAMINA_COLOR, TELL_COLOR,
|
||||
TEXT_BG, TEXT_COLOR,
|
||||
};
|
||||
use crate::{
|
||||
hud::{get_buff_image, get_buff_info},
|
||||
@ -16,6 +16,7 @@ use conrod_core::{
|
||||
widget::{self, Image, Rectangle, Text},
|
||||
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||
};
|
||||
use inline_tweak::*;
|
||||
const MAX_BUBBLE_WIDTH: f64 = 250.0;
|
||||
widget_ids! {
|
||||
struct Ids {
|
||||
@ -42,6 +43,7 @@ widget_ids! {
|
||||
level,
|
||||
level_skull,
|
||||
health_bar,
|
||||
decay_bar,
|
||||
health_bar_bg,
|
||||
health_txt,
|
||||
mana_bar,
|
||||
@ -67,7 +69,10 @@ pub struct Info<'a> {
|
||||
pub fn should_show_healthbar(health: &Health) -> bool {
|
||||
health.current() != health.maximum() || health.current() < health.base_max()
|
||||
}
|
||||
|
||||
/// Determines if there is decayed health being applied
|
||||
pub fn decayed_health_displayed(health: &Health) -> bool {
|
||||
(1.0 - health.maximum() as f64 / health.base_max() as f64) > 0.0
|
||||
}
|
||||
/// ui widget containing everything that goes over a character's head
|
||||
/// (Speech bubble, Name, Level, HP/energy bars, etc.)
|
||||
#[derive(WidgetCommon)]
|
||||
@ -147,6 +152,11 @@ impl<'a> Ingameable for Overhead<'a> {
|
||||
} else {
|
||||
0
|
||||
}
|
||||
+ if info.health.map_or(false, |h| decayed_health_displayed(h)) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}) + if self.bubble.is_some() { 13 } else { 0 }
|
||||
}
|
||||
}
|
||||
@ -300,11 +310,13 @@ impl<'a> Widget for Overhead<'a> {
|
||||
.set(state.ids.name, ui);
|
||||
|
||||
match health {
|
||||
Some(health) if should_show_healthbar(health) => {
|
||||
Some(health)
|
||||
if should_show_healthbar(health) || decayed_health_displayed(health) =>
|
||||
{
|
||||
// Show HP Bar
|
||||
let hp_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 1.0; //Animation timer
|
||||
let crit_hp_color: Color = Color::Rgba(0.93, 0.59, 0.03, hp_ani);
|
||||
|
||||
let decayed_health = 1.0 - health.maximum() as f64 / health.base_max() as f64;
|
||||
// Background
|
||||
Image::new(if self.in_group {self.imgs.health_bar_group_bg} else {self.imgs.enemy_health_bg})
|
||||
.w_h(84.0 * BARSIZE, 10.0 * BARSIZE)
|
||||
@ -341,6 +353,26 @@ impl<'a> Widget for Overhead<'a> {
|
||||
})
|
||||
.parent(id)
|
||||
.set(state.ids.health_bar, ui);
|
||||
|
||||
if decayed_health > 0.0 {
|
||||
let x_decayed = if self.in_group {
|
||||
(tweak!(0.0) + (decayed_health / 100.0 * tweak!(41.0) - tweak!(41.0)))
|
||||
* BARSIZE
|
||||
} else {
|
||||
(tweak!(-4.5)
|
||||
+ (decayed_health / 100.0 * tweak!(36.45) - tweak!(36.45)))
|
||||
* BARSIZE
|
||||
};
|
||||
|
||||
let decay_bar_len =
|
||||
decayed_health * 0.5 * if self.in_group { 82.0 } else { 73.0 };
|
||||
Image::new(self.imgs.enemy_bar)
|
||||
.w_h(decay_bar_len, h)
|
||||
.x_y(x_decayed * tweak!(-1.0), MANA_BAR_Y + 8.0)
|
||||
.color(Some(QUALITY_EPIC))
|
||||
.parent(id)
|
||||
.set(state.ids.decay_bar, ui);
|
||||
}
|
||||
let mut txt = format!("{}/{}", health_cur_txt, health_max_txt);
|
||||
if health.is_dead {
|
||||
txt = self.i18n.get("hud.group.dead").to_string()
|
||||
@ -411,7 +443,7 @@ impl<'a> Widget for Overhead<'a> {
|
||||
.parent(id)
|
||||
.set(state.ids.level, ui);
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user