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,
|
group,
|
||||||
invite::{InviteKind, InviteResponse},
|
invite::{InviteKind, InviteResponse},
|
||||||
skills::Skill,
|
skills::Skill,
|
||||||
slot::Slot,
|
slot::{InvSlotId, Slot},
|
||||||
CharacterState, ChatMode, ControlAction, ControlEvent, Controller, ControllerInputs,
|
CharacterState, ChatMode, ControlAction, ControlEvent, Controller, ControllerInputs,
|
||||||
GroupManip, InputKind, InventoryAction, InventoryEvent, InventoryUpdateEvent,
|
GroupManip, InputKind, InventoryAction, InventoryEvent, InventoryUpdateEvent,
|
||||||
UtteranceKind,
|
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) {
|
fn update_available_recipes(&mut self) {
|
||||||
self.available_recipes = self
|
self.available_recipes = self
|
||||||
.recipe_book
|
.recipe_book
|
||||||
|
@ -75,7 +75,7 @@ use common::{
|
|||||||
combat,
|
combat,
|
||||||
comp::{
|
comp::{
|
||||||
self, fluid_dynamics,
|
self, fluid_dynamics,
|
||||||
inventory::trade_pricing::TradePricing,
|
inventory::{slot::InvSlotId, trade_pricing::TradePricing},
|
||||||
item::{tool::ToolKind, ItemDesc, MaterialStatManifest, Quality},
|
item::{tool::ToolKind, ItemDesc, MaterialStatManifest, Quality},
|
||||||
skills::{Skill, SkillGroupKind},
|
skills::{Skill, SkillGroupKind},
|
||||||
BuffData, BuffKind, Item,
|
BuffData, BuffKind, Item,
|
||||||
@ -521,6 +521,7 @@ pub enum Event {
|
|||||||
recipe: String,
|
recipe: String,
|
||||||
craft_sprite: Option<(Vec3<i32>, SpriteKind)>,
|
craft_sprite: Option<(Vec3<i32>, SpriteKind)>,
|
||||||
},
|
},
|
||||||
|
SalvageItem(InvSlotId),
|
||||||
InviteMember(Uid),
|
InviteMember(Uid),
|
||||||
AcceptInvite,
|
AcceptInvite,
|
||||||
DeclineInvite,
|
DeclineInvite,
|
||||||
@ -3329,10 +3330,18 @@ impl Hud {
|
|||||||
slot::Event::Used(from) => {
|
slot::Event::Used(from) => {
|
||||||
// Item used (selected and then clicked again)
|
// Item used (selected and then clicked again)
|
||||||
if let Some(from) = to_slot(from) {
|
if let Some(from) = to_slot(from) {
|
||||||
events.push(Event::UseSlot {
|
if self.show.crafting
|
||||||
slot: from,
|
&& matches!(self.show.crafting_tab, CraftingTab::Dismantle)
|
||||||
bypass_dialog: false,
|
{
|
||||||
});
|
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 {
|
} else if let Hotbar(h) = from {
|
||||||
// Used from hotbar
|
// Used from hotbar
|
||||||
self.hotbar.get(h).map(|s| {
|
self.hotbar.get(h).map(|s| {
|
||||||
|
@ -1397,6 +1397,9 @@ impl PlayState for SessionState {
|
|||||||
} => {
|
} => {
|
||||||
self.client.borrow_mut().craft_recipe(&recipe, craft_sprite);
|
self.client.borrow_mut().craft_recipe(&recipe, craft_sprite);
|
||||||
},
|
},
|
||||||
|
HudEvent::SalvageItem(slot) => {
|
||||||
|
self.client.borrow_mut().salvage_item(slot);
|
||||||
|
},
|
||||||
HudEvent::InviteMember(uid) => {
|
HudEvent::InviteMember(uid) => {
|
||||||
self.client.borrow_mut().send_invite(uid, InviteKind::Group);
|
self.client.borrow_mut().send_invite(uid, InviteKind::Group);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user