patchinstaller.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef LEGACYAPP_H
  2. #define LEGACYAPP_H
  3. #include <QObject>
  4. #include <QSettings>
  5. #include <QApplication>
  6. #include <QVector>
  7. #include <QVariant>
  8. #include "models/downloader.h"
  9. #include <LotroDat/datfile.h>
  10. #include <LotroDat/database.h>
  11. class PatchInstaller : public QObject
  12. {
  13. Q_OBJECT
  14. public:
  15. struct Status {
  16. size_t total_parts = 0;
  17. size_t finished_parts = 0;
  18. };
  19. public:
  20. static PatchInstaller& instance() {
  21. static PatchInstaller instance_;
  22. return instance_;
  23. }
  24. bool initialised();
  25. ~PatchInstaller();
  26. // TODO: bool NotPatched();
  27. private:
  28. enum RESOURCE_FILE_TYPE : int {
  29. E_CLIENT_LOCAL = 0,
  30. E_CLIENT_GENERAL = 1
  31. };
  32. explicit PatchInstaller(QObject *parent = nullptr);
  33. bool datPathIsRelevant();
  34. void deinit();
  35. void installPatch(QString patch_name, LOTRO_DAT::Database* database);
  36. void installLoadscreens(LOTRO_DAT::Database* database);
  37. void installVideos(LOTRO_DAT::Database* database);
  38. public slots:
  39. void init();
  40. void startGame(bool freeze_updates);
  41. void startPatchInstallationChain();
  42. private slots:
  43. void onDownloaderProgressChanged(Downloader* context, Downloader::Status progress);
  44. signals:
  45. void started();
  46. void progressChanged(PatchInstaller::Status status);
  47. void videosDownloadProgressChanged(int finished_videos, int total_videos, Downloader::Status status);
  48. void finished();
  49. private:
  50. LOTRO_DAT::DatFile* client_local_file_;
  51. LOTRO_DAT::DatFile* client_general_file_;
  52. Status current_status;
  53. int download_video_finished_videos = 0;
  54. int download_video_total_videos = 0;
  55. };
  56. Q_DECLARE_METATYPE(PatchInstaller::Status)
  57. #endif // LEGACYAPP_H