diff --git a/assets/voxygen/element/icons/staff_m2.vox b/assets/voxygen/element/icons/staff_m2.vox index 2ad23b82a8..74fb309158 100644 --- a/assets/voxygen/element/icons/staff_m2.vox +++ b/assets/voxygen/element/icons/staff_m2.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7b01ee5e7ae025ed6f82c40cd81d37472624c7d67164a8c42f76b4295e963c85 +oid sha256:b1dd296878391652f6c5151cee6eba5bf003e07360ecbe08f342f7ac631d103d size 60360 diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index e79965efd7..2b5eb02237 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -544,7 +544,7 @@ impl Hud { let own_level = stats .get(client.entity()) .map_or(0, |stats| stats.level.level()); - + //self.input = client.read_storage::(); if let Some(stats) = stats.get(me) { // Hurt Frame let hp_percentage = @@ -1653,10 +1653,12 @@ impl Hud { let energy = ecs.read_storage::(); let character_state = ecs.read_storage::(); let entity = client.entity(); - if let (Some(stats), Some(energy), Some(character_state)) = ( + let controller = ecs.read_storage::(); + if let (Some(stats), Some(energy), Some(character_state), Some(controller)) = ( stats.get(entity), energy.get(entity), character_state.get(entity), + controller.get(entity).map(|c| &c.inputs), ) { Skillbar::new( global_state, @@ -1666,6 +1668,7 @@ impl Hud { &energy, &character_state, self.pulse, + &controller, ) .set(self.ids.skillbar, ui_widgets); } diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 76cf9a7dba..c11c13d236 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -3,7 +3,9 @@ use super::{ /*FOCUS_COLOR, RAGE_COLOR,*/ HP_COLOR, LOW_HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR, }; use crate::GlobalState; -use common::comp::{item::Debug, item::Tool, ActionState, CharacterState, Energy, ItemKind, Stats}; +use common::comp::{ + item::Debug, item::Tool, ActionState, CharacterState, ControllerInputs, Energy, ItemKind, Stats, +}; use conrod_core::{ color, widget::{self, Button, Image, Rectangle, Text}, @@ -103,6 +105,7 @@ pub struct Skillbar<'a> { stats: &'a Stats, energy: &'a Energy, character_state: &'a CharacterState, + controller: &'a ControllerInputs, pulse: f32, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -118,6 +121,7 @@ impl<'a> Skillbar<'a> { energy: &'a Energy, character_state: &'a CharacterState, pulse: f32, + controller: &'a ControllerInputs, ) -> Self { Self { imgs, @@ -129,6 +133,7 @@ impl<'a> Skillbar<'a> { common: widget::CommonBuilder::default(), character_state, pulse, + controller, } } } @@ -526,17 +531,32 @@ impl<'a> Widget for Skillbar<'a> { match self.character_state.action { ActionState::Attack { .. } => { - 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); + 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) @@ -548,7 +568,6 @@ impl<'a> Widget for Skillbar<'a> { } } // M1 Slot - Image::new(self.imgs.skillbar_slot_big_bg) .w_h(38.0 * scale, 38.0 * scale) .color(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { @@ -576,7 +595,7 @@ impl<'a> Widget for Skillbar<'a> { .w(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { Some(ItemKind::Tool { kind, .. }) => match kind { Tool::Bow => 30.0 * scale, - Tool::Staff => 30.0 * scale, + Tool::Staff => 32.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, @@ -584,7 +603,7 @@ impl<'a> Widget for Skillbar<'a> { .h(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { Some(ItemKind::Tool { kind, .. }) => match kind { Tool::Bow => 30.0 * scale, - Tool::Staff => 36.0 * scale, + Tool::Staff => 32.0 * scale, _ => 38.0 * scale, }, _ => 38.0 * scale, @@ -595,16 +614,43 @@ impl<'a> Widget for Skillbar<'a> { match self.character_state.action { ActionState::Block { .. } => { 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) - .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); + 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); + } + } + ActionState::Attack { .. } => { + 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)