Exemplo n.º 1
0
void Inventory::handleMapDrag() {
	if (m_mapInterface == nullptr) return;
	InventorySlot* selectedSlot = getSelectedSlot();
	if (selectedSlot != nullptr && !m_isEquipmentSlotDragged) {
		m_equipment->highlightEquipmentSlot(selectedSlot->getItemType(), true);
	}
}
Exemplo n.º 2
0
void Inventory::handleLevelDrag() {
	if (m_levelInterface == nullptr) return;
	InventorySlot* selectedSlot = getSelectedSlot();
	if (selectedSlot != nullptr && selectedSlot->getItemType() == ItemType::Consumable) {
		m_levelInterface->highlightQuickslots(true);
	}
}
Exemplo n.º 3
0
void Inventory::handleLevelDrop() {
	if (m_levelInterface == nullptr || m_currentClone == nullptr) return;
	InventorySlot* selectedSlot = getSelectedSlot();
	if (selectedSlot != nullptr && selectedSlot->getItemType() == ItemType::Consumable) {
		m_levelInterface->notifyConsumableDrop(m_currentClone);
		m_levelInterface->highlightQuickslots(false);
	}
}
Exemplo n.º 4
0
void Inventory::update(const sf::Time& frameTime) {
	if (!m_isVisible) return;

	// check whether an item was selected
	for (auto& it : *(m_typeMap.at(m_currentTab))) {
		it.second.update(frameTime);
		if (it.second.isClicked()) {
			selectSlot(it.second.getItemID(), ItemType::VOID);
			return;
		}
		if (it.second.isRightClicked()) {
			handleLevelRightClick(&it.second);
			handleMapRightClick(&it.second);
			break;
		}
	}

	for (auto& it : m_tabs) {
		it.first.update(frameTime);
		if (it.first.isClicked() && m_currentTab != it.second) {
			selectTab(it.second);
			return;
		}
	}

	// update equipment part
	m_equipment->update(frameTime);
	InventorySlot* eqSlot = m_equipment->getSelectedSlot();
	if (eqSlot != nullptr) {
		selectSlot(eqSlot->getItemID(), eqSlot->getItemType());
	}

	handleDragAndDrop();

	if (m_equipment->requiresReload()) {
		reload();
	}
}