Fix selecting and remove amount text when dragging

This commit is contained in:
Imbris 2020-04-09 22:59:28 -04:00 committed by Pfauenauge90
parent c1c09dce1b
commit f52d66d721
2 changed files with 9 additions and 6 deletions

View File

@ -246,5 +246,5 @@ pub fn unequip(slot: EquipSlot, inventory: &mut Inventory, loadout: &mut Loadout
loadout_remove(slot, loadout) // Remove item from loadout
.and_then(|i| inventory.push(i)) // Insert into inventory
.and_then(|i| loadout_insert(slot, i, loadout)) // If that fails put back in loadout
.unwrap(); // Never fails
.unwrap_none(); // Never fails
}

View File

@ -255,11 +255,10 @@ where
};
}
// If not dragging and the mouse is down and started on this slot start dragging
let input = &ui.global_input().current;
if let mouse::ButtonPosition::Down(_, Some(id)) = input.mouse.buttons.left() {
// If not dragging and there is a drag event on this slot start dragging
if ui.widget_input(widget).drags().left().next().is_some() {
match self.state {
ManagerState::Selected(_, _) | ManagerState::Idle if widget == *id => {
ManagerState::Selected(_, _) | ManagerState::Idle => {
// Start dragging if widget is filled
if let Some(img) = content_img {
self.state = ManagerState::Dragging(widget, slot, img);
@ -459,7 +458,11 @@ where
};
// Get amount (None => no amount text)
let amount = slot_key.amount(content_source);
let amount = if let Interaction::Dragging = interaction {
None // Don't show amount if being dragged
} else {
slot_key.amount(content_source)
};
// Get slot widget dimensions and position
let (x, y, w, h) = rect.x_y_w_h();