From b4be7a4b1f6612becb9caa512772849fec1cb873 Mon Sep 17 00:00:00 2001 From: Ryan <59930937+1xelerate@users.noreply.github.com> Date: Sun, 31 Oct 2021 06:37:06 -0400 Subject: [PATCH] Fix underlying text from disabled emotes not being colorized after using /me (#3333) --- CHANGELOG.md | 1 + src/messages/MessageElement.cpp | 7 ++++--- src/messages/MessageElement.hpp | 3 ++- src/providers/twitch/TwitchMessageBuilder.cpp | 18 ++++++++++++------ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9f4b0e02..8fbd03419 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ - Bugfix: Fixed being unable to disable `First Message` highlights (#3293) - Bugfix: Fixed `First Message` custom sound not persisting through restart. (#3303) - Bugfix: Fixed `First Message` scrollbar highlights not being disabled. (#3325) +- Bugfix: Fixed underlying text from disabled emotes not being colorized properly. (#3333) - Dev: Add GitHub action to test builds without precompiled headers enabled. (#3327) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index f371fe500..e1edbcc0e 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -142,12 +142,13 @@ void ImageElement::addToContainer(MessageLayoutContainer &container, } // EMOTE -EmoteElement::EmoteElement(const EmotePtr &emote, MessageElementFlags flags) +EmoteElement::EmoteElement(const EmotePtr &emote, MessageElementFlags flags, + const MessageColor &textElementColor) : MessageElement(flags) , emote_(emote) { - this->textElement_.reset( - new TextElement(emote->getCopyString(), MessageElementFlag::Misc)); + this->textElement_.reset(new TextElement( + emote->getCopyString(), MessageElementFlag::Misc, textElementColor)); this->setTooltip(emote->tooltip.string); } diff --git a/src/messages/MessageElement.hpp b/src/messages/MessageElement.hpp index fb06b924f..295157e17 100644 --- a/src/messages/MessageElement.hpp +++ b/src/messages/MessageElement.hpp @@ -238,7 +238,8 @@ private: class EmoteElement : public MessageElement { public: - EmoteElement(const EmotePtr &data, MessageElementFlags flags_); + EmoteElement(const EmotePtr &data, MessageElementFlags flags_, + const MessageColor &textElementColor = MessageColor::Text); void addToContainer(MessageLayoutContainer &container, MessageElementFlags flags_) override; diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 337edb64c..a24b8320a 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -319,7 +319,9 @@ void TwitchMessageBuilder::addWords( { // This emote exists right at the start of the word! this->emplace(currentTwitchEmote.ptr, - MessageElementFlag::TwitchEmote); + MessageElementFlag::TwitchEmote, + this->textColor_); + auto len = currentTwitchEmote.name.string.length(); cursor += len; word = word.mid(len); @@ -1007,7 +1009,7 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name) if (emote) { - this->emplace(emote.get(), flags); + this->emplace(emote.get(), flags, this->textColor_); return Success; } @@ -1162,12 +1164,14 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string) if (cheerEmote.staticEmote) { this->emplace(cheerEmote.staticEmote, - MessageElementFlag::BitsStatic); + MessageElementFlag::BitsStatic, + this->textColor_); } if (cheerEmote.animatedEmote) { this->emplace(cheerEmote.animatedEmote, - MessageElementFlag::BitsAnimated); + MessageElementFlag::BitsAnimated, + this->textColor_); } if (cheerEmote.color != QColor()) { @@ -1195,12 +1199,14 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string) if (cheerEmote.staticEmote) { this->emplace(cheerEmote.staticEmote, - MessageElementFlag::BitsStatic); + MessageElementFlag::BitsStatic, + this->textColor_); } if (cheerEmote.animatedEmote) { this->emplace(cheerEmote.animatedEmote, - MessageElementFlag::BitsAnimated); + MessageElementFlag::BitsAnimated, + this->textColor_); } if (cheerEmote.color != QColor()) {