mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Scroll through all aiblities in the same pages.
This commit is contained in:
parent
3870688717
commit
70d6f3a854
@ -9,30 +9,9 @@
|
|||||||
// TODO: Remove these
|
// TODO: Remove these
|
||||||
(Some(Axe(UnlockLeap)), "common.abilities.axe.leap"),
|
(Some(Axe(UnlockLeap)), "common.abilities.axe.leap"),
|
||||||
(Some(Hammer(UnlockLeap)), "common.abilities.hammer.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(Hammer(UnlockLeap)), "common.abilities.hammer.leap"),
|
||||||
(Some(Sword(UnlockSpin)), "common.abilities.sword.spin"),
|
|
||||||
(Some(Axe(UnlockLeap)), "common.abilities.axe.leap"),
|
(Some(Axe(UnlockLeap)), "common.abilities.axe.leap"),
|
||||||
(Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"),
|
|
||||||
(Some(Sword(UnlockSpin)), "common.abilities.sword.spin"),
|
(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(Sword(UnlockSpin)), "common.abilities.sword.spin"),
|
||||||
(Some(Axe(UnlockLeap)), "common.abilities.axe.leap"),
|
(Some(Axe(UnlockLeap)), "common.abilities.axe.leap"),
|
||||||
(Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"),
|
(Some(Hammer(UnlockLeap)), "common.abilities.hammer.leap"),
|
||||||
@ -47,30 +26,9 @@
|
|||||||
(Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"),
|
(Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"),
|
||||||
(Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"),
|
(Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"),
|
||||||
(Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"),
|
(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(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"),
|
||||||
(Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"),
|
|
||||||
(Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"),
|
(Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"),
|
||||||
(Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"),
|
|
||||||
(Some(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"),
|
(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(Bow(UnlockShotgun)), "common.abilities.bow.shotgun"),
|
||||||
(Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"),
|
(Some(Staff(UnlockShockwave)), "common.abilities.staff.fireshockwave"),
|
||||||
(Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"),
|
(Some(Sceptre(UnlockAura)), "common.abilities.sceptre.wardingaura"),
|
||||||
|
@ -350,16 +350,10 @@ pub enum DiarySection {
|
|||||||
Stats,
|
Stats,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AbilitySource {
|
|
||||||
MainWeapon,
|
|
||||||
OffWeapon,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct DiaryState {
|
pub struct DiaryState {
|
||||||
ids: Ids,
|
ids: Ids,
|
||||||
dragged_ability: Option<AuxiliaryAbility>,
|
dragged_ability: Option<AuxiliaryAbility>,
|
||||||
id_ability_map: HashMap<widget::Id, AuxiliaryAbility>,
|
id_ability_map: HashMap<widget::Id, AuxiliaryAbility>,
|
||||||
ability_source: AbilitySource,
|
|
||||||
ability_page: usize,
|
ability_page: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +368,6 @@ impl<'a> Widget for Diary<'a> {
|
|||||||
dragged_ability: None,
|
dragged_ability: None,
|
||||||
// Constructed during update sequence
|
// Constructed during update sequence
|
||||||
id_ability_map: HashMap::new(),
|
id_ability_map: HashMap::new(),
|
||||||
ability_source: AbilitySource::MainWeapon,
|
|
||||||
ability_page: 0,
|
ability_page: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -915,54 +908,49 @@ impl<'a> Widget for Diary<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch between mainhand and offhand weapon abilities
|
let same_weap_kinds = self
|
||||||
if Button::image(self.imgs.spellbook_ico)
|
.inventory
|
||||||
.bottom_left_with_margins_on(state.ids.content_align, tweak!(5.0), tweak!(5.0))
|
.equipped(EquipSlot::ActiveMainhand)
|
||||||
.w_h(40.0, 40.0)
|
.zip(self.inventory.equipped(EquipSlot::ActiveOffhand))
|
||||||
.set(state.ids.main_weap_select, ui)
|
.map_or(false, |(a, b)| {
|
||||||
.was_clicked()
|
if let (ItemKind::Tool(tool_a), ItemKind::Tool(tool_b)) = (&a.kind, &b.kind)
|
||||||
{
|
{
|
||||||
state.update(|s| {
|
(a.ability_spec(), tool_a.kind) == (b.ability_spec(), tool_b.kind)
|
||||||
s.ability_source = AbilitySource::MainWeapon;
|
} else {
|
||||||
s.ability_page = 0;
|
false
|
||||||
})
|
}
|
||||||
}
|
});
|
||||||
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;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Maybe try to keep this as an iterator. Not sure how to get length
|
// TODO: Maybe try to keep this as an iterator. Not sure how to get length
|
||||||
// though since size_hint didn't work
|
// though since size_hint didn't work
|
||||||
let abilities: Vec<_> = match state.ability_source {
|
let main_weap_abilities = ActiveAbilities::iter_unlocked_abilities(
|
||||||
AbilitySource::MainWeapon => ActiveAbilities::iter_unlocked_abilities(
|
Some(self.inventory),
|
||||||
Some(self.inventory),
|
Some(self.skill_set),
|
||||||
Some(self.skill_set),
|
EquipSlot::ActiveMainhand,
|
||||||
EquipSlot::ActiveMainhand,
|
)
|
||||||
)
|
.map(AuxiliaryAbility::MainWeapon)
|
||||||
.map(AuxiliaryAbility::MainWeapon)
|
.map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a));
|
||||||
.map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a))
|
let off_weap_abilities = ActiveAbilities::iter_unlocked_abilities(
|
||||||
.collect(),
|
Some(self.inventory),
|
||||||
AbilitySource::OffWeapon => ActiveAbilities::iter_unlocked_abilities(
|
Some(self.skill_set),
|
||||||
Some(self.inventory),
|
EquipSlot::ActiveOffhand,
|
||||||
Some(self.skill_set),
|
)
|
||||||
EquipSlot::ActiveOffhand,
|
.map(AuxiliaryAbility::OffWeapon)
|
||||||
)
|
.map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a));
|
||||||
.map(AuxiliaryAbility::OffWeapon)
|
|
||||||
.map(|a| (Ability::from(a).ability_id(Some(self.inventory)), a))
|
let abilities: Vec<_> = if same_weap_kinds {
|
||||||
.collect(),
|
// 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;
|
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 {
|
if state.ability_page > page_indices {
|
||||||
state.update(|s| s.ability_page = 0);
|
state.update(|s| s.ability_page = 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user