Beispiel #1
0
void Spellbook::update(const sf::Time& frameTime) {
	if (!m_isVisible) return;

	m_tabBar->update(frameTime);
	int activeIndex = m_tabBar->getActiveTabIndex();
	SpellType type;
	if (activeIndex == 0) {
		type = SpellType::VOID;
	}
	else if (activeIndex == 1) {
		type = SpellType::Elemental;
	}
	else if (activeIndex == 2) {
		type = SpellType::Divine;
	}
	else if (activeIndex == 3) {
		type = SpellType::Necromancy;
	}
	else if (activeIndex == 4) {
		type = SpellType::Twilight;
	}

	if (m_tabBar->getTabButton(activeIndex)->isClicked() && m_currentTab != type) {
		selectTab(type);
	}

	// update weapon part
	m_weaponWindow->update(frameTime);

	if (m_currentTab == SpellType::VOID) {
		// handle gems
		for (auto& it : m_modifierSlots) {
			it.update(frameTime);
			if (it.isClicked()) {
				selectModifierSlot(&it);
				return;
			}
		}
	}
	else {
		// handle spells
		for (auto& it : *(m_typeMap[m_currentTab])) {
			it.first.update(frameTime);
			if (it.first.isClicked()) {
				selectSpellSlot(&it.first);
				return;
			}
		}
	}

	if (!m_isModifiable) return;

	handleDragAndDrop();
}
Beispiel #2
0
void Spellbook::update(const sf::Time& frameTime)
{
	if (!m_isVisible) return;

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

	// update weapon part
	m_weaponWindow->update(frameTime);

	if (!m_isClickable) return;

	if (m_currentTab == SpellType::VOID)
	{
		// handle gems
		for (auto& it : m_modifierSlots)
		{
			it.update(frameTime);
			if (it.isClicked())
			{
				selectModifierSlot(&it);
				return;
			}
		}
	}
	else
	{
		// handle spells
		for (auto& it : *(m_typeMap[m_currentTab]))
		{
			it.first.update(frameTime);
			if (it.first.isClicked())
			{
				selectSpellSlot(&it.first);
				return;
			}
		}
	}

	handleDragAndDrop();
}
Beispiel #3
0
void WeaponWindow::update(const sf::Time& frameTime)
{
	if (!m_isVisible) return;

	if (m_requireReload) reload();

	if (!m_isClickable) return;

	for (auto& it : m_weaponSlots)
	{
		it.first.update(frameTime);
		if (it.first.isClicked())
		{
			selectSpellSlot(&it.first);
			return;
		}
		else if (it.first.isRightClicked())
		{
			m_core->removeSpell(it.first.getNr());
			m_requireReload = true;
			return;
		}
		for (auto& it2 : it.second)
		{
			it2.update(frameTime);
			if (it2.isClicked())
			{
				selectModifierSlot(&it2);
				return;
			}
			else if (it2.isRightClicked())
			{
				m_core->removeModifier(it2.getModifier().type, it2.getNr());
				m_requireReload = true;
				return;
			}
		}
	}

	handleDragAndDrop();
}