Add support FrankerFaceZ badges. (#2101)
On startup, we poll https://api.frankerfacez.com/v1/badges/ids and store the mappings of user IDs to badges for the remainder of the applications lifetime.
This commit is contained in:
@@ -253,6 +253,24 @@ MessageLayoutElement *ModBadgeElement::makeImageLayoutElement(
|
||||
return element;
|
||||
}
|
||||
|
||||
// FFZ Badge
|
||||
FfzBadgeElement::FfzBadgeElement(const EmotePtr &data,
|
||||
MessageElementFlags flags_, QColor &color)
|
||||
: BadgeElement(data, flags_)
|
||||
{
|
||||
this->color = color;
|
||||
}
|
||||
|
||||
MessageLayoutElement *FfzBadgeElement::makeImageLayoutElement(
|
||||
const ImagePtr &image, const QSize &size)
|
||||
{
|
||||
auto element =
|
||||
(new ImageWithBackgroundLayoutElement(*this, image, size, this->color))
|
||||
->setLink(this->getLink());
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
// TEXT
|
||||
TextElement::TextElement(const QString &text, MessageElementFlags flags,
|
||||
const MessageColor &color, FontStyle style)
|
||||
|
||||
@@ -26,91 +26,99 @@ using ImagePtr = std::shared_ptr<Image>;
|
||||
struct Emote;
|
||||
using EmotePtr = std::shared_ptr<const Emote>;
|
||||
|
||||
enum class MessageElementFlag {
|
||||
None = 0,
|
||||
Misc = (1 << 0),
|
||||
Text = (1 << 1),
|
||||
enum class MessageElementFlag : int64_t {
|
||||
None = 0LL,
|
||||
Misc = (1LL << 0),
|
||||
Text = (1LL << 1),
|
||||
|
||||
Username = (1 << 2),
|
||||
Timestamp = (1 << 3),
|
||||
Username = (1LL << 2),
|
||||
Timestamp = (1LL << 3),
|
||||
|
||||
TwitchEmoteImage = (1 << 4),
|
||||
TwitchEmoteText = (1 << 5),
|
||||
TwitchEmoteImage = (1LL << 4),
|
||||
TwitchEmoteText = (1LL << 5),
|
||||
TwitchEmote = TwitchEmoteImage | TwitchEmoteText,
|
||||
BttvEmoteImage = (1 << 6),
|
||||
BttvEmoteText = (1 << 7),
|
||||
BttvEmoteImage = (1LL << 6),
|
||||
BttvEmoteText = (1LL << 7),
|
||||
BttvEmote = BttvEmoteImage | BttvEmoteText,
|
||||
|
||||
ChannelPointReward = (1 << 8),
|
||||
ChannelPointReward = (1LL << 8),
|
||||
ChannelPointRewardImage = ChannelPointReward | TwitchEmoteImage,
|
||||
|
||||
FfzEmoteImage = (1 << 10),
|
||||
FfzEmoteText = (1 << 11),
|
||||
FfzEmoteImage = (1LL << 10),
|
||||
FfzEmoteText = (1LL << 11),
|
||||
FfzEmote = FfzEmoteImage | FfzEmoteText,
|
||||
EmoteImages = TwitchEmoteImage | BttvEmoteImage | FfzEmoteImage,
|
||||
EmoteText = TwitchEmoteText | BttvEmoteText | FfzEmoteText,
|
||||
|
||||
BitsStatic = (1 << 12),
|
||||
BitsAnimated = (1 << 13),
|
||||
BitsStatic = (1LL << 12),
|
||||
BitsAnimated = (1LL << 13),
|
||||
|
||||
// Slot 1: Twitch
|
||||
// - Staff badge
|
||||
// - Admin badge
|
||||
// - Global Moderator badge
|
||||
BadgeGlobalAuthority = (1 << 14),
|
||||
BadgeGlobalAuthority = (1LL << 14),
|
||||
|
||||
// Slot 2: Twitch
|
||||
// - Moderator badge
|
||||
// - Broadcaster badge
|
||||
BadgeChannelAuthority = (1 << 15),
|
||||
BadgeChannelAuthority = (1LL << 15),
|
||||
|
||||
// Slot 3: Twitch
|
||||
// - Subscription badges
|
||||
BadgeSubscription = (1 << 16),
|
||||
BadgeSubscription = (1LL << 16),
|
||||
|
||||
// Slot 4: Twitch
|
||||
// - Turbo badge
|
||||
// - Prime badge
|
||||
// - Bit badges
|
||||
// - Game badges
|
||||
BadgeVanity = (1 << 17),
|
||||
BadgeVanity = (1LL << 17),
|
||||
|
||||
// Slot 5: Chatterino
|
||||
// - Chatterino developer badge
|
||||
// - Chatterino donator badge
|
||||
// - Chatterino top donator badge
|
||||
BadgeChatterino = (1 << 18),
|
||||
BadgeChatterino = (1LL << 18),
|
||||
|
||||
// Slot 6: FrankerFaceZ
|
||||
// - FFZ developer badge
|
||||
// - FFZ bot badge
|
||||
// - FFZ donator badge
|
||||
BadgeFfz = (1LL << 32),
|
||||
|
||||
Badges = BadgeGlobalAuthority | BadgeChannelAuthority | BadgeSubscription |
|
||||
BadgeVanity | BadgeChatterino,
|
||||
BadgeVanity | BadgeChatterino | BadgeFfz,
|
||||
|
||||
ChannelName = (1 << 19),
|
||||
ChannelName = (1LL << 19),
|
||||
|
||||
BitsAmount = (1 << 20),
|
||||
BitsAmount = (1LL << 20),
|
||||
|
||||
ModeratorTools = (1 << 21),
|
||||
ModeratorTools = (1LL << 21),
|
||||
|
||||
EmojiImage = (1 << 23),
|
||||
EmojiText = (1 << 24),
|
||||
EmojiImage = (1LL << 23),
|
||||
EmojiText = (1LL << 24),
|
||||
EmojiAll = EmojiImage | EmojiText,
|
||||
|
||||
AlwaysShow = (1 << 25),
|
||||
AlwaysShow = (1LL << 25),
|
||||
|
||||
// used in the ChannelView class to make the collapse buttons visible if
|
||||
// needed
|
||||
Collapsed = (1 << 26),
|
||||
Collapsed = (1LL << 26),
|
||||
|
||||
// used for dynamic bold usernames
|
||||
BoldUsername = (1 << 27),
|
||||
NonBoldUsername = (1 << 28),
|
||||
BoldUsername = (1LL << 27),
|
||||
NonBoldUsername = (1LL << 28),
|
||||
|
||||
// for links
|
||||
LowercaseLink = (1 << 29),
|
||||
OriginalLink = (1 << 30),
|
||||
LowercaseLink = (1LL << 29),
|
||||
OriginalLink = (1LL << 30),
|
||||
|
||||
// ZeroWidthEmotes are emotes that are supposed to overlay over any pre-existing emotes
|
||||
// e.g. BTTV's SoSnowy during christmas season
|
||||
ZeroWidthEmote = (1 << 31),
|
||||
ZeroWidthEmote = (1LL << 31),
|
||||
|
||||
// (1LL << 32) is used by BadgeFfz, it is next to BadgeChatterino
|
||||
|
||||
Default = Timestamp | Badges | Username | BitsStatic | FfzEmoteImage |
|
||||
BttvEmoteImage | TwitchEmoteImage | BitsAmount | Text |
|
||||
@@ -267,6 +275,18 @@ protected:
|
||||
const QSize &size) override;
|
||||
};
|
||||
|
||||
class FfzBadgeElement : public BadgeElement
|
||||
{
|
||||
public:
|
||||
FfzBadgeElement(const EmotePtr &data, MessageElementFlags flags_,
|
||||
QColor &color);
|
||||
|
||||
protected:
|
||||
MessageLayoutElement *makeImageLayoutElement(const ImagePtr &image,
|
||||
const QSize &size) override;
|
||||
QColor color;
|
||||
};
|
||||
|
||||
// contains a text, formated depending on the preferences
|
||||
class TimestampElement : public MessageElement
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ struct Selection;
|
||||
struct MessageLayoutContainer;
|
||||
class MessageLayoutElement;
|
||||
|
||||
enum class MessageElementFlag;
|
||||
enum class MessageElementFlag : int64_t;
|
||||
using MessageElementFlags = FlagsEnum<MessageElementFlag>;
|
||||
|
||||
enum class MessageLayoutFlag : uint8_t {
|
||||
|
||||
Reference in New Issue
Block a user