示例#1
0
capCan::capCan(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

    //this->setAttribute(Qt::WA_DeleteOnClose, true);
    //setWindowState(Qt::WindowMaximized);
#ifdef Q_OS_WIN
    upgradeProcess = "httpUpgrade.exe";
#else
	upgradeProcess = "httpUpgrade";
#endif

	QString verStr;
	verStr.sprintf("%s %d.%d.%d", "AutoIO CAN Capture Tool", VERSION_H, VERSION_M, VERSION_L);
	setWindowTitle(verStr);
	
	QLabel *ctlCanStsPrefix = new QLabel();
	ui.ctlStatusBar->addWidget(ctlCanStsPrefix);
	ctlCanStsPrefix->setText(QString::fromLocal8Bit("CAN设备:"));

	ctlUsbCanSts = new QLabel();
	ui.ctlStatusBar->addWidget(ctlUsbCanSts);
	ctlUsbCanSts->setText(QString::fromLocal8Bit("未连接"));

//#ifdef QT_NO_DEBUG
	checkUpgrade();	// 检查升级
//#endif
	// 定时抓包,抓包设备驱动自己有缓存,不用太频繁地抓
	onBtnClear();
	mTmrCap = new QTimer();
	connect(mTmrCap,SIGNAL(timeout()),this,SLOT(onTimerCap()));
	mTmrCap->start(1000);

	// 定时刷新LOG列表
	mTmrRefresh = new QTimer();
	connect(mTmrRefresh,SIGNAL(timeout()),this,SLOT(onTimerRefresh()));
	mTmrRefresh->start(1000);

	switchCanSts();
	// 授权
	initAuth();
}
示例#2
0
void MenuPowers::upgradeByCell(int pci) {
	if (checkUpgrade(pci))
		upgradePower(pci);
}
示例#3
0
void MenuPowers::logic() {
	setUnlockedPowers();

	for (size_t i=0; i<power_cell_unlocked.size(); i++) {
		if (static_cast<size_t>(power_cell_unlocked[i].id) < powers->powers.size() && powers->powers[power_cell_unlocked[i].id].passive) {
			bool unlocked_power = std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell_unlocked[i].id) != stats->powers_list.end();
			std::vector<int>::iterator it = std::find(stats->powers_passive.begin(), stats->powers_passive.end(), power_cell_unlocked[i].id);

			int cell_index = getCellByPowerIndex(power_cell_unlocked[i].id, power_cell_all);
			bool is_current_upgrade_max = (getCellByPowerIndex(power_cell_unlocked[i].id, power_cell) != -1);

			if (it != stats->powers_passive.end()) {
				if (!is_current_upgrade_max || (!checkRequirements(cell_index) && power_cell_unlocked[i].passive_on)) {
					// passive power is activated, but does not meet requirements, so remove it
					stats->powers_passive.erase(it);
					stats->effects.removeEffectPassive(power_cell_unlocked[i].id);
					power_cell[i].passive_on = false;
					stats->refresh_stats = true;
				}
			}
			else if (is_current_upgrade_max && ((checkRequirements(cell_index) && !power_cell_unlocked[i].requires_point) || unlocked_power) && !power_cell_unlocked[i].passive_on) {
				// passive power has not been activated, so activate it here
				stats->powers_passive.push_back(power_cell_unlocked[i].id);
				power_cell_unlocked[i].passive_on = true;
				// for passives without special triggers, we need to trigger them here
				if (stats->effects.triggered_others)
					powers->activateSinglePassive(stats, power_cell_unlocked[i].id);
			}
		}
	}

	for (size_t i=0; i<power_cell.size(); i++) {
		//upgrade buttons logic
		if (upgradeButtons[i] != NULL) {
			upgradeButtons[i]->enabled = false;
			// enable button only if current level is unlocked and next level can be unlocked
			if (checkUpgrade(static_cast<int>(i))) {
				upgradeButtons[i]->enabled = true;
			}
			if ((!tab_control || power_cell[i].tab == tab_control->getActiveTab()) && upgradeButtons[i]->checkClick()) {
				upgradePower(static_cast<int>(i));
			}

			// automatically apply upgrades when requires_point = false
			if (upgradeButtons[i]->enabled) {
				int next_index;
				int prev_index = -1;
				while ((next_index = getNextLevelCell(static_cast<int>(i))) != -1) {
					if (prev_index == next_index) {
						// this should never happen, but if it ever does, it would be an infinite loop
						break;
					}

					if (!power_cell_upgrade[next_index].requires_point && checkUpgrade(static_cast<int>(i))) {
						upgradePower(static_cast<int>(i), true);
					}
					else {
						break;
					}

					prev_index = next_index;
				}
			}
		}
	}

	points_left = (stats->level * stats->power_points_per_level) - getPointsUsed();
	if (points_left > 0) {
		newPowerNotification = true;
	}

	if (!visible) return;

	tablist.logic();
	if (!tabs.empty()) {
		for (size_t i=0; i<tabs.size(); i++) {
			if (tab_control && tab_control->getActiveTab() == static_cast<int>(i)) {
				tablist.setNextTabList(&tablist_pow[i]);
			}
			tablist_pow[i].logic();
		}
	}

	if (closeButton->checkClick()) {
		visible = false;
		snd->play(sfx_close);
	}

	if (tab_control) {
		// make shure keyboard navigation leads us to correct tab
		for (size_t i=0; i<slots.size(); i++) {
			if (power_cell[i].tab == tab_control->getActiveTab())
				continue;

			if (slots[i] && slots[i]->in_focus)
				slots[i]->defocus();
		}

		tab_control->logic();
	}
}
示例#4
0
void MenuPowers::logic() {
	for (size_t i=0; i<power_cell_unlocked.size(); i++) {
		if (static_cast<size_t>(power_cell_unlocked[i].id) < powers->powers.size() && powers->powers[power_cell_unlocked[i].id].passive) {
			bool unlocked_power = std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell_unlocked[i].id) != stats->powers_list.end();
			std::vector<int>::iterator it = std::find(stats->powers_passive.begin(), stats->powers_passive.end(), power_cell_unlocked[i].id);

			int cell_index = getCellByPowerIndex(power_cell_unlocked[i].id, power_cell_all);
			if (it != stats->powers_passive.end()) {
				if (!checkRequirements(cell_index) && power_cell_unlocked[i].passive_on) {
					stats->powers_passive.erase(it);
					stats->effects.removeEffectPassive(power_cell_unlocked[i].id);
					power_cell[i].passive_on = false;
					stats->refresh_stats = true;
				}
			}
			else if (((checkRequirements(cell_index) && !power_cell_unlocked[i].requires_point) || unlocked_power) && !power_cell_unlocked[i].passive_on) {
				stats->powers_passive.push_back(power_cell_unlocked[i].id);
				power_cell_unlocked[i].passive_on = true;
				// for passives without special triggers, we need to trigger them here
				if (stats->effects.triggered_others)
					powers->activateSinglePassive(stats, power_cell_unlocked[i].id);
			}
		}
	}

	for (size_t i=0; i<power_cell.size(); i++) {
		//upgrade buttons logic
		if (upgradeButtons[i] != NULL) {
			upgradeButtons[i]->enabled = false;
			// enable button only if current level is unlocked and next level can be unlocked
			if (checkUpgrade(static_cast<int>(i))) {
				upgradeButtons[i]->enabled = true;
			}
			if ((!tab_control || power_cell[i].tab == tab_control->getActiveTab()) && upgradeButtons[i]->checkClick()) {
				upgradePower(static_cast<int>(i));
			}
		}
	}

	points_left = (stats->level * stats->power_points_per_level) - getPointsUsed();
	if (points_left > 0) {
		newPowerNotification = true;
	}

	if (!visible) return;

	tablist.logic();
	if (!tabs.empty()) {
		for (size_t i=0; i<tabs.size(); i++) {
			if (tab_control->getActiveTab() == static_cast<int>(i)) {
				tablist.setNextTabList(&tablist_pow[i]);
			}
			tablist_pow[i].logic();
		}
	}

	if (closeButton->checkClick()) {
		visible = false;
		snd->play(sfx_close);
	}

	if (tab_control) {
		// make shure keyboard navigation leads us to correct tab
		for (size_t i=0; i<slots.size(); i++) {
			if (power_cell[i].tab == tab_control->getActiveTab())
				continue;

			if (slots[i] && slots[i]->in_focus)
				slots[i]->defocus();
		}

		tab_control->logic();
	}
}