mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'pfau/nametag_height' into 'master'
Nametag height See merge request veloren/veloren!1335
This commit is contained in:
commit
4d77d61dc0
@ -193,7 +193,7 @@ impl Body {
|
|||||||
Body::QuadrupedLow(body) => match body.species {
|
Body::QuadrupedLow(body) => match body.species {
|
||||||
quadruped_low::Species::Monitor => 1.5,
|
quadruped_low::Species::Monitor => 1.5,
|
||||||
quadruped_low::Species::Tortoise => 2.0,
|
quadruped_low::Species::Tortoise => 2.0,
|
||||||
quadruped_low::Species::Rocksnapper => 2.0,
|
quadruped_low::Species::Rocksnapper => 2.9,
|
||||||
quadruped_low::Species::Maneater => 4.0,
|
quadruped_low::Species::Maneater => 4.0,
|
||||||
_ => 1.3,
|
_ => 1.3,
|
||||||
},
|
},
|
||||||
@ -206,7 +206,7 @@ impl Body {
|
|||||||
Body::Dragon(_) => 20.0,
|
Body::Dragon(_) => 20.0,
|
||||||
Body::BirdSmall(_) => 1.1,
|
Body::BirdSmall(_) => 1.1,
|
||||||
Body::FishSmall(_) => 0.9,
|
Body::FishSmall(_) => 0.9,
|
||||||
Body::BipedLarge(_) => 4.5,
|
Body::BipedLarge(_) => 4.6,
|
||||||
Body::Golem(_) => 5.8,
|
Body::Golem(_) => 5.8,
|
||||||
Body::Object(_) => 1.0,
|
Body::Object(_) => 1.0,
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ use std::{
|
|||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0);
|
const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0);
|
||||||
const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
|
const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
|
||||||
const TEXT_GRAY_COLOR: Color = Color::Rgba(0.5, 0.5, 0.5, 1.0);
|
const TEXT_GRAY_COLOR: Color = Color::Rgba(0.5, 0.5, 0.5, 1.0);
|
||||||
@ -126,7 +125,7 @@ const UI_HIGHLIGHT_0: Color = Color::Rgba(0.79, 1.09, 1.09, 1.0);
|
|||||||
//const UI_DARK_0: Color = Color::Rgba(0.25, 0.37, 0.37, 1.0);
|
//const UI_DARK_0: Color = Color::Rgba(0.25, 0.37, 0.37, 1.0);
|
||||||
|
|
||||||
/// Distance at which nametags are visible for group members
|
/// Distance at which nametags are visible for group members
|
||||||
const NAMETAG_GROUP_RANGE: f32 = 300.0;
|
const NAMETAG_GROUP_RANGE: f32 = 1000.0;
|
||||||
/// Distance at which nametags are visible
|
/// Distance at which nametags are visible
|
||||||
const NAMETAG_RANGE: f32 = 40.0;
|
const NAMETAG_RANGE: f32 = 40.0;
|
||||||
/// Time nametags stay visible after doing damage even if they are out of range
|
/// Time nametags stay visible after doing damage even if they are out of range
|
||||||
@ -1153,8 +1152,7 @@ impl Hud {
|
|||||||
name,
|
name,
|
||||||
stats,
|
stats,
|
||||||
energy,
|
energy,
|
||||||
// TODO: when body.height() is more accurate remove the 2.0
|
body.height() * scale.map_or(1.0, |s| s.0) + 0.5,
|
||||||
body.height() * 2.0 * scale.map_or(1.0, |s| s.0),
|
|
||||||
hpfl,
|
hpfl,
|
||||||
uid,
|
uid,
|
||||||
in_group,
|
in_group,
|
||||||
@ -1170,6 +1168,9 @@ impl Hud {
|
|||||||
);
|
);
|
||||||
let ingame_pos = pos + Vec3::unit_z() * height_offset;
|
let ingame_pos = pos + Vec3::unit_z() * height_offset;
|
||||||
|
|
||||||
|
//
|
||||||
|
// * height_offset
|
||||||
|
|
||||||
// Speech bubble, name, level, and hp bars
|
// Speech bubble, name, level, and hp bars
|
||||||
overhead::Overhead::new(
|
overhead::Overhead::new(
|
||||||
&name,
|
&name,
|
||||||
|
@ -13,7 +13,6 @@ 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,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MAX_BUBBLE_WIDTH: f64 = 250.0;
|
const MAX_BUBBLE_WIDTH: f64 = 250.0;
|
||||||
|
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
@ -148,18 +147,19 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
|
|
||||||
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
||||||
let widget::UpdateArgs { id, state, ui, .. } = args;
|
let widget::UpdateArgs { id, state, ui, .. } = args;
|
||||||
|
const BARSIZE: f64 = 2.0; // Scaling
|
||||||
const BARSIZE: f64 = 2.0;
|
|
||||||
const MANA_BAR_HEIGHT: f64 = BARSIZE * 1.5;
|
const MANA_BAR_HEIGHT: f64 = BARSIZE * 1.5;
|
||||||
const MANA_BAR_Y: f64 = MANA_BAR_HEIGHT / 2.0;
|
const MANA_BAR_Y: f64 = MANA_BAR_HEIGHT / 2.0;
|
||||||
|
// Used to set healthbar colours based on hp_percentage
|
||||||
let hp_percentage =
|
let hp_percentage =
|
||||||
self.stats.health.current() as f64 / self.stats.health.maximum() as f64 * 100.0;
|
self.stats.health.current() as f64 / self.stats.health.maximum() as f64 * 100.0;
|
||||||
|
// Compare levels to decide if a skull is shown
|
||||||
let level_comp = self.stats.level.level() as i64 - self.own_level as i64;
|
let level_comp = self.stats.level.level() as i64 - self.own_level as i64;
|
||||||
let health_current = (self.stats.health.current() / 10) as f64;
|
let health_current = (self.stats.health.current() / 10) as f64;
|
||||||
let health_max = (self.stats.health.maximum() / 10) as f64;
|
let health_max = (self.stats.health.maximum() / 10) as f64;
|
||||||
let name_y = if (health_current - health_max).abs() < 1e-6 {
|
let name_y = if (health_current - health_max).abs() < 1e-6 {
|
||||||
MANA_BAR_Y + 20.0
|
MANA_BAR_Y + 20.0
|
||||||
} else if level_comp > 9 {
|
} else if level_comp > 9 && !self.in_group {
|
||||||
MANA_BAR_Y + 38.0
|
MANA_BAR_Y + 38.0
|
||||||
} else {
|
} else {
|
||||||
MANA_BAR_Y + 32.0
|
MANA_BAR_Y + 32.0
|
||||||
@ -426,7 +426,7 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
// + 5-10 levels above player -> high
|
// + 5-10 levels above player -> high
|
||||||
// -5 - +5 levels around player level -> equal
|
// -5 - +5 levels around player level -> equal
|
||||||
// - 5 levels below player -> low
|
// - 5 levels below player -> low
|
||||||
if level_comp > 9 {
|
if level_comp > 9 && !self.in_group {
|
||||||
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
|
||||||
Image::new(if skull_ani as i32 == 1 && rand::random::<f32>() < 0.9 {
|
Image::new(if skull_ani as i32 == 1 && rand::random::<f32>() < 0.9 {
|
||||||
self.imgs.skull_2
|
self.imgs.skull_2
|
||||||
@ -439,13 +439,15 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
.parent(id)
|
.parent(id)
|
||||||
.set(state.ids.level_skull, ui);
|
.set(state.ids.level_skull, ui);
|
||||||
} else {
|
} else {
|
||||||
|
let fnt_size = match self.stats.level.level() {
|
||||||
|
0..=9 => 15,
|
||||||
|
10..=99 => 12,
|
||||||
|
100..=999 => 9,
|
||||||
|
_ => 2,
|
||||||
|
};
|
||||||
Text::new(&format!("{}", self.stats.level.level()))
|
Text::new(&format!("{}", self.stats.level.level()))
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
.font_size(if self.stats.level.level() > 9 && level_comp < 10 {
|
.font_size(fnt_size)
|
||||||
14
|
|
||||||
} else {
|
|
||||||
15
|
|
||||||
})
|
|
||||||
.color(if level_comp > 4 {
|
.color(if level_comp > 4 {
|
||||||
HIGH
|
HIGH
|
||||||
} else if level_comp < -5 {
|
} else if level_comp < -5 {
|
||||||
|
Loading…
Reference in New Issue
Block a user