Fixed verified badges

Refactor more underscores into this->
This commit is contained in:
Rasmus Karlsson 2017-06-13 22:03:29 +02:00
parent 59d383c161
commit e7282b5097
8 changed files with 64 additions and 35 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -8,6 +8,7 @@
<file>images/cheer10000.png</file>
<file>images/cheer100000.png</file>
<file>images/cheer5000.png</file>
<file>images/verified.png</file>
<file>images/CopyLongTextToClipboard_16x.png</file>
<file>images/CustomActionEditor_16x.png</file>
<file>images/Emoji_Color_1F60A_19.png</file>

View file

@ -21,67 +21,66 @@ namespace chatterino {
namespace messages {
Message::Message(const QString &text)
: _text(text)
, _words()
: text(text)
{
_words.push_back(
this->words.push_back(
Word(text, Word::Text, ColorScheme::getInstance().SystemMessageColor, text, QString()));
}
Message::Message(const QString &text, const std::vector<Word> &words)
: _text(text)
, _words(words)
: text(text)
, words(words)
{
}
bool Message::getCanHighlightTab() const
{
return _highlightTab;
return this->highlightTab;
}
const QString &Message::getTimeoutUser() const
{
return _timeoutUser;
return this->timeoutUser;
}
int Message::getTimeoutCount() const
{
return _timeoutCount;
return this->timeoutCount;
}
const QString &Message::getUserName() const
{
return _userName;
return this->userName;
}
const QString &Message::getDisplayName() const
{
return _displayName;
return this->displayName;
}
const QString &Message::getContent() const
{
return _content;
return this->content;
}
const std::chrono::time_point<std::chrono::system_clock> &Message::getParseTime() const
{
return _parseTime;
return this->parseTime;
}
std::vector<Word> &Message::getWords()
{
return _words;
return this->words;
}
bool Message::isDisabled() const
{
return _isDisabled;
return this->disabled;
}
const QString &Message::getId() const
{
return _id;
return this->id;
}
} // namespace messages

View file

@ -37,7 +37,7 @@ public:
bool isDisabled() const;
const QString &getId() const;
const QString _text;
const QString text;
private:
static LazyLoadedImage *badgeStaff;
@ -50,18 +50,18 @@ private:
static QRegularExpression *cheerRegex;
bool _highlightTab = false;
QString _timeoutUser = "";
int _timeoutCount = 0;
bool _isDisabled = false;
std::chrono::time_point<std::chrono::system_clock> _parseTime;
bool highlightTab = false;
QString timeoutUser = "";
int timeoutCount = 0;
bool disabled = false;
std::chrono::time_point<std::chrono::system_clock> parseTime;
QString _userName = "";
QString _displayName = "";
QString _content;
QString _id = "";
QString userName = "";
QString displayName = "";
QString content;
QString id = "";
std::vector<Word> _words;
std::vector<Word> words;
};
} // namespace messages

View file

@ -44,17 +44,18 @@ public:
BadgePremium = (1 << 20),
BadgeChatterino = (1 << 21),
BadgeCheer = (1 << 22),
BadgeVerified = (1 << 23),
Badges = BadgeStaff | BadgeAdmin | BadgeGlobalMod | BadgeModerator | BadgeTurbo |
BadgeBroadcaster | BadgePremium | BadgeChatterino | BadgeCheer,
BadgeBroadcaster | BadgePremium | BadgeChatterino | BadgeCheer | BadgeVerified,
Username = (1 << 23),
BitsAmount = (1 << 24),
Username = (1 << 24),
BitsAmount = (1 << 25),
ButtonBan = (1 << 25),
ButtonTimeout = (1 << 26),
ButtonBan = (1 << 26),
ButtonTimeout = (1 << 27),
EmojiImage = (1 << 27),
EmojiText = (1 << 28),
EmojiImage = (1 << 28),
EmojiText = (1 << 29),
Default = TimestampNoSeconds | Badges | Username | BitsStatic | FfzEmoteImage |
BttvEmoteImage | BttvGifEmoteImage | TwitchEmoteImage | BitsAmount | Text |

View file

@ -25,6 +25,7 @@ Resources::Resources(EmoteManager &emoteManager, WindowManager &windowManager)
, badgeTurbo(lli(emoteManager, windowManager, ":/images/turbo_bg.png"))
, badgeBroadcaster(lli(emoteManager, windowManager, ":/images/broadcaster_bg.png"))
, badgePremium(lli(emoteManager, windowManager, ":/images/twitchprime_bg.png"))
, badgeVerified(lli(emoteManager, windowManager, ":/images/verified.png"))
, cheerBadge100000(lli(emoteManager, windowManager, ":/images/cheer100000"))
, cheerBadge10000(lli(emoteManager, windowManager, ":/images/cheer10000"))
, cheerBadge5000(lli(emoteManager, windowManager, ":/images/cheer5000"))

View file

@ -19,6 +19,7 @@ public:
messages::LazyLoadedImage *badgeTurbo;
messages::LazyLoadedImage *badgeBroadcaster;
messages::LazyLoadedImage *badgePremium;
messages::LazyLoadedImage *badgeVerified;
messages::LazyLoadedImage *cheerBadge100000;
messages::LazyLoadedImage *cheerBadge10000;

View file

@ -335,6 +335,10 @@ void TwitchMessageBuilder::appendTwitchBadges(const QStringList &badges, const R
EmoteManager &emoteManager)
{
for (QString badge : badges) {
if (badge.isEmpty()) {
continue;
}
if (badge.startsWith("bits/")) {
long long int cheer = std::strtoll(badge.mid(5).toStdString().c_str(), nullptr, 10);
appendWord(Word(emoteManager.getCheerBadge(cheer), Word::BadgeCheer, QString(),
@ -349,8 +353,8 @@ void TwitchMessageBuilder::appendTwitchBadges(const QStringList &badges, const R
appendWord(Word(resources.badgeGlobalModerator, Word::BadgeGlobalMod, QString(),
QString("Global Moderator")));
} else if (badge == "moderator/1") {
// TODO: implement this xD
appendWord(Word(resources.badgeTurbo, Word::BadgeModerator, QString(),
// TODO: Implement custom FFZ moderator badge
appendWord(Word(resources.badgeModerator, Word::BadgeModerator, QString(),
QString("Channel Moderator"))); // custom badge
} else if (badge == "turbo/1") {
appendWord(Word(resources.badgeStaff, Word::BadgeTurbo, QString(),
@ -361,6 +365,28 @@ void TwitchMessageBuilder::appendTwitchBadges(const QStringList &badges, const R
} else if (badge == "premium/1") {
appendWord(Word(resources.badgePremium, Word::BadgePremium, QString(),
QString("Twitch Prime")));
} else if (badge.startsWith("partner/")) {
int index = badge.midRef(8).toInt();
switch (index) {
case 1: {
appendWord(Word(resources.badgeVerified, Word::BadgeVerified, QString(),
"Twitch Verified"));
} break;
default: {
printf("[TwitchMessageBuilder] Unhandled partner badge index: %d\n", index);
} break;
}
} else if (badge.startsWith("subscriber/")) {
int index = badge.midRef(11).toInt();
// TODO: Implement subscriber badges here
switch (index) {
default: {
// printf("[TwitchMessageBuilder] Unhandled subscriber badge index: %d\n", index);
} break;
}
} else {
printf("[TwitchMessageBuilder] Unhandled badge: %s\n", qPrintable(badge));
}
}
}