lotrodatmanager.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 <LotroDat/LotroDat.h>
  9. using LOTRO_DAT::DatStatus;
  10. namespace debug {
  11. void ClientLocalDatStatusChangedHandler(DatStatus::ProgressInfo info);
  12. void ClientGeneralDatStatusChangedHandler(DatStatus::ProgressInfo info);
  13. }
  14. class LotroDatManager : public QObject
  15. {
  16. Q_OBJECT
  17. public:
  18. using Status = LOTRO_DAT::DatStatus::ProgressInfo;
  19. enum Category : int {
  20. E_TEXTS_COMMON = 100,
  21. E_TEXTS_ITEMS = 101,
  22. E_TEXTS_EMOTES = 102,
  23. E_TEXTS_VIDEOS_REFS = 103,
  24. E_MAPS_COMMON = 200,
  25. E_TEXTURES_COMMON = 201,
  26. E_AUDIOS_COMMON = 300,
  27. E_FONTS_COMMON = 400
  28. };
  29. public:
  30. explicit LotroDatManager(QObject *parent = nullptr);
  31. ~LotroDatManager();
  32. bool Initialised();
  33. bool NotPatched();
  34. bool DatPathIsRelevant();
  35. public slots:
  36. void initializeManager();
  37. void deinitializeManager();
  38. void startGame(LOTRO_DAT::DatLocaleManager::LOCALE locale);
  39. void installPatch(QString patch_name, QString database_path);
  40. void enableCategory(QString patch_name, LotroDatManager::Category category);
  41. void disableCategory(QString patch_name, LotroDatManager::Category category);
  42. void createBackup();
  43. void restoreFromBackup();
  44. void removeBackup();
  45. private:
  46. bool startLotroLauncherWithParameters(LOTRO_DAT::DatLocaleManager::LOCALE locale);
  47. signals:
  48. void operationStarted(QString operation_name, QVector<QVariant> args = {});
  49. void errorOccured(QString operation_name, QVector<QVariant> args = {}, QString message = "No error message provided");
  50. void operationFinished(QString operation_name, QVector<QVariant> args = {}, bool successful = true);
  51. void statusChanged(Status status);
  52. private:
  53. LOTRO_DAT::DatFile client_local_file_;
  54. LOTRO_DAT::DatFile client_general_file_;
  55. const LOTRO_DAT::DatStatus::Callback client_local_status_updated_callback_ = [&](Status status) {
  56. emit statusChanged(status);
  57. debug::ClientLocalDatStatusChangedHandler(status);
  58. };
  59. const LOTRO_DAT::DatStatus::Callback client_general_status_updated_callback_ = [&](Status status) {
  60. emit statusChanged(status);
  61. debug::ClientGeneralDatStatusChangedHandler(status);
  62. };
  63. };
  64. #endif // LEGACYAPP_H