Beispiel #1
0
/**
 * Show mouseover descriptions of disciplines and powers
 */
TooltipData MenuPowers::checkTooltip(const Point& mouse) {

	TooltipData tip;

	for (size_t i=0; i<power_cell.size(); i++) {

		if (tab_control && (tab_control->getActiveTab() != power_cell[i].tab)) continue;

		int cell_index = getCellByPowerIndex(power_cell[i].id, power_cell_all);
		if (!checkCellVisible(cell_index)) continue;

		if (slots[i] && isWithinRect(slots[i]->pos, mouse)) {
			bool base_unlocked = checkUnlocked(cell_index) || std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end();

			createTooltip(&tip, static_cast<int>(i), power_cell, !base_unlocked);
			if (!power_cell[i].upgrades.empty()) {
				int next_level = getNextLevelCell(static_cast<int>(i));
				if (next_level != -1) {
					tip.addText("\n" + msg->get("Next Level:"));
					createTooltip(&tip, next_level, power_cell_upgrade, base_unlocked);
				}
			}

			return tip;
		}
	}

	return tip;
}
Beispiel #2
0
/**
 * Check if we can unlock power.
 */
bool MenuPowers::checkUnlock(int pci) {
	// If we didn't find power in power_menu, than it has no requirements
	if (pci == -1) return true;

	if (!checkCellVisible(pci)) return false;

	// If we already have a power, don't try to unlock it
	if (checkUnlocked(pci)) return false;

	// Check base requirements
	if (checkRequirements(pci)) return true;
	return false;
}
Beispiel #3
0
bool MenuPowers::checkUnlocked(int pci) {
	// If we didn't find power in power_menu, than it has no requirements
	if (pci == -1) return true;

	if (!checkCellVisible(pci)) return false;

	// If power_id is saved into vector, it's unlocked anyway
	// check power_cell_unlocked and stats->powers_list
	for (size_t i=0; i<power_cell_unlocked.size(); ++i) {
		if (power_cell_unlocked[i].id == power_cell_all[pci].id)
			return true;
	}
	if (std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell_all[pci].id) != stats->powers_list.end()) return true;

	// Check the rest requirements
	if (checkRequirements(pci) && !power_cell_all[pci].requires_point) return true;
	return false;
}
Beispiel #4
0
void MenuPowers::renderPowers(int tab_num) {

	Rect disabled_src;
	disabled_src.x = disabled_src.y = 0;
	disabled_src.w = disabled_src.h = ICON_SIZE;

	for (size_t i=0; i<power_cell.size(); i++) {
		bool power_in_vector = false;

		// Continue if slot is not filled with data
		if (power_cell[i].tab != tab_num) continue;

		int cell_index = getCellByPowerIndex(power_cell[i].id, power_cell_all);
		if (!checkCellVisible(cell_index)) continue;

		if (std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end()) power_in_vector = true;

		if (slots[i])
			slots[i]->render();

		// highlighting
		if (power_in_vector || checkUnlocked(cell_index)) {
			Rect src_unlock;

			src_unlock.x = 0;
			src_unlock.y = 0;
			src_unlock.w = ICON_SIZE;
			src_unlock.h = ICON_SIZE;

			int selected_slot = -1;
			if (isTabListSelected()) {
				selected_slot = getSelectedCellIndex();
			}

			for (size_t j=0; j<power_cell.size(); j++) {
				if (selected_slot == static_cast<int>(j))
					continue;

				if (power_cell[j].id == power_cell[i].id && powers_unlock && slots[j]) {
					powers_unlock->setClip(src_unlock);
					powers_unlock->setDest(slots[j]->pos);
					render_device->render(powers_unlock);
				}
			}
		}
		else {
			if (overlay_disabled && slots[i]) {
				overlay_disabled->setClip(disabled_src);
				overlay_disabled->setDest(slots[i]->pos);
				render_device->render(overlay_disabled);
			}
		}

		if (slots[i])
			slots[i]->renderSelection();

		// upgrade buttons
		if (upgradeButtons[i])
			upgradeButtons[i]->render();
	}
}