示例#1
0
	void saveCurrentProfile()
	{
		if(currentProfilePtr == nullptr) return;

		Json::StyledStreamWriter writer;
		ofstream o{getCurrentProfileFilePath(), std::ifstream::binary};

		Json::Value profileRoot;
		profileRoot["version"] = getVersion();
		profileRoot["name"] = getCurrentProfile().getName();
		profileRoot["scores"] = getCurrentProfile().getScores();
		for(const auto& n : getCurrentProfile().getTrackedNames()) profileRoot["trackedNames"].append(n);

		writer.write(o, profileRoot); o.flush(); o.close();
	}
示例#2
0
void ConfigDialog::setIniPath(const QString & _strIniPath)
{
	m_strIniPath = _strIniPath;

	QStringList translationFiles;
	_getTranslations(translationFiles);

	const QString currentTranslation = getTranslationFile();
	int listIndex = 0;
	QStringList translationLanguages("English");
	for (int i = 0; i < translationFiles.size(); ++i) {
		// get locale extracted by filename
		QString locale = translationFiles[i]; // "TranslationExample_de.qm"
		const bool bCurrent = locale == currentTranslation;
		locale.truncate(locale.lastIndexOf('.')); // "TranslationExample_de"
		locale.remove(0, locale.indexOf('_') + 1); // "de"
		QString language = QLocale(locale).nativeLanguageName();
		language = language.left(1).toUpper() + language.remove(0, 1);
		if (bCurrent) {
			listIndex = i + 1;
		}
		translationLanguages << language;
	}

	ui->translationsComboBox->insertItems(0, translationLanguages);
	ui->translationsComboBox->setCurrentIndex(listIndex);

	// Profile
	ui->profilesComboBox->blockSignals(true);
	const QStringList aProfiles = getProfiles(m_strIniPath);
	ui->profilesComboBox->addItems(aProfiles);
	ui->profilesComboBox->setCurrentIndex(aProfiles.indexOf(getCurrentProfile(m_strIniPath)));
	ui->profilesComboBox->blockSignals(false);
	ui->removeProfilePushButton->setEnabled(ui->profilesComboBox->count() > 1);
}
void ProfileManager::setProfiles(const QList<Profile*>& profiles)
{
	QList<Profile*> currentProfiles = this->profiles;

	QList<Profile*>::const_iterator it;

	for (it = currentProfiles.begin() ; it != currentProfiles.end() ; it++) {
		Profile* profile = *it;

		if (!profiles.contains(profile)) {
			if (getCurrentProfile() == profile) {
				setCurrentProfile(NULL);
			}

			removeProfile(profile);
			delete profile;
		}
	}

	for (it = profiles.begin() ; it != profiles.end() ; it++) {
		Profile* profile = *it;

		if (!currentProfiles.contains(profile)) {
			addProfile(profile);
		}
	}
}
示例#4
0
void showProfilePage(void)
{
    uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;

    tfp_sprintf(lineBuffer, "Profile: %d", getCurrentProfile());
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    uint8_t currentRateProfileIndex = getCurrentControlRateProfile();
    tfp_sprintf(lineBuffer, "Rate profile: %d", currentRateProfileIndex);
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    controlRateConfig_t *controlRateConfig = getControlRateConfig(currentRateProfileIndex);

    tfp_sprintf(lineBuffer, "RCE: %d, RCR: %d",
        controlRateConfig->rcExpo8,
        controlRateConfig->rcRate8
    );
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    tfp_sprintf(lineBuffer, "RR:%d PR:%d YR:%d",
        controlRateConfig->rates[FD_ROLL],
        controlRateConfig->rates[FD_PITCH],
        controlRateConfig->rates[FD_YAW]
    );
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);
}
示例#5
0
bool Netctl::updateSourceEvent(const QString &source)
{
    if (debug) qDebug() << "[DE]" << "[updateSourceEvent]";
    if (debug) qDebug() << "[DE]" << "[updateSourceEvent]" << ":" << "Source name" << source;

    QString key = QString("value");
    QString value = QString("");
    if (source == QString("currentProfile")) {
        value = getCurrentProfile(configuration[QString("NETCTLAUTOCMD")]);
        if (value.isEmpty())
            value = getCurrentProfile(configuration[QString("CMD")]);
    }
    else if (source == QString("extIp")) {
        if (configuration[QString("EXTIP")] == QString("true"))
            value = getExtIp(configuration[QString("EXTIPCMD")]);
    }
    else if (source == QString("interfaces")) {
        value = getInterfaceList(configuration[QString("NETDIR")]).join(QChar(','));
    }
    else if (source == QString("intIp")) {
        value = getIntIp(configuration[QString("IPCMD")], configuration[QString("NETDIR")]);
    }
    else if (source == QString("profiles")) {
        value = getProfileList(configuration[QString("NETCTLAUTOCMD")]).join(QChar(','));
        if (value.isEmpty())
            value = getProfileList(configuration[QString("CMD")]).join(QChar(','));
    }
    else if (source == QString("statusBool")) {
        if (getProfileStatus(configuration[QString("NETCTLAUTOCMD")]))
            value = QString("true");
        else if (getProfileStatus(configuration[QString("CMD")]))
            value = QString("true");
        else
            value = QString("false");
    }
    else if (source == QString("statusString")) {
        value = getProfileStringStatus(configuration[QString("CMD")],
                configuration[QString("NETCTLAUTOCMD")]);
    }
    setData(source, key, value);

    return true;
}
示例#6
0
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
    if (debug) qDebug() << PDEBUG;
    getNetctlAutoStatus(cmdNetctlAuto);

    QString status = QString("false");
    QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
    if (!currentProfile.isEmpty())
        status = QString("true");

    return status;
}
示例#7
0
QString Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
    if (debug) qDebug() << "[DE]" << "[getProfileStringStatus]";
    if (debug) qDebug() << "[DE]" << "[getProfileStringStatus]" << ":" << "Cmd" << cmdNetctl;
    if (debug) qDebug() << "[DE]" << "[getProfileStringStatus]" << ":" << "Cmd" << cmdNetctlAuto;

    QProcess command;
    QString status = QString("static");
    // check netctl-auto
    if (!getCurrentProfile(cmdNetctlAuto).isEmpty())
        status = QString("netctl-auto");
    else {
        // check netctl
        command.start(cmdNetctl + QString(" is-enabled ") + getCurrentProfile(cmdNetctl));
        command.waitForFinished(-1);
        if (command.exitCode() == 0)
            status = QString("enabled");
    }

    return status;
}
示例#8
0
bool Netctl::getProfileStatus(const QString cmd)
{
    if (debug) qDebug() << "[DE]" << "[getProfileStatus]";
    if (debug) qDebug() << "[DE]" << "[getProfileStatus]" << ":" << "Cmd" << cmd;

    bool status = false;
    QString cmdOutput = getCurrentProfile(cmd);
    if (!cmdOutput.isEmpty())
        status = true;

    return status;
}
示例#9
0
    void saveCurrentProfile()
    {
#ifdef LEGACY_FILES
        FILE *f = fopen("profiles/current_profile.txt", "wb");
#else
        FILE *f = fopen("profiles/current_profile.txt", "wb");
#endif
        if (f != NULL)
        {   /*
            char *buf = new char[64 + strlen(getCurrentProfile()) + 1];
            strcpy(buf, "current_profile=");
            strcat(buf, getCurrentProfile());
            strcat(buf, "\r\n\r\n");
            fwrite(buf, strlen(buf), 1, f);
            delete [] buf;*/

            {
                std::string buf = std::string( "current_profile=" ) + getCurrentProfile( 0 ) + "\r\n\r\n";
                fwrite( buf.c_str(), buf.size(), 1, f);
            }

            {
                std::string buf = std::string( "player2_profile=" ) + getCurrentProfile( 1 ) + "\r\n\r\n";
                fwrite( buf.c_str(), buf.size(), 1, f);
            }

            {
                std::string buf = std::string( "player3_profile=" ) + getCurrentProfile( 2 ) + "\r\n\r\n";
                fwrite( buf.c_str(), buf.size(), 1, f);
            }

            {
                std::string buf = std::string( "player4_profile=" ) + getCurrentProfile( 3 ) + "\r\n\r\n";
                fwrite( buf.c_str(), buf.size(), 1, f);
            }

            fclose(f);
        }
    }
示例#10
0
	void HexagonGame::checkAndSaveScore()
	{
		if(getInvincible()) return;

		string localValidator{getLocalValidator(levelData.getId(), difficultyMult)};
		if(getScore(localValidator) < status.currentTime) setScore(localValidator, status.currentTime);
		saveCurrentProfile();

		if(status.scoreInvalid || !isEligibleForScore()) return;

		string validator{Online::getValidator(levelData.getPackPath(), levelData.getId(), levelData.getLevelRootPath(), levelData.getStyleRootPath(), levelData.getLuaScriptPath())};
		Online::startSendScore(toLower(getCurrentProfile().getName()), validator, difficultyMult, status.currentTime);
	}
示例#11
0
bool ProfileManager::removeProfile(Profile* profile)
{
	profiles.removeOne(profile);

	if (getCurrentProfile() == profile) {
		if (profiles.size() == 0) {
			setCurrentProfile(NULL);
		} else {
			setCurrentProfile(profiles[0]);
		}
	}

	emit profileRemoved(profile);

    return true;
}
示例#12
0
void showProfilePage(void)
{
    uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;

    tfp_sprintf(lineBuffer, "Profile: %d", getCurrentProfile());
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    static const char* const axisTitles[3] = {"ROL", "PIT", "YAW"};
    const pidProfile_t *pidProfile = &currentProfile->pidProfile;
    for (int axis = 0; axis < 3; ++axis) {
        tfp_sprintf(lineBuffer, "%s P:%3d I:%3d D:%3d",
            axisTitles[axis],
            pidProfile->P8[axis],
            pidProfile->I8[axis],
            pidProfile->D8[axis]
        );
        padLineBuffer();
        i2c_OLED_set_line(rowIndex++);
        i2c_OLED_send_string(lineBuffer);
    }

    const uint8_t currentRateProfileIndex = getCurrentControlRateProfile();
    tfp_sprintf(lineBuffer, "Rate profile: %d", currentRateProfileIndex);
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    const controlRateConfig_t *controlRateConfig = getControlRateConfig(currentRateProfileIndex);
    tfp_sprintf(lineBuffer, "RCE: %d, RCR: %d",
        controlRateConfig->rcExpo8,
        controlRateConfig->rcRate8
    );
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    tfp_sprintf(lineBuffer, "RR:%d PR:%d YR:%d",
        controlRateConfig->rates[FD_ROLL],
        controlRateConfig->rates[FD_PITCH],
        controlRateConfig->rates[FD_YAW]
    );
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);
}
示例#13
0
void readEEPROM(void)
{
    suspendRxSignal();

    // Sanity check, read flash
    if (!loadEEPROM()) {
        failureMode(FAILURE_INVALID_EEPROM_CONTENTS);
    }

    pgActivateProfile(getCurrentProfile());

    setControlRateProfile(rateProfileSelection()->defaultRateProfileIndex);

    validateAndFixConfig();
    activateConfig();

    resumeRxSignal();
}
示例#14
0
bool Netctl::updateSourceEvent(const QString &source)
{
    if (debug) qDebug() << PDEBUG;
    if (debug) qDebug() << PDEBUG << ":" << "Source name" << source;

    QString value = QString("N\\A");
    if (source == QString("active")) {
        value = getStatus(configuration[QString("NETCTLCMD")],
                          configuration[QString("NETCTLAUTOCMD")]);
    } else if (source == QString("current")) {
        value = getCurrentProfile(configuration[QString("NETCTLCMD")],
                                  configuration[QString("NETCTLAUTOCMD")])
                .join(QChar('|'));
        current = value;
    } else if (source == QString("extip4")) {
        if (configuration[QString("EXTIP4")] == QString("true"))
            value = getExtIp(configuration[QString("EXTIP4CMD")]);
    } else if (source == QString("extip6")) {
        if (configuration[QString("EXTIP6")] == QString("true"))
            value = getExtIp(configuration[QString("EXTIP6CMD")]);
    } else if (source == QString("info")) {
        value = getInfo();
    } else if (source == QString("interfaces")) {
        value = getInterfaceList().join(QChar(','));
    } else if (source == QString("intip4")) {
        value = getIntIp(QAbstractSocket::IPv4Protocol);
    } else if (source == QString("intip6")) {
        value = getIntIp(QAbstractSocket::IPv6Protocol);
    } else if (source == QString("netctlauto")) {
        value = getNetctlAutoStatus(configuration[QString("NETCTLAUTOCMD")]);
    } else if (source == QString("profiles")) {
        value = getProfileList(configuration[QString("NETCTLCMD")],
                               configuration[QString("NETCTLAUTOCMD")])
                .join(QChar(','));
    } else if (source == QString("status")) {
        value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
                                       configuration[QString("NETCTLAUTOCMD")])
                .join(QChar('|'));
        status = value;
    }
    setData(source, QString("value"), value);

    return true;
}
示例#15
0
void readEEPROM(void)
{
    suspendRxSignal();

    // Sanity check
    // Read flash
    if (!scanEEPROM(true)) {
        failureMode(FAILURE_INVALID_EEPROM_CONTENTS);
    }

    pgActivateProfile(getCurrentProfile());

    if (rateProfileSelection()->defaultRateProfileIndex > MAX_CONTROL_RATE_PROFILE_COUNT - 1) // sanity check
        rateProfileSelection()->defaultRateProfileIndex = 0;

    setControlRateProfile(rateProfileSelection()->defaultRateProfileIndex);

    validateAndFixConfig();
    activateConfig();

    resumeRxSignal();
}
示例#16
0
void showProfilePage(void)
{
    uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;

    tfp_sprintf(lineBuffer, "Profile: %d", getCurrentProfile());
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    uint8_t currentRateProfileIndex = getCurrentControlRateProfile();
    tfp_sprintf(lineBuffer, "Rate profile: %d", currentRateProfileIndex);
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    controlRateConfig_t *controlRateConfig = getControlRateConfig(currentRateProfileIndex);

    tfp_sprintf(lineBuffer, "RC Expo: %d", controlRateConfig->rcExpo8);
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    tfp_sprintf(lineBuffer, "RC Rate: %d", controlRateConfig->rcRate8);
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    tfp_sprintf(lineBuffer, "R&P Rate: %d", controlRateConfig->rollPitchRate);
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

    tfp_sprintf(lineBuffer, "Yaw Rate: %d", controlRateConfig->yawRate);
    padLineBuffer();
    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string(lineBuffer);

}
示例#17
0
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
    if (debug) qDebug() << PDEBUG;
    getNetctlAutoStatus(cmdNetctlAuto);

    QStringList status;
    if (netctlAutoStatus)
        status.append(QString("netctl-auto"));
    else {
        QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
        for (int i=0; i<profiles.count(); i++) {
            TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
            if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
            if (process.exitCode != 0)
                if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
            if (process.exitCode == 0)
                status.append(QString("enabled"));
            else
                status.append(QString("static"));
        }
    }

    return status;
}
示例#18
0
	float getScore(const string& mId) 				{ return getCurrentProfile().getScore(mId); }
示例#19
0
static void setControlRateProfile(uint8_t profileIndex)
{
    currentControlRateProfileIndex = profileIndex;
    masterConfig.profile[getCurrentProfile()].activeRateProfile = profileIndex;
    currentControlRateProfile = &masterConfig.profile[getCurrentProfile()].controlRateProfile[profileIndex];
}
示例#20
0
	void setScore(const string& mId, float mScore)	{ getCurrentProfile().setScore(mId, mScore); }