Add ability to hide Twitch Prediction badges (#2668)

We now properly categorize the Twitch `predictions` badges since they take up their own slot in Twitch web chat
This commit is contained in:
Paweł 2021-04-25 14:37:19 +02:00 committed by GitHub
parent 1ef2f17cd4
commit c3d61ad77b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 25 deletions

View file

@ -2,6 +2,7 @@
## Unversioned ## Unversioned
- Minor: Added a setting to hide Twitch Predictions badges. (#2668)
- Bugfix: Added missing Copy/Open link context menu entries to emotes in Emote Picker. (#2670) - Bugfix: Added missing Copy/Open link context menu entries to emotes in Emote Picker. (#2670)
- Bugfix: Fixed visual glitch with smooth scrolling. (#2084) - Bugfix: Fixed visual glitch with smooth scrolling. (#2084)

View file

@ -44,58 +44,65 @@ enum class MessageElementFlag : int64_t {
ChannelPointReward = (1LL << 8), ChannelPointReward = (1LL << 8),
ChannelPointRewardImage = ChannelPointReward | TwitchEmoteImage, ChannelPointRewardImage = ChannelPointReward | TwitchEmoteImage,
FfzEmoteImage = (1LL << 10), FfzEmoteImage = (1LL << 9),
FfzEmoteText = (1LL << 11), FfzEmoteText = (1LL << 10),
FfzEmote = FfzEmoteImage | FfzEmoteText, FfzEmote = FfzEmoteImage | FfzEmoteText,
EmoteImages = TwitchEmoteImage | BttvEmoteImage | FfzEmoteImage, EmoteImages = TwitchEmoteImage | BttvEmoteImage | FfzEmoteImage,
EmoteText = TwitchEmoteText | BttvEmoteText | FfzEmoteText, EmoteText = TwitchEmoteText | BttvEmoteText | FfzEmoteText,
BitsStatic = (1LL << 12), BitsStatic = (1LL << 11),
BitsAnimated = (1LL << 13), BitsAnimated = (1LL << 12),
// Slot 1: Twitch // Slot 1: Twitch
// - Staff badge // - Staff badge
// - Admin badge // - Admin badge
// - Global Moderator badge // - Global Moderator badge
BadgeGlobalAuthority = (1LL << 14), BadgeGlobalAuthority = (1LL << 13),
// Slot 2: Twitch // Slot 2: Twitch
// - Predictions badge
BadgePredictions = (1LL << 14),
// Slot 3: Twitch
// - VIP badge // - VIP badge
// - Moderator badge // - Moderator badge
// - Broadcaster badge // - Broadcaster badge
BadgeChannelAuthority = (1LL << 15), BadgeChannelAuthority = (1LL << 15),
// Slot 3: Twitch // Slot 4: Twitch
// - Subscription badges // - Subscription badges
BadgeSubscription = (1LL << 16), BadgeSubscription = (1LL << 16),
// Slot 4: Twitch // Slot 5: Twitch
// - Turbo badge // - Turbo badge
// - Prime badge // - Prime badge
// - Bit badges // - Bit badges
// - Game badges // - Game badges
BadgeVanity = (1LL << 17), BadgeVanity = (1LL << 17),
// Slot 5: Chatterino // Slot 6: Chatterino
// - Chatterino developer badge // - Chatterino developer badge
// - Chatterino contributor badge
// - Chatterino donator badge // - Chatterino donator badge
// - Chatterino top donator badge // - Chatterino top donator badge
// - Chatterino special pepe badge
// - Chatterino gnome badge
BadgeChatterino = (1LL << 18), BadgeChatterino = (1LL << 18),
// Slot 6: FrankerFaceZ // Slot 7: FrankerFaceZ
// - FFZ developer badge // - FFZ developer badge
// - FFZ bot badge // - FFZ bot badge
// - FFZ donator badge // - FFZ donator badge
BadgeFfz = (1LL << 32), BadgeFfz = (1LL << 19),
Badges = BadgeGlobalAuthority | BadgeChannelAuthority | BadgeSubscription | Badges = BadgeGlobalAuthority | BadgePredictions | BadgeChannelAuthority |
BadgeVanity | BadgeChatterino | BadgeFfz, BadgeSubscription | BadgeVanity | BadgeChatterino | BadgeFfz,
ChannelName = (1LL << 19), ChannelName = (1LL << 20),
BitsAmount = (1LL << 20), BitsAmount = (1LL << 21),
ModeratorTools = (1LL << 21), ModeratorTools = (1LL << 22),
EmojiImage = (1LL << 23), EmojiImage = (1LL << 23),
EmojiText = (1LL << 24), EmojiText = (1LL << 24),
@ -119,8 +126,6 @@ enum class MessageElementFlag : int64_t {
// e.g. BTTV's SoSnowy during christmas season // e.g. BTTV's SoSnowy during christmas season
ZeroWidthEmote = (1LL << 31), ZeroWidthEmote = (1LL << 31),
// (1LL << 32) is used by BadgeFfz, it is next to BadgeChatterino
Default = Timestamp | Badges | Username | BitsStatic | FfzEmoteImage | Default = Timestamp | Badges | Username | BitsStatic | FfzEmoteImage |
BttvEmoteImage | TwitchEmoteImage | BitsAmount | Text | BttvEmoteImage | TwitchEmoteImage | BitsAmount | Text |
AlwaysShow, AlwaysShow,

View file

@ -7,6 +7,7 @@ namespace chatterino {
// set of badge IDs that should be given specific flags. // set of badge IDs that should be given specific flags.
// vanity flag is left out on purpose as it is our default flag // vanity flag is left out on purpose as it is our default flag
const QSet<QString> globalAuthority{"staff", "admin", "global_mod"}; const QSet<QString> globalAuthority{"staff", "admin", "global_mod"};
const QSet<QString> predictions{"predictions"};
const QSet<QString> channelAuthority{"moderator", "vip", "broadcaster"}; const QSet<QString> channelAuthority{"moderator", "vip", "broadcaster"};
const QSet<QString> subBadges{"subscriber", "founder"}; const QSet<QString> subBadges{"subscriber", "founder"};
@ -18,6 +19,10 @@ Badge::Badge(QString key, QString value)
{ {
this->flag_ = MessageElementFlag::BadgeGlobalAuthority; this->flag_ = MessageElementFlag::BadgeGlobalAuthority;
} }
else if (predictions.contains(this->key_))
{
this->flag_ = MessageElementFlag::BadgePredictions;
}
else if (channelAuthority.contains(this->key_)) else if (channelAuthority.contains(this->key_))
{ {
this->flag_ = MessageElementFlag::BadgeChannelAuthority; this->flag_ = MessageElementFlag::BadgeChannelAuthority;

View file

@ -122,6 +122,8 @@ public:
// Badges // Badges
BoolSetting showBadgesGlobalAuthority = { BoolSetting showBadgesGlobalAuthority = {
"/appearance/badges/GlobalAuthority", true}; "/appearance/badges/GlobalAuthority", true};
BoolSetting showBadgesPredictions = {"/appearance/badges/predictions",
true};
BoolSetting showBadgesChannelAuthority = { BoolSetting showBadgesChannelAuthority = {
"/appearance/badges/ChannelAuthority", true}; "/appearance/badges/ChannelAuthority", true};
BoolSetting showBadgesSubscription = {"/appearance/badges/subscription", BoolSetting showBadgesSubscription = {"/appearance/badges/subscription",

View file

@ -104,6 +104,7 @@ WindowManager::WindowManager()
this->wordFlagsListener_.addSetting(settings->showTimestamps); this->wordFlagsListener_.addSetting(settings->showTimestamps);
this->wordFlagsListener_.addSetting(settings->showBadgesGlobalAuthority); this->wordFlagsListener_.addSetting(settings->showBadgesGlobalAuthority);
this->wordFlagsListener_.addSetting(settings->showBadgesPredictions);
this->wordFlagsListener_.addSetting(settings->showBadgesChannelAuthority); this->wordFlagsListener_.addSetting(settings->showBadgesChannelAuthority);
this->wordFlagsListener_.addSetting(settings->showBadgesSubscription); this->wordFlagsListener_.addSetting(settings->showBadgesSubscription);
this->wordFlagsListener_.addSetting(settings->showBadgesVanity); this->wordFlagsListener_.addSetting(settings->showBadgesVanity);
@ -167,6 +168,8 @@ void WindowManager::updateWordTypeMask()
// badges // badges
flags.set(settings->showBadgesGlobalAuthority ? MEF::BadgeGlobalAuthority flags.set(settings->showBadgesGlobalAuthority ? MEF::BadgeGlobalAuthority
: MEF::None); : MEF::None);
flags.set(settings->showBadgesPredictions ? MEF::BadgePredictions
: MEF::None);
flags.set(settings->showBadgesChannelAuthority ? MEF::BadgeChannelAuthority flags.set(settings->showBadgesChannelAuthority ? MEF::BadgeChannelAuthority
: MEF::None); : MEF::None);
flags.set(settings->showBadgesSubscription ? MEF::BadgeSubscription flags.set(settings->showBadgesSubscription ? MEF::BadgeSubscription

View file

@ -545,16 +545,15 @@ void GeneralPage::initLayout(GeneralPageView &layout)
}); });
layout.addSubtitle("Visible badges"); layout.addSubtitle("Visible badges");
layout.addCheckbox("Authority (staff, admin)", layout.addCheckbox("Authority (staff, admin)", s.showBadgesGlobalAuthority);
getSettings()->showBadgesGlobalAuthority); layout.addCheckbox("Predictions", s.showBadgesPredictions);
layout.addCheckbox("Channel (broadcaster, moderator)", layout.addCheckbox("Channel (broadcaster, moderator)",
getSettings()->showBadgesChannelAuthority); s.showBadgesChannelAuthority);
layout.addCheckbox("Subscriber ", getSettings()->showBadgesSubscription); layout.addCheckbox("Subscriber ", s.showBadgesSubscription);
layout.addCheckbox("Vanity (prime, bits, subgifter)", layout.addCheckbox("Vanity (prime, bits, subgifter)", s.showBadgesVanity);
getSettings()->showBadgesVanity); layout.addCheckbox("Chatterino", s.showBadgesChatterino);
layout.addCheckbox("Chatterino", getSettings()->showBadgesChatterino);
layout.addCheckbox("FrankerFaceZ (Bot, FFZ Supporter, FFZ Developer)", layout.addCheckbox("FrankerFaceZ (Bot, FFZ Supporter, FFZ Developer)",
getSettings()->showBadgesFfz); s.showBadgesFfz);
layout.addSubtitle("Miscellaneous"); layout.addSubtitle("Miscellaneous");