patchinstaller.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef LEGACYAPP_H
  2. #define LEGACYAPP_H
  3. #include <QObject>
  4. #include <QSqlDatabase>
  5. #include "models/downloader.h"
  6. #include <LotroDat/datfile.h>
  7. #include <LotroDat/database.h>
  8. class PatchInstaller : public QObject
  9. {
  10. Q_OBJECT
  11. public:
  12. struct Status {
  13. size_t total_parts = 0;
  14. size_t finished_parts = 0;
  15. };
  16. struct AppliedPatchesInfo {
  17. bool patched_by_old_legacy = false;
  18. bool has_no_patch_mark = false;
  19. QString texts_patch_hashsum = "";
  20. QString images_patch_hashsum = "";
  21. QString sounds_patch_hashsum = "";
  22. QString loadscreens_patch_hashsum = "";
  23. QString textures_patch_hashsum = "";
  24. QString fonts_patch_hashsum = "";
  25. QString videos_patch_hashsum = "";
  26. };
  27. public:
  28. static PatchInstaller& instance() {
  29. static PatchInstaller instance_;
  30. return instance_;
  31. }
  32. bool initialised();
  33. ~PatchInstaller();
  34. AppliedPatchesInfo getPatchesInfo(); // TODO: Implement
  35. private:
  36. Q_DISABLE_COPY(PatchInstaller)
  37. enum RESOURCE_FILE_TYPE : int {
  38. E_CLIENT_LOCAL = 0,
  39. E_CLIENT_GENERAL = 1
  40. };
  41. explicit PatchInstaller(QObject *parent = nullptr);
  42. bool datPathIsRelevant();
  43. void installPatch(QString patch_name, LOTRO_DAT::Database* database);
  44. void installOriginalPatch(QString patch_name);
  45. void installLoadscreens(LOTRO_DAT::Database* database);
  46. void installVideos(LOTRO_DAT::Database* database);
  47. AppliedPatchesInfo getAppliedPatchesInfoFromDatFile();
  48. void insertPatchesInfoInDatFile(const AppliedPatchesInfo& info);
  49. public slots:
  50. void deinit();
  51. void init();
  52. void startGame();
  53. void startPatchInstallationChain();
  54. private slots:
  55. void onDownloaderProgressChanged(Downloader* context, Downloader::Status progress);
  56. signals:
  57. void started();
  58. void progressChanged(PatchInstaller::Status status);
  59. void videosDownloadProgressChanged(int finished_videos, int total_videos, Downloader::Status status);
  60. void finished();
  61. void successfullyInitialized();
  62. void deinitialized();
  63. private:
  64. LOTRO_DAT::DatFile* client_local_file_;
  65. LOTRO_DAT::DatFile* client_general_file_;
  66. AppliedPatchesInfo _current_applied_patches_info;
  67. Status current_status;
  68. const QString _patch_mark_header = "HI_FROM_ENDEVIR_V2.0";
  69. const int _applied_patches_file_id = 0x23F4F0F0;
  70. const int _patch_files_versions = 6;
  71. int download_video_finished_videos = 0;
  72. int download_video_total_videos = 0;
  73. };
  74. Q_DECLARE_METATYPE(PatchInstaller::Status)
  75. #endif // LEGACYAPP_H