12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #ifndef PATCHDOWNLOADER_H
- #define PATCHDOWNLOADER_H
- #include <QObject>
- #include <QList>
- #include <QString>
- #include <QMap>
- #include "models/downloader.h"
- class PatchDownloader : public QObject
- {
- Q_OBJECT
- public:
- static PatchDownloader& instance() {
- static PatchDownloader instance_;
- return instance_;
- }
- ~PatchDownloader();
- private:
- PatchDownloader();
- void checkForUpdates(); // Checks for updates. Returns true, if there are new patch updates
- void beginDownload(); // Starts downloading all necessary patches.
- static bool needDownloadDatabase(QString db_name); // Checks if database needs to be downloaded (by checksum comparing)
- public slots:
- void init();
- void startPatchDownloaderChain();
- signals:
- void started();
- void progressChanged(Downloader::Status status);
- void finished();
- private slots:
- void onDownloaderProgressChanged(Downloader* context, Downloader::Status progress);
- void onDownloaderFinished(Downloader* context);
- private:
- bool started_ = false;
- const QList<QString> patches_ = {"text", "font", "image", "texture", "loadscreen", "sound", "video"};
- QMap<QString, Downloader*> patch_downloaders_;
- QMap<Downloader*, Downloader::Status> patch_downloaders_status_;
- };
- #endif // PATCHDOWNLOADER_H
|