From be898e88dd09d59d5b082270966137f94bbb9903 Mon Sep 17 00:00:00 2001 From: apa420 <17131426+apa420@users.noreply.github.com> Date: Sat, 21 Dec 2019 10:36:46 +0100 Subject: [PATCH] Add setting to stack bits (#1452) --- src/providers/twitch/TwitchMessageBuilder.cpp | 26 +++++++++++++++++++ src/providers/twitch/TwitchMessageBuilder.hpp | 1 + src/singletons/Settings.hpp | 2 ++ src/widgets/settingspages/GeneralPage.cpp | 1 + 4 files changed, 30 insertions(+) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 13785e173..b781061e7 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -1286,6 +1286,32 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string) int cheerValue = match.captured(1).toInt(); + if (getSettings()->stackBits) + { + if (this->bitsStacked) + { + return Success; + } + if (cheerEmote.staticEmote) + { + this->emplace(cheerEmote.staticEmote, + MessageElementFlag::BitsStatic); + } + if (cheerEmote.animatedEmote) + { + this->emplace(cheerEmote.animatedEmote, + MessageElementFlag::BitsAnimated); + } + if (cheerEmote.color != QColor()) + { + this->emplace(QString::number(this->bitsLeft), + MessageElementFlag::BitsAmount, + cheerEmote.color); + } + this->bitsStacked = true; + return Success; + } + if (this->bitsLeft >= cheerValue) { this->bitsLeft -= cheerValue; diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index b91f1a831..e85fce950 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -82,6 +82,7 @@ private: bool hasBits_ = false; QString bits; int bitsLeft; + bool bitsStacked = false; bool historicalMessage_ = false; QString userId_; diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 25e87a8b8..acdb495d1 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -120,6 +120,8 @@ public: QStringSetting emojiSet = {"/emotes/emojiSet", "EmojiOne 2"}; + BoolSetting stackBits = {"/emotes/stackBits", false}; + /// Links BoolSetting linksDoubleClickOnly = {"/links/doubleClickToOpen", false}; BoolSetting linkInfoTooltip = {"/links/linkInfoTooltip", false}; diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index e838c815f..0ffa1c8b5 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -391,6 +391,7 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addCheckbox("Animate", s.animateEmotes); layout.addCheckbox("Animate only when Chatterino is focused", s.animationsWhenFocused); + layout.addCheckbox("Stack bits", s.stackBits); layout.addDropdown( "Size", {"0.5x", "0.75x", "Default", "1.25x", "1.5x", "2x"}, s.emoteScale,