ChatWidgetView -> ChannelView, added Emote Picker
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
#include "twitchchannel.hpp"
|
||||
#include "emotemanager.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace chatterino {
|
||||
namespace twitch {
|
||||
|
||||
TwitchChannel::TwitchChannel(EmoteManager &emoteManager, IrcManager &ircManager,
|
||||
const QString &channelName, bool isSpecial)
|
||||
: emoteManager(emoteManager)
|
||||
, ircManager(ircManager)
|
||||
// , name(channelName)
|
||||
, bttvChannelEmotes(new EmoteMap)
|
||||
, ffzChannelEmotes(new EmoteMap)
|
||||
, subLink("https://www.twitch.tv/" + name + "/subscribe?ref=in_chat_subscriber_link")
|
||||
, channelLink("https://twitch.tv/" + name)
|
||||
, popoutPlayerLink("https://player.twitch.tv/?channel=" + name)
|
||||
, isLive(false)
|
||||
, isSpecial(isSpecial)
|
||||
{
|
||||
this->name = channelName;
|
||||
|
||||
qDebug() << "Open twitch channel:" << this->name;
|
||||
|
||||
if (!isSpecial) {
|
||||
this->reloadChannelEmotes();
|
||||
}
|
||||
}
|
||||
|
||||
bool TwitchChannel::isEmpty() const
|
||||
{
|
||||
return this->name.isEmpty();
|
||||
}
|
||||
|
||||
const QString &TwitchChannel::getSubLink() const
|
||||
{
|
||||
return this->subLink;
|
||||
}
|
||||
|
||||
bool TwitchChannel::canSendMessage() const
|
||||
{
|
||||
return !this->isEmpty() && !this->isSpecial;
|
||||
}
|
||||
|
||||
const QString &TwitchChannel::getChannelLink() const
|
||||
{
|
||||
return this->channelLink;
|
||||
}
|
||||
|
||||
const QString &TwitchChannel::getPopoutPlayerLink() const
|
||||
{
|
||||
return this->popoutPlayerLink;
|
||||
}
|
||||
|
||||
void TwitchChannel::setRoomID(std::string id)
|
||||
{
|
||||
this->roomID = id;
|
||||
this->roomIDchanged();
|
||||
}
|
||||
|
||||
void TwitchChannel::reloadChannelEmotes()
|
||||
{
|
||||
printf("[TwitchChannel:%s] Reloading channel emotes\n", qPrintable(this->name));
|
||||
|
||||
this->emoteManager.reloadBTTVChannelEmotes(this->name, this->bttvChannelEmotes);
|
||||
this->emoteManager.reloadFFZChannelEmotes(this->name, this->ffzChannelEmotes);
|
||||
}
|
||||
|
||||
void TwitchChannel::sendMessage(const QString &message)
|
||||
{
|
||||
qDebug() << "TwitchChannel send message: " << message;
|
||||
|
||||
// Do last message processing
|
||||
QString parsedMessage = this->emoteManager.replaceShortCodes(message);
|
||||
|
||||
this->ircManager.sendMessage(this->name, parsedMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "channel.hpp"
|
||||
#include "concurrentmap.hpp"
|
||||
#include "ircmanager.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace twitch {
|
||||
|
||||
class TwitchChannel : public Channel
|
||||
{
|
||||
public:
|
||||
explicit TwitchChannel(EmoteManager &emoteManager, IrcManager &ircManager,
|
||||
const QString &channelName, bool isSpecial = false);
|
||||
|
||||
void reloadChannelEmotes();
|
||||
|
||||
bool isEmpty() const override;
|
||||
bool canSendMessage() const override;
|
||||
void sendMessage(const QString &message) override;
|
||||
|
||||
const QString &getSubLink() const;
|
||||
const QString &getChannelLink() const;
|
||||
const QString &getPopoutPlayerLink() const;
|
||||
|
||||
void setRoomID(std::string id);
|
||||
boost::signals2::signal<void()> roomIDchanged;
|
||||
|
||||
std::string roomID;
|
||||
bool isLive;
|
||||
QString streamViewerCount;
|
||||
QString streamStatus;
|
||||
QString streamGame;
|
||||
QString streamUptime;
|
||||
|
||||
const std::shared_ptr<EmoteMap> bttvChannelEmotes;
|
||||
const std::shared_ptr<EmoteMap> ffzChannelEmotes;
|
||||
|
||||
private:
|
||||
EmoteManager &emoteManager;
|
||||
IrcManager &ircManager;
|
||||
|
||||
QString subLink;
|
||||
QString channelLink;
|
||||
QString popoutPlayerLink;
|
||||
bool isSpecial;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,13 @@ using namespace chatterino::messages;
|
||||
namespace chatterino {
|
||||
namespace twitch {
|
||||
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, Resources &_resources,
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(TwitchChannel *_channel, Resources &_resources,
|
||||
EmoteManager &_emoteManager,
|
||||
WindowManager &_windowManager,
|
||||
const Communi::IrcPrivateMessage *_ircMessage,
|
||||
const messages::MessageParseArgs &_args)
|
||||
: channel(_channel)
|
||||
, twitchChannel(_channel)
|
||||
, resources(_resources)
|
||||
, windowManager(_windowManager)
|
||||
, colorScheme(this->windowManager.colorScheme)
|
||||
@@ -249,7 +250,7 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||
// HighlightTab = false;
|
||||
// }
|
||||
|
||||
return this->build();
|
||||
return this->getMessage();
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::parseMessageID()
|
||||
@@ -264,11 +265,12 @@ void TwitchMessageBuilder::parseMessageID()
|
||||
void TwitchMessageBuilder::parseRoomID()
|
||||
{
|
||||
auto iterator = this->tags.find("room-id");
|
||||
|
||||
if (iterator != std::end(this->tags)) {
|
||||
this->roomID = iterator.value().toString().toStdString();
|
||||
|
||||
if (this->channel->roomID.empty()) {
|
||||
this->channel->roomID = this->roomID;
|
||||
if (this->twitchChannel->roomID.empty()) {
|
||||
this->twitchChannel->roomID = this->roomID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -503,13 +505,13 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||
if (emoteManager.bttvGlobalEmotes.tryGet(emoteString, emoteData)) {
|
||||
// BTTV Global Emote
|
||||
return this->appendEmote(emoteData);
|
||||
} else if (this->channel->bttvChannelEmotes.tryGet(emoteString, emoteData)) {
|
||||
} else if (this->twitchChannel->bttvChannelEmotes->tryGet(emoteString, emoteData)) {
|
||||
// BTTV Channel Emote
|
||||
return this->appendEmote(emoteData);
|
||||
} else if (emoteManager.ffzGlobalEmotes.tryGet(emoteString, emoteData)) {
|
||||
// FFZ Global Emote
|
||||
return this->appendEmote(emoteData);
|
||||
} else if (this->channel->ffzChannelEmotes.tryGet(emoteString, emoteData)) {
|
||||
} else if (this->twitchChannel->ffzChannelEmotes->tryGet(emoteString, emoteData)) {
|
||||
// FFZ Channel Emote
|
||||
return this->appendEmote(emoteData);
|
||||
} else if (emoteManager.getChatterinoEmotes().tryGet(emoteString, emoteData)) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "emotemanager.hpp"
|
||||
#include "messages/messagebuilder.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "twitch/twitchchannel.hpp"
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
@@ -26,12 +27,13 @@ public:
|
||||
|
||||
TwitchMessageBuilder() = delete;
|
||||
|
||||
explicit TwitchMessageBuilder(Channel *_channel, Resources &_resources,
|
||||
explicit TwitchMessageBuilder(TwitchChannel *_channel, Resources &_resources,
|
||||
EmoteManager &_emoteManager, WindowManager &_windowManager,
|
||||
const Communi::IrcPrivateMessage *_ircMessage,
|
||||
const messages::MessageParseArgs &_args);
|
||||
|
||||
Channel *channel;
|
||||
TwitchChannel *twitchChannel;
|
||||
Resources &resources;
|
||||
WindowManager &windowManager;
|
||||
ColorScheme &colorScheme;
|
||||
|
||||
Reference in New Issue
Block a user