2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
#define GIF_FRAME_LENGTH 33
|
|
|
|
|
2017-06-11 09:31:45 +02:00
|
|
|
#include "concurrentmap.hpp"
|
2017-06-26 16:41:20 +02:00
|
|
|
#include "emojis.hpp"
|
2017-06-11 09:31:45 +02:00
|
|
|
#include "messages/lazyloadedimage.hpp"
|
|
|
|
#include "twitch/emotevalue.hpp"
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
#include <QMap>
|
|
|
|
#include <QMutex>
|
2017-06-26 16:41:20 +02:00
|
|
|
#include <QString>
|
2017-04-12 17:46:44 +02:00
|
|
|
#include <QTimer>
|
|
|
|
#include <boost/signals2.hpp>
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
class WindowManager;
|
|
|
|
class Resources;
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
class EmoteManager
|
|
|
|
{
|
|
|
|
public:
|
2017-06-13 21:13:58 +02:00
|
|
|
using FFZEmoteMap = ConcurrentMap<QString, messages::LazyLoadedImage *>;
|
|
|
|
using BTTVEmoteMap = ConcurrentMap<QString, messages::LazyLoadedImage *>;
|
|
|
|
using ChatterinoEmoteMap = ConcurrentMap<QString, messages::LazyLoadedImage *>;
|
|
|
|
|
|
|
|
EmoteManager(WindowManager &_windowManager, Resources &_resources);
|
|
|
|
|
|
|
|
void loadGlobalEmotes();
|
|
|
|
|
|
|
|
void reloadBTTVChannelEmotes(const QString &channelName, BTTVEmoteMap &channelEmoteMap);
|
|
|
|
void reloadFFZChannelEmotes(const QString &channelName, FFZEmoteMap &channelEmoteMap);
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
ConcurrentMap<QString, twitch::EmoteValue *> &getTwitchEmotes();
|
2017-06-13 21:13:58 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> &getBTTVEmotes();
|
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> &getFFZEmotes();
|
2017-04-12 17:46:44 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> &getChatterinoEmotes();
|
2017-06-13 21:13:58 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> &getBTTVChannelEmoteFromCaches();
|
|
|
|
ConcurrentMap<int, messages::LazyLoadedImage *> &getFFZChannelEmoteFromCaches();
|
2017-04-12 17:46:44 +02:00
|
|
|
ConcurrentMap<long, messages::LazyLoadedImage *> &getTwitchEmoteFromCache();
|
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> &getMiscImageFromCache();
|
|
|
|
|
|
|
|
messages::LazyLoadedImage *getCheerImage(long long int amount, bool animated);
|
|
|
|
messages::LazyLoadedImage *getCheerBadge(long long int amount);
|
|
|
|
|
|
|
|
messages::LazyLoadedImage *getTwitchEmoteById(const QString &name, long int id);
|
|
|
|
|
|
|
|
int getGeneration()
|
|
|
|
{
|
|
|
|
return _generation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void incGeneration()
|
|
|
|
{
|
|
|
|
_generation++;
|
|
|
|
}
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
boost::signals2::signal<void()> &getGifUpdateSignal();
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
private:
|
2017-06-13 21:13:58 +02:00
|
|
|
WindowManager &windowManager;
|
|
|
|
Resources &resources;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-07-02 17:37:17 +02:00
|
|
|
/// Emojis
|
|
|
|
// shortCodeToEmoji maps strings like "sunglasses" to its emoji
|
|
|
|
QMap<QString, EmojiData> emojiShortCodeToEmoji;
|
2017-06-26 16:41:20 +02:00
|
|
|
|
2017-07-02 17:37:17 +02:00
|
|
|
// Maps the first character of the emoji unicode string to a vector of possible emojis
|
|
|
|
QMap<QChar, QVector<EmojiData>> emojiFirstByte;
|
2017-06-26 16:41:20 +02:00
|
|
|
|
2017-07-02 17:37:17 +02:00
|
|
|
// url Emoji-one image
|
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> emojiCache;
|
2017-06-26 16:41:20 +02:00
|
|
|
|
|
|
|
void loadEmojis();
|
|
|
|
|
|
|
|
public:
|
2017-07-02 17:37:17 +02:00
|
|
|
void parseEmojis(std::vector<std::tuple<messages::LazyLoadedImage *, QString>> &parsedWords,
|
2017-06-26 16:41:20 +02:00
|
|
|
const QString &text);
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
private:
|
2017-07-02 17:37:17 +02:00
|
|
|
/// Twitch emotes
|
2017-04-12 17:46:44 +02:00
|
|
|
ConcurrentMap<QString, twitch::EmoteValue *> _twitchEmotes;
|
2017-06-26 16:41:20 +02:00
|
|
|
ConcurrentMap<long, messages::LazyLoadedImage *> _twitchEmoteFromCache;
|
|
|
|
|
2017-07-02 17:37:17 +02:00
|
|
|
/// BTTV emotes
|
2017-06-26 16:41:20 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> bttvChannelEmotes;
|
2017-04-12 17:46:44 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> _bttvEmotes;
|
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> _bttvChannelEmoteFromCaches;
|
2017-06-26 16:41:20 +02:00
|
|
|
|
|
|
|
void loadBTTVEmotes();
|
|
|
|
|
2017-07-02 17:37:17 +02:00
|
|
|
/// FFZ emotes
|
2017-06-26 16:41:20 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> ffzChannelEmotes;
|
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> _ffzEmotes;
|
2017-04-12 17:46:44 +02:00
|
|
|
ConcurrentMap<int, messages::LazyLoadedImage *> _ffzChannelEmoteFromCaches;
|
2017-06-26 16:41:20 +02:00
|
|
|
|
|
|
|
void loadFFZEmotes();
|
|
|
|
|
2017-07-02 17:37:17 +02:00
|
|
|
/// Chatterino emotes
|
2017-06-26 16:41:20 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> _chatterinoEmotes;
|
|
|
|
|
|
|
|
// ???
|
2017-04-12 17:46:44 +02:00
|
|
|
ConcurrentMap<QString, messages::LazyLoadedImage *> _miscImageFromCache;
|
|
|
|
|
2017-05-27 16:16:39 +02:00
|
|
|
boost::signals2::signal<void()> _gifUpdateTimerSignal;
|
2017-04-12 17:46:44 +02:00
|
|
|
QTimer _gifUpdateTimer;
|
2017-06-13 21:13:58 +02:00
|
|
|
bool _gifUpdateTimerInitiated = false;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
int _generation = 0;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
// methods
|
|
|
|
static QString getTwitchEmoteLink(long id, qreal &scale);
|
|
|
|
};
|
2017-05-27 16:16:39 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace chatterino
|