#pragma once #define GIF_FRAME_LENGTH 33 #include "concurrentmap.hpp" #include "emojis.hpp" #include "messages/lazyloadedimage.hpp" #include "twitch/emotevalue.hpp" #include #include #include #include #include namespace chatterino { class WindowManager; class Resources; struct EmoteData { EmoteData() { } EmoteData(messages::LazyLoadedImage *_image) : image(_image) { } messages::LazyLoadedImage *image = nullptr; }; class EmoteManager { public: using EmoteMap = ConcurrentMap; EmoteManager(WindowManager &_windowManager, Resources &_resources); void loadGlobalEmotes(); void reloadBTTVChannelEmotes(const QString &channelName); void reloadFFZChannelEmotes(const QString &channelName); ConcurrentMap &getTwitchEmotes(); EmoteMap &getBTTVEmotes(); EmoteMap &getFFZEmotes(); EmoteMap &getChatterinoEmotes(); EmoteMap &getBTTVChannelEmoteFromCaches(); ConcurrentMap &getFFZChannelEmoteFromCaches(); ConcurrentMap &getTwitchEmoteFromCache(); EmoteData getCheerImage(long long int amount, bool animated); EmoteData getTwitchEmoteById(long int id, const QString &emoteName); int getGeneration() { return _generation; } void incGeneration() { _generation++; } boost::signals2::signal &getGifUpdateSignal(); // Bit badge/emotes? ConcurrentMap miscImageCache; private: WindowManager &windowManager; Resources &resources; /// Emojis // shortCodeToEmoji maps strings like "sunglasses" to its emoji QMap emojiShortCodeToEmoji; // Maps the first character of the emoji unicode string to a vector of possible emojis QMap> emojiFirstByte; // url Emoji-one image EmoteMap emojiCache; void loadEmojis(); public: void parseEmojis(std::vector> &parsedWords, const QString &text); private: /// Twitch emotes ConcurrentMap _twitchEmotes; ConcurrentMap _twitchEmoteFromCache; /// BTTV emotes EmoteMap bttvChannelEmotes; public: ConcurrentMap bttvChannels; private: EmoteMap _bttvEmotes; EmoteMap _bttvChannelEmoteFromCaches; void loadBTTVEmotes(); /// FFZ emotes EmoteMap ffzChannelEmotes; public: ConcurrentMap ffzChannels; private: EmoteMap _ffzEmotes; ConcurrentMap _ffzChannelEmoteFromCaches; void loadFFZEmotes(); /// Chatterino emotes EmoteMap _chatterinoEmotes; boost::signals2::signal _gifUpdateTimerSignal; QTimer _gifUpdateTimer; bool _gifUpdateTimerInitiated = false; int _generation = 0; // methods static QString getTwitchEmoteLink(long id, qreal &scale); }; } // namespace chatterino