internallogicmanager.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef INTERNALLOGICMANAGER_H
  2. #define INTERNALLOGICMANAGER_H
  3. #include <QObject>
  4. #include <QSettings>
  5. #include <QThread>
  6. #include "models/patchdownloader.h"
  7. #include "models/lotrodatmanager.h"
  8. #include "models/filesystem.h"
  9. /*
  10. Stage 1 - check if user opened application for the first time - then we need to show
  11. hello messages.
  12. Stage 2 - check if lotro folder is correct (there's file LotroLauncher.exe in it).
  13. If no - then show him settings (ask to find lotro folder) where user can set it.
  14. Stage 3 - check if there are client_local_English.dat and client_general.dat files.
  15. If no - then remove file and show message that we need to download them.
  16. Stage 4 - try to open client_local_English.dat and client_general.dat. If at least one of them
  17. fails to open at all - show that there may be other processes taken ownage.
  18. Stage 5 - if .dat files are opened, but there was an error telling that file has incorrect version -
  19. remove file and show message that we need to download them.
  20. --- After this assuming that .dat files are correct and opened.
  21. Stage 6 - if user runs for the first time, then ask to create backup
  22. Stage 7 - check that user has chosen patches options. Otherwise move user to settings with enabled
  23. position of choosing (this skips stage 8 and goes to st.9)
  24. Stage 8 - if user runs app for the first time - ask to download micropatches
  25. Stage 9 - if there are flags that patches already applied but this is not true with .dat - ask to
  26. apply them once more
  27. Stage 10 - All settings are checked and set. If user is for the first time - show message "ready to begin"
  28. Start check for updates. Start check for updates timer.
  29. */
  30. class MainWindow;
  31. enum class APP_STATE {
  32. NO_PROCESS,
  33. SEMI_CRITICAL_PROCESS,
  34. CRITICAL_PROCESS
  35. };
  36. class InternalLogicManager : public QObject
  37. {
  38. Q_OBJECT
  39. public:
  40. explicit InternalLogicManager(MainWindow *gui_, QSettings *settings_, QObject *parent = nullptr);
  41. ~InternalLogicManager();
  42. signals:
  43. void stateChanged(APP_STATE state);
  44. public slots:
  45. void startInitPipeline();
  46. // Actions from UI -> general window
  47. void startGame(QString locale = "Original"); // Original/RU
  48. // Actions from UI -> settings window
  49. void lotroSettingsUpdated();
  50. void createLotroFilesBackup();
  51. void removeLotroFilesBackup();
  52. void applySelectedPatches();
  53. void updateSettingsChanged();
  54. void terminateThreads();
  55. void stopThreads();
  56. private slots:
  57. void onLotroManagerStarted(QString, QVector<QVariant>);
  58. void onLotroManagerFinished(QString, QVector<QVariant>);
  59. void onLotroManagerErrorOccured(QString, QVector<QVariant>);
  60. void onLotroManagerProgressChanged();
  61. private slots:
  62. void checkFirstTimeOpening();
  63. void checkGameFolderCorrectness();
  64. void checkDatFilesExist();
  65. void processLotroManagerInit();
  66. void processPatchDownloaderInit(); // There begins also checkForUpdates cycle;
  67. void checkBackupExist();
  68. void checkUserHasEnteredPatchOptions();
  69. void checkDatFileWasPatched();
  70. private:
  71. PatchDownloader *patch_downloader;
  72. QThread *patch_downloader_thread;
  73. LotroDatManager *lotro_manager;
  74. QThread *lotro_manager_thread;
  75. QSettings *settings;
  76. MainWindow *gui;
  77. APP_STATE state;
  78. size_t active_critical_process_count;
  79. size_t active_non_critical_process_count;
  80. };
  81. #endif // INTERNALLOGICMANAGER_H