hardcoded list of BTTV's christmas emotes

This commit is contained in:
Rasmus Karlsson 2019-12-05 20:10:56 -08:00
parent bcc53c9aa7
commit 2d3fb8950e
3 changed files with 28 additions and 3 deletions

View file

@ -103,6 +103,10 @@ enum class MessageElementFlag {
LowercaseLink = (1 << 29),
OriginalLink = (1 << 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),
Default = Timestamp | Badges | Username | BitsStatic | FfzEmoteImage |
BttvEmoteImage | TwitchEmoteImage | BitsAmount | Text |
AlwaysShow,

View file

@ -115,15 +115,27 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element,
// update line height
this->lineHeight_ = std::max(this->lineHeight_, newLineHeight);
auto xOffset = 0;
if (element->getCreator().getFlags().has(
MessageElementFlag::ZeroWidthEmote))
{
xOffset -= element->getRect().width() + this->spaceWidth_;
}
// set move element
element->setPosition(
QPoint(this->currentX_, this->currentY_ - element->getRect().height()));
element->setPosition(QPoint(this->currentX_ + xOffset,
this->currentY_ - element->getRect().height()));
// add element
this->elements_.push_back(std::unique_ptr<MessageLayoutElement>(element));
// set current x
if (!element->getCreator().getFlags().has(
MessageElementFlag::ZeroWidthEmote))
{
this->currentX_ += element->getRect().width();
}
if (element->hasTrailingSpace())
{

View file

@ -28,6 +28,10 @@
namespace {
const QStringList zeroWidthEmotes{
"SoSnowy", "IceCold", "SantaHat", "TopHat", "ReinDeer", "CandyCane",
};
QColor getRandomColor(const QVariant &userId)
{
static const std::vector<QColor> twitchUsernameColors = {
@ -1162,6 +1166,11 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
else if ((emote = globalBttvEmotes.emote(name)))
{
flags = MessageElementFlag::BttvEmote;
if (zeroWidthEmotes.contains(name.string))
{
flags.set(MessageElementFlag::ZeroWidthEmote);
}
}
if (emote)