mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make nametag positioning slightly better
This commit is contained in:
parent
f8283116a8
commit
fb7edd2404
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Brighter / higher contrast main-map
|
- Brighter / higher contrast main-map
|
||||||
|
- Removed highlighting of non-collectible sprites
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ impl Body {
|
|||||||
// TODO: Improve these values (some might be reliant on more info in inner type)
|
// TODO: Improve these values (some might be reliant on more info in inner type)
|
||||||
match self {
|
match self {
|
||||||
Body::Humanoid(_) => 0.5,
|
Body::Humanoid(_) => 0.5,
|
||||||
Body::QuadrupedSmall(_) => 0.6,
|
Body::QuadrupedSmall(_) => 0.3,
|
||||||
Body::QuadrupedMedium(_) => 0.9,
|
Body::QuadrupedMedium(_) => 0.9,
|
||||||
Body::Critter(_) => 0.5,
|
Body::Critter(_) => 0.2,
|
||||||
Body::BirdMedium(_) => 0.5,
|
Body::BirdMedium(_) => 0.5,
|
||||||
Body::FishMedium(_) => 0.5,
|
Body::FishMedium(_) => 0.5,
|
||||||
Body::Dragon(_) => 2.5,
|
Body::Dragon(_) => 2.5,
|
||||||
@ -113,6 +113,9 @@ impl Body {
|
|||||||
Body::Object(_) => 0.3,
|
Body::Object(_) => 0.3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: currently assumes sphericality
|
||||||
|
pub fn height(&self) -> f32 { self.radius() * 2.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Body {
|
impl Component for Body {
|
||||||
|
@ -546,6 +546,7 @@ impl Hud {
|
|||||||
let interpolated = ecs.read_storage::<vcomp::Interpolated>();
|
let interpolated = ecs.read_storage::<vcomp::Interpolated>();
|
||||||
let players = ecs.read_storage::<comp::Player>();
|
let players = ecs.read_storage::<comp::Player>();
|
||||||
let scales = ecs.read_storage::<comp::Scale>();
|
let scales = ecs.read_storage::<comp::Scale>();
|
||||||
|
let bodies = ecs.read_storage::<comp::Body>();
|
||||||
let entities = ecs.entities();
|
let entities = ecs.entities();
|
||||||
let me = client.entity();
|
let me = client.entity();
|
||||||
let own_level = stats
|
let own_level = stats
|
||||||
@ -609,6 +610,8 @@ impl Hud {
|
|||||||
// Max amount the sct font size increases when "flashing"
|
// Max amount the sct font size increases when "flashing"
|
||||||
const FLASH_MAX: f32 = 25.0;
|
const FLASH_MAX: f32 = 25.0;
|
||||||
const BARSIZE: f64 = 2.0;
|
const BARSIZE: f64 = 2.0;
|
||||||
|
const MANA_BAR_HEIGHT: f64 = BARSIZE * 1.5;
|
||||||
|
const MANA_BAR_Y: f64 = MANA_BAR_HEIGHT / 2.0;
|
||||||
// Get player position.
|
// Get player position.
|
||||||
let player_pos = client
|
let player_pos = client
|
||||||
.state()
|
.state()
|
||||||
@ -628,22 +631,23 @@ impl Hud {
|
|||||||
let mut sct_id_walker = self.ids.scts.walk();
|
let mut sct_id_walker = self.ids.scts.walk();
|
||||||
|
|
||||||
// Render Health Bars
|
// Render Health Bars
|
||||||
for (pos, stats, energy, scale, hp_floater_list) in (
|
for (pos, stats, energy, height_offset, hp_floater_list) in (
|
||||||
&entities,
|
&entities,
|
||||||
&pos,
|
&pos,
|
||||||
interpolated.maybe(),
|
interpolated.maybe(),
|
||||||
&stats,
|
&stats,
|
||||||
&energy,
|
&energy,
|
||||||
scales.maybe(),
|
scales.maybe(),
|
||||||
|
&bodies,
|
||||||
&hp_floater_lists,
|
&hp_floater_lists,
|
||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
.filter(|(entity, _, _, stats, _, _, _)| {
|
.filter(|(entity, _, _, stats, _, _, _, _)| {
|
||||||
*entity != me && !stats.is_dead
|
*entity != me && !stats.is_dead
|
||||||
//&& stats.health.current() != stats.health.maximum()
|
//&& stats.health.current() != stats.health.maximum()
|
||||||
})
|
})
|
||||||
// Don't show outside a certain range
|
// Don't show outside a certain range
|
||||||
.filter(|(_, pos, _, _, _, _, hpfl)| {
|
.filter(|(_, pos, _, _, _, _, _, hpfl)| {
|
||||||
pos.0.distance_squared(player_pos)
|
pos.0.distance_squared(player_pos)
|
||||||
< (if hpfl
|
< (if hpfl
|
||||||
.time_since_last_dmg_by_me
|
.time_since_last_dmg_by_me
|
||||||
@ -655,12 +659,13 @@ impl Hud {
|
|||||||
})
|
})
|
||||||
.powi(2)
|
.powi(2)
|
||||||
})
|
})
|
||||||
.map(|(_, pos, interpolated, stats, energy, scale, f)| {
|
.map(|(_, pos, interpolated, stats, energy, scale, body, f)| {
|
||||||
(
|
(
|
||||||
interpolated.map_or(pos.0, |i| i.pos),
|
interpolated.map_or(pos.0, |i| i.pos),
|
||||||
stats,
|
stats,
|
||||||
energy,
|
energy,
|
||||||
scale.map_or(1.0, |s| s.0),
|
// TODO: when body.height() is more accurate remove the 2.0
|
||||||
|
body.height() * 2.0 * scale.map_or(1.0, |s| s.0),
|
||||||
f,
|
f,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -687,13 +692,15 @@ impl Hud {
|
|||||||
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.79, 0.19, 0.17, hp_ani);
|
let crit_hp_color: Color = Color::Rgba(0.79, 0.19, 0.17, hp_ani);
|
||||||
|
|
||||||
|
let ingame_pos = pos + Vec3::unit_z() * height_offset;
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
Rectangle::fill_with(
|
Rectangle::fill_with(
|
||||||
[82.0 * BARSIZE + 1.0, 8.0 * BARSIZE + 1.0],
|
[82.0 * BARSIZE + 1.0, 8.0],
|
||||||
Color::Rgba(0.1, 0.1, 0.1, 0.9),
|
Color::Rgba(0.1, 0.1, 0.1, 0.9),
|
||||||
)
|
)
|
||||||
.x_y(0.0, -25.0)
|
.x_y(0.0, MANA_BAR_Y + 7.0) //-25.0)
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(back_id, ui_widgets);
|
.set(back_id, ui_widgets);
|
||||||
|
|
||||||
// % HP Filling
|
// % HP Filling
|
||||||
@ -701,7 +708,7 @@ impl Hud {
|
|||||||
.w_h(72.9 * (hp_percentage / 100.0) * BARSIZE, 5.9 * BARSIZE)
|
.w_h(72.9 * (hp_percentage / 100.0) * BARSIZE, 5.9 * BARSIZE)
|
||||||
.x_y(
|
.x_y(
|
||||||
(4.5 + (hp_percentage / 100.0 * 36.45 - 36.45)) * BARSIZE,
|
(4.5 + (hp_percentage / 100.0 * 36.45 - 36.45)) * BARSIZE,
|
||||||
-23.0,
|
MANA_BAR_Y + 9.0,
|
||||||
)
|
)
|
||||||
.color(Some(if hp_percentage <= 25.0 {
|
.color(Some(if hp_percentage <= 25.0 {
|
||||||
crit_hp_color
|
crit_hp_color
|
||||||
@ -710,29 +717,29 @@ impl Hud {
|
|||||||
} else {
|
} else {
|
||||||
HP_COLOR
|
HP_COLOR
|
||||||
}))
|
}))
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(health_bar_id, ui_widgets);
|
.set(health_bar_id, ui_widgets);
|
||||||
// % Mana Filling
|
// % Mana Filling
|
||||||
Rectangle::fill_with(
|
Rectangle::fill_with(
|
||||||
[
|
[
|
||||||
73.0 * (energy.current() as f64 / energy.maximum() as f64) * BARSIZE,
|
73.0 * (energy.current() as f64 / energy.maximum() as f64) * BARSIZE,
|
||||||
1.5 * BARSIZE,
|
MANA_BAR_HEIGHT,
|
||||||
],
|
],
|
||||||
MANA_COLOR,
|
MANA_COLOR,
|
||||||
)
|
)
|
||||||
.x_y(
|
.x_y(
|
||||||
((4.5 + (energy_percentage / 100.0 * 36.5)) - 36.45) * BARSIZE,
|
((4.5 + (energy_percentage / 100.0 * 36.5)) - 36.45) * BARSIZE,
|
||||||
-32.0,
|
MANA_BAR_Y, //-32.0,
|
||||||
)
|
)
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(mana_bar_id, ui_widgets);
|
.set(mana_bar_id, ui_widgets);
|
||||||
|
|
||||||
// Foreground
|
// Foreground
|
||||||
Image::new(self.imgs.enemy_health)
|
Image::new(self.imgs.enemy_health)
|
||||||
.w_h(84.0 * BARSIZE, 10.0 * BARSIZE)
|
.w_h(84.0 * BARSIZE, 10.0 * BARSIZE)
|
||||||
.x_y(0.0, -25.5)
|
.x_y(0.0, MANA_BAR_Y + 6.5) //-25.5)
|
||||||
.color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.99)))
|
.color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.99)))
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(front_id, ui_widgets);
|
.set(front_id, ui_widgets);
|
||||||
|
|
||||||
// Enemy SCT
|
// Enemy SCT
|
||||||
@ -794,7 +801,7 @@ impl Hud {
|
|||||||
// Timer sets the widget offset
|
// Timer sets the widget offset
|
||||||
let y = (timer as f64 / crate::ecs::sys::floater::HP_SHOWTIME as f64
|
let y = (timer as f64 / crate::ecs::sys::floater::HP_SHOWTIME as f64
|
||||||
* number_speed)
|
* number_speed)
|
||||||
+ 30.0;
|
+ 100.0;
|
||||||
// Timer sets text transparency
|
// Timer sets text transparency
|
||||||
let fade = ((crate::ecs::sys::floater::HP_SHOWTIME - timer) * 0.25) + 0.2;
|
let fade = ((crate::ecs::sys::floater::HP_SHOWTIME - timer) * 0.25) + 0.2;
|
||||||
|
|
||||||
@ -802,7 +809,7 @@ impl Hud {
|
|||||||
.font_size(font_size)
|
.font_size(font_size)
|
||||||
.color(Color::Rgba(0.0, 0.0, 0.0, fade))
|
.color(Color::Rgba(0.0, 0.0, 0.0, fade))
|
||||||
.x_y(0.0, y - 3.0)
|
.x_y(0.0, y - 3.0)
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale as f32 + 1.8))
|
.position_ingame(ingame_pos)
|
||||||
.set(sct_bg_id, ui_widgets);
|
.set(sct_bg_id, ui_widgets);
|
||||||
Text::new(&format!("{}", hp_damage.abs()))
|
Text::new(&format!("{}", hp_damage.abs()))
|
||||||
.font_size(font_size)
|
.font_size(font_size)
|
||||||
@ -812,7 +819,7 @@ impl Hud {
|
|||||||
} else {
|
} else {
|
||||||
Color::Rgba(0.1, 1.0, 0.1, fade)
|
Color::Rgba(0.1, 1.0, 0.1, fade)
|
||||||
})
|
})
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale as f32 + 1.8))
|
.position_ingame(ingame_pos)
|
||||||
.set(sct_id, ui_widgets);
|
.set(sct_id, ui_widgets);
|
||||||
} else {
|
} else {
|
||||||
for floater in floaters {
|
for floater in floaters {
|
||||||
@ -838,7 +845,7 @@ impl Hud {
|
|||||||
let y = (floater.timer as f64
|
let y = (floater.timer as f64
|
||||||
/ crate::ecs::sys::floater::HP_SHOWTIME as f64
|
/ crate::ecs::sys::floater::HP_SHOWTIME as f64
|
||||||
* number_speed)
|
* number_speed)
|
||||||
+ 30.0;
|
+ 100.0;
|
||||||
// Timer sets text transparency
|
// Timer sets text transparency
|
||||||
let fade = ((crate::ecs::sys::floater::HP_SHOWTIME - floater.timer)
|
let fade = ((crate::ecs::sys::floater::HP_SHOWTIME - floater.timer)
|
||||||
* 0.25)
|
* 0.25)
|
||||||
@ -852,9 +859,7 @@ impl Hud {
|
|||||||
Color::Rgba(0.1, 1.0, 0.1, 0.0)
|
Color::Rgba(0.1, 1.0, 0.1, 0.0)
|
||||||
})
|
})
|
||||||
.x_y(0.0, y - 3.0)
|
.x_y(0.0, y - 3.0)
|
||||||
.position_ingame(
|
.position_ingame(ingame_pos)
|
||||||
pos + Vec3::new(0.0, 0.0, 1.5 * scale as f32 + 1.8),
|
|
||||||
)
|
|
||||||
.set(sct_bg_id, ui_widgets);
|
.set(sct_bg_id, ui_widgets);
|
||||||
Text::new(&format!("{}", (floater.hp_change).abs()))
|
Text::new(&format!("{}", (floater.hp_change).abs()))
|
||||||
.font_size(font_size)
|
.font_size(font_size)
|
||||||
@ -864,9 +869,7 @@ impl Hud {
|
|||||||
} else {
|
} else {
|
||||||
Color::Rgba(0.1, 1.0, 0.1, 0.0)
|
Color::Rgba(0.1, 1.0, 0.1, 0.0)
|
||||||
})
|
})
|
||||||
.position_ingame(
|
.position_ingame(ingame_pos)
|
||||||
pos + Vec3::new(0.0, 0.0, 1.5 * scale as f32 + 1.8),
|
|
||||||
)
|
|
||||||
.set(sct_id, ui_widgets);
|
.set(sct_id, ui_widgets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1105,19 +1108,20 @@ impl Hud {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render Name Tags
|
// Render Name Tags
|
||||||
for (pos, name, level, scale) in (
|
for (pos, name, level, height_offset) in (
|
||||||
&entities,
|
&entities,
|
||||||
&pos,
|
&pos,
|
||||||
interpolated.maybe(),
|
interpolated.maybe(),
|
||||||
&stats,
|
&stats,
|
||||||
players.maybe(),
|
players.maybe(),
|
||||||
scales.maybe(),
|
scales.maybe(),
|
||||||
|
&bodies,
|
||||||
&hp_floater_lists,
|
&hp_floater_lists,
|
||||||
)
|
)
|
||||||
.join()
|
.join()
|
||||||
.filter(|(entity, _, _, stats, _, _, _)| *entity != me && !stats.is_dead)
|
.filter(|(entity, _, _, stats, _, _, _, _)| *entity != me && !stats.is_dead)
|
||||||
// Don't show outside a certain range
|
// Don't show outside a certain range
|
||||||
.filter(|(_, pos, _, _, _, _, hpfl)| {
|
.filter(|(_, pos, _, _, _, _, _, hpfl)| {
|
||||||
pos.0.distance_squared(player_pos)
|
pos.0.distance_squared(player_pos)
|
||||||
< (if hpfl
|
< (if hpfl
|
||||||
.time_since_last_dmg_by_me
|
.time_since_last_dmg_by_me
|
||||||
@ -1129,7 +1133,7 @@ impl Hud {
|
|||||||
})
|
})
|
||||||
.powi(2)
|
.powi(2)
|
||||||
})
|
})
|
||||||
.map(|(_, pos, interpolated, stats, player, scale, _)| {
|
.map(|(_, pos, interpolated, stats, player, scale, body, _)| {
|
||||||
// TODO: This is temporary
|
// TODO: This is temporary
|
||||||
// If the player used the default character name display their name instead
|
// If the player used the default character name display their name instead
|
||||||
let name = if stats.name == "Character Name" {
|
let name = if stats.name == "Character Name" {
|
||||||
@ -1141,7 +1145,7 @@ impl Hud {
|
|||||||
interpolated.map_or(pos.0, |i| i.pos),
|
interpolated.map_or(pos.0, |i| i.pos),
|
||||||
format!("{}", name),
|
format!("{}", name),
|
||||||
stats.level,
|
stats.level,
|
||||||
scale.map_or(1.0, |s| s.0),
|
body.height() * 2.0 * scale.map_or(1.0, |s| s.0),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
@ -1160,18 +1164,20 @@ impl Hud {
|
|||||||
&mut ui_widgets.widget_id_generator(),
|
&mut ui_widgets.widget_id_generator(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let ingame_pos = pos + Vec3::unit_z() * height_offset;
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
Text::new(&name)
|
Text::new(&name)
|
||||||
.font_size(30)
|
.font_size(30)
|
||||||
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
|
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
|
||||||
.x_y(-1.0, 16.0)
|
.x_y(-1.0, MANA_BAR_Y + 48.0)
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(name_bg_id, ui_widgets);
|
.set(name_bg_id, ui_widgets);
|
||||||
Text::new(&name)
|
Text::new(&name)
|
||||||
.font_size(30)
|
.font_size(30)
|
||||||
.color(Color::Rgba(0.61, 0.61, 0.89, 1.0))
|
.color(Color::Rgba(0.61, 0.61, 0.89, 1.0))
|
||||||
.x_y(0.0, 18.0)
|
.x_y(0.0, MANA_BAR_Y + 50.0)
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(name_id, ui_widgets);
|
.set(name_id, ui_widgets);
|
||||||
|
|
||||||
// Level
|
// Level
|
||||||
@ -1200,8 +1206,8 @@ impl Hud {
|
|||||||
} else {
|
} else {
|
||||||
EQUAL
|
EQUAL
|
||||||
})
|
})
|
||||||
.x_y(-37.0 * BARSIZE, -23.0)
|
.x_y(-37.0 * BARSIZE, MANA_BAR_Y + 9.0)
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(level_id, ui_widgets);
|
.set(level_id, ui_widgets);
|
||||||
if level_comp > 9 {
|
if level_comp > 9 {
|
||||||
let skull_ani = ((self.pulse * 0.7/* speed factor */).cos() * 0.5 + 0.5) * 10.0; //Animation timer
|
let skull_ani = ((self.pulse * 0.7/* speed factor */).cos() * 0.5 + 0.5) * 10.0; //Animation timer
|
||||||
@ -1211,9 +1217,9 @@ impl Hud {
|
|||||||
self.imgs.skull
|
self.imgs.skull
|
||||||
})
|
})
|
||||||
.w_h(18.0 * BARSIZE, 18.0 * BARSIZE)
|
.w_h(18.0 * BARSIZE, 18.0 * BARSIZE)
|
||||||
.x_y(-39.0 * BARSIZE, -25.0)
|
.x_y(-39.0 * BARSIZE, MANA_BAR_Y + 7.0)
|
||||||
.color(Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)))
|
.color(Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)))
|
||||||
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
|
.position_ingame(ingame_pos)
|
||||||
.set(level_skull_id, ui_widgets);
|
.set(level_skull_id, ui_widgets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user