mirror-chatterino2/src/providers/twitch/twitchemotes.hpp
Rasmus Karlsson 93fe7adce7 Make TwitchEmotes class conform to QString standard
Make twitch emotes only be identified by a string ID, instead of sometimes by a string and sometimes by an int

Make the EmoteSet a struct instead of just a vector of emotes. This will be handy when we later fill in the emote sets name and other info (i.e. whether it's a subscription benifit or not)
2018-06-07 16:40:31 +02:00

66 lines
1.4 KiB
C++

#pragma once
#include "providers/twitch/emotevalue.hpp"
#include "providers/twitch/twitchaccount.hpp"
#include "providers/twitch/twitchemotes.hpp"
#include "util/concurrentmap.hpp"
#include "util/emotemap.hpp"
#include <map>
namespace chatterino {
namespace providers {
namespace twitch {
class TwitchEmotes
{
public:
util::EmoteData getEmoteById(const QString &id, const QString &emoteName);
/// Twitch emotes
void refresh(const std::shared_ptr<providers::twitch::TwitchAccount> &user);
struct TwitchEmote {
TwitchEmote(const QString &_id, const QString &_code)
: id(_id)
, code(_code)
{
}
// i.e. "403921"
QString id;
// i.e. "forsenE"
QString code;
};
struct EmoteSet {
QString key;
std::vector<TwitchEmote> emotes;
};
struct TwitchAccountEmoteData {
std::vector<EmoteSet> emoteSets;
std::vector<QString> emoteCodes;
util::EmoteMap emotes;
bool filled = false;
};
// Key is the user ID
std::map<QString, TwitchAccountEmoteData> emotes;
private:
// emote code
util::ConcurrentMap<QString, providers::twitch::EmoteValue *> _twitchEmotes;
// emote id
util::ConcurrentMap<QString, util::EmoteData> _twitchEmoteFromCache;
};
} // namespace twitch
} // namespace providers
} // namespace chatterino