mirror-chatterino2/emotes.h
2017-02-06 17:42:28 +01:00

130 lines
3.1 KiB
C++

#ifndef EMOTES_H
#define EMOTES_H
#include "concurrentmap.h"
#include "messages/lazyloadedimage.h"
#include "twitchemotevalue.h"
#include <QMap>
#include <QMutex>
#include <QTimer>
namespace chatterino {
class Emotes
{
public:
static ConcurrentMap<QString, TwitchEmoteValue *> &
getTwitchEmotes()
{
return twitchEmotes;
}
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getBttvEmotes()
{
return bttvEmotes;
}
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getFfzEmotes()
{
return ffzEmotes;
}
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getChatterinoEmotes()
{
return chatterinoEmotes;
}
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getBttvChannelEmoteFromCaches()
{
return bttvChannelEmoteFromCaches;
}
static ConcurrentMap<int, messages::LazyLoadedImage *> &
getFfzChannelEmoteFromCaches()
{
return ffzChannelEmoteFromCaches;
}
static ConcurrentMap<long, messages::LazyLoadedImage *> &
getTwitchEmoteFromCache()
{
return twitchEmoteFromCache;
}
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
getMiscImageFromCache()
{
return miscImageFromCache;
}
static void loadGlobalEmotes();
static messages::LazyLoadedImage *getCheerImage(long long int amount,
bool animated);
static messages::LazyLoadedImage *getCheerBadge(long long int amount);
static messages::LazyLoadedImage *getTwitchEmoteById(const QString &name,
long int id);
static int
getGeneration()
{
return generation;
}
static void
incGeneration()
{
generation++;
}
static QTimer &
getGifUpdateTimer()
{
if (!gifUpdateTimerInitiated) {
gifUpdateTimerInitiated = true;
gifUpdateTimer.setInterval(33);
gifUpdateTimer.start();
}
return gifUpdateTimer;
}
private:
Emotes();
static QString twitchEmoteTemplate;
static ConcurrentMap<QString, TwitchEmoteValue *> twitchEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *> bttvEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *> ffzEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *> chatterinoEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *>
bttvChannelEmoteFromCaches;
static ConcurrentMap<int, messages::LazyLoadedImage *>
ffzChannelEmoteFromCaches;
static ConcurrentMap<long, messages::LazyLoadedImage *>
twitchEmoteFromCache;
static ConcurrentMap<QString, messages::LazyLoadedImage *>
miscImageFromCache;
static QString getTwitchEmoteLink(long id, qreal &scale);
static QTimer gifUpdateTimer;
static bool gifUpdateTimerInitiated;
static void loadFfzEmotes();
static void loadBttvEmotes();
static int generation;
};
}
#endif // EMOTES_H