コード例 #1
0
void FlashController::meassureBrigtness()
{

    Mat gray;
    cvtColor(picture,gray,CV_BGR2GRAY);
    /**
    //very simple...
    cv::Scalar cvMean;
    cv::Scalar cvStddev;
    cv::meanStdDev(gray, cvMean, cvStddev);
    if(cvMean.val[0]>200) emit setFlash(OFF);
    else emit setFlash(FLASH_ON);
    **/
    Mat histLuminance;
    float range[] = { 0, 256 };
    const float* histRange = { range };

    calcHist( &gray, 1, 0, Mat(), histLuminance, 1, &histSize, &histRange, true, false);
    this->size= gray.cols*gray.rows;
    double quantil20=calcHistogramQuantile(0.2,histLuminance);
    double quantil80=calcHistogramQuantile(0.6,histLuminance);
    if(quantil80-quantil20>0.4){
        qDebug()<<"exposure okay";
    }else if(1-quantil80>0.3){
        qDebug()<<"over exposure";
        emit setFlash(OFF);
    }
    else{
        qDebug()<<"under exposure";
        emit setFlash(FLASH_ON);
    }
    //qDebug()<<"flash controller: quantil20:"<<quantil20<<", quantil60"<<quantil80;
}
コード例 #2
0
/*!
  \~english
  Sets the validation errors to flash variant.

  \~japanese
  バリデーションエラーとなったメッセージをフラッシュ変数へ設定する
*/
void TActionController::setFlashValidationErrors(const TFormValidator &v, const QString &prefix)
{
    for (QStringListIterator i(v.validationErrorKeys()); i.hasNext(); ) {
        const QString &key = i.next();
        QString msg = v.errorMessage(key);
        setFlash(prefix + key, msg);
    }
}
コード例 #3
0
ファイル: CWebUser.cpp プロジェクト: djvibegga/yii-cws
_string CWebUser::getFlash(const string & key, const _string & defaultValue, bool remove)
{
	_string value = getState(FLASH_KEY_PREFIX + key, defaultValue);
	if (remove) {
		setFlash(key, _(""));
	}
	return value;
}
コード例 #4
0
	void ExplosionSystem::setExplosion()
	{
		setMist();
		setBurst();
    	setFlash();
    	setTrails();
    	setShockwave();
    	setExplosionSparks();
    	setDebris();
	}
コード例 #5
0
ファイル: chattab.cpp プロジェクト: dreamsxin/ManaPlus
void ChatTab::chatLog(std::string line,
                      ChatMsgTypeT own,
                      const IgnoreRecord ignoreRecord,
                      const TryRemoveColors tryRemoveColors)
{
    // Trim whitespace
    trim(line);

    if (line.empty())
        return;

    if (tryRemoveColors == TryRemoveColors_true &&
        own == ChatMsgType::BY_OTHER &&
        config.getBoolValue("removeColors"))
    {
        line = removeColors(line);
        if (line.empty())
            return;
    }

    const unsigned lineLim = config.getIntValue("chatMaxCharLimit");
    if (lineLim > 0 && line.length() > lineLim)
        line = line.substr(0, lineLim);

    if (line.empty())
        return;

    CHATLOG tmp;
    tmp.own = own;
    tmp.nick.clear();
    tmp.text = line;

    const size_t pos = line.find(" : ");
    if (pos != std::string::npos)
    {
        if (line.length() <= pos + 3)
            return;

        tmp.nick = line.substr(0, pos);
        tmp.text = line.substr(pos + 3);
    }
    else
    {
        // Fix the owner of welcome message.
        if (line.length() > 7 && line.substr(0, 7) == "Welcome")
            own = ChatMsgType::BY_SERVER;
    }

    // *implements actions in a backwards compatible way*
    if ((own == ChatMsgType::BY_PLAYER || own == ChatMsgType::BY_OTHER) &&
        tmp.text.at(0) == '*' &&
        tmp.text.at(tmp.text.length()-1) == '*')
    {
        tmp.text[0] = ' ';
        tmp.text.erase(tmp.text.length() - 1);
        own = ChatMsgType::ACT_IS;
    }

    std::string lineColor("##C");
    switch (own)
    {
        case ChatMsgType::BY_GM:
            if (tmp.nick.empty())
            {
                // TRANSLATORS: chat message
                tmp.nick = std::string(_("Global announcement:")).append(" ");
                lineColor = "##G";
            }
            else
            {
                // TRANSLATORS: chat message
                tmp.nick = strprintf(_("Global announcement from %s:"),
                                     tmp.nick.c_str()).append(" ");
                lineColor = "##g";  // Equiv. to BrowserBox::RED
            }
            break;
        case ChatMsgType::BY_PLAYER:
            tmp.nick.append(": ");
            lineColor = "##Y";
            break;
        case ChatMsgType::BY_OTHER:
        case ChatMsgType::BY_UNKNOWN:
            tmp.nick.append(": ");
            lineColor = "##C";
            break;
        case ChatMsgType::BY_SERVER:
            // TRANSLATORS: chat message
            tmp.nick.clear();
            tmp.text = line;
            lineColor = "##S";
            break;
        case ChatMsgType::BY_CHANNEL:
            tmp.nick.clear();
            lineColor = "##2";  // Equiv. to BrowserBox::GREEN
            break;
        case ChatMsgType::ACT_WHISPER:
            // TRANSLATORS: chat message
            tmp.nick = strprintf(_("%s whispers: %s"), tmp.nick.c_str(), "");
            lineColor = "##W";
            break;
        case ChatMsgType::ACT_IS:
            lineColor = "##I";
            break;
        case ChatMsgType::BY_LOGGER:
            tmp.nick.clear();
            tmp.text = line;
            lineColor = "##L";
            break;
        default:
            break;
    }

    if (tmp.nick == ": ")
    {
        tmp.nick.clear();
        lineColor = "##S";
    }

    // if configured, move magic messages log to debug chat tab
    if (!serverFeatures->haveChatChannels()
        && localChatTab && this == localChatTab
        && ((config.getBoolValue("showMagicInDebug")
        && own == ChatMsgType::BY_PLAYER
        && tmp.text.length() > 1
        && tmp.text.at(0) == '#'
        && tmp.text.at(1) != '#')
        || (config.getBoolValue("serverMsgInDebug")
        && (own == ChatMsgType::BY_SERVER
        || tmp.nick.empty()))))
    {
        if (debugChatTab)
            debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
        return;
    }

    // Get the current system time
    time_t t;
    time(&t);

    if (config.getBoolValue("useLocalTime"))
    {
        const tm *const timeInfo = localtime(&t);
        if (timeInfo)
        {
            line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(),
                timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(),
                tmp.text.c_str());
        }
        else
        {
            line = strprintf("%s %s%s", lineColor.c_str(),
                tmp.nick.c_str(), tmp.text.c_str());
        }
    }
    else
    {
        // Format the time string properly
        std::stringstream timeStr;
        timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
            << CAST_S32(((t / 60) / 60) % 24)
            << ":" << (((t / 60) % 60 < 10) ? "0" : "")
            << CAST_S32((t / 60) % 60)
            << "] ";
        line = std::string(lineColor).append(timeStr.str()).append(
            tmp.nick).append(tmp.text);
    }

    if (config.getBoolValue("enableChatLog"))
        saveToLogFile(line);

    mTextOutput->setMaxRow(config.getIntValue("chatMaxLinesLimit"));

    // We look if the Vertical Scroll Bar is set at the max before
    // adding a row, otherwise the max will always be a row higher
    // at comparison.
    if (mScrollArea->getVerticalScrollAmount() + 2 >=
        mScrollArea->getVerticalMaxScroll())
    {
        addRow(line);
        mScrollArea->setVerticalScrollAmount(
            mScrollArea->getVerticalMaxScroll());
    }
    else
    {
        addRow(line);
    }

    if (chatWindow && this == localChatTab)
        chatWindow->addToAwayLog(line);

    mScrollArea->logic();
    if (own != ChatMsgType::BY_PLAYER)
    {
        if (own == ChatMsgType::BY_SERVER &&
            (getType() == ChatTabType::PARTY ||
            getType() == ChatTabType::CHANNEL ||
            getType() == ChatTabType::GUILD))
        {
            return;
        }

        const TabbedArea *const tabArea = getTabbedArea();
        if (!tabArea)
            return;

        const bool notFocused = WindowManager::getIsMinimized() ||
            (!settings.mouseFocused && !settings.inputFocused);

        if (this != tabArea->getSelectedTab() || notFocused)
        {
            if (getFlash() == 0)
            {
                if (chatWindow && chatWindow->findHighlight(tmp.text))
                {
                    setFlash(2);
                    soundManager.playGuiSound(SOUND_HIGHLIGHT);
                }
                else
                {
                    setFlash(1);
                }
            }
            else if (getFlash() == 2)
            {
                if (chatWindow && chatWindow->findHighlight(tmp.text))
                    soundManager.playGuiSound(SOUND_HIGHLIGHT);
            }
        }

        if ((getAllowHighlight() ||
            own == ChatMsgType::BY_GM) &&
            (this != tabArea->getSelectedTab() ||
            notFocused))
        {
            if (own == ChatMsgType::BY_GM)
            {
                if (chatWindow)
                    chatWindow->unHideWindow();
                soundManager.playGuiSound(SOUND_GLOBAL);
            }
            else if (own != ChatMsgType::BY_SERVER)
            {
                if (chatWindow)
                    chatWindow->unHideWindow();
                playNewMessageSound();
            }
            WindowManager::newChatMessage();
        }
    }
}
コード例 #6
0
ファイル: chattab.cpp プロジェクト: Ablu/invertika
void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord)
{
    // Trim whitespace
    trim(line);

    if (line.empty())
        return;

    CHATLOG tmp;
    tmp.own = own;
    tmp.nick = "";
    tmp.text = line;

    std::string::size_type pos = line.find(" : ");
    if (pos != std::string::npos)
    {
        tmp.nick = line.substr(0, pos);
        tmp.text = line.substr(pos + 3);
    }
    else
    {
        // Fix the owner of welcome message.
        if (line.substr(0, 7) == "Welcome")
        {
            own = BY_SERVER;
        }
    }

    // *implements actions in a backwards compatible way*
    if ((own == BY_PLAYER || own == BY_OTHER) &&
        tmp.text.at(0) == '*' &&
        tmp.text.at(tmp.text.length()-1) == '*')
    {
        tmp.text[0] = ' ';
        tmp.text.erase(tmp.text.length() - 1);
        own = ACT_IS;
    }

    std::string lineColor = "##C";
    switch (own)
    {
        case BY_GM:
            if (tmp.nick.empty())
            {
                tmp.nick = std::string(_("Global announcement:"));
                tmp.nick += " ";
                lineColor = "##G";
            }
            else
            {
                tmp.nick = strprintf(_("Global announcement from %s:"),
                                     tmp.nick.c_str());
                tmp.nick += " ";
                lineColor = "##1"; // Equiv. to BrowserBox::RED
            }
            break;
        case BY_PLAYER:
            tmp.nick += ": ";
            lineColor = "##Y";
            break;
        case BY_OTHER:
            tmp.nick += ": ";
            lineColor = "##C";
            break;
        case BY_SERVER:
            tmp.nick = _("Server:");
            tmp.nick += " ";
            tmp.text = line;
            lineColor = "##S";
            break;
        case BY_CHANNEL:
            tmp.nick = "";
            // TODO: Use a predefined color
            lineColor = "##2"; // Equiv. to BrowserBox::GREEN
            break;
        case ACT_WHISPER:
            tmp.nick = strprintf(_("%s whispers: %s"), tmp.nick.c_str(), "");
            lineColor = "##W";
            break;
        case ACT_IS:
            lineColor = "##I";
            break;
        case BY_LOGGER:
            tmp.nick = "";
            tmp.text = line;
            lineColor = "##L";
            break;
    }

    if (tmp.nick == ": ")
    {
        tmp.nick = "";
        lineColor = "##S";
    }

    // Get the current system time
    time_t t;
    time(&t);

    // Format the time string properly
    std::stringstream timeStr;
    timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
        << (int) (((t / 60) / 60) % 24)
        << ":" << (((t / 60) % 60 < 10) ? "0" : "")
        << (int) ((t / 60) % 60)
        << "] ";

    line = lineColor + timeStr.str() + tmp.nick + tmp.text;

    if (config.getBoolValue("enableChatLog"))
        saveToLogFile(line);

    // We look if the Vertical Scroll Bar is set at the max before
    // adding a row, otherwise the max will always be a row higher
    // at comparison.
    if (mScrollArea->getVerticalScrollAmount() >= mScrollArea->getVerticalMaxScroll())
    {
        addRow(line);
        mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
    }
    else
    {
        addRow(line);
    }

    mScrollArea->logic();
    chatWindow->mRecorder->record(line.substr(3));
    if (this != getTabbedArea()->getSelectedTab() &&
        own != BY_PLAYER)
        setFlash(true);
}