diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index 871bbfffe..e5920fb6f 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -138,10 +138,7 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container, if (image->isEmpty()) return; - auto emoteScale = - this->getFlags().hasAny(MessageElementFlag::Badges) - ? 1 - : getSettings()->emoteScale.getValue(); + auto emoteScale = getSettings()->emoteScale.getValue(); auto size = QSize(int(container.getScale() * image->width() * emoteScale), @@ -161,6 +158,31 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container, } } +// BADGE +BadgeElement::BadgeElement(const EmotePtr &emote, MessageElementFlags flags) + : MessageElement(flags) + , emote_(emote) +{ + this->setTooltip(emote->tooltip.string); +} + +void BadgeElement::addToContainer(MessageLayoutContainer &container, + MessageElementFlags flags) +{ + if (flags.hasAny(this->getFlags())) + { + auto image = this->emote_->images.getImage(container.getScale()); + if (image->isEmpty()) + return; + + auto size = QSize(int(container.getScale() * image->width()), + int(container.getScale() * image->height())); + + container.addElement((new ImageLayoutElement(*this, image, size)) + ->setLink(this->getLink())); + } +} + // TEXT TextElement::TextElement(const QString &text, MessageElementFlags flags, const MessageColor &color, FontStyle style) diff --git a/src/messages/MessageElement.hpp b/src/messages/MessageElement.hpp index a418347b3..95c7090d4 100644 --- a/src/messages/MessageElement.hpp +++ b/src/messages/MessageElement.hpp @@ -42,6 +42,7 @@ enum class MessageElementFlag { FfzEmoteText = (1 << 11), FfzEmote = FfzEmoteImage | FfzEmoteText, EmoteImages = TwitchEmoteImage | BttvEmoteImage | FfzEmoteImage, + EmoteText = TwitchEmoteText | BttvEmoteText | FfzEmoteText, BitsStatic = (1 << 12), BitsAnimated = (1 << 13), @@ -213,6 +214,18 @@ private: EmotePtr emote_; }; +class BadgeElement : public MessageElement +{ +public: + BadgeElement(const EmotePtr &data, MessageElementFlags flags_); + + void addToContainer(MessageLayoutContainer &container, + MessageElementFlags flags_) override; + +private: + EmotePtr emote_; +}; + // contains a text, formated depending on the preferences class TimestampElement : public MessageElement { diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index ed9923215..b68eb8d8a 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -1026,7 +1026,7 @@ void TwitchMessageBuilder::appendTwitchBadges() if (const auto &_badge = this->twitchChannel->twitchBadge( "bits", cheerAmount)) { - this->emplace( + this->emplace( _badge.get(), MessageElementFlag::BadgeVanity) ->setTooltip(tooltip); continue; @@ -1041,7 +1041,7 @@ void TwitchMessageBuilder::appendTwitchBadges() if (auto _badge = this->twitchChannel->globalTwitchBadges().badge( "bits", cheerAmount)) { - this->emplace(_badge.get(), + this->emplace(_badge.get(), MessageElementFlag::BadgeVanity) ->setTooltip(tooltip); } @@ -1071,7 +1071,7 @@ void TwitchMessageBuilder::appendTwitchBadges() { if (auto customModBadge = this->twitchChannel->ffzCustomModBadge()) { - this->emplace( + this->emplace( customModBadge.get(), MessageElementFlag::BadgeChannelAuthority) ->setTooltip((*customModBadge)->tooltip.string); @@ -1131,7 +1131,7 @@ void TwitchMessageBuilder::appendTwitchBadges() if (auto badgeEmote = this->twitchChannel->twitchBadge( "subscriber", badge.mid(11))) { - this->emplace( + this->emplace( badgeEmote.get(), MessageElementFlag::BadgeSubscription) ->setTooltip((*badgeEmote)->tooltip.string); continue; @@ -1152,7 +1152,7 @@ void TwitchMessageBuilder::appendTwitchBadges() if (auto badgeEmote = this->twitchChannel->twitchBadge(splits[0], splits[1])) { - this->emplace(badgeEmote.get(), + this->emplace(badgeEmote.get(), MessageElementFlag::BadgeVanity) ->setTooltip((*badgeEmote)->tooltip.string); continue; @@ -1160,7 +1160,7 @@ void TwitchMessageBuilder::appendTwitchBadges() if (auto _badge = this->twitchChannel->globalTwitchBadges().badge( splits[0], splits[1])) { - this->emplace(_badge.get(), + this->emplace(_badge.get(), MessageElementFlag::BadgeVanity) ->setTooltip((*_badge)->tooltip.string); continue; @@ -1175,7 +1175,7 @@ void TwitchMessageBuilder::appendChatterinoBadges() getApp()->chatterinoBadges->getBadge({this->userName}); if (chatterinoBadgePtr) { - this->emplace(*chatterinoBadgePtr, + this->emplace(*chatterinoBadgePtr, MessageElementFlag::BadgeChatterino); } } diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index e4b30de67..602232371 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -105,10 +105,7 @@ public: /// Emotes BoolSetting scaleEmotesByLineHeight = {"/emotes/scaleEmotesByLineHeight", false}; - BoolSetting enableTwitchEmotes = {"/emotes/enableTwitchEmotes", true}; - BoolSetting enableBttvEmotes = {"/emotes/enableBTTVEmotes", true}; - BoolSetting enableFfzEmotes = {"/emotes/enableFFZEmotes", true}; - BoolSetting enableEmojis = {"/emotes/enableEmojis", true}; + BoolSetting enableEmoteImages = {"/emotes/enableEmoteImages", true}; BoolSetting animateEmotes = {"/emotes/enableGifAnimations", true}; FloatSetting emoteScale = {"/emotes/scale", 1.f}; diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 982484e6e..59c84c7e3 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -76,10 +76,7 @@ WindowManager::WindowManager() this->wordFlagsListener_.addSetting(settings->showBadgesSubscription); this->wordFlagsListener_.addSetting(settings->showBadgesVanity); this->wordFlagsListener_.addSetting(settings->showBadgesChatterino); - this->wordFlagsListener_.addSetting(settings->enableBttvEmotes); - this->wordFlagsListener_.addSetting(settings->enableEmojis); - this->wordFlagsListener_.addSetting(settings->enableFfzEmotes); - this->wordFlagsListener_.addSetting(settings->enableTwitchEmotes); + this->wordFlagsListener_.addSetting(settings->enableEmoteImages); this->wordFlagsListener_.addSetting(settings->boldUsernames); this->wordFlagsListener_.addSetting(settings->lowercaseDomains); this->wordFlagsListener_.setCB([this] { @@ -115,13 +112,12 @@ void WindowManager::updateWordTypeMask() } // emotes - flags.set(settings->enableTwitchEmotes ? MEF::TwitchEmoteImage - : MEF::TwitchEmoteText); - flags.set(settings->enableFfzEmotes ? MEF::FfzEmoteImage - : MEF::FfzEmoteText); - flags.set(settings->enableBttvEmotes ? MEF::BttvEmoteImage - : MEF::BttvEmoteText); - flags.set(settings->enableEmojis ? MEF::EmojiImage : MEF::EmojiText); + if (settings->enableEmoteImages) + { + flags.set(MEF::EmoteImages); + } + flags.set(MEF::EmoteText); + flags.set(MEF::EmojiText); // bits flags.set(MEF::BitsAmount); diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 32414a7f9..d1e26d1f8 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -228,6 +228,7 @@ void GeneralPage::initLayout(SettingsLayout &layout) [](auto args) { return fuzzyToFloat(args.value, 1.f); }); layout.addCheckbox("Gif animations", s.animateEmotes); layout.addCheckbox("Animate only when focused", s.animationsWhenFocused); + layout.addCheckbox("Emote images", s.enableEmoteImages); layout.addDropdown("Emoji set", {"EmojiOne 2", "EmojiOne 3", "Twitter", "Facebook", "Apple", "Google", "Messenger"},