Пример #1
0
inline void TextLayout::set(TextFormatter& formatter, const wchar_t* begin, const wchar_t* end,
                            int page_idx)
{
    formatter.clear(); // Throws
    std::size_t n = std::size_t(end - begin);
    formatter.write(begin, n); // Throws
    formatter.format(*this, page_idx); // Throws
}
Пример #2
0
	const string Armour::paramDesc() const {
		TextFormatter out;
		float resistance = proto().damage_resistance;
		float melee_mod = proto().melee_mod;

		out("Resistance: %c%.0f%%\n", resistance >= 0.0f? '+' : '-', fabs(resistance * 100.0f));
		if(melee_mod != 1.0f)
			out("Strength mod: %.0f%%\n", melee_mod * 100.0f);
		return string(out.text());
	}
Пример #3
0
	const string Weapon::paramDesc() const {
		TextFormatter out;
		out("Damage: %.0f", estimateDamage(false));
		if(proto().burst_ammo > 1)
			out(" (x%d)", proto().burst_ammo);
		out("\n");
		if(needAmmo())
			out("Max ammo: %d\n", maxAmmo());
		if(hasRangedAttack())
			out("Accuracy: %.0f", proto().accuracy);
		return string(out.text());
	}
Пример #4
0
inline void TextLayout::set(TextFormatter& formatter, std::wstring text, int page_idx)
{
    formatter.clear(); // Throws
    formatter.write(text); // Throws
    formatter.format(*this, page_idx); // Throws
}
Пример #5
0
ChatMessage::Ptr ChatMessage::createChatMessage(const QString& sender, const QString& rawMessage,
                                                MessageType type, bool isMe, const QDateTime& date)
{
    ChatMessage::Ptr msg = ChatMessage::Ptr(new ChatMessage);

    QString text = rawMessage.toHtmlEscaped();
    QString senderText = sender;

    const QColor actionColor =
        QColor("#1818FF"); // has to match the color in innerStyle.css (div.action)

    // smileys
    if (Settings::getInstance().getUseEmoticons())
        text = SmileyPack::getInstance().smileyfied(text);

    // quotes (green text)
    text = detectQuotes(text, type);

    // text styling
    Settings::StyleType styleType = Settings::getInstance().getStylePreference();
    if (styleType != Settings::StyleType::NONE) {
        TextFormatter tf = TextFormatter(text);
        text = tf.applyStyling(styleType == Settings::StyleType::WITH_CHARS);
    }


    switch (type) {
    case NORMAL:
        text = wrapDiv(text, "msg");
        break;
    case ACTION:
        senderText = "*";
        text = wrapDiv(QString("%1 %2").arg(sender.toHtmlEscaped(), text), "action");
        msg->setAsAction();
        break;
    case ALERT:
        text = wrapDiv(text, "alert");
        break;
    }

    // Note: Eliding cannot be enabled for RichText items. (QTBUG-17207)
    QFont baseFont = Settings::getInstance().getChatMessageFont();
    QFont authorFont = baseFont;
    if (isMe)
        authorFont.setBold(true);

    msg->addColumn(new Text(senderText, authorFont, true, sender,
                            type == ACTION ? actionColor : Qt::black),
                   ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
    msg->addColumn(new Text(text, baseFont, false, ((type == ACTION) && isMe)
                                                       ? QString("%1 %2").arg(sender, rawMessage)
                                                       : rawMessage),
                   ColumnFormat(1.0, ColumnFormat::VariableSize));
    msg->addColumn(new Spinner(":/ui/chatArea/spinner.svg", QSize(16, 16), 360.0 / 1.6),
                   ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));

    if (!date.isNull())
        msg->markAsSent(date);

    return msg;
}