#pragma once #define GIF_FRAME_LENGTH 33 #include "emojis.hpp" #include "messages/image.hpp" #include "signalvector.hpp" #include "twitch/emotevalue.hpp" #include "twitch/twitchuser.hpp" #include "util/concurrentmap.hpp" #include "util/emotemap.hpp" #include #include #include #include #include #include namespace chatterino { namespace singletons { class SettingManager; class WindowManager; class EmoteManager { explicit EmoteManager(singletons::SettingManager &manager, singletons::WindowManager &windowManager); public: static EmoteManager &getInstance(); void loadGlobalEmotes(); void reloadBTTVChannelEmotes(const QString &channelName, std::weak_ptr channelEmoteMap); void reloadFFZChannelEmotes(const QString &channelName, std::weak_ptr channelEmoteMap); util::ConcurrentMap &getTwitchEmotes(); util::EmoteMap &getFFZEmotes(); util::EmoteMap &getChatterinoEmotes(); util::EmoteMap &getBTTVChannelEmoteFromCaches(); util::EmoteMap &getEmojis(); util::ConcurrentMap &getFFZChannelEmoteFromCaches(); util::ConcurrentMap &getTwitchEmoteFromCache(); util::EmoteData getCheerImage(long long int amount, bool animated); util::EmoteData getTwitchEmoteById(long int id, const QString &emoteName); int getGeneration() { return _generation; } void incGeneration() { _generation++; } boost::signals2::signal &getGifUpdateSignal(); // Bit badge/emotes? util::ConcurrentMap miscImageCache; private: SettingManager &settingsManager; WindowManager &windowManager; /// Emojis QRegularExpression findShortCodesRegex; // 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 util::EmoteMap emojis; void loadEmojis(); public: void parseEmojis(std::vector> &parsedWords, const QString &text); QString replaceShortCodes(const QString &text); std::vector emojiShortCodes; /// Twitch emotes void refreshTwitchEmotes(const std::shared_ptr &user); struct TwitchAccountEmoteData { struct TwitchEmote { std::string id; std::string code; }; // emote set std::map> emoteSets; std::vector emoteCodes; bool filled = false; }; std::map twitchAccountEmotes; private: // emote code util::ConcurrentMap _twitchEmotes; // emote id util::ConcurrentMap _twitchEmoteFromCache; /// BTTV emotes util::EmoteMap bttvChannelEmotes; public: util::ConcurrentMap bttvChannels; util::EmoteMap bttvGlobalEmotes; SignalVector bttvGlobalEmoteCodes; // roomID std::map> bttvChannelEmoteCodes; util::EmoteMap _bttvChannelEmoteFromCaches; private: void loadBTTVEmotes(); /// FFZ emotes util::EmoteMap ffzChannelEmotes; public: util::ConcurrentMap ffzChannels; util::EmoteMap ffzGlobalEmotes; SignalVector ffzGlobalEmoteCodes; std::map> ffzChannelEmoteCodes; private: util::ConcurrentMap _ffzChannelEmoteFromCaches; void loadFFZEmotes(); /// Chatterino emotes util::EmoteMap _chatterinoEmotes; boost::signals2::signal gifUpdateTimerSignal; QTimer gifUpdateTimer; bool gifUpdateTimerInitiated = false; int _generation = 0; }; } // namespace singletons } // namespace chatterino