void UIItemInventory::dropicon(Point<int16_t> cursorpos, Type type, int16_t identifier) { int16_t slot = slotbypos(cursorpos - position); if (slot > 0) { switch (type) { case ITEMINVENTORY: if (slot != identifier) { using Net::MoveItemPacket; Session::get().dispatch(MoveItemPacket(tab, identifier, slot, 1)); } break; case EQUIPINVENTORY: if (tab == Inventory::EQUIP) { Optional<Item> item = inventory.getitem(Inventory::EQUIP, slot); if (item) { int32_t itemid = item.map(&Item::getid); Equipslot::Value eqslot = inventory.findequipslot(itemid); if (identifier == eqslot) { using Net::EquipItemPacket; Session::get().dispatch(EquipItemPacket(identifier, eqslot)); } } else { using Net::UnequipItemPacket; Session::get().dispatch(UnequipItemPacket(identifier, slot)); } } break; } } }
void UIItemInventory::doubleclick(Point<int16_t> cursorpos) { int16_t slot = slotbypos(cursorpos - position); if (icons.count(slot) && isvisible(slot)) { Optional<Item> item = inventory.getitem(tab, slot); if (item) { int32_t itemid = item.map(&Item::getid); switch (tab) { case Inventory::EQUIP: using Net::EquipItemPacket; Session::get().dispatch(EquipItemPacket(slot, inventory.findequipslot(itemid))); break; case Inventory::USE: using Net::UseItemPacket; Session::get().dispatch(UseItemPacket(slot, itemid)); break; } } } }