mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
commit
b09e87f837
3 changed files with 26 additions and 23 deletions
|
@ -174,10 +174,17 @@ MessagePtr TwitchMessageBuilder::build()
|
||||||
if (iterator != this->tags.end())
|
if (iterator != this->tags.end())
|
||||||
{
|
{
|
||||||
QStringList emoteString = iterator.value().toString().split('/');
|
QStringList emoteString = iterator.value().toString().split('/');
|
||||||
|
std::vector<int> correctPositions;
|
||||||
|
for (int i = 0; i < this->originalMessage_.size(); ++i)
|
||||||
|
{
|
||||||
|
if (!this->originalMessage_.at(i).isLowSurrogate())
|
||||||
|
{
|
||||||
|
correctPositions.push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (QString emote : emoteString)
|
for (QString emote : emoteString)
|
||||||
{
|
{
|
||||||
this->appendTwitchEmote(emote, twitchEmotes);
|
this->appendTwitchEmote(emote, twitchEmotes, correctPositions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
@ -452,17 +459,7 @@ void TwitchMessageBuilder::addWords(
|
||||||
variant);
|
variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < word.size(); j++)
|
i += word.size() + 1;
|
||||||
{
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if (word.at(j).isHighSurrogate())
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,7 +932,8 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg)
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendTwitchEmote(
|
void TwitchMessageBuilder::appendTwitchEmote(
|
||||||
const QString &emote,
|
const QString &emote,
|
||||||
std::vector<std::tuple<int, EmotePtr, EmoteName>> &vec)
|
std::vector<std::tuple<int, EmotePtr, EmoteName>> &vec,
|
||||||
|
std::vector<int> &correctPositions)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
if (!emote.contains(':'))
|
if (!emote.contains(':'))
|
||||||
|
@ -963,8 +961,8 @@ void TwitchMessageBuilder::appendTwitchEmote(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto start = coords.at(0).toInt();
|
auto start = correctPositions[coords.at(0).toInt()];
|
||||||
auto end = coords.at(1).toInt();
|
auto end = correctPositions[coords.at(1).toInt()];
|
||||||
|
|
||||||
if (start >= end || start < 0 || end > this->originalMessage_.length())
|
if (start >= end || start < 0 || end > this->originalMessage_.length())
|
||||||
{
|
{
|
||||||
|
@ -987,19 +985,24 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
||||||
{
|
{
|
||||||
// Special channels, like /whispers and /channels return here
|
// Special channels, like /whispers and /channels return here
|
||||||
// This means they will not render any BTTV or FFZ emotes
|
// This means they will not render any BTTV or FFZ emotes
|
||||||
if (this->twitchChannel == nullptr) {
|
if (this->twitchChannel == nullptr)
|
||||||
|
{
|
||||||
auto *app = getApp();
|
auto *app = getApp();
|
||||||
const auto &bttvemotes = app->twitch.server->getBttvEmotes();
|
const auto &bttvemotes = app->twitch.server->getBttvEmotes();
|
||||||
const auto &ffzemotes = app->twitch.server->getFfzEmotes();
|
const auto &ffzemotes = app->twitch.server->getFfzEmotes();
|
||||||
auto flags = MessageElementFlags();
|
auto flags = MessageElementFlags();
|
||||||
auto emote = boost::optional<EmotePtr>{};
|
auto emote = boost::optional<EmotePtr>{};
|
||||||
{ // bttv/ffz emote
|
{ // bttv/ffz emote
|
||||||
if ((emote = bttvemotes.emote(name))) {
|
if ((emote = bttvemotes.emote(name)))
|
||||||
|
{
|
||||||
flags = MessageElementFlag::BttvEmote;
|
flags = MessageElementFlag::BttvEmote;
|
||||||
} else if ((emote = ffzemotes.emote(name))) {
|
}
|
||||||
|
else if ((emote = ffzemotes.emote(name)))
|
||||||
|
{
|
||||||
flags = MessageElementFlag::FfzEmote;
|
flags = MessageElementFlag::FfzEmote;
|
||||||
}
|
}
|
||||||
if (emote) {
|
if (emote)
|
||||||
|
{
|
||||||
this->emplace<EmoteElement>(emote.get(), flags);
|
this->emplace<EmoteElement>(emote.get(), flags);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,8 @@ private:
|
||||||
void appendUsername();
|
void appendUsername();
|
||||||
void parseHighlights(bool isPastMsg);
|
void parseHighlights(bool isPastMsg);
|
||||||
|
|
||||||
void appendTwitchEmote(
|
void appendTwitchEmote(const QString &emote,
|
||||||
const QString &emote,
|
std::vector<std::tuple<int, EmotePtr, EmoteName>> &vec, std::vector<int> &correctPositions);
|
||||||
std::vector<std::tuple<int, EmotePtr, EmoteName>> &vec);
|
|
||||||
Outcome tryAppendEmote(const EmoteName &name);
|
Outcome tryAppendEmote(const EmoteName &name);
|
||||||
|
|
||||||
void addWords(
|
void addWords(
|
||||||
|
|
|
@ -108,6 +108,7 @@ void IgnoresPage::onShow()
|
||||||
{
|
{
|
||||||
users << ignoredUser.name;
|
users << ignoredUser.name;
|
||||||
}
|
}
|
||||||
|
users.sort(Qt::CaseInsensitive);
|
||||||
this->userListModel_.setStringList(users);
|
this->userListModel_.setStringList(users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue