patchdownloader.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef PATCHDOWNLOADER_H
  2. #define PATCHDOWNLOADER_H
  3. #include <QObject>
  4. #include <QList>
  5. #include <QString>
  6. #include <QMap>
  7. #include "models/downloader.h"
  8. class PatchDownloader : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. static PatchDownloader& instance() {
  13. static PatchDownloader instance_;
  14. return instance_;
  15. }
  16. ~PatchDownloader();
  17. private:
  18. PatchDownloader();
  19. void checkForUpdates(); // Checks for updates. Returns true, if there are new patch updates
  20. void beginDownload(); // Starts downloading all necessary patches.
  21. static bool needDownloadDatabase(QString db_name); // Checks if database needs to be downloaded (by checksum comparing)
  22. public slots:
  23. void init();
  24. void startPatchDownloaderChain();
  25. signals:
  26. void started();
  27. void progressChanged(Downloader::Status status);
  28. void finished();
  29. private slots:
  30. void onDownloaderProgressChanged(Downloader* context, Downloader::Status progress);
  31. void onDownloaderFinished(Downloader* context);
  32. private:
  33. bool started_ = false;
  34. const QList<QString> patches_ = {"text", "font", "image", "texture", "loadscreen", "sound", "video"};
  35. QMap<QString, Downloader*> patch_downloaders_;
  36. QMap<Downloader*, Downloader::Status> patch_downloaders_status_;
  37. };
  38. #endif // PATCHDOWNLOADER_H