Browse Source

Finished with patch installing impl

Ivan Arkhipov 4 years ago
parent
commit
fa7d1132df

+ 2 - 6
src/Legacy/models/lotrodatmanager.cpp

@@ -107,8 +107,8 @@ void debug::ClientGeneralDatStatusChangedHandler(DatStatus::ProgressInfo info) {
 LotroDatManager::LotroDatManager(QObject *parent) :
     QObject(parent) {
 
-    qRegisterMetaType<Status>();
-    qRegisterMetaType<LOTRO_DAT::DatLocaleManager::LOCALE>();
+    qRegisterMetaType<Status>("Status");
+    qRegisterMetaType<LOTRO_DAT::DatLocaleManager::LOCALE>("LOCALE");
     client_local_file_.GetStatusModule().AddStatusChangedCallbackFunction(client_local_status_updated_callback_);
     client_general_file_.GetStatusModule().AddStatusChangedCallbackFunction(client_general_status_updated_callback_);
 }
@@ -276,8 +276,6 @@ void LotroDatManager::installPatch(QString patch_name, QString database_path)
         emit operationFinished("installPatch", {patch_name, database_path}, false);
         return;
     }
-    client_local_file_.GetFileSystem().CommitDirectories();
-    client_local_file_.GetLocaleManager().CommitLocales();
 
     if (client_general_file_.GetPatcher().PatchAllDatabase(&db).result != LOTRO_DAT::SUCCESS) {
         db.CloseDatabase();
@@ -285,8 +283,6 @@ void LotroDatManager::installPatch(QString patch_name, QString database_path)
         emit operationFinished("installPatch", {patch_name, database_path}, false);
         return;
     }
-    client_general_file_.GetFileSystem().CommitDirectories();
-    client_general_file_.GetLocaleManager().CommitLocales();
 
     db.CloseDatabase();
     emit operationFinished("installPatch", {patch_name, database_path}, true);

+ 16 - 4
src/Legacy/models/patch/graphicspatch.cpp

@@ -110,12 +110,20 @@ void GraphicsPatch::install()
     installLoadscreens();
 
     foreach (QString db_name, QStringList({"image", "texture"})) {
+        if (!Settings::getValue("DatabaseNeedInstall/" + db_name).toBool()) {
+            continue;
+        }
+
         ++elapsed_patches_to_install_;
         QMetaObject::invokeMethod(lotro_mgr_, "installPatch", Qt::QueuedConnection,
                                   Q_ARG(QString, getPatchName() + "_" + db_name),
                                   Q_ARG(QString, Settings::getValue("PatchDatabases/" + db_name + "/path").toString())
                                   );
     }
+
+    if (elapsed_patches_to_install_ == 0) {
+        emit operationFinished(E_INSTALL, this);
+    }
 }
 
 void GraphicsPatch::activate()
@@ -182,14 +190,14 @@ void GraphicsPatch::onLotroDatManagerOperationFinished(QString operation_name, Q
     }
 
     if (operation_name.contains("installPatch")) {
-        QString db_name = args[0].toString().split('_').at(1);
-        qDebug() << "DATABASE NAME: " << db_name;
-
         if (!successful) {
             qCritical() << *this << "Database " + args[0].toString() + " (" + args[1].toString() + ") was not installed due to Legacy core error.";
             emit errorOccured(E_INSTALL, this, "Database " + args[0].toString() + " (" + args[1].toString() + ") was not installed due to Legacy core error.");
         }
 
+        QString db_name = args[0].toString().split('_').at(1);
+        Settings::setValue("DatabaseNeedInstall/" + db_name, false);
+
         --elapsed_patches_to_install_;
         if (!elapsed_patches_to_install_) {
             is_being_patched_by_lotro_dat_manager_ = false;
@@ -211,7 +219,7 @@ void GraphicsPatch::onLotroDatManagerOperationFinished(QString operation_name, Q
     }
 }
 
-void GraphicsPatch::onLotroDatManagerOperationStarted(QString operation_name, QVector<QVariant> args)
+void GraphicsPatch::onLotroDatManagerOperationStarted(QString, QVector<QVariant> args)
 {
     if (args.size() == 0 || !args[0].toString().contains(getPatchName())) {
         return;
@@ -231,6 +239,10 @@ void GraphicsPatch::onLotroDatManagerStatusChanged(LotroDatManager::Status statu
 
 void GraphicsPatch::installLoadscreens()
 {
+    if (!Settings::getValue("DatabaseNeedInstall/loadscreen").toBool()) {
+        return;
+    }
+
     QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
 
     const QStringList loadscreens_filenames = {

+ 13 - 1
src/Legacy/models/patch/soundspatch.cpp

@@ -89,6 +89,8 @@ void SoundsPatch::download()
 
         qInfo() << *this << ": beginning download of file " << target_filename;
 
+        Settings::setValue("DatabaseNeedInstall/" + db_name, true);
+
         Downloader* downloader = new Downloader();
         downloader->setUrl(Settings::getValue(settings_prefix + "/url").toUrl());
         downloader->targetFile = target_file;
@@ -106,12 +108,20 @@ void SoundsPatch::download()
 void SoundsPatch::install()
 {
     foreach (QString db_name, QStringList({"sound"})) {
+        if (!Settings::getValue("DatabaseNeedInstall/" + db_name).toBool()) {
+            continue;
+        }
+
         ++elapsed_patches_to_install_;
         QMetaObject::invokeMethod(lotro_mgr_, "installPatch", Qt::QueuedConnection,
                                   Q_ARG(QString, getPatchName() + "_" + db_name),
                                   Q_ARG(QString, Settings::getValue("PatchDatabases/" + db_name + "/path").toString())
                                   );
     }
+
+    if (elapsed_patches_to_install_ == 0) {
+        emit operationFinished(E_INSTALL, this);
+    }
 }
 
 void SoundsPatch::activate()
@@ -167,6 +177,8 @@ void SoundsPatch::onLotroDatManagerOperationFinished(QString operation_name, QVe
             qCritical() << *this << "Database " + args[0].toString() + " (" + args[1].toString() + ") was not installed due to Legacy core error.";
             emit errorOccured(E_INSTALL, this, "Database " + args[0].toString() + " (" + args[1].toString() + ") was not installed due to Legacy core error.");
         }
+        QString db_name = args[0].toString().split('_').at(1);
+        Settings::setValue("DatabaseNeedInstall/" + db_name, false);
 
         --elapsed_patches_to_install_;
         if (!elapsed_patches_to_install_) {
@@ -189,7 +201,7 @@ void SoundsPatch::onLotroDatManagerOperationFinished(QString operation_name, QVe
     }
 }
 
-void SoundsPatch::onLotroDatManagerOperationStarted(QString operation_name, QVector<QVariant> args)
+void SoundsPatch::onLotroDatManagerOperationStarted(QString, QVector<QVariant> args)
 {
     if (args.size() == 0 || !args[0].toString().contains(getPatchName())) {
         return;

+ 14 - 1
src/Legacy/models/patch/textspatch.cpp

@@ -89,6 +89,8 @@ void TextsPatch::download()
 
         qInfo() << *this << ": beginning download of file " << target_filename;
 
+        Settings::setValue("DatabaseNeedInstall/" + db_name, true);
+
         Downloader* downloader = new Downloader();
         downloader->setUrl(Settings::getValue(settings_prefix + "/url").toUrl());
         downloader->targetFile = target_file;
@@ -106,12 +108,20 @@ void TextsPatch::download()
 void TextsPatch::install()
 {
     foreach (QString db_name, databases_names) {
+        if (!Settings::getValue("DatabaseNeedInstall/" + db_name).toBool()) {
+            continue;
+        }
+
         ++elapsed_patches_to_install_;
         QMetaObject::invokeMethod(lotro_mgr_, "installPatch", Qt::QueuedConnection,
                                   Q_ARG(QString, getPatchName() + "_" + db_name),
                                   Q_ARG(QString, Settings::getValue("PatchDatabases/" + db_name + "/path").toString())
                                   );
     }
+
+    if (elapsed_patches_to_install_ == 0) {
+        emit operationFinished(E_INSTALL, this);
+    }
 }
 
 void TextsPatch::activate()
@@ -196,6 +206,9 @@ void TextsPatch::onLotroDatManagerOperationFinished(QString operation_name, QVec
             emit errorOccured(E_INSTALL, this, "Database " + args[0].toString() + " (" + args[1].toString() + ") was not installed due to Legacy core error.");
         }
 
+        QString db_name = args[0].toString().split('_').at(1);
+        Settings::setValue("DatabaseNeedInstall/" + db_name, false);
+
         --elapsed_patches_to_install_;
         if (!elapsed_patches_to_install_) {
             is_being_patched_by_lotro_dat_manager_ = false;
@@ -217,7 +230,7 @@ void TextsPatch::onLotroDatManagerOperationFinished(QString operation_name, QVec
     }
 }
 
-void TextsPatch::onLotroDatManagerOperationStarted(QString operation_name, QVector<QVariant> args)
+void TextsPatch::onLotroDatManagerOperationStarted(QString, QVector<QVariant> args)
 {
     if (args.size() == 0 || !args[0].toString().contains(getPatchName())) {
         return;