mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Salvage works by double clicking from inventory while salvage tab in crafting is open.
This commit is contained in:
parent
111abbc3bc
commit
7a17863988
@ -27,7 +27,7 @@ use common::{
|
||||
group,
|
||||
invite::{InviteKind, InviteResponse},
|
||||
skills::Skill,
|
||||
slot::Slot,
|
||||
slot::{InvSlotId, Slot},
|
||||
CharacterState, ChatMode, ControlAction, ControlEvent, Controller, ControllerInputs,
|
||||
GroupManip, InputKind, InventoryAction, InventoryEvent, InventoryUpdateEvent,
|
||||
UtteranceKind,
|
||||
@ -1015,6 +1015,26 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_salvage_item(&self, slot: InvSlotId) -> bool {
|
||||
self.inventories()
|
||||
.get(self.entity())
|
||||
.and_then(|inv| inv.get(slot))
|
||||
.map_or(false, |item| item.is_salvageable())
|
||||
}
|
||||
|
||||
pub fn salvage_item(&mut self, slot: InvSlotId) -> bool {
|
||||
let is_salvageable = self.can_salvage_item(slot);
|
||||
if is_salvageable {
|
||||
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::InventoryEvent(
|
||||
InventoryEvent::CraftRecipe {
|
||||
craft_event: CraftEvent::Salvage(slot),
|
||||
craft_sprite: None,
|
||||
},
|
||||
)));
|
||||
}
|
||||
is_salvageable
|
||||
}
|
||||
|
||||
fn update_available_recipes(&mut self) {
|
||||
self.available_recipes = self
|
||||
.recipe_book
|
||||
|
@ -75,7 +75,7 @@ use common::{
|
||||
combat,
|
||||
comp::{
|
||||
self, fluid_dynamics,
|
||||
inventory::trade_pricing::TradePricing,
|
||||
inventory::{slot::InvSlotId, trade_pricing::TradePricing},
|
||||
item::{tool::ToolKind, ItemDesc, MaterialStatManifest, Quality},
|
||||
skills::{Skill, SkillGroupKind},
|
||||
BuffData, BuffKind, Item,
|
||||
@ -521,6 +521,7 @@ pub enum Event {
|
||||
recipe: String,
|
||||
craft_sprite: Option<(Vec3<i32>, SpriteKind)>,
|
||||
},
|
||||
SalvageItem(InvSlotId),
|
||||
InviteMember(Uid),
|
||||
AcceptInvite,
|
||||
DeclineInvite,
|
||||
@ -3329,10 +3330,18 @@ impl Hud {
|
||||
slot::Event::Used(from) => {
|
||||
// Item used (selected and then clicked again)
|
||||
if let Some(from) = to_slot(from) {
|
||||
events.push(Event::UseSlot {
|
||||
slot: from,
|
||||
bypass_dialog: false,
|
||||
});
|
||||
if self.show.crafting
|
||||
&& matches!(self.show.crafting_tab, CraftingTab::Dismantle)
|
||||
{
|
||||
if let Slot::Inventory(slot) = from {
|
||||
events.push(Event::SalvageItem(slot))
|
||||
}
|
||||
} else {
|
||||
events.push(Event::UseSlot {
|
||||
slot: from,
|
||||
bypass_dialog: false,
|
||||
});
|
||||
}
|
||||
} else if let Hotbar(h) = from {
|
||||
// Used from hotbar
|
||||
self.hotbar.get(h).map(|s| {
|
||||
|
@ -1397,6 +1397,9 @@ impl PlayState for SessionState {
|
||||
} => {
|
||||
self.client.borrow_mut().craft_recipe(&recipe, craft_sprite);
|
||||
},
|
||||
HudEvent::SalvageItem(slot) => {
|
||||
self.client.borrow_mut().salvage_item(slot);
|
||||
},
|
||||
HudEvent::InviteMember(uid) => {
|
||||
self.client.borrow_mut().send_invite(uid, InviteKind::Group);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user