Restore option to disable emote images

Condensed into a single option, which will disable/enable all emote and emoji images

Also moved badges into their own element
This commit is contained in:
Rasmus Karlsson 2019-06-22 14:34:54 +02:00
parent a34e3084df
commit 27114c5154
6 changed files with 55 additions and 26 deletions

View file

@ -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)

View file

@ -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
{

View file

@ -1026,7 +1026,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
if (const auto &_badge = this->twitchChannel->twitchBadge(
"bits", cheerAmount))
{
this->emplace<EmoteElement>(
this->emplace<BadgeElement>(
_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<EmoteElement>(_badge.get(),
this->emplace<BadgeElement>(_badge.get(),
MessageElementFlag::BadgeVanity)
->setTooltip(tooltip);
}
@ -1071,7 +1071,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
{
if (auto customModBadge = this->twitchChannel->ffzCustomModBadge())
{
this->emplace<EmoteElement>(
this->emplace<BadgeElement>(
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<EmoteElement>(
this->emplace<BadgeElement>(
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<EmoteElement>(badgeEmote.get(),
this->emplace<BadgeElement>(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<EmoteElement>(_badge.get(),
this->emplace<BadgeElement>(_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<EmoteElement>(*chatterinoBadgePtr,
this->emplace<BadgeElement>(*chatterinoBadgePtr,
MessageElementFlag::BadgeChatterino);
}
}

View file

@ -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};

View file

@ -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);

View file

@ -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"},