From 70d6f3a8546cddf68ad9c512a2caf1bbc142d5bf Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 3 Dec 2021 19:17:11 -0500 Subject: [PATCH] Scroll through all aiblities in the same pages. --- .../common/abilities/ability_set_manifest.ron | 42 ---------- voxygen/src/hud/diary.rs | 84 ++++++++----------- 2 files changed, 36 insertions(+), 90 deletions(-) diff --git a/assets/common/abilities/ability_set_manifest.ron b/assets/common/abilities/ability_set_manifest.ron index 13efd323bd..25c96cd1bd 100644 --- a/assets/common/abilities/ability_set_manifest.ron +++ b/assets/common/abilities/ability_set_manifest.ron @@ -9,30 +9,9 @@ // TODO: Remove these (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), - (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), - (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), - (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), - (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), - (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), - (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), - (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), - (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), - (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), - (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), - (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), - (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), - (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), - (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), - (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), - (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), - (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), - (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), - (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), - (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), - (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), (Some(Sword(UnlockSpin)), "common.abilities.sword.spin"), (Some(Axe(UnlockLeap)), "common.abilities.axe.leap"), (Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"), @@ -47,30 +26,9 @@ (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), - (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), - (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), - (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), - (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), - (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), - (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), - (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), - (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), - (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), - (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), - (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), - (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), - (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), - (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), - (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), - (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), - (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), - (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), - (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), - (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), - (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), (Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"), (Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"), (Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"), diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index 3d548537b9..b0b46afe2e 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -350,16 +350,10 @@ pub enum DiarySection { Stats, } -enum AbilitySource { - MainWeapon, - OffWeapon, -} - pub struct DiaryState { ids: Ids, dragged_ability: Option, id_ability_map: HashMap, - ability_source: AbilitySource, ability_page: usize, } @@ -374,7 +368,6 @@ impl<'a> Widget for Diary<'a> { dragged_ability: None, // Constructed during update sequence id_ability_map: HashMap::new(), - ability_source: AbilitySource::MainWeapon, ability_page: 0, } } @@ -915,54 +908,49 @@ impl<'a> Widget for Diary<'a> { } } - // Switch between mainhand and offhand weapon abilities - if Button::image(self.imgs.spellbook_ico) - .bottom_left_with_margins_on(state.ids.content_align, tweak!(5.0), tweak!(5.0)) - .w_h(40.0, 40.0) - .set(state.ids.main_weap_select, ui) - .was_clicked() - { - state.update(|s| { - s.ability_source = AbilitySource::MainWeapon; - s.ability_page = 0; - }) - } - if Button::image(self.imgs.spellbook_ico) - .mid_right_with_margin_on(state.ids.main_weap_select, tweak!(-45.0)) - .w_h(40.0, 40.0) - .set(state.ids.off_weap_select, ui) - .was_clicked() - { - state.update(|s| { - s.ability_source = AbilitySource::OffWeapon; - s.ability_page = 0; - }) - } + let same_weap_kinds = self + .inventory + .equipped(EquipSlot::ActiveMainhand) + .zip(self.inventory.equipped(EquipSlot::ActiveOffhand)) + .map_or(false, |(a, b)| { + if let (ItemKind::Tool(tool_a), ItemKind::Tool(tool_b)) = (&a.kind, &b.kind) + { + (a.ability_spec(), tool_a.kind) == (b.ability_spec(), tool_b.kind) + } else { + false + } + }); // TODO: Maybe try to keep this as an iterator. Not sure how to get length // though since size_hint didn't work - let abilities: Vec<_> = match state.ability_source { - AbilitySource::MainWeapon => ActiveAbilities::iter_unlocked_abilities( - Some(self.inventory), - Some(self.skill_set), - EquipSlot::ActiveMainhand, - ) - .map(AuxiliaryAbility::MainWeapon) - .map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a)) - .collect(), - AbilitySource::OffWeapon => ActiveAbilities::iter_unlocked_abilities( - Some(self.inventory), - Some(self.skill_set), - EquipSlot::ActiveOffhand, - ) - .map(AuxiliaryAbility::OffWeapon) - .map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a)) - .collect(), + let main_weap_abilities = ActiveAbilities::iter_unlocked_abilities( + Some(self.inventory), + Some(self.skill_set), + EquipSlot::ActiveMainhand, + ) + .map(AuxiliaryAbility::MainWeapon) + .map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a)); + let off_weap_abilities = ActiveAbilities::iter_unlocked_abilities( + Some(self.inventory), + Some(self.skill_set), + EquipSlot::ActiveOffhand, + ) + .map(AuxiliaryAbility::OffWeapon) + .map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a)); + + let abilities: Vec<_> = if same_weap_kinds { + // When the weapons have the same ability kind, interweave the abilities + main_weap_abilities + .zip(off_weap_abilities) + .flat_map(|(a, b)| [a, b]) + .collect() + } else { + main_weap_abilities.chain(off_weap_abilities).collect() }; const ABILITIES_PER_PAGE: usize = 12; - let page_indices = abilities.len() / ABILITIES_PER_PAGE; + let page_indices = (abilities.len() - 1) / ABILITIES_PER_PAGE; if state.ability_page > page_indices { state.update(|s| s.ability_page = 0);