mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fall back to default subscriber badge if there's no other badge available
This commit is contained in:
parent
49c2f442cb
commit
ad8ee97de9
6 changed files with 26 additions and 19 deletions
BIN
resources/images/subscriber.png
Normal file
BIN
resources/images/subscriber.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -32,6 +32,7 @@
|
|||
<file>images/UserProfile_22x.png</file>
|
||||
<file>images/VSO_Link_blue_16x.png</file>
|
||||
<file>sounds/ping2.wav</file>
|
||||
<file>images/subscriber.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/qt/etc">
|
||||
<file>qt.conf</file>
|
||||
|
|
|
@ -19,8 +19,6 @@ namespace messages {
|
|||
class Message;
|
||||
}
|
||||
|
||||
class IrcManager;
|
||||
|
||||
class Channel
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -29,6 +29,7 @@ Resources::Resources(EmoteManager &em, WindowManager &wm)
|
|||
, badgeBroadcaster(lli(em, wm, ":/images/broadcaster_bg.png"))
|
||||
, badgePremium(lli(em, wm, ":/images/twitchprime_bg.png"))
|
||||
, badgeVerified(lli(em, wm, ":/images/verified.png", 0.25))
|
||||
, badgeSubscriber(lli(em, wm, ":/images/subscriber.png", 0.25))
|
||||
, cheerBadge100000(lli(em, wm, ":/images/cheer100000"))
|
||||
, cheerBadge10000(lli(em, wm, ":/images/cheer10000"))
|
||||
, cheerBadge5000(lli(em, wm, ":/images/cheer5000"))
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
messages::LazyLoadedImage *badgeBroadcaster;
|
||||
messages::LazyLoadedImage *badgePremium;
|
||||
messages::LazyLoadedImage *badgeVerified;
|
||||
messages::LazyLoadedImage *badgeSubscriber;
|
||||
|
||||
messages::LazyLoadedImage *cheerBadge100000;
|
||||
messages::LazyLoadedImage *cheerBadge10000;
|
||||
|
|
|
@ -619,25 +619,31 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const auto &badgeSet = channelResources.badgeSets.at("subscriber");
|
||||
|
||||
std::string versionKey = badge.mid(11).toStdString();
|
||||
|
||||
try {
|
||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||
|
||||
appendWord(
|
||||
Word(badgeVersion.badgeImage1x, Word::Type::BadgeSubscription, QString(),
|
||||
QString("Twitch " + QString::fromStdString(badgeVersion.title))));
|
||||
} catch (const std::exception &e) {
|
||||
qDebug() << "Exception caught:" << e.what()
|
||||
<< "when trying to fetch badge version " << versionKey.c_str();
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
qDebug() << "No channel badge set with key `subscriber`. Exception: " << e.what();
|
||||
auto badgeSetIt = channelResources.badgeSets.find("subscriber");
|
||||
if (badgeSetIt == channelResources.badgeSets.end()) {
|
||||
// Fall back to default badge
|
||||
appendWord(Word(this->resources.badgeSubscriber, Word::Type::BadgeSubscription,
|
||||
QString(), QString("Twitch Subscriber")));
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto &badgeSet = badgeSetIt->second;
|
||||
|
||||
std::string versionKey = badge.mid(11).toStdString();
|
||||
|
||||
auto badgeVersionIt = badgeSet.versions.find(versionKey);
|
||||
|
||||
if (badgeVersionIt == badgeSet.versions.end()) {
|
||||
// Fall back to default badge
|
||||
appendWord(Word(this->resources.badgeSubscriber, Word::Type::BadgeSubscription,
|
||||
QString(), QString("Twitch Subscriber")));
|
||||
continue;
|
||||
}
|
||||
|
||||
auto &badgeVersion = badgeVersionIt->second;
|
||||
|
||||
appendWord(Word(badgeVersion.badgeImage1x, Word::Type::BadgeSubscription, QString(),
|
||||
QString("Twitch " + QString::fromStdString(badgeVersion.title))));
|
||||
} else {
|
||||
if (!this->resources.dynamicBadgesLoaded) {
|
||||
// Do nothing
|
||||
|
|
Loading…
Reference in a new issue