2022-04-21 23:42:53 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <QJsonDocument>
|
2022-04-22 00:26:10 +02:00
|
|
|
#include <opencv2/opencv.hpp>
|
2022-04-21 23:42:53 +02:00
|
|
|
|
2022-04-23 20:33:21 +02:00
|
|
|
#include "datadragonimagecache.h"
|
|
|
|
|
2022-04-21 23:42:53 +02:00
|
|
|
class DataDragon {
|
|
|
|
public:
|
|
|
|
DataDragon();
|
|
|
|
DataDragon(const DataDragon&) = delete;
|
|
|
|
DataDragon& operator=(const DataDragon&) = delete;
|
|
|
|
|
|
|
|
struct ChampData {
|
|
|
|
public:
|
2022-04-23 00:39:45 +02:00
|
|
|
ChampData();
|
2022-04-21 23:42:53 +02:00
|
|
|
ChampData(const QJsonObject& source);
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
std::string id;
|
|
|
|
int key;
|
|
|
|
std::string partype;
|
|
|
|
std::string title;
|
|
|
|
};
|
|
|
|
|
2022-04-22 00:26:10 +02:00
|
|
|
enum class ImageType {
|
2022-04-23 20:33:21 +02:00
|
|
|
SQUARE = 0,
|
|
|
|
LOADING = 1,
|
|
|
|
SPLASH = 2
|
2022-04-22 00:26:10 +02:00
|
|
|
};
|
|
|
|
|
2022-04-21 23:42:53 +02:00
|
|
|
const std::string& getVersion();
|
|
|
|
const std::vector<ChampData>& getChamps();
|
2022-04-22 00:26:10 +02:00
|
|
|
cv::Mat getImage(const std::string& champid, ImageType imgtype = ImageType::SQUARE);
|
2022-04-23 01:53:19 +02:00
|
|
|
const ChampData& getBestMatchingChamp(const std::string& name, int* count = nullptr);
|
2022-04-21 23:42:53 +02:00
|
|
|
|
2022-04-23 00:39:45 +02:00
|
|
|
static const ChampData EMPTYCHAMP;
|
2022-04-21 23:42:53 +02:00
|
|
|
protected:
|
2022-04-22 00:26:10 +02:00
|
|
|
std::string getCDNString() const;
|
|
|
|
QByteArray requestRaw(const std::string& url);
|
2022-04-21 23:42:53 +02:00
|
|
|
QJsonDocument request(const std::string& url);
|
|
|
|
|
|
|
|
std::string version;
|
|
|
|
std::vector<ChampData> champs;
|
|
|
|
|
|
|
|
private:
|
|
|
|
CURL* curl = nullptr; // the curl (does curling)
|
2022-04-23 20:33:21 +02:00
|
|
|
|
|
|
|
DataDragonImageCache cache[3];
|
2022-04-21 23:42:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& str, const DataDragon::ChampData& cd);
|