2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-01-13 18:59:11 +01:00
|
|
|
|
2018-01-12 19:37:11 +01:00
|
|
|
#include "util/emotemap.hpp"
|
|
|
|
|
|
|
|
#include <QRegularExpression>
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-06-15 23:13:01 +02:00
|
|
|
#include <map>
|
2017-08-12 13:20:52 +02:00
|
|
|
#include <memory>
|
2017-06-15 23:13:01 +02:00
|
|
|
#include <mutex>
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
2017-12-31 22:58:35 +01:00
|
|
|
namespace singletons {
|
2017-01-13 18:59:11 +01:00
|
|
|
|
2017-12-31 02:21:33 +01:00
|
|
|
class ResourceManager
|
2017-01-13 18:59:11 +01:00
|
|
|
{
|
2018-04-28 15:20:18 +02:00
|
|
|
public:
|
2017-12-31 02:21:33 +01:00
|
|
|
ResourceManager();
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
~ResourceManager() = delete;
|
|
|
|
|
|
|
|
void initialize();
|
2017-12-31 00:50:07 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
messages::Image *badgeStaff;
|
|
|
|
messages::Image *badgeAdmin;
|
|
|
|
messages::Image *badgeGlobalModerator;
|
|
|
|
messages::Image *badgeModerator;
|
|
|
|
messages::Image *badgeTurbo;
|
|
|
|
messages::Image *badgeBroadcaster;
|
|
|
|
messages::Image *badgePremium;
|
|
|
|
messages::Image *badgeVerified;
|
|
|
|
messages::Image *badgeSubscriber;
|
|
|
|
messages::Image *badgeCollapsed;
|
|
|
|
|
|
|
|
messages::Image *cheerBadge100000;
|
|
|
|
messages::Image *cheerBadge10000;
|
|
|
|
messages::Image *cheerBadge5000;
|
|
|
|
messages::Image *cheerBadge1000;
|
|
|
|
messages::Image *cheerBadge100;
|
|
|
|
messages::Image *cheerBadge1;
|
|
|
|
|
2018-01-17 16:52:51 +01:00
|
|
|
messages::Image *moderationmode_enabled;
|
|
|
|
messages::Image *moderationmode_disabled;
|
|
|
|
|
|
|
|
messages::Image *splitHeaderContext;
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
std::map<std::string, messages::Image *> cheerBadges;
|
2017-06-15 23:13:01 +02:00
|
|
|
|
|
|
|
struct BadgeVersion {
|
|
|
|
BadgeVersion() = delete;
|
|
|
|
|
2017-12-17 02:18:13 +01:00
|
|
|
explicit BadgeVersion(QJsonObject &&root);
|
2017-06-15 23:13:01 +02:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
messages::Image *badgeImage1x;
|
|
|
|
messages::Image *badgeImage2x;
|
|
|
|
messages::Image *badgeImage4x;
|
2017-06-15 23:13:01 +02:00
|
|
|
std::string description;
|
|
|
|
std::string title;
|
|
|
|
std::string clickAction;
|
2017-06-16 08:03:13 +02:00
|
|
|
std::string clickURL;
|
2017-06-15 23:13:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct BadgeSet {
|
|
|
|
std::map<std::string, BadgeVersion> versions;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::map<std::string, BadgeSet> badgeSets;
|
|
|
|
|
|
|
|
bool dynamicBadgesLoaded = false;
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
messages::Image *buttonBan;
|
|
|
|
messages::Image *buttonTimeout;
|
2017-06-15 23:13:01 +02:00
|
|
|
|
2018-01-12 19:37:11 +01:00
|
|
|
struct JSONCheermoteSet {
|
|
|
|
QString prefix;
|
|
|
|
std::vector<QString> scales;
|
|
|
|
|
|
|
|
std::vector<QString> backgrounds;
|
|
|
|
std::vector<QString> states;
|
|
|
|
|
|
|
|
QString type;
|
|
|
|
QString updatedAt;
|
|
|
|
int priority;
|
|
|
|
|
|
|
|
struct CheermoteTier {
|
|
|
|
int minBits;
|
|
|
|
QString id;
|
|
|
|
QString color;
|
|
|
|
|
|
|
|
// Background State Scale
|
|
|
|
std::map<QString, std::map<QString, std::map<QString, messages::Image *>>> images;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<CheermoteTier> tiers;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Cheermote {
|
|
|
|
// a Cheermote indicates one tier
|
|
|
|
QColor color;
|
|
|
|
int minBits;
|
|
|
|
|
|
|
|
util::EmoteData emoteDataAnimated;
|
|
|
|
util::EmoteData emoteDataStatic;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CheermoteSet {
|
|
|
|
QRegularExpression regex;
|
|
|
|
std::vector<Cheermote> cheermotes;
|
|
|
|
};
|
|
|
|
|
2017-06-15 23:13:01 +02:00
|
|
|
struct Channel {
|
2017-06-17 11:37:13 +02:00
|
|
|
std::map<std::string, BadgeSet> badgeSets;
|
2018-01-12 19:37:11 +01:00
|
|
|
std::vector<JSONCheermoteSet> jsonCheermoteSets;
|
|
|
|
std::vector<CheermoteSet> cheermoteSets;
|
2017-06-15 23:13:01 +02:00
|
|
|
|
2017-06-17 11:37:13 +02:00
|
|
|
bool loaded = false;
|
2017-06-15 23:13:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// channelId
|
2017-11-04 14:57:29 +01:00
|
|
|
std::map<QString, Channel> channels;
|
2017-06-16 10:01:21 +02:00
|
|
|
|
2017-08-12 13:20:52 +02:00
|
|
|
// Chatterino badges
|
|
|
|
struct ChatterinoBadge {
|
2018-01-11 20:16:25 +01:00
|
|
|
ChatterinoBadge(const std::string &_tooltip, messages::Image *_image)
|
2017-08-12 13:20:52 +02:00
|
|
|
: tooltip(_tooltip)
|
|
|
|
, image(_image)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string tooltip;
|
2018-01-11 20:16:25 +01:00
|
|
|
messages::Image *image;
|
2017-08-12 13:20:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// username
|
|
|
|
std::map<std::string, std::shared_ptr<ChatterinoBadge>> chatterinoBadges;
|
|
|
|
|
2017-11-04 14:57:29 +01:00
|
|
|
void loadChannelData(const QString &roomID, bool bypassCache = false);
|
2017-10-27 21:22:06 +02:00
|
|
|
void loadDynamicTwitchBadges();
|
2017-08-12 13:20:52 +02:00
|
|
|
void loadChatterinoBadges();
|
2017-01-13 18:59:11 +01:00
|
|
|
};
|
|
|
|
|
2018-01-12 19:37:11 +01:00
|
|
|
} // namespace singletons
|
2017-06-07 10:09:24 +02:00
|
|
|
} // namespace chatterino
|