From c3d61ad77b00f87309559840a497e0d4824ff7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Sun, 25 Apr 2021 14:37:19 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 1 + src/messages/MessageElement.hpp | 39 +++++++++++++---------- src/providers/twitch/TwitchBadge.cpp | 5 +++ src/singletons/Settings.hpp | 2 ++ src/singletons/WindowManager.cpp | 3 ++ src/widgets/settingspages/GeneralPage.cpp | 15 ++++----- 6 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 948ed0eb..df17e89f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 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: Fixed visual glitch with smooth scrolling. (#2084) diff --git a/src/messages/MessageElement.hpp b/src/messages/MessageElement.hpp index 48f6cdf4..bb0b6048 100644 --- a/src/messages/MessageElement.hpp +++ b/src/messages/MessageElement.hpp @@ -44,58 +44,65 @@ enum class MessageElementFlag : int64_t { ChannelPointReward = (1LL << 8), ChannelPointRewardImage = ChannelPointReward | TwitchEmoteImage, - FfzEmoteImage = (1LL << 10), - FfzEmoteText = (1LL << 11), + FfzEmoteImage = (1LL << 9), + FfzEmoteText = (1LL << 10), FfzEmote = FfzEmoteImage | FfzEmoteText, EmoteImages = TwitchEmoteImage | BttvEmoteImage | FfzEmoteImage, EmoteText = TwitchEmoteText | BttvEmoteText | FfzEmoteText, - BitsStatic = (1LL << 12), - BitsAnimated = (1LL << 13), + BitsStatic = (1LL << 11), + BitsAnimated = (1LL << 12), // Slot 1: Twitch // - Staff badge // - Admin badge // - Global Moderator badge - BadgeGlobalAuthority = (1LL << 14), + BadgeGlobalAuthority = (1LL << 13), // Slot 2: Twitch + // - Predictions badge + BadgePredictions = (1LL << 14), + + // Slot 3: Twitch // - VIP badge // - Moderator badge // - Broadcaster badge BadgeChannelAuthority = (1LL << 15), - // Slot 3: Twitch + // Slot 4: Twitch // - Subscription badges BadgeSubscription = (1LL << 16), - // Slot 4: Twitch + // Slot 5: Twitch // - Turbo badge // - Prime badge // - Bit badges // - Game badges BadgeVanity = (1LL << 17), - // Slot 5: Chatterino + // Slot 6: Chatterino // - Chatterino developer badge + // - Chatterino contributor badge // - Chatterino donator badge // - Chatterino top donator badge + // - Chatterino special pepe badge + // - Chatterino gnome badge BadgeChatterino = (1LL << 18), - // Slot 6: FrankerFaceZ + // Slot 7: FrankerFaceZ // - FFZ developer badge // - FFZ bot badge // - FFZ donator badge - BadgeFfz = (1LL << 32), + BadgeFfz = (1LL << 19), - Badges = BadgeGlobalAuthority | BadgeChannelAuthority | BadgeSubscription | - BadgeVanity | BadgeChatterino | BadgeFfz, + Badges = BadgeGlobalAuthority | BadgePredictions | BadgeChannelAuthority | + 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), EmojiText = (1LL << 24), @@ -119,8 +126,6 @@ enum class MessageElementFlag : int64_t { // e.g. BTTV's SoSnowy during christmas season ZeroWidthEmote = (1LL << 31), - // (1LL << 32) is used by BadgeFfz, it is next to BadgeChatterino - Default = Timestamp | Badges | Username | BitsStatic | FfzEmoteImage | BttvEmoteImage | TwitchEmoteImage | BitsAmount | Text | AlwaysShow, diff --git a/src/providers/twitch/TwitchBadge.cpp b/src/providers/twitch/TwitchBadge.cpp index 699e4b87..b48d3cb7 100644 --- a/src/providers/twitch/TwitchBadge.cpp +++ b/src/providers/twitch/TwitchBadge.cpp @@ -7,6 +7,7 @@ namespace chatterino { // set of badge IDs that should be given specific flags. // vanity flag is left out on purpose as it is our default flag const QSet globalAuthority{"staff", "admin", "global_mod"}; +const QSet predictions{"predictions"}; const QSet channelAuthority{"moderator", "vip", "broadcaster"}; const QSet subBadges{"subscriber", "founder"}; @@ -18,6 +19,10 @@ Badge::Badge(QString key, QString value) { this->flag_ = MessageElementFlag::BadgeGlobalAuthority; } + else if (predictions.contains(this->key_)) + { + this->flag_ = MessageElementFlag::BadgePredictions; + } else if (channelAuthority.contains(this->key_)) { this->flag_ = MessageElementFlag::BadgeChannelAuthority; diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index a8f6fc7d..2283135c 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -122,6 +122,8 @@ public: // Badges BoolSetting showBadgesGlobalAuthority = { "/appearance/badges/GlobalAuthority", true}; + BoolSetting showBadgesPredictions = {"/appearance/badges/predictions", + true}; BoolSetting showBadgesChannelAuthority = { "/appearance/badges/ChannelAuthority", true}; BoolSetting showBadgesSubscription = {"/appearance/badges/subscription", diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 51420927..8492ca0c 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -104,6 +104,7 @@ WindowManager::WindowManager() this->wordFlagsListener_.addSetting(settings->showTimestamps); this->wordFlagsListener_.addSetting(settings->showBadgesGlobalAuthority); + this->wordFlagsListener_.addSetting(settings->showBadgesPredictions); this->wordFlagsListener_.addSetting(settings->showBadgesChannelAuthority); this->wordFlagsListener_.addSetting(settings->showBadgesSubscription); this->wordFlagsListener_.addSetting(settings->showBadgesVanity); @@ -167,6 +168,8 @@ void WindowManager::updateWordTypeMask() // badges flags.set(settings->showBadgesGlobalAuthority ? MEF::BadgeGlobalAuthority : MEF::None); + flags.set(settings->showBadgesPredictions ? MEF::BadgePredictions + : MEF::None); flags.set(settings->showBadgesChannelAuthority ? MEF::BadgeChannelAuthority : MEF::None); flags.set(settings->showBadgesSubscription ? MEF::BadgeSubscription diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 1e55b238..7c7c1ad2 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -545,16 +545,15 @@ void GeneralPage::initLayout(GeneralPageView &layout) }); layout.addSubtitle("Visible badges"); - layout.addCheckbox("Authority (staff, admin)", - getSettings()->showBadgesGlobalAuthority); + layout.addCheckbox("Authority (staff, admin)", s.showBadgesGlobalAuthority); + layout.addCheckbox("Predictions", s.showBadgesPredictions); layout.addCheckbox("Channel (broadcaster, moderator)", - getSettings()->showBadgesChannelAuthority); - layout.addCheckbox("Subscriber ", getSettings()->showBadgesSubscription); - layout.addCheckbox("Vanity (prime, bits, subgifter)", - getSettings()->showBadgesVanity); - layout.addCheckbox("Chatterino", getSettings()->showBadgesChatterino); + s.showBadgesChannelAuthority); + layout.addCheckbox("Subscriber ", s.showBadgesSubscription); + layout.addCheckbox("Vanity (prime, bits, subgifter)", s.showBadgesVanity); + layout.addCheckbox("Chatterino", s.showBadgesChatterino); layout.addCheckbox("FrankerFaceZ (Bot, FFZ Supporter, FFZ Developer)", - getSettings()->showBadgesFfz); + s.showBadgesFfz); layout.addSubtitle("Miscellaneous");