Beispiel #1
0
	void HexagonGame::draw()
	{
		styleData.computeColors();

		window.clear(Color::Black);
		if(!getNoBackground()) { backgroundCamera.apply(); styleData.drawBackground(window.getRenderWindow(), {0, 0}, getSides()); }
		if(get3D())
		{
			status.drawing3D = true;

			float effect{styleData.get3DSkew() * get3DMultiplier() * status.pulse3D};
			Vector2f skew{1.f, 1.f + effect};
			backgroundCamera.setSkew(skew);

			for(unsigned int i{0}; i < depthCameras.size(); ++i)
			{
				Camera& depthCamera(depthCameras[i]);
				depthCamera.setView(backgroundCamera.getView());
				depthCamera.setSkew(skew);
				depthCamera.setOffset({0, styleData.get3DSpacing() * (i * styleData.get3DPerspectiveMultiplier()) * (effect * 3.6f)});
			}

			for(unsigned int i{0}; i < depthCameras.size(); ++i)
			{
				status.overrideColor = getColorDarkened(styleData.get3DOverrideColor(), styleData.get3DDarkenMultiplier());
				status.overrideColor.a /= styleData.get3DAlphaMultiplier();
				status.overrideColor.a -= i * styleData.get3DAlphaFalloff();

				depthCameras[i].apply();
				manager.draw();
			}
			status.drawing3D = false;
		}
		backgroundCamera.apply(); manager.draw();
		overlayCamera.apply(); drawText();

		if(getFlash()) render(flashPolygon);
		if(mustTakeScreenshot) { window.getRenderWindow().capture().saveToFile("screenshot.png"); mustTakeScreenshot = false; }
	}
Beispiel #2
0
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();
        }
    }
}
Beispiel #3
0
QStringList *ExifReaderWriter::readExifInfo(QString pictureName, FormatHandler *formatH)
{
    QStringList *exifList = new QStringList;

    Exiv2::Image::AutoPtr image = openExif(pictureName);
    if(image.get() == 0)
        return exifList;
    Exiv2::ExifData &exifData = image->exifData();
    if (exifData.empty()) {
        //nejsou exif data
        return exifList;
    }


    //cteniGPS souradnic
    double lat = readLatLon("Exif.GPSInfo.GPSLatitude", exifData);
    double lon = readLatLon("Exif.GPSInfo.GPSLongitude", exifData);
    double alt = readAltitude("Exif.GPSInfo.GPSAltitude", exifData);
    ////////////////////////////

    //cteni data
    QDateTime *dateTime = NULL;
    if((dateTime = readExifDate(exifData,"Exif.Photo.DateTimeOriginal")) == NULL)
        if((dateTime = readExifDate(exifData,"Exif.Image.DateTimeOriginal")) == NULL)
            if((dateTime = readExifDate(exifData,"Exif.Photo.DateTimeDigitized")) == NULL)
                dateTime = readExifDate(exifData,"Exif.Image.DateTime");


    ////////////////////
    QString cameraMake = readExifItem(exifData, "Exif.Image.Make");
    QString cameraModel = readExifItem(exifData, "Exif.Image.Model");
    QString imageSize = readExifItem(exifData, "Exif.Photo.PixelXDimension")
                        +" x "
                        + readExifItem(exifData, "Exif.Photo.PixelYDimension");
    QString exposureTime = getExposureTime(exifData);
    QString flash = getFlash(exifData);
    //'5' flash fired but strobe return light not detected, '7' flash fired and strobe return light detected.
    QString meteringMode = getMeteringMode(exifData);
    QString fNumber = getFNumber(exifData);
    QString isoSpeed = readExifItem(exifData, "Exif.Photo.ISOSpeedRatings");
    QString focalLength = getFocalLength(exifData);
    QString comment = readExifItem(exifData, "Exif.Photo.UserComment");
    QString exposureBias = getExposureBias(exifData);
    QString exposureProgram = getExposureProgram(exifData);
    //////////////////
    (*exifList) << ((dateTime != NULL) ? dateTime->toString(formatH->formatDateTime) : "")
            << (lat < 1000 ?(formatH->gpsInFormat(lat) + (lat>=0 ? tr("N") : tr("S"))) : "")
            << (lon < 1000 ?(formatH->gpsInFormat(lon) + (lon>=0 ? tr("E") : tr("W"))) : "")
            << (alt > -999 ?(QString::number(alt) + tr(" m")) : "")
            << cameraMake
            << cameraModel
            << exposureTime
            << exposureBias
            << exposureProgram
            << imageSize
            << flash
            << fNumber
            << meteringMode
            << isoSpeed
            << focalLength
            << comment
            ;

    return exifList;

}
Beispiel #4
0
bool CWebUser::hasFlash(const string & key)
{
	return !getFlash(key, _(""), false).empty();
}