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,
|
cr_color,
|
||||||
img_ids::{Imgs, ImgsRot},
|
img_ids::{Imgs, ImgsRot},
|
||||||
Show, BLACK, BUFF_COLOR, DEBUFF_COLOR, ERROR_COLOR, GROUP_COLOR, HP_COLOR, KILL_COLOR,
|
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::{
|
use crate::{
|
||||||
@ -51,6 +52,7 @@ widget_ids! {
|
|||||||
member_panels_txt_bg[],
|
member_panels_txt_bg[],
|
||||||
member_panels_txt[],
|
member_panels_txt[],
|
||||||
member_health[],
|
member_health[],
|
||||||
|
member_health_decay[],
|
||||||
member_stam[],
|
member_stam[],
|
||||||
buffs[],
|
buffs[],
|
||||||
buff_timers[],
|
buff_timers[],
|
||||||
@ -287,6 +289,13 @@ impl<'a> Widget for Group<'a> {
|
|||||||
.resize(group_size, &mut ui.widget_id_generator());
|
.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 {
|
if state.ids.member_stam.len() < group_size {
|
||||||
state.update(|s| {
|
state.update(|s| {
|
||||||
s.ids
|
s.ids
|
||||||
@ -395,6 +404,16 @@ impl<'a> Widget for Group<'a> {
|
|||||||
.color(Some(health_col))
|
.color(Some(health_col))
|
||||||
.top_left_with_margins_on(state.ids.member_panels_bg[i], 2.0, 2.0)
|
.top_left_with_margins_on(state.ids.member_panels_bg[i], 2.0, 2.0)
|
||||||
.set(state.ids.member_health[i], ui);
|
.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 {
|
if health.is_dead {
|
||||||
// Death Text
|
// Death Text
|
||||||
Text::new(&self.localized_strings.get("hud.group.dead"))
|
Text::new(&self.localized_strings.get("hud.group.dead"))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::{
|
use super::{
|
||||||
cr_color, img_ids::Imgs, DEFAULT_NPC, ENEMY_HP_COLOR, FACTION_COLOR, GROUP_COLOR, GROUP_MEMBER,
|
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,
|
HP_COLOR, LOW_HP_COLOR, QUALITY_EPIC, REGION_COLOR, SAY_COLOR, STAMINA_COLOR, TELL_COLOR,
|
||||||
TEXT_COLOR,
|
TEXT_BG, TEXT_COLOR,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
hud::{get_buff_image, get_buff_info},
|
hud::{get_buff_image, get_buff_info},
|
||||||
@ -16,6 +16,7 @@ use conrod_core::{
|
|||||||
widget::{self, Image, Rectangle, Text},
|
widget::{self, Image, Rectangle, Text},
|
||||||
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
|
use inline_tweak::*;
|
||||||
const MAX_BUBBLE_WIDTH: f64 = 250.0;
|
const MAX_BUBBLE_WIDTH: f64 = 250.0;
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
@ -42,6 +43,7 @@ widget_ids! {
|
|||||||
level,
|
level,
|
||||||
level_skull,
|
level_skull,
|
||||||
health_bar,
|
health_bar,
|
||||||
|
decay_bar,
|
||||||
health_bar_bg,
|
health_bar_bg,
|
||||||
health_txt,
|
health_txt,
|
||||||
mana_bar,
|
mana_bar,
|
||||||
@ -67,7 +69,10 @@ pub struct Info<'a> {
|
|||||||
pub fn should_show_healthbar(health: &Health) -> bool {
|
pub fn should_show_healthbar(health: &Health) -> bool {
|
||||||
health.current() != health.maximum() || health.current() < health.base_max()
|
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
|
/// ui widget containing everything that goes over a character's head
|
||||||
/// (Speech bubble, Name, Level, HP/energy bars, etc.)
|
/// (Speech bubble, Name, Level, HP/energy bars, etc.)
|
||||||
#[derive(WidgetCommon)]
|
#[derive(WidgetCommon)]
|
||||||
@ -147,6 +152,11 @@ impl<'a> Ingameable for Overhead<'a> {
|
|||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
+ if info.health.map_or(false, |h| decayed_health_displayed(h)) {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
}) + if self.bubble.is_some() { 13 } else { 0 }
|
}) + if self.bubble.is_some() { 13 } else { 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,18 +310,20 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
.set(state.ids.name, ui);
|
.set(state.ids.name, ui);
|
||||||
|
|
||||||
match health {
|
match health {
|
||||||
Some(health) if should_show_healthbar(health) => {
|
Some(health)
|
||||||
|
if should_show_healthbar(health) || decayed_health_displayed(health) =>
|
||||||
|
{
|
||||||
// Show HP Bar
|
// Show HP Bar
|
||||||
let hp_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 1.0; //Animation timer
|
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 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
|
// Background
|
||||||
Image::new(if self.in_group {self.imgs.health_bar_group_bg} else {self.imgs.enemy_health_bg})
|
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)
|
.w_h(84.0 * BARSIZE, 10.0 * BARSIZE)
|
||||||
.x_y(0.0, MANA_BAR_Y + 6.5) //-25.5)
|
.x_y(0.0, MANA_BAR_Y + 6.5) //-25.5)
|
||||||
.color(Some(Color::Rgba(0.1, 0.1, 0.1, 0.8)))
|
.color(Some(Color::Rgba(0.1, 0.1, 0.1, 0.8)))
|
||||||
.parent(id)
|
.parent(id)
|
||||||
.set(state.ids.health_bar_bg, ui);
|
.set(state.ids.health_bar_bg, ui);
|
||||||
|
|
||||||
// % HP Filling
|
// % HP Filling
|
||||||
let size_factor = (hp_percentage / 100.0) * BARSIZE;
|
let size_factor = (hp_percentage / 100.0) * BARSIZE;
|
||||||
@ -341,6 +353,26 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
})
|
})
|
||||||
.parent(id)
|
.parent(id)
|
||||||
.set(state.ids.health_bar, ui);
|
.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);
|
let mut txt = format!("{}/{}", health_cur_txt, health_max_txt);
|
||||||
if health.is_dead {
|
if health.is_dead {
|
||||||
txt = self.i18n.get("hud.group.dead").to_string()
|
txt = self.i18n.get("hud.group.dead").to_string()
|
||||||
@ -411,7 +443,7 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
.parent(id)
|
.parent(id)
|
||||||
.set(state.ids.level, ui);
|
.set(state.ids.level, ui);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user