diff --git a/assets/voxygen/element/icons/m1.png b/assets/voxygen/element/icons/m1.png index 6ad45b0c47..318ab7bc51 100644 --- a/assets/voxygen/element/icons/m1.png +++ b/assets/voxygen/element/icons/m1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dcb880d0d477525faa286adf34cbbb342059848e96ee042581ffa41f3a4f2acb -size 605 +oid sha256:ba71d24489dbaf1213e2dff747da626ebba4cf08b7689ba08f712baf32749a93 +size 2015 diff --git a/assets/voxygen/element/icons/m2.png b/assets/voxygen/element/icons/m2.png index 62d9df8b4c..70041f10f3 100644 --- a/assets/voxygen/element/icons/m2.png +++ b/assets/voxygen/element/icons/m2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:613ad50374735c2eaa80552cde9c25c12954bfd778f62a63f43d29562547b314 -size 605 +oid sha256:512b97dd8fe8a0ec484fb811ce92cb0cf51e6929c3e1bcce170b18e7872330e4 +size 2015 diff --git a/assets/voxygen/element/skillbar/bar_content.png b/assets/voxygen/element/skillbar/bar_content.png index 740e497fd2..261270a9fe 100644 --- a/assets/voxygen/element/skillbar/bar_content.png +++ b/assets/voxygen/element/skillbar/bar_content.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:554ab7e7ab2b4711dde9d63f1b176a589e978036c96df44af8e34213ca308d3c -size 90 +oid sha256:7dbf07842f8e0a2f8a10d63178a2d66c05c78842c6146704d8b3e5b6e0d37b24 +size 1410 diff --git a/assets/voxygen/element/skillbar/bg.png b/assets/voxygen/element/skillbar/bg.png new file mode 100644 index 0000000000..34db3e374c --- /dev/null +++ b/assets/voxygen/element/skillbar/bg.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc09c589c1d88fb11b92352c7e9f3e38109641b23a3e2c2c64b35342427f67a4 +size 2430 diff --git a/assets/voxygen/element/skillbar/energybar_bg.png b/assets/voxygen/element/skillbar/energybar_bg.png deleted file mode 100644 index ce25e47252..0000000000 --- a/assets/voxygen/element/skillbar/energybar_bg.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e74fb3a0d89ebd0e183881aa29e1315fe9aa0417099d5d0f24a3d7244ed82f66 -size 193 diff --git a/assets/voxygen/element/skillbar/frame.png b/assets/voxygen/element/skillbar/frame.png new file mode 100644 index 0000000000..0372a480ba --- /dev/null +++ b/assets/voxygen/element/skillbar/frame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc363fb4b3d0587fd7e1be06a7991b0539050d4e1dae06366bb586b3375c7318 +size 3383 diff --git a/assets/voxygen/element/skillbar/healthbar_bg.png b/assets/voxygen/element/skillbar/healthbar_bg.png deleted file mode 100644 index 85e206287c..0000000000 --- a/assets/voxygen/element/skillbar/healthbar_bg.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:99db830a62bcc2a77867df849e5c5eb3689514782ec95b1b0f62c0b096d21bcd -size 190 diff --git a/assets/voxygen/element/skillbar/skillbar_slot.png b/assets/voxygen/element/skillbar/skillbar_slot.png deleted file mode 100644 index b23b25967f..0000000000 --- a/assets/voxygen/element/skillbar/skillbar_slot.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e684e902c11fe48c4875997799834fa597cc14a7eab86cf48d63c56de1191f11 -size 610 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_active.png b/assets/voxygen/element/skillbar/skillbar_slot_active.png deleted file mode 100644 index 97dbb17702..0000000000 --- a/assets/voxygen/element/skillbar/skillbar_slot_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:11caed86e7b99aa9a552bfe2f3bce3ea84c175e39069a909b5bc7e2ac2cbfe7e -size 3533 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_big.png b/assets/voxygen/element/skillbar/skillbar_slot_big.png deleted file mode 100644 index 8638974e52..0000000000 --- a/assets/voxygen/element/skillbar/skillbar_slot_big.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:82aa46ad7cd827151206e79180200d40b72755b9ec3ba2016f081a9c38f3100c -size 243 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_l.png b/assets/voxygen/element/skillbar/skillbar_slot_l.png deleted file mode 100644 index 615e91ffd2..0000000000 --- a/assets/voxygen/element/skillbar/skillbar_slot_l.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0308eac5f6ca52d9e1425ae5c7f17c0451f628d2b8443d699eece95e3480adfd -size 607 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_l_active.png b/assets/voxygen/element/skillbar/skillbar_slot_l_active.png deleted file mode 100644 index 3e629d7c6c..0000000000 --- a/assets/voxygen/element/skillbar/skillbar_slot_l_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:48ed7345f1920bc9a6105771659ebef797a07d690369cdb2bb299d92bb583e65 -size 3533 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_r.png b/assets/voxygen/element/skillbar/skillbar_slot_r.png deleted file mode 100644 index 16591871c0..0000000000 --- a/assets/voxygen/element/skillbar/skillbar_slot_r.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:56dbe92fe64b64b59b554ada0d1eb0dbb537593e3a1d87dfccd721c6519e521d -size 608 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_r_active.png b/assets/voxygen/element/skillbar/skillbar_slot_r_active.png deleted file mode 100644 index 6ba1610d29..0000000000 --- a/assets/voxygen/element/skillbar/skillbar_slot_r_active.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3cfe0bef782ebdff6665e866e1ec659f139d36ded000a3c9fac298037ae86787 -size 3533 diff --git a/assets/voxygen/element/skillbar/xp_bar_content.png b/assets/voxygen/element/skillbar/xp_bar_content.png deleted file mode 100644 index 87d1f20c4c..0000000000 --- a/assets/voxygen/element/skillbar/xp_bar_content.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8c547c12c27a835c845a1b6e20c6e66b632fcba64e2cfad5a0df635263191dbe -size 111 diff --git a/assets/voxygen/element/skillbar/xp_bar_left.png b/assets/voxygen/element/skillbar/xp_bar_left.png deleted file mode 100644 index 5f045d8ce8..0000000000 --- a/assets/voxygen/element/skillbar/xp_bar_left.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5bf8eaeecd8a80e343951be5d9e2ef215f897bc2b25bac1681d14203f29e6a41 -size 170 diff --git a/assets/voxygen/element/skillbar/xp_bar_mid.png b/assets/voxygen/element/skillbar/xp_bar_mid.png deleted file mode 100644 index 36e5211848..0000000000 --- a/assets/voxygen/element/skillbar/xp_bar_mid.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:893cb632175e00fe32f83c1de7232cbfdad5a31cf251de5948895781ab870922 -size 133 diff --git a/assets/voxygen/element/skillbar/xp_bar_right.png b/assets/voxygen/element/skillbar/xp_bar_right.png deleted file mode 100644 index 6b9edbb223..0000000000 --- a/assets/voxygen/element/skillbar/xp_bar_right.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f2cb46b07a8f7fa0f6ecf029bda641abe17c107a3a0558013ac31d3fec3a93bf -size 159 diff --git a/voxygen/src/hud/group.rs b/voxygen/src/hud/group.rs index 26060b3084..26b853cd08 100644 --- a/voxygen/src/hud/group.rs +++ b/voxygen/src/hud/group.rs @@ -1,6 +1,6 @@ use super::{ img_ids::Imgs, Show, BLACK, ERROR_COLOR, GROUP_COLOR, HP_COLOR, KILL_COLOR, LOW_HP_COLOR, - MANA_COLOR, TEXT_COLOR, TEXT_COLOR_GREY, UI_HIGHLIGHT_0, UI_MAIN, + STAMINA_COLOR, TEXT_COLOR, TEXT_COLOR_GREY, UI_HIGHLIGHT_0, UI_MAIN, }; use crate::{ @@ -404,7 +404,7 @@ impl<'a> Widget for Group<'a> { // Stamina Image::new(self.imgs.bar_content) .w_h(100.0 * stam_perc, 8.0) - .color(Some(MANA_COLOR)) + .color(Some(STAMINA_COLOR)) .top_left_with_margins_on(state.ids.member_panels_bg[i], 26.0, 2.0) .set(state.ids.member_stam[i], ui); } diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index eecd9d18da..a955e2685f 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -147,22 +147,12 @@ image_ids! { // Skillbar level_up: "voxygen.element.misc_bg.level_up", - level_down: "voxygen.element.misc_bg.level_down", - xp_bar_mid: "voxygen.element.skillbar.xp_bar_mid", - xp_bar_left: "voxygen.element.skillbar.xp_bar_left", - xp_bar_right: "voxygen.element.skillbar.xp_bar_right", - healthbar_bg: "voxygen.element.skillbar.healthbar_bg", - energybar_bg: "voxygen.element.skillbar.energybar_bg", + level_down:"voxygen.element.misc_bg.level_down", bar_content: "voxygen.element.skillbar.bar_content", - skillbar_slot_big: "voxygen.element.skillbar.skillbar_slot_big", - skillbar_slot_big_bg: "voxygen.element.skillbar.skillbar_slot_big", - skillbar_slot_big_act: "voxygen.element.skillbar.skillbar_slot_big", - skillbar_slot: "voxygen.element.skillbar.skillbar_slot", - skillbar_slot_act: "voxygen.element.skillbar.skillbar_slot_active", - skillbar_slot_l: "voxygen.element.skillbar.skillbar_slot_l", - skillbar_slot_r: "voxygen.element.skillbar.skillbar_slot_r", - skillbar_slot_l_act: "voxygen.element.skillbar.skillbar_slot_l_active", - skillbar_slot_r_act: "voxygen.element.skillbar.skillbar_slot_r_active", + skillbar_bg: "voxygen.element.skillbar.bg", + skillbar_frame: "voxygen.element.skillbar.frame", + m1_ico: "voxygen.element.icons.m1", + m2_ico: "voxygen.element.icons.m2", // Other Icons/Art skull: "voxygen.element.icons.skull", diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 0350b89dd1..409c13bc2f 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -91,7 +91,7 @@ const BLACK: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0); const HP_COLOR: Color = Color::Rgba(0.33, 0.63, 0.0, 1.0); const LOW_HP_COLOR: Color = Color::Rgba(0.93, 0.59, 0.03, 1.0); const CRITICAL_HP_COLOR: Color = Color::Rgba(0.79, 0.19, 0.17, 1.0); -const MANA_COLOR: Color = Color::Rgba(0.29, 0.62, 0.75, 0.9); +const STAMINA_COLOR: Color = Color::Rgba(0.29, 0.62, 0.75, 0.9); //const TRANSPARENT: Color = Color::Rgba(0.0, 0.0, 0.0, 0.0); //const FOCUS_COLOR: Color = Color::Rgba(1.0, 0.56, 0.04, 1.0); //const RAGE_COLOR: Color = Color::Rgba(0.5, 0.04, 0.13, 1.0); @@ -2031,10 +2031,7 @@ impl Hud { }, settings_window::Event::CrosshairType(crosshair_type) => { events.push(Event::CrosshairType(crosshair_type)); - }, - settings_window::Event::ToggleXpBar(xp_bar) => { - events.push(Event::ToggleXpBar(xp_bar)); - }, + }, settings_window::Event::ToggleBarNumbers(bar_numbers) => { events.push(Event::ToggleBarNumbers(bar_numbers)); }, diff --git a/voxygen/src/hud/overhead.rs b/voxygen/src/hud/overhead.rs index a69bccbea6..e24e4eb853 100644 --- a/voxygen/src/hud/overhead.rs +++ b/voxygen/src/hud/overhead.rs @@ -1,6 +1,6 @@ use super::{ img_ids::Imgs, DEFAULT_NPC, FACTION_COLOR, GROUP_COLOR, GROUP_MEMBER, HP_COLOR, LOW_HP_COLOR, - MANA_COLOR, REGION_COLOR, SAY_COLOR, TELL_COLOR, TEXT_BG, TEXT_COLOR, + REGION_COLOR, SAY_COLOR, STAMINA_COLOR, TELL_COLOR, TEXT_BG, TEXT_COLOR, }; use crate::{ i18n::VoxygenLocalization, @@ -254,7 +254,7 @@ impl<'a> Widget for Overhead<'a> { Rectangle::fill_with( [72.0 * energy_factor * BARSIZE, MANA_BAR_HEIGHT], - MANA_COLOR, + STAMINA_COLOR, ) .x_y( ((3.5 + (energy_factor * 36.5)) - 36.45) * BARSIZE, diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index 6fb2473742..e6c0af70b5 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -1,6 +1,5 @@ use super::{ - img_ids::Imgs, BarNumbers, CrosshairType, PressBehavior, ShortcutNumbers, Show, XpBar, - CRITICAL_HP_COLOR, ERROR_COLOR, HP_COLOR, LOW_HP_COLOR, MANA_COLOR, MENU_BG, + img_ids::Imgs, BarNumbers, CrosshairType, PressBehavior, ShortcutNumbers, Show, CRITICAL_HP_COLOR, ERROR_COLOR, HP_COLOR, LOW_HP_COLOR, MENU_BG, STAMINA_COLOR, TEXT_BIND_CONFLICT_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, }; use crate::{ @@ -258,8 +257,7 @@ pub struct State { pub enum Event { ToggleHelp, ToggleDebug, - ToggleTips(bool), - ToggleXpBar(XpBar), + ToggleTips(bool), ToggleBarNumbers(BarNumbers), ToggleShortcutNumbers(ShortcutNumbers), ChangeTab(SettingsTab), @@ -795,41 +793,7 @@ impl<'a> Widget for SettingsWindow<'a> { .font_size(self.fonts.cyri.scale(18)) .font_id(self.fonts.cyri.conrod_id) .color(TEXT_COLOR) - .set(state.ids.hotbar_title, ui); - // Show xp bar - if Button::image(match self.global_state.settings.gameplay.xp_bar { - XpBar::Always => self.imgs.checkbox_checked, - XpBar::OnGain => self.imgs.checkbox, - }) - .w_h(18.0, 18.0) - .hover_image(match self.global_state.settings.gameplay.xp_bar { - XpBar::Always => self.imgs.checkbox_checked_mo, - XpBar::OnGain => self.imgs.checkbox_mo, - }) - .press_image(match self.global_state.settings.gameplay.xp_bar { - XpBar::Always => self.imgs.checkbox_checked, - XpBar::OnGain => self.imgs.checkbox_press, - }) - .down_from(state.ids.hotbar_title, 8.0) - .set(state.ids.show_xpbar_button, ui) - .was_clicked() - { - match self.global_state.settings.gameplay.xp_bar { - XpBar::Always => events.push(Event::ToggleXpBar(XpBar::OnGain)), - XpBar::OnGain => events.push(Event::ToggleXpBar(XpBar::Always)), - } - } - Text::new( - &self - .localized_strings - .get("hud.settings.toggle_bar_experience"), - ) - .right_from(state.ids.show_xpbar_button, 10.0) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .graphics_for(state.ids.show_xpbar_button) - .color(TEXT_COLOR) - .set(state.ids.show_xpbar_text, ui); + .set(state.ids.hotbar_title, ui); // Show Shortcut Numbers if Button::image(match self.global_state.settings.gameplay.shortcut_numbers { ShortcutNumbers::On => self.imgs.checkbox_checked, @@ -844,7 +808,7 @@ impl<'a> Widget for SettingsWindow<'a> { ShortcutNumbers::On => self.imgs.checkbox_checked, ShortcutNumbers::Off => self.imgs.checkbox_press, }) - .down_from(state.ids.show_xpbar_button, 8.0) + .down_from(state.ids.hotbar_title, 8.0) .set(state.ids.show_shortcuts_button, ui) .was_clicked() { @@ -1692,7 +1656,7 @@ impl<'a> Widget for SettingsWindow<'a> { 0..=14 => CRITICAL_HP_COLOR, 15..=29 => LOW_HP_COLOR, 30..=50 => HP_COLOR, - _ => MANA_COLOR, + _ => STAMINA_COLOR, }; Text::new(&format!("FPS: {:.0}", self.fps)) .color(fps_col) diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 21e1aa2bd4..f27bb47257 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -2,8 +2,8 @@ use super::{ hotbar, img_ids::{Imgs, ImgsRot}, item_imgs::ItemImgs, - slots, BarNumbers, ShortcutNumbers, Show, XpBar, BLACK, CRITICAL_HP_COLOR, HP_COLOR, - LOW_HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR, + slots, BarNumbers, ShortcutNumbers, Show, BLACK, CRITICAL_HP_COLOR, HP_COLOR, + LOW_HP_COLOR, STAMINA_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN, XP_COLOR, }; use crate::{ i18n::VoxygenLocalization, @@ -27,27 +27,51 @@ use conrod_core::{ widget::{self, Button, Image, Rectangle, Text}, widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; +use inline_tweak::*; use std::time::{Duration, Instant}; use vek::*; widget_ids! { struct Ids { + // Death message death_message_1, death_message_2, death_message_1_bg, death_message_2_bg, - level_text, - next_level_text, - xp_bar_mid, - xp_bar_mid_top, - xp_bar_left, - xp_bar_left_top, - xp_bar_right, - xp_bar_right_top, - xp_bar_filling, - xp_bar_filling_top, - hotbar_align, - xp_bar_subdivision, + death_bg, + // Level up message + level_up, + level_down, + level_align, + level_message, + level_message_bg, + // Hurt BG + hurt_bg, + // Skillbar + alignment, + bg, + frame, + m1_ico, + m2_ico, + // Level + level_bg, + level, + // Exp-Bar + exp_alignment, + exp_filling, + // HP-Bar + hp_alignment, + hp_filling, + hp_txt_alignment, + hp_txt_bg, + hp_txt, + // Stamina-Bar + stamina_alignment, + stamina_filling, + stamina_txt_alignment, + stamina_txt_bg, + stamina_txt, + // Slots m1_slot, m1_slot_bg, m1_text, @@ -91,29 +115,9 @@ widget_ids! { slot10, slot10_text, slot10_text_bg, - healthbar_bg, - healthbar_filling, - health_text, - health_text_bg, - energybar_bg, - energybar_filling, - energy_text, - energy_text_bg, - level_up, - level_down, - level_align, - level_message, - level_message_bg, - death_bg, - hurt_bg, } } -pub enum ResourceType { - Mana, - /*Rage, - *Focus, */ -} #[derive(WidgetCommon)] pub struct Skillbar<'a> { global_state: &'a GlobalState, @@ -133,8 +137,7 @@ pub struct Skillbar<'a> { localized_strings: &'a std::sync::Arc, pulse: f32, #[conrod(common_builder)] - common: widget::CommonBuilder, - current_resource: ResourceType, + common: widget::CommonBuilder, show: &'a Show, } @@ -167,8 +170,7 @@ impl<'a> Skillbar<'a> { rot_imgs, stats, loadout, - energy, - current_resource: ResourceType::Mana, + energy, common: widget::CommonBuilder::default(), character_state, pulse, @@ -184,11 +186,8 @@ impl<'a> Skillbar<'a> { } pub struct State { - ids: Ids, - - last_xp_value: u32, - last_level: u32, - last_update_xp: Instant, + ids: Ids, + last_level: u32, last_update_level: Instant, } @@ -199,11 +198,8 @@ impl<'a> Widget for Skillbar<'a> { fn init_state(&self, id_gen: widget::id::Generator) -> Self::State { State { - ids: Ids::new(id_gen), - - last_xp_value: 0, - last_level: 1, - last_update_xp: Instant::now(), + ids: Ids::new(id_gen), + last_level: 1, last_update_level: Instant::now(), } } @@ -214,8 +210,7 @@ impl<'a> Widget for Skillbar<'a> { fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; - let level = (self.stats.level.level()).to_string(); - let next_level = (self.stats.level.level() + 1).to_string(); + let level = if self.stats.level.level() > 999 {"A".to_string()} else {(self.stats.level.level()).to_string()}; let exp_percentage = (self.stats.exp.current() as f64) / (self.stats.exp.maximum() as f64); @@ -226,8 +221,7 @@ impl<'a> Widget for Skillbar<'a> { if self.stats.is_dead { hp_percentage = 0.0; energy_percentage = 0.0; - }; - let scale = 2.0; + }; let bar_values = self.global_state.settings.gameplay.bar_numbers; let shortcuts = self.global_state.settings.gameplay.shortcut_numbers; @@ -339,410 +333,147 @@ impl<'a> Widget for Skillbar<'a> { .set(state.ids.death_message_2, ui); } } - // Experience-Bar - match self.global_state.settings.gameplay.xp_bar { - XpBar::Always => { - // Constant Display of the Exp Bar at the bottom of the screen - Image::new(self.imgs.xp_bar_mid) - .w_h(80.0 * scale, 10.0 * scale) - .mid_bottom_with_margin_on(ui.window, 2.0) - .set(state.ids.xp_bar_mid, ui); - Image::new(self.imgs.xp_bar_right) - .w_h(100.0 * scale, 10.0 * scale) - .right_from(state.ids.xp_bar_mid, 0.0) - .set(state.ids.xp_bar_right, ui); - Image::new(self.imgs.xp_bar_left) - .w_h(100.0 * scale, 10.0 * scale) - .left_from(state.ids.xp_bar_mid, 0.0) - .set(state.ids.xp_bar_left, ui); - Image::new(self.imgs.bar_content) - .w_h(260.0 * scale * exp_percentage, 5.0 * scale) + // Skillbar + // Alignment and BG + Rectangle::fill_with([524.0, 80.0], color::TRANSPARENT) + .mid_bottom_with_margin_on(ui.window, 10.0) + .set(state.ids.alignment, ui); + Image::new(self.imgs.skillbar_bg) + .w_h(480.0, 80.0) + .color(Some(UI_MAIN)) + .middle_of(state.ids.alignment) + .set(state.ids.bg, ui); + // Level + let lvl_size = match self.stats.level.level() { + 11..=99 => tweak!(13), + 100..=999 => tweak!(10), + _ => tweak!(14), + }; + Text::new(&level) + .mid_top_with_margin_on(state.ids.bg, 3.0) + .font_size(self.fonts.cyri.scale(lvl_size)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.level, ui); + // Exp-Bar + Rectangle::fill_with([476.0, 8.0], color::TRANSPARENT) + .mid_bottom_with_margin_on(state.ids.bg, 4.0) + .set(state.ids.exp_alignment, ui); + Image::new(self.imgs.bar_content) + .w_h(476.0 * exp_percentage, 8.0) .color(Some(XP_COLOR)) - .top_left_with_margins_on(state.ids.xp_bar_left, 2.0 * scale, 10.0 * scale) - .set(state.ids.xp_bar_filling, ui); - // Level Display - if self.stats.level.level() < 10 { - Text::new(&level) - .bottom_left_with_margins_on( - state.ids.xp_bar_left, - 3.5 * scale, - 4.0 * scale, - ) - .font_size(self.fonts.cyri.scale(10)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - .set(state.ids.level_text, ui); - Text::new(&next_level) - .bottom_right_with_margins_on( - state.ids.xp_bar_right, - 3.5 * scale, - 4.0 * scale, - ) - .font_size(self.fonts.cyri.scale(10)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - .set(state.ids.next_level_text, ui); - } else if self.stats.level.level() < 100 { - // Change offset and fontsize for levels > 9 - Text::new(&level) - .bottom_left_with_margins_on( - state.ids.xp_bar_left, - 3.5 * scale, - 3.0 * scale, - ) - .font_size(self.fonts.cyri.scale(9)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - .set(state.ids.level_text, ui); - Text::new(&next_level) - .bottom_right_with_margins_on( - state.ids.xp_bar_right, - 3.5 * scale, - 3.0 * scale, - ) - .font_size(self.fonts.cyri.scale(9)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - .set(state.ids.next_level_text, ui); - } else { - // Change offset and fontsize for levels > 9 - Text::new(&level) - .bottom_left_with_margins_on( - state.ids.xp_bar_left, - 3.5 * scale, - 2.5 * scale, - ) - .font_size(self.fonts.cyri.scale(8)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - .set(state.ids.level_text, ui); - Text::new(&next_level) - .bottom_right_with_margins_on( - state.ids.xp_bar_right, - 3.5 * scale, - 2.5 * scale, - ) - .font_size(self.fonts.cyri.scale(8)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, 1.0)) - .set(state.ids.next_level_text, ui); - } - // M1 Slot - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .top_left_with_margins_on(state.ids.xp_bar_mid, -40.0 * scale, 0.0) - .set(state.ids.m1_slot, ui); - }, - XpBar::OnGain => { - // Displays the Exp Bar at the top of the screen when exp is gained and fades it - // out afterwards - const FADE_IN_XP: f32 = 1.0; - const FADE_HOLD_XP: f32 = 3.0; - const FADE_OUT_XP: f32 = 2.0; - let current_xp = self.stats.exp.current(); - // Check if no other popup is displayed and a new one is needed - if state.last_update_xp.elapsed() - > Duration::from_secs_f32(FADE_IN_XP + FADE_HOLD_XP + FADE_OUT_XP) - && state.last_xp_value != current_xp - { - // Update last_value - state.update(|s| s.last_xp_value = current_xp); - state.update(|s| s.last_update_xp = Instant::now()); - } - - let seconds_xp = state.last_update_xp.elapsed().as_secs_f32(); - let fade_xp = if current_xp == 0 { - 0.0 - } else if seconds_xp < FADE_IN_XP { - seconds_xp / FADE_IN_XP - } else if seconds_xp < FADE_IN_XP + FADE_HOLD_XP { - 1.0 - } else { - (1.0 - (seconds_xp - FADE_IN_XP - FADE_HOLD_XP) / FADE_OUT_XP).max(0.0) - }; - // Hotbar parts - Image::new(self.imgs.xp_bar_mid) - .w_h(80.0 * scale * 1.5, 10.0 * scale * 1.5) - .mid_top_with_margin_on(ui.window, 20.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_xp))) - .set(state.ids.xp_bar_mid_top, ui); - Image::new(self.imgs.xp_bar_right) - .w_h(100.0 * scale * 1.5, 10.0 * scale * 1.5) - .right_from(state.ids.xp_bar_mid_top, 0.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_xp))) - .set(state.ids.xp_bar_right_top, ui); - Image::new(self.imgs.xp_bar_left) - .w_h(100.0 * scale * 1.5, 10.0 * scale * 1.5) - .left_from(state.ids.xp_bar_mid_top, 0.0) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_xp))) - .set(state.ids.xp_bar_left_top, ui); - Image::new(self.imgs.bar_content) - .w_h(260.0 * scale * 1.5 * exp_percentage, 6.0 * scale * 1.5) - .color(Some(Color::Rgba(0.59, 0.41, 0.67, fade_xp))) - .top_left_with_margins_on( - state.ids.xp_bar_left_top, - 2.0 * scale * 1.5, - 10.0 * scale * 1.5, - ) - .set(state.ids.xp_bar_filling_top, ui); - // Level Display - if self.stats.level.level() < 10 { - Text::new(&level) - .bottom_left_with_margins_on( - state.ids.xp_bar_left_top, - 3.0 * scale * 1.5, - 4.0 * scale * 1.5, - ) - .font_size(self.fonts.cyri.scale(17)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, fade_xp)) - .set(state.ids.level_text, ui); - Text::new(&next_level) - .bottom_right_with_margins_on( - state.ids.xp_bar_right_top, - 3.0 * scale * 1.5, - 4.0 * scale * 1.5, - ) - .font_size(self.fonts.cyri.scale(15)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, fade_xp)) - .set(state.ids.next_level_text, ui); - } else if self.stats.level.level() < 100 { - // Change offset and fontsize for levels > 9 - Text::new(&level) - .bottom_left_with_margins_on( - state.ids.xp_bar_left_top, - 3.0 * scale * 1.5, - 3.0 * scale * 1.5, - ) - .font_size(self.fonts.cyri.scale(15)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, fade_xp)) - .set(state.ids.level_text, ui); - Text::new(&next_level) - .bottom_right_with_margins_on( - state.ids.xp_bar_right_top, - 3.0 * scale * 1.5, - 3.0 * scale * 1.5, - ) - .font_size(self.fonts.cyri.scale(15)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, fade_xp)) - .set(state.ids.next_level_text, ui); - } else { - // Change offset and fontsize for levels > 9 - Text::new(&level) - .bottom_left_with_margins_on( - state.ids.xp_bar_left_top, - 3.0 * scale * 1.5, - 2.75 * scale * 1.5, - ) - .font_size(self.fonts.cyri.scale(12)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, fade_xp)) - .set(state.ids.level_text, ui); - Text::new(&next_level) - .bottom_right_with_margins_on( - state.ids.xp_bar_right_top, - 3.0 * scale * 1.5, - 2.75 * scale * 1.5, - ) - .font_size(self.fonts.cyri.scale(12)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(1.0, 1.0, 1.0, fade_xp)) - .set(state.ids.next_level_text, ui); - } - // Alignment for hotbar - Rectangle::fill_with([80.0 * scale, 1.0], color::TRANSPARENT) - .mid_bottom_with_margin_on(ui.window, 9.0) - .set(state.ids.hotbar_align, ui); - // M1 Slot - - match self.character_state { - CharacterState::BasicMelee { .. } => { - if self.controller.primary.is_pressed() { - let fade_pulse = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.6; //Animation timer; - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .top_left_with_margins_on( - state.ids.hotbar_align, - -40.0 * scale, - 0.0, - ) - .set(state.ids.m1_slot, ui); - Image::new(self.imgs.skillbar_slot_big_act) - .w_h(40.0 * scale, 40.0 * scale) - .middle_of(state.ids.m1_slot) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_pulse))) - .floating(true) - .set(state.ids.m1_slot_act, ui); - } else { - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .top_left_with_margins_on( - state.ids.hotbar_align, - -40.0 * scale, - 0.0, - ) - .set(state.ids.m1_slot, ui); - } - }, - _ => { - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .top_left_with_margins_on(state.ids.hotbar_align, -40.0 * scale, 0.0) - .set(state.ids.m1_slot, ui); - }, - } - }, + .bottom_left_with_margins_on(state.ids.exp_alignment, 0.0, 0.0) + .set(state.ids.exp_filling, ui); + // Health and Stamina bar + // Alignment + Rectangle::fill_with([240.0, 17.0], color::TRANSPARENT) + .top_left_with_margins_on(state.ids.alignment, 0.0, 0.0) + .set(state.ids.hp_alignment, ui); + Rectangle::fill_with([240.0, 17.0], color::TRANSPARENT) + .top_right_with_margins_on(state.ids.alignment, 0.0, 0.0) + .set(state.ids.stamina_alignment, ui); + let health_col = match hp_percentage as u8 { + 0..=20 => crit_hp_color, + 21..=40 => LOW_HP_COLOR, + _ => HP_COLOR, + }; + // Content + Image::new(self.imgs.bar_content) + .w_h(216.0 * hp_percentage / 100.0, 14.0) + .color(Some(health_col)) + .top_right_with_margins_on(state.ids.hp_alignment, 4.0, 0.0) + .set(state.ids.hp_filling, ui); + Image::new(self.imgs.bar_content) + .w_h(216.0 * energy_percentage / 100.0, 14.0) + .color(Some(STAMINA_COLOR)) + .top_left_with_margins_on(state.ids.stamina_alignment, 4.0, 0.0) + .set(state.ids.stamina_filling, ui); + Rectangle::fill_with([216.0, 14.0], color::TRANSPARENT) + .top_left_with_margins_on(state.ids.hp_alignment, 4.0, 13.0) + .set(state.ids.hp_txt_alignment, ui); + Rectangle::fill_with([216.0, 14.0], color::TRANSPARENT) + .top_right_with_margins_on(state.ids.stamina_alignment, 4.0, 13.0) + .set(state.ids.stamina_txt_alignment, ui); + // Bar Text + // Values + if let BarNumbers::Values = bar_values { + let mut hp_txt = format!( + "{}/{}", + (self.stats.health.current() / 10).max(1) as u32, /* Don't show 0 health for + * living players */ + (self.stats.health.maximum() / 10) as u32 + ); + let mut energy_txt = format!("{}", energy_percentage as u32); + if self.stats.is_dead { + hp_txt = self.localized_strings.get("hud.group.dead").to_string(); + energy_txt = self.localized_strings.get("hud.group.dead").to_string(); + }; + Text::new(&hp_txt) + .middle_of(state.ids.hp_txt_alignment) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .set(state.ids.hp_txt_bg, ui); + Text::new(&hp_txt) + .bottom_left_with_margins_on(state.ids.hp_txt_bg, 2.0, 2.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.hp_txt, ui); + Text::new(&energy_txt) + .middle_of(state.ids.stamina_txt_alignment) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .set(state.ids.stamina_txt_bg, ui); + Text::new(&energy_txt) + .bottom_left_with_margins_on(state.ids.stamina_txt_bg, 2.0, 2.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.stamina_txt, ui); } - // M1 Slot - Image::new(self.imgs.skillbar_slot_big_bg) - .w_h(38.0 * scale, 38.0 * scale) - .color( - match self.loadout.active_item.as_ref().map(|i| i.item.kind()) { - Some(ItemKind::Tool(Tool { kind, .. })) => match kind { - ToolKind::Bow(_) => Some(BG_COLOR_2), - ToolKind::Staff(_) => Some(BG_COLOR_2), - _ => Some(BG_COLOR_2), - }, - _ => Some(BG_COLOR_2), - }, - ) - .middle_of(state.ids.m1_slot) - .set(state.ids.m1_slot_bg, ui); - Button::image( - match self.loadout.active_item.as_ref().map(|i| i.item.kind()) { - Some(ItemKind::Tool(Tool { kind, .. })) => match kind { - ToolKind::Sword(_) => self.imgs.twohsword_m1, - ToolKind::Dagger(_) => self.imgs.onehdagger_m1, - ToolKind::Shield(_) => self.imgs.onehshield_m1, - ToolKind::Hammer(_) => self.imgs.twohhammer_m1, - ToolKind::Axe(_) => self.imgs.twohaxe_m1, - ToolKind::Bow(_) => self.imgs.bow_m1, - ToolKind::Sceptre(_) => self.imgs.heal_0, - ToolKind::Staff(_) => self.imgs.fireball, - ToolKind::Debug(kind) => match kind.as_ref() { - "Boost" => self.imgs.flyingrod_m1, - _ => self.imgs.nothing, - }, - _ => self.imgs.nothing, - }, - _ => self.imgs.nothing, - }, - ) // Insert Icon here - .w_h(32.0 * scale, 32.0 * scale) - .middle_of(state.ids.m1_slot_bg) - .set(state.ids.m1_content, ui); - // M2 Slot - match self.character_state { - CharacterState::BasicMelee { .. } => { - let fade_pulse = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.6; //Animation timer; - if self.controller.secondary.is_pressed() { - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .right_from(state.ids.m1_slot, 0.0) - .set(state.ids.m2_slot, ui); - Image::new(self.imgs.skillbar_slot_big_act) - .w_h(40.0 * scale, 40.0 * scale) - .middle_of(state.ids.m2_slot) - .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_pulse))) - .floating(true) - .set(state.ids.m2_slot_act, ui); - } else { - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .right_from(state.ids.m1_slot, 0.0) - .set(state.ids.m2_slot, ui); - } - }, - _ => { - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .right_from(state.ids.m1_slot, 0.0) - .set(state.ids.m2_slot, ui); - }, + //Percentages + if let BarNumbers::Percent = bar_values { + let mut hp_txt = format!("{}%", hp_percentage as u32); + let mut energy_txt = format!("{}", energy_percentage as u32); + if self.stats.is_dead { + hp_txt = self.localized_strings.get("hud.group.dead").to_string(); + energy_txt = self.localized_strings.get("hud.group.dead").to_string(); + }; + Text::new(&hp_txt) + .middle_of(state.ids.hp_txt_alignment) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .set(state.ids.hp_txt_bg, ui); + Text::new(&hp_txt) + .bottom_left_with_margins_on(state.ids.hp_txt_bg, 2.0, 2.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.hp_txt, ui); + Text::new(&energy_txt) + .middle_of(state.ids.stamina_txt_alignment) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) + .set(state.ids.stamina_txt_bg, ui); + Text::new(&energy_txt) + .bottom_left_with_margins_on(state.ids.stamina_txt_bg, 2.0, 2.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.stamina_txt, ui); } - - let active_tool_kind = match self.loadout.active_item.as_ref().map(|i| i.item.kind()) { - Some(ItemKind::Tool(Tool { kind, .. })) => Some(kind), - _ => None, - }; - - let second_tool_kind = match self.loadout.second_item.as_ref().map(|i| i.item.kind()) { - Some(ItemKind::Tool(Tool { kind, .. })) => Some(kind), - _ => None, - }; - - let tool_kind = match ( - active_tool_kind.map(|tk| tk.hands()), - second_tool_kind.map(|tk| tk.hands()), - ) { - (Some(Hands::TwoHand), _) => active_tool_kind, - (_, Some(Hands::OneHand)) => second_tool_kind, - (_, _) => None, - }; - - Image::new(self.imgs.skillbar_slot_big_bg) - .w_h(38.0 * scale, 38.0 * scale) - .color(match tool_kind { - Some(ToolKind::Bow(_)) => Some(BG_COLOR_2), - Some(ToolKind::Staff(_)) => Some(BG_COLOR_2), - _ => Some(BG_COLOR_2), - }) - .middle_of(state.ids.m2_slot) - .set(state.ids.m2_slot_bg, ui); - Button::image(match tool_kind { - Some(ToolKind::Sword(_)) => self.imgs.twohsword_m2, - Some(ToolKind::Dagger(_)) => self.imgs.onehdagger_m2, - Some(ToolKind::Shield(_)) => self.imgs.onehshield_m2, - Some(ToolKind::Hammer(_)) => self.imgs.hammergolf, - Some(ToolKind::Axe(_)) => self.imgs.axespin, - Some(ToolKind::Bow(_)) => self.imgs.bow_m2, - Some(ToolKind::Sceptre(_)) => self.imgs.heal_bomb, - Some(ToolKind::Staff(_)) => self.imgs.flamethrower, - Some(ToolKind::Debug(kind)) => match kind.as_ref() { - "Boost" => self.imgs.flyingrod_m2, - _ => self.imgs.nothing, - }, - _ => self.imgs.nothing, - }) - .w_h(32.0 * scale, 32.0 * scale) - .middle_of(state.ids.m2_slot_bg) - .image_color(match tool_kind { - Some(ToolKind::Sword(_)) => { - if self.energy.current() as f64 >= 200.0 { - Color::Rgba(1.0, 1.0, 1.0, 1.0) - } else { - Color::Rgba(0.3, 0.3, 0.3, 0.8) - } - }, - Some(ToolKind::Sceptre(_)) => { - if self.energy.current() as f64 >= 400.0 { - Color::Rgba(1.0, 1.0, 1.0, 1.0) - } else { - Color::Rgba(0.3, 0.3, 0.3, 0.8) - } - }, - Some(ToolKind::Axe(_)) => { - if self.energy.current() as f64 >= 100.0 { - Color::Rgba(1.0, 1.0, 1.0, 1.0) - } else { - Color::Rgba(0.3, 0.3, 0.3, 0.8) - } - }, - _ => Color::Rgba(1.0, 1.0, 1.0, 1.0), - }) - .set(state.ids.m2_content, ui); // Slots let content_source = (self.hotbar, self.inventory, self.loadout, self.energy); // TODO: avoid this let image_source = (self.item_imgs, self.imgs); - let mut slot_maker = SlotMaker { // TODO: is a separate image needed for the frame? - empty_slot: self.imgs.skillbar_slot, - filled_slot: self.imgs.skillbar_slot, - selected_slot: self.imgs.skillbar_slot_act, + empty_slot: self.imgs.inv_slot, + filled_slot: self.imgs.inv_slot, + selected_slot: self.imgs.inv_slot_sel, background_color: None, content_size: ContentSize { width_height_ratio: 1.0, @@ -792,14 +523,6 @@ impl<'a> Widget for Skillbar<'a> { .map(|i| i.item.kind()) .and_then(|kind| match kind { ItemKind::Tool(Tool { kind, .. }) => match kind { - ToolKind::Hammer(_) => Some(( - "Smash of Doom", - "\nAn AOE attack with knockback. \nLeaps to position of \ - cursor.", - )), - ToolKind::Axe(_) => { - Some(("Spin Leap", "\nA slashing running spin leap.")) - }, ToolKind::Staff(_) => Some(( "Firebomb", "\nWhirls a big fireball into the air. \nExplodes the ground \ @@ -809,10 +532,6 @@ impl<'a> Widget for Skillbar<'a> { "Whirlwind", "\nMove forward while spinning with \n your sword.", )), - ToolKind::Bow(_) => Some(( - "Burst", - "\nLaunches a burst of arrows at the top \nof a running leap.", - )), ToolKind::Debug(kind) => match kind.as_ref() { "Boost" => Some(( "Possessing Arrow", @@ -827,71 +546,209 @@ impl<'a> Widget for Skillbar<'a> { }), }) }; - - //Slot 5 - let slot = slot_maker - .fabricate(hotbar::Slot::Five, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) - .bottom_left_with_margins_on(state.ids.m1_slot, 0.0, -20.0 * scale); - if let Some((title, desc)) = tooltip_text(hotbar::Slot::Five) { - slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) - .set(state.ids.slot5, ui); - } else { - slot.set(state.ids.slot5, ui); - } - // Slot 4 - let slot = slot_maker - .fabricate(hotbar::Slot::Four, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) - .left_from(state.ids.slot5, 0.0); - if let Some((title, desc)) = tooltip_text(hotbar::Slot::Four) { - slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) - .set(state.ids.slot4, ui); - } else { - slot.set(state.ids.slot4, ui); - } - // Slot 3 - let slot = slot_maker - .fabricate(hotbar::Slot::Three, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) - .left_from(state.ids.slot4, 0.0); - if let Some((title, desc)) = tooltip_text(hotbar::Slot::Three) { - slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) - .set(state.ids.slot3, ui); - } else { - slot.set(state.ids.slot3, ui); - } - // Slot 2 - let slot = slot_maker - .fabricate(hotbar::Slot::Two, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) - .left_from(state.ids.slot3, 0.0); - if let Some((title, desc)) = tooltip_text(hotbar::Slot::Two) { - slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) - .set(state.ids.slot2, ui); - } else { - slot.set(state.ids.slot2, ui); - } + // Slot 1-5 // Slot 1 - slot_maker.empty_slot = self.imgs.skillbar_slot_l; - slot_maker.selected_slot = self.imgs.skillbar_slot_l_act; + slot_maker.empty_slot = self.imgs.inv_slot; + slot_maker.selected_slot = self.imgs.inv_slot; let slot = slot_maker - .fabricate(hotbar::Slot::One, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot_l) - .left_from(state.ids.slot2, 0.0); + .fabricate(hotbar::Slot::One, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) + .bottom_left_with_margins_on(state.ids.frame, 15.0, 22.0); if let Some((title, desc)) = tooltip_text(hotbar::Slot::One) { slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) .set(state.ids.slot1, ui); } else { slot.set(state.ids.slot1, ui); } - // Slot 6 - slot_maker.empty_slot = self.imgs.skillbar_slot; - slot_maker.selected_slot = self.imgs.skillbar_slot_act; + // Slot 2 let slot = slot_maker - .fabricate(hotbar::Slot::Six, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) - .bottom_right_with_margins_on(state.ids.m2_slot, 0.0, -20.0 * scale); + .fabricate(hotbar::Slot::Two, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) + .right_from(state.ids.slot1, 0.0); + if let Some((title, desc)) = tooltip_text(hotbar::Slot::Two) { + slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) + .set(state.ids.slot2, ui); + } else { + slot.set(state.ids.slot2, ui); + } + // Slot 3 + let slot = slot_maker + .fabricate(hotbar::Slot::Three, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) + .right_from(state.ids.slot2, 0.0); + if let Some((title, desc)) = tooltip_text(hotbar::Slot::Three) { + slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) + .set(state.ids.slot3, ui); + } else { + slot.set(state.ids.slot3, ui); + } + // Slot 4 + let slot = slot_maker + .fabricate(hotbar::Slot::Four, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) + .right_from(state.ids.slot3, 0.0); + if let Some((title, desc)) = tooltip_text(hotbar::Slot::Three) { + slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) + .set(state.ids.slot4, ui); + } else { + slot.set(state.ids.slot4, ui); + } + // Slot 5 + let slot = slot_maker + .fabricate(hotbar::Slot::Five, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) + .right_from(state.ids.slot4, 0.0); + if let Some((title, desc)) = tooltip_text(hotbar::Slot::Three) { + slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) + .set(state.ids.slot5, ui); + } else { + slot.set(state.ids.slot5, ui); + } + // Slot M1 + Image::new(self.imgs.inv_slot) + .w_h(40.0, 40.0) + .color( + match self.loadout.active_item.as_ref().map(|i| i.item.kind()) { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { + ToolKind::Bow(_) => Some(BG_COLOR_2), + ToolKind::Staff(_) => Some(BG_COLOR_2), + _ => Some(BG_COLOR_2), + }, + _ => Some(BG_COLOR_2), + }, + ) + .right_from(state.ids.slot5, 0.0) + .set(state.ids.m1_slot_bg, ui); + Button::image( + match self.loadout.active_item.as_ref().map(|i| i.item.kind()) { + Some(ItemKind::Tool(Tool { kind, .. })) => match kind { + ToolKind::Sword(_) => self.imgs.twohsword_m1, + ToolKind::Dagger(_) => self.imgs.onehdagger_m1, + ToolKind::Shield(_) => self.imgs.onehshield_m1, + ToolKind::Hammer(_) => self.imgs.twohhammer_m1, + ToolKind::Axe(_) => self.imgs.twohaxe_m1, + ToolKind::Bow(_) => self.imgs.bow_m1, + ToolKind::Sceptre(_) => self.imgs.heal_0, + ToolKind::Staff(_) => self.imgs.fireball, + ToolKind::Debug(kind) => match kind.as_ref() { + "Boost" => self.imgs.flyingrod_m1, + _ => self.imgs.nothing, + }, + _ => self.imgs.nothing, + }, + _ => self.imgs.nothing, + }, + ) // Insert Icon here + .w_h(36.0, 36.0) + .middle_of(state.ids.m1_slot_bg) + .set(state.ids.m1_content, ui); + // Slot M2 + match self.character_state { + CharacterState::BasicMelee { .. } => { + let fade_pulse = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.6; //Animation timer; + if self.controller.secondary.is_pressed() { + Image::new(self.imgs.inv_slot) + .w_h(40.0, 40.0) + .right_from(state.ids.m1_slot_bg, 0.0) + .set(state.ids.m2_slot, ui); + Image::new(self.imgs.inv_slot) + .w_h(40.0, 40.0) + .middle_of(state.ids.m2_slot) + .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_pulse))) + .set(state.ids.m2_slot_act, ui); + } else { + Image::new(self.imgs.inv_slot) + .w_h(40.0, 40.0) + .right_from(state.ids.m1_slot_bg, 0.0) + .set(state.ids.m2_slot, ui); + } + }, + _ => { + Image::new(self.imgs.inv_slot) + .w_h(40.0, 40.0) + .right_from(state.ids.m1_slot_bg, 0.0) + .set(state.ids.m2_slot, ui); + }, + } + + let active_tool_kind = match self.loadout.active_item.as_ref().map(|i| i.item.kind()) { + Some(ItemKind::Tool(Tool { kind, .. })) => Some(kind), + _ => None, + }; + + let second_tool_kind = match self.loadout.second_item.as_ref().map(|i| i.item.kind()) { + Some(ItemKind::Tool(Tool { kind, .. })) => Some(kind), + _ => None, + }; + + let tool_kind = match ( + active_tool_kind.map(|tk| tk.hands()), + second_tool_kind.map(|tk| tk.hands()), + ) { + (Some(Hands::TwoHand), _) => active_tool_kind, + (_, Some(Hands::OneHand)) => second_tool_kind, + (_, _) => None, + }; + + Image::new(self.imgs.inv_slot) + .w_h(40.0, 40.0) + .color(match tool_kind { + Some(ToolKind::Bow(_)) => Some(BG_COLOR_2), + Some(ToolKind::Staff(_)) => Some(BG_COLOR_2), + _ => Some(BG_COLOR_2), + }) + .middle_of(state.ids.m2_slot) + .set(state.ids.m2_slot_bg, ui); + Button::image(match tool_kind { + Some(ToolKind::Sword(_)) => self.imgs.twohsword_m2, + Some(ToolKind::Dagger(_)) => self.imgs.onehdagger_m2, + Some(ToolKind::Shield(_)) => self.imgs.onehshield_m2, + Some(ToolKind::Hammer(_)) => self.imgs.hammergolf, + Some(ToolKind::Axe(_)) => self.imgs.axespin, + Some(ToolKind::Bow(_)) => self.imgs.bow_m2, + Some(ToolKind::Sceptre(_)) => self.imgs.heal_bomb, + Some(ToolKind::Staff(_)) => self.imgs.flamethrower, + Some(ToolKind::Debug(kind)) => match kind.as_ref() { + "Boost" => self.imgs.flyingrod_m2, + _ => self.imgs.nothing, + }, + _ => self.imgs.nothing, + }) + .w_h(36.0, 36.0) + .middle_of(state.ids.m2_slot_bg) + .image_color(match tool_kind { + Some(ToolKind::Sword(_)) => { + if self.energy.current() as f64 >= 200.0 { + Color::Rgba(1.0, 1.0, 1.0, 1.0) + } else { + Color::Rgba(0.3, 0.3, 0.3, 0.8) + } + }, + Some(ToolKind::Sceptre(_)) => { + if self.energy.current() as f64 >= 400.0 { + Color::Rgba(1.0, 1.0, 1.0, 1.0) + } else { + Color::Rgba(0.3, 0.3, 0.3, 0.8) + } + }, + Some(ToolKind::Axe(_)) => { + if self.energy.current() as f64 >= 100.0 { + Color::Rgba(1.0, 1.0, 1.0, 1.0) + } else { + Color::Rgba(0.3, 0.3, 0.3, 0.8) + } + }, + _ => Color::Rgba(1.0, 1.0, 1.0, 1.0), + }) + .set(state.ids.m2_content, ui); + // Slot 6-10 + // Slot 6 + slot_maker.empty_slot = self.imgs.inv_slot; + slot_maker.selected_slot = self.imgs.inv_slot; + let slot = slot_maker + .fabricate(hotbar::Slot::Six, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) + .right_from(state.ids.m2_slot_bg, 0.0); if let Some((title, desc)) = tooltip_text(hotbar::Slot::Six) { slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) .set(state.ids.slot6, ui); @@ -900,8 +757,8 @@ impl<'a> Widget for Skillbar<'a> { } // Slot 7 let slot = slot_maker - .fabricate(hotbar::Slot::Seven, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) + .fabricate(hotbar::Slot::Seven, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) .right_from(state.ids.slot6, 0.0); if let Some((title, desc)) = tooltip_text(hotbar::Slot::Seven) { slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) @@ -911,8 +768,8 @@ impl<'a> Widget for Skillbar<'a> { } // Slot 8 let slot = slot_maker - .fabricate(hotbar::Slot::Eight, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) + .fabricate(hotbar::Slot::Eight, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) .right_from(state.ids.slot7, 0.0); if let Some((title, desc)) = tooltip_text(hotbar::Slot::Eight) { slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) @@ -922,8 +779,8 @@ impl<'a> Widget for Skillbar<'a> { } // Slot 9 let slot = slot_maker - .fabricate(hotbar::Slot::Nine, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot) + .fabricate(hotbar::Slot::Nine, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) .right_from(state.ids.slot8, 0.0); if let Some((title, desc)) = tooltip_text(hotbar::Slot::Nine) { slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) @@ -932,11 +789,11 @@ impl<'a> Widget for Skillbar<'a> { slot.set(state.ids.slot9, ui); } // Quickslot - slot_maker.empty_slot = self.imgs.skillbar_slot_r; - slot_maker.selected_slot = self.imgs.skillbar_slot_r_act; + slot_maker.empty_slot = self.imgs.inv_slot; + slot_maker.selected_slot = self.imgs.inv_slot; let slot = slot_maker - .fabricate(hotbar::Slot::Ten, [20.0 * scale as f32; 2]) - .filled_slot(self.imgs.skillbar_slot_r) + .fabricate(hotbar::Slot::Ten, [40.0; 2]) + .filled_slot(self.imgs.inv_slot) .right_from(state.ids.slot9, 0.0); if let Some((title, desc)) = tooltip_text(hotbar::Slot::Ten) { slot.with_tooltip(self.tooltip_manager, title, desc, &item_tooltip, TEXT_COLOR) @@ -1176,114 +1033,27 @@ impl<'a> Widget for Skillbar<'a> { .set(state.ids.slot10_text, ui); } }; + // Frame + Image::new(self.imgs.skillbar_frame) + .w_h(524.0, 80.0) + .color(Some(UI_MAIN)) + .middle_of(state.ids.bg) + .floating(true) + .set(state.ids.frame, ui); + // M1 and M2 icons + Image::new(self.imgs.m1_ico) + .w_h(16.0, 18.0) + .mid_bottom_with_margin_on(state.ids.m1_content, tweak!(-9.0)) + .set(state.ids.m1_ico, ui); + Image::new(self.imgs.m2_ico) + .w_h(16.0, 18.0) + .mid_bottom_with_margin_on(state.ids.m2_content, tweak!(-9.0)) + .set(state.ids.m2_ico, ui); - // Lifebar - Image::new(self.imgs.healthbar_bg) - .w_h(100.0 * scale, 20.0 * scale) - .top_left_with_margins_on(state.ids.m1_slot, 0.0, -100.0 * scale) - .set(state.ids.healthbar_bg, ui); - let health_col = match hp_percentage as u8 { - 0..=20 => crit_hp_color, - 21..=40 => LOW_HP_COLOR, - _ => HP_COLOR, - }; - Image::new(self.imgs.bar_content) - .w_h(97.0 * scale * hp_percentage / 100.0, 16.0 * scale) - .color(Some(health_col)) - .top_right_with_margins_on(state.ids.healthbar_bg, 2.0 * scale, 1.0 * scale) - .set(state.ids.healthbar_filling, ui); - // Energybar - Image::new(self.imgs.energybar_bg) - .w_h(100.0 * scale, 20.0 * scale) - .top_right_with_margins_on(state.ids.m2_slot, 0.0, -100.0 * scale) - .set(state.ids.energybar_bg, ui); - Image::new(self.imgs.bar_content) - .w_h(97.0 * scale * energy_percentage / 100.0, 16.0 * scale) - .top_left_with_margins_on(state.ids.energybar_bg, 2.0 * scale, 1.0 * scale) - .color(Some(match self.current_resource { - ResourceType::Mana => MANA_COLOR, - /*ResourceType::Focus => FOCUS_COLOR, - *ResourceType::Rage => RAGE_COLOR, */ - })) - .set(state.ids.energybar_filling, ui); - // Bar Text - // Values - if let BarNumbers::Values = bar_values { - let mut hp_text = format!( - "{}/{}", - (self.stats.health.current() / 10).max(1) as u32, /* Don't show 0 health for - * living players */ - (self.stats.health.maximum() / 10) as u32 - ); - let mut energy_text = format!( - "{}/{}", - self.energy.current() as u32 / 10, /* TODO Fix regeneration with smaller energy - * numbers instead of dividing by 10 here */ - self.energy.maximum() as u32 / 10 - ); - if self.stats.is_dead { - hp_text = self.localized_strings.get("hud.group.dead").to_string(); - energy_text = self.localized_strings.get("hud.group.dead").to_string(); - }; - Text::new(&hp_text) - .mid_top_with_margin_on(state.ids.healthbar_bg, 6.0 * scale) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) - .set(state.ids.health_text_bg, ui); - Text::new(&hp_text) - .bottom_left_with_margins_on(state.ids.health_text_bg, 2.0, 2.0) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(TEXT_COLOR) - .set(state.ids.health_text, ui); - Text::new(&energy_text) - .mid_top_with_margin_on(state.ids.energybar_bg, 6.0 * scale) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) - .set(state.ids.energy_text_bg, ui); - Text::new(&energy_text) - .bottom_left_with_margins_on(state.ids.energy_text_bg, 2.0, 2.0) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(TEXT_COLOR) - .set(state.ids.energy_text, ui); - } - //Percentages - if let BarNumbers::Percent = bar_values { - let hp_text = format!("{}%", hp_percentage as u32); - Text::new(&hp_text) - .mid_top_with_margin_on(state.ids.healthbar_bg, 6.0 * scale) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) - .set(state.ids.health_text_bg, ui); - Text::new(&hp_text) - .bottom_left_with_margins_on(state.ids.health_text_bg, 2.0, 2.0) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(TEXT_COLOR) - .set(state.ids.health_text, ui); - let energy_text = format!("{}%", energy_percentage as u32); - Text::new(&energy_text) - .mid_top_with_margin_on(state.ids.energybar_bg, 6.0 * scale) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(Color::Rgba(0.0, 0.0, 0.0, 1.0)) - .set(state.ids.energy_text_bg, ui); - Text::new(&energy_text) - .bottom_left_with_margins_on(state.ids.energy_text_bg, 2.0, 2.0) - .font_size(self.fonts.cyri.scale(14)) - .font_id(self.fonts.cyri.conrod_id) - .color(TEXT_COLOR) - .set(state.ids.energy_text, ui); - } + // Buffs + // Add debuff slots above the health bar + // Add buff slots above the mana bar + + // Debuffs } - - // Buffs - // Add debuff slots above the health bar - // Add buff slots above the mana bar - - // Debuffs }