mirror-chatterino2/emotes.h

132 lines
3.1 KiB
C
Raw Normal View History

2017-01-04 15:12:31 +01:00
#ifndef EMOTES_H
#define EMOTES_H
#define GIF_FRAME_LENGTH 33
2017-01-04 15:12:31 +01:00
#include "concurrentmap.h"
2017-01-18 21:30:23 +01:00
#include "messages/lazyloadedimage.h"
2017-01-11 18:52:09 +01:00
#include "twitchemotevalue.h"
2017-01-04 15:12:31 +01:00
2017-01-18 04:52:47 +01:00
#include <QMap>
#include <QMutex>
2017-02-06 17:42:28 +01:00
#include <QTimer>
2017-01-18 04:52:47 +01:00
2017-01-18 21:30:23 +01:00
namespace chatterino {
2017-01-04 15:12:31 +01:00
class Emotes
{
public:
2017-01-11 18:52:09 +01:00
static ConcurrentMap<QString, TwitchEmoteValue *> &
2017-01-18 04:33:30 +01:00
getTwitchEmotes()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return twitchEmotes;
2017-01-11 18:52:09 +01:00
}
2017-01-13 18:59:11 +01:00
2017-01-18 21:30:23 +01:00
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
2017-01-18 04:33:30 +01:00
getBttvEmotes()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return bttvEmotes;
2017-01-11 18:52:09 +01:00
}
2017-01-13 18:59:11 +01:00
2017-01-18 21:30:23 +01:00
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
2017-01-18 04:33:30 +01:00
getFfzEmotes()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return ffzEmotes;
2017-01-11 18:52:09 +01:00
}
2017-01-13 18:59:11 +01:00
2017-01-18 21:30:23 +01:00
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
2017-01-18 04:33:30 +01:00
getChatterinoEmotes()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return chatterinoEmotes;
2017-01-11 18:52:09 +01:00
}
2017-01-13 18:59:11 +01:00
2017-01-18 21:30:23 +01:00
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
2017-01-18 04:33:30 +01:00
getBttvChannelEmoteFromCaches()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return bttvChannelEmoteFromCaches;
2017-01-11 18:52:09 +01:00
}
2017-01-13 18:59:11 +01:00
2017-01-26 18:22:04 +01:00
static ConcurrentMap<int, messages::LazyLoadedImage *> &
2017-01-18 04:33:30 +01:00
getFfzChannelEmoteFromCaches()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return ffzChannelEmoteFromCaches;
2017-01-11 18:52:09 +01:00
}
2017-01-13 18:59:11 +01:00
2017-01-18 21:30:23 +01:00
static ConcurrentMap<long, messages::LazyLoadedImage *> &
2017-01-18 04:33:30 +01:00
getTwitchEmoteFromCache()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return twitchEmoteFromCache;
2017-01-11 18:52:09 +01:00
}
2017-01-13 18:59:11 +01:00
2017-01-18 21:30:23 +01:00
static ConcurrentMap<QString, messages::LazyLoadedImage *> &
2017-01-18 04:33:30 +01:00
getMiscImageFromCache()
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return miscImageFromCache;
2017-01-11 18:52:09 +01:00
}
2017-01-04 15:12:31 +01:00
2017-01-05 16:07:20 +01:00
static void loadGlobalEmotes();
2017-01-18 21:30:23 +01:00
static messages::LazyLoadedImage *getCheerImage(long long int amount,
bool animated);
static messages::LazyLoadedImage *getCheerBadge(long long int amount);
2017-01-05 16:07:20 +01:00
2017-01-18 21:30:23 +01:00
static messages::LazyLoadedImage *getTwitchEmoteById(const QString &name,
long int id);
2017-01-06 23:28:48 +01:00
2017-01-15 16:38:30 +01:00
static int
2017-01-18 04:33:30 +01:00
getGeneration()
2017-01-15 16:38:30 +01:00
{
2017-01-18 04:33:30 +01:00
return generation;
2017-01-15 16:38:30 +01:00
}
static void
incGeneration()
{
2017-01-18 04:33:30 +01:00
generation++;
2017-01-15 16:38:30 +01:00
}
2017-02-06 17:42:28 +01:00
static QTimer &
getGifUpdateTimer()
{
if (!gifUpdateTimerInitiated) {
gifUpdateTimerInitiated = true;
gifUpdateTimer.setInterval(GIF_FRAME_LENGTH);
2017-02-06 17:42:28 +01:00
gifUpdateTimer.start();
}
return gifUpdateTimer;
}
2017-01-04 15:12:31 +01:00
private:
Emotes();
2017-01-18 04:33:30 +01:00
static QString twitchEmoteTemplate;
2017-01-13 18:59:11 +01:00
2017-01-18 04:33:30 +01:00
static ConcurrentMap<QString, TwitchEmoteValue *> twitchEmotes;
2017-01-18 21:30:23 +01:00
static ConcurrentMap<QString, messages::LazyLoadedImage *> bttvEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *> ffzEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *> chatterinoEmotes;
static ConcurrentMap<QString, messages::LazyLoadedImage *>
bttvChannelEmoteFromCaches;
2017-01-26 18:22:04 +01:00
static ConcurrentMap<int, messages::LazyLoadedImage *>
2017-01-18 21:30:23 +01:00
ffzChannelEmoteFromCaches;
static ConcurrentMap<long, messages::LazyLoadedImage *>
twitchEmoteFromCache;
static ConcurrentMap<QString, messages::LazyLoadedImage *>
miscImageFromCache;
2017-01-13 18:59:11 +01:00
static QString getTwitchEmoteLink(long id, qreal &scale);
2017-01-15 16:38:30 +01:00
2017-02-06 17:42:28 +01:00
static QTimer gifUpdateTimer;
static bool gifUpdateTimerInitiated;
2017-01-26 17:26:20 +01:00
static void loadFfzEmotes();
static void loadBttvEmotes();
2017-01-18 04:33:30 +01:00
static int generation;
2017-01-04 15:12:31 +01:00
};
2017-01-18 21:30:23 +01:00
}
2017-01-04 15:12:31 +01:00
2017-01-11 18:52:09 +01:00
#endif // EMOTES_H