Fix: Healthbars size

This commit is contained in:
Monty Marz 2020-01-26 01:19:36 +00:00
parent 1a49121c90
commit 49071400d2
3 changed files with 48 additions and 40 deletions

BIN
assets/voxygen/background/bg_main.png (Stored with Git LFS)

Binary file not shown.

View File

@ -614,6 +614,7 @@ impl Hud {
// Max amount the sct font size increases when "flashing"
const FLASH_MAX: f32 = 25.0;
const BARSIZE: f64 = 2.0;
// Get player position.
let player_pos = client
.state()
@ -693,15 +694,21 @@ impl Hud {
let crit_hp_color: Color = Color::Rgba(0.79, 0.19, 0.17, hp_ani);
// Background
Rectangle::fill_with([82.0, 8.0], Color::Rgba(0.3, 0.3, 0.3, 0.5))
.x_y(0.0, -25.0)
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
.set(back_id, ui_widgets);
Rectangle::fill_with(
[82.0 * BARSIZE + 1.0, 8.0 * BARSIZE + 1.0],
Color::Rgba(0.1, 0.1, 0.1, 0.9),
)
.x_y(0.0, -25.0)
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
.set(back_id, ui_widgets);
// % HP Filling
Image::new(self.imgs.enemy_bar)
.w_h(72.9 * (hp_percentage / 100.0), 5.9)
.x_y(4.5 + (hp_percentage / 100.0 * 36.45) - 36.45, -24.0)
.w_h(72.9 * (hp_percentage / 100.0) * BARSIZE, 5.9 * BARSIZE)
.x_y(
(4.5 + (hp_percentage / 100.0 * 36.45 - 36.45)) * BARSIZE,
-23.0,
)
.color(Some(if hp_percentage <= 25.0 {
crit_hp_color
} else if hp_percentage <= 50.0 {
@ -714,19 +721,22 @@ impl Hud {
// % Mana Filling
Rectangle::fill_with(
[
73.0 * (energy.current() as f64 / energy.maximum() as f64),
1.5,
73.0 * (energy.current() as f64 / energy.maximum() as f64) * BARSIZE,
1.5 * BARSIZE,
],
MANA_COLOR,
)
.x_y(4.5 + (energy_percentage / 100.0 * 36.5) - 36.45, -28.0)
.x_y(
((4.5 + (energy_percentage / 100.0 * 36.5)) - 36.45) * BARSIZE,
-32.0,
)
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
.set(mana_bar_id, ui_widgets);
// Foreground
Image::new(self.imgs.enemy_health)
.w_h(84.0, 10.0)
.x_y(0.0, -25.0)
.w_h(84.0 * BARSIZE, 10.0 * BARSIZE)
.x_y(0.0, -25.5)
.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))
.set(front_id, ui_widgets);
@ -1158,15 +1168,15 @@ impl Hud {
// Name
Text::new(&name)
.font_size(20)
.font_size(30)
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
.x_y(-1.0, -1.0)
.x_y(-1.0, 16.0)
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
.set(name_bg_id, ui_widgets);
Text::new(&name)
.font_size(20)
.font_size(30)
.color(Color::Rgba(0.61, 0.61, 0.89, 1.0))
.x_y(0.0, 0.0)
.x_y(0.0, 18.0)
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
.set(name_id, ui_widgets);
@ -1184,9 +1194,9 @@ impl Hud {
// - 5 levels below player -> low
Text::new(if level_comp < 10 { &level_str } else { "?" })
.font_size(if op_level > 9 && level_comp < 10 {
7
14
} else {
8
15
})
.color(if level_comp > 4 {
HIGH
@ -1195,7 +1205,7 @@ impl Hud {
} else {
EQUAL
})
.x_y(-37.0, -24.0)
.x_y(-37.0 * BARSIZE, -23.0)
.position_ingame(pos + Vec3::new(0.0, 0.0, 1.5 * scale + 1.5))
.set(level_id, ui_widgets);
if level_comp > 9 {
@ -1205,8 +1215,8 @@ impl Hud {
} else {
self.imgs.skull
})
.w_h(18.0, 18.0)
.x_y(-39.0, -25.0)
.w_h(18.0 * BARSIZE, 18.0 * BARSIZE)
.x_y(-39.0 * BARSIZE, -25.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))
.set(level_skull_id, ui_widgets);

View File

@ -478,34 +478,32 @@ impl CharSelectionUi {
// Enter World Button
let character_count = global_state.meta.characters.len();
if character_count != 0 {
if Button::image(self.imgs.button)
.mid_bottom_with_margin_on(ui_widgets.window, 10.0)
.w_h(250.0, 60.0)
let enter_world_str = &localized_strings.get("char_selection.enter_world");
let enter_button = Button::image(self.imgs.button)
.mid_bottom_with_margin_on(ui_widgets.window, 10.0)
.w_h(250.0, 60.0)
.label(enter_world_str)
.label_font_size(26)
.label_font_id(self.fonts.cyri)
.label_y(conrod_core::position::Relative::Scalar(3.0));
if match &self.mode {
Mode::Select(opt) => opt.is_some(),
Mode::Create { .. } => true,
} {
if enter_button
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.label(&localized_strings.get("char_selection.enter_world"))
.label_color(TEXT_COLOR)
.label_font_size(26)
.label_font_id(self.fonts.cyri)
.label_y(conrod_core::position::Relative::Scalar(3.0))
.set(self.ids.enter_world_button, ui_widgets)
.was_clicked()
{
events.push(Event::Play);
}
} else {
if Button::image(self.imgs.button)
.mid_bottom_with_margin_on(ui_widgets.window, 10.0)
.w_h(250.0, 60.0)
.label(&localized_strings.get("char_selection.enter_world"))
&enter_button
.label_color(TEXT_COLOR_2)
.label_font_size(26)
.label_font_id(self.fonts.cyri)
.label_y(conrod_core::position::Relative::Scalar(3.0))
.set(self.ids.enter_world_button, ui_widgets)
.was_clicked()
{}
.set(self.ids.enter_world_button, ui_widgets);
}
// Logout_Button