mirror-chatterino2/src/singletons/ResourceManager.hpp

157 lines
3.6 KiB
C++
Raw Normal View History

#pragma once
2017-01-13 18:59:11 +01:00
2018-06-26 15:33:51 +02:00
#include "common/Emotemap.hpp"
2018-05-24 15:42:06 +02:00
#include <QIcon>
#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-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
{
public:
2017-12-31 02:21:33 +01:00
ResourceManager();
~ResourceManager() = delete;
void initialize();
2017-12-31 00:50:07 +01:00
struct {
QIcon left;
QIcon right;
QIcon up;
QIcon down;
QIcon move;
} split;
2018-06-06 10:46:23 +02:00
struct {
QPixmap ban;
QPixmap unban;
QPixmap mod;
QPixmap unmod;
} buttons;
2018-06-26 17:06:17 +02:00
chatterino::Image *badgeStaff;
chatterino::Image *badgeAdmin;
chatterino::Image *badgeGlobalModerator;
chatterino::Image *badgeModerator;
chatterino::Image *badgeTurbo;
chatterino::Image *badgeBroadcaster;
chatterino::Image *badgePremium;
chatterino::Image *badgeVerified;
chatterino::Image *badgeSubscriber;
chatterino::Image *badgeCollapsed;
chatterino::Image *cheerBadge100000;
chatterino::Image *cheerBadge10000;
chatterino::Image *cheerBadge5000;
chatterino::Image *cheerBadge1000;
chatterino::Image *cheerBadge100;
chatterino::Image *cheerBadge1;
chatterino::Image *moderationmode_enabled;
chatterino::Image *moderationmode_disabled;
chatterino::Image *splitHeaderContext;
std::map<std::string, chatterino::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-06-26 17:06:17 +02:00
chatterino::Image *badgeImage1x;
chatterino::Image *badgeImage2x;
chatterino::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-06-26 17:06:17 +02:00
chatterino::Image *buttonBan;
chatterino::Image *buttonTimeout;
2017-06-15 23:13:01 +02: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
2018-06-26 17:06:17 +02:00
std::map<QString, std::map<QString, std::map<QString, chatterino::Image *>>> images;
};
std::vector<CheermoteTier> tiers;
};
struct Cheermote {
// a Cheermote indicates one tier
QColor color;
int minBits;
2018-06-26 17:06:17 +02:00
EmoteData emoteDataAnimated;
EmoteData emoteDataStatic;
};
struct CheermoteSet {
QRegularExpression regex;
std::vector<Cheermote> cheermotes;
};
2017-06-15 23:13:01 +02:00
struct Channel {
std::map<std::string, BadgeSet> badgeSets;
std::vector<JSONCheermoteSet> jsonCheermoteSets;
std::vector<CheermoteSet> cheermoteSets;
2017-06-15 23:13:01 +02:00
bool loaded = false;
2017-06-15 23:13:01 +02:00
};
// channelId
std::map<QString, Channel> channels;
2017-08-12 13:20:52 +02:00
// Chatterino badges
struct ChatterinoBadge {
2018-06-26 17:06:17 +02:00
ChatterinoBadge(const std::string &_tooltip, chatterino::Image *_image)
2017-08-12 13:20:52 +02:00
: tooltip(_tooltip)
, image(_image)
{
}
std::string tooltip;
2018-06-26 17:06:17 +02:00
chatterino::Image *image;
2017-08-12 13:20:52 +02:00
};
// username
std::map<std::string, std::shared_ptr<ChatterinoBadge>> chatterinoBadges;
void loadChannelData(const QString &roomID, bool bypassCache = false);
void loadDynamicTwitchBadges();
2017-08-12 13:20:52 +02:00
void loadChatterinoBadges();
2017-01-13 18:59:11 +01:00
};
} // namespace chatterino