1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #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:
- Q_DISABLE_COPY(PatchDownloader)
- PatchDownloader();
- void downloadDatabases(); // 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 checkForUpdates(); // Checks for updates
- 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
|