From 6946de2682f699b8b6a0fd04812d60dc603aac1c Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Tue, 25 Aug 2020 21:54:47 +0200 Subject: [PATCH] fixed nametag height fmt fmt --- common/src/comp/body.rs | 4 ++-- voxygen/src/hud/mod.rs | 9 +++++---- voxygen/src/hud/overhead.rs | 22 ++++++++++++---------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index ef0496043f..19a6670dc7 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -193,7 +193,7 @@ impl Body { Body::QuadrupedLow(body) => match body.species { quadruped_low::Species::Monitor => 1.5, quadruped_low::Species::Tortoise => 2.0, - quadruped_low::Species::Rocksnapper => 2.0, + quadruped_low::Species::Rocksnapper => 2.9, quadruped_low::Species::Maneater => 4.0, _ => 1.3, }, @@ -206,7 +206,7 @@ impl Body { Body::Dragon(_) => 20.0, Body::BirdSmall(_) => 1.1, Body::FishSmall(_) => 0.9, - Body::BipedLarge(_) => 4.5, + Body::BipedLarge(_) => 4.6, Body::Golem(_) => 5.8, Body::Object(_) => 1.0, } diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index b5a2bb8db8..0950b188c3 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -68,7 +68,6 @@ use std::{ time::Instant, }; use vek::*; - 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_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); /// 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 const NAMETAG_RANGE: f32 = 40.0; /// Time nametags stay visible after doing damage even if they are out of range @@ -1153,8 +1152,7 @@ impl Hud { name, stats, energy, - // TODO: when body.height() is more accurate remove the 2.0 - body.height() * 2.0 * scale.map_or(1.0, |s| s.0), + body.height() * scale.map_or(1.0, |s| s.0) + 0.5, hpfl, uid, in_group, @@ -1170,6 +1168,9 @@ impl Hud { ); let ingame_pos = pos + Vec3::unit_z() * height_offset; + // + // * height_offset + // Speech bubble, name, level, and hp bars overhead::Overhead::new( &name, diff --git a/voxygen/src/hud/overhead.rs b/voxygen/src/hud/overhead.rs index 25bdc5e06a..22c789cd40 100644 --- a/voxygen/src/hud/overhead.rs +++ b/voxygen/src/hud/overhead.rs @@ -13,7 +13,6 @@ use conrod_core::{ widget::{self, Image, Rectangle, Text}, widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; - const MAX_BUBBLE_WIDTH: f64 = 250.0; widget_ids! { @@ -148,18 +147,19 @@ impl<'a> Widget for Overhead<'a> { fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { id, state, ui, .. } = args; - - const BARSIZE: f64 = 2.0; + const BARSIZE: f64 = 2.0; // Scaling const MANA_BAR_HEIGHT: f64 = BARSIZE * 1.5; const MANA_BAR_Y: f64 = MANA_BAR_HEIGHT / 2.0; + // Used to set healthbar colours based on hp_percentage let hp_percentage = 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 health_current = (self.stats.health.current() / 10) as f64; let health_max = (self.stats.health.maximum() / 10) as f64; let name_y = if (health_current - health_max).abs() < 1e-6 { MANA_BAR_Y + 20.0 - } else if level_comp > 9 { + } else if level_comp > 9 && !self.in_group { MANA_BAR_Y + 38.0 } else { MANA_BAR_Y + 32.0 @@ -426,7 +426,7 @@ impl<'a> Widget for Overhead<'a> { // + 5-10 levels above player -> high // -5 - +5 levels around player level -> equal // - 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 Image::new(if skull_ani as i32 == 1 && rand::random::() < 0.9 { self.imgs.skull_2 @@ -439,13 +439,15 @@ impl<'a> Widget for Overhead<'a> { .parent(id) .set(state.ids.level_skull, ui); } 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())) .font_id(self.fonts.cyri.conrod_id) - .font_size(if self.stats.level.level() > 9 && level_comp < 10 { - 14 - } else { - 15 - }) + .font_size(fnt_size) .color(if level_comp > 4 { HIGH } else if level_comp < -5 {