Browse Source

Patch installation working

Ivan Arkhipov 3 years ago
parent
commit
180cc4013e

+ 18 - 15
src/Legacy/models/patchinstaller.cpp

@@ -100,30 +100,33 @@ void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* datab
             continue;
         }
 
-        const int category = file.options["cat"] ? file.options["cat"].as<int>() : -1;
-        QString component_name = getComponentNameFromId(category);
-        if (category != -1 && !Settings::getValue("Components/" + component_name).toBool()) {
+        const int dat_id = file.options["did"] ? file.options["did"].as<int>() : E_CLIENT_LOCAL;
+        if (dat_id != E_CLIENT_LOCAL && dat_id != E_CLIENT_GENERAL) {
+            qWarning() << "Unknown dat id parameter for file " << file.options["fid"].as<long long>() << " (dat id value = " << dat_id << "), SKIPPING!";
             continue;
         }
-        const int dat_id = file.options["did"] ? file.options["did"].as<int>() : 0;
+
         const int file_id = file.options["fid"].as<int>();
         int file_version = -1;
+
+
         if (dat_id == E_CLIENT_LOCAL) {
-            client_local_file_->PatchFile(file);
             file_version = client_local_file_->GetFileVersion(file_id);
         } else if (dat_id == E_CLIENT_GENERAL) {
-            client_general_file_->PatchFile(file);
             file_version = client_local_file_->GetFileVersion(file_id);
-        } else {
-            qWarning() << "Unknown dat id parameter for file " << file.options["fid"].as<long long>() << " (dat id value = " << dat_id << "), SKIPPING!";
         }
 
-        if (file_version != _patch_files_versions) {
-            const QString query = "INSERT INTO `patch_data` (`file_id`, `options`) VALUES ('"
-                    + QString::number(file_id) + "', '" + QString::number(file_version)
-                    + "') ON CONFLICT(`file_id`) DO UPDATE SET `options`='" + QString::number(file_version) + "';";
-            qDebug() << "EXECUTING: " << query;
-            orig_files_db.exec(query);
+//        if (file_version != _patch_files_versions) {
+//            const QString query = "INSERT INTO `patch_data` (`file_id`, `options`) VALUES ('"
+//                    + QString::number(file_id) + "', '" + QString::number(file_version)
+//                    + "') ON CONFLICT(`file_id`) DO UPDATE SET `options`='" + QString::number(file_version) + "';";
+//            orig_files_db.exec(query);
+//        }
+
+        if (dat_id == E_CLIENT_LOCAL) {
+            client_local_file_->PatchFile(file, _patch_files_versions);
+        } else if (dat_id == E_CLIENT_GENERAL) {
+            client_general_file_->PatchFile(file, _patch_files_versions);
         }
     }
     _current_applied_patches_info.has_no_patch_mark = false;
@@ -471,7 +474,7 @@ void PatchInstaller::startPatchInstallationChain() {
 
         if (patch_hashsum == hashsum_in_dat_file) {
             qDebug() << "Skipping patch " << patch << " because its hashsum (" << patch_hashsum << ") is equal to hashsum in dat file (" << hashsum_in_dat_file << ")";
-            return;
+            continue;
         }
 
         const QString real_file_hashsum = FileSystem::fileHash(patch_filename);

+ 1 - 1
src/Legacy/models/patchinstaller.h

@@ -95,7 +95,7 @@ private:
     Status current_status;
     const QString _patch_mark_header = "HI_FROM_ENDEVIR_V2.0";
     const int _applied_patches_file_id = 0x23F4F0F0;
-    const int _patch_files_versions = 721359;
+    const int _patch_files_versions = 6;
     int download_video_finished_videos = 0;
     int download_video_total_videos = 0;
 

+ 4 - 4
src/Legacy/widgets/serverstatuswidget.cpp

@@ -109,9 +109,9 @@ void ServerStatusWidget::updateTechWorksMessage()
 {
     if (tech_work_message_data.isEmpty()) {
         if (!servers_disabled) {
-            server_status_tooltip_ = "ИГРОВЫЕ СЕРВЕРЫ LOTRO РАБОТАЮТ В ШТАТНОМ РЕЖИМЕ";
+            server_status_tooltip_ = "Серверы игры работают в штатном режиме.";
         } else {
-            server_status_tooltip_ = "<p style =\"color:#ff0000\">СЕРВЕРЫ ИГРЫ ОТКЛЮЧЕНЫ</p>";
+            server_status_tooltip_ = "<p style =\"color:#ff0000\">Серверы игры отключены.</p>";
         }
         tech_work_message_data = "";
         return;
@@ -129,9 +129,9 @@ void ServerStatusWidget::updateTechWorksMessage()
     QString month = QString(" " + list[3]).toUpper();
 
     if (!servers_disabled) {
-        server_status_tooltip_ = "<p style=\"color:#ffff7f\">ПЛАНИРУЕТСЯ ОТКЛЮЧЕНИЕ СЕРВЕРОВ ИГРЫ " + day + month + " С " + time_beginning + " ДО " + time_end+ " (МСК).</p>";
+        server_status_tooltip_ = "<p style=\"color:#ffff7f\">Планируется отключение серверов игры " + day + month + " с " + time_beginning + " до " + time_end+ " (мск).</p>";
     } else {
-        server_status_tooltip_ = "<p style=\"color:#ff0000\">СЕРВЕРЫ ИГРЫ ОТКЛЮЧЕНЫ<br>ВРЕМЯ ПРОФ.РАБОТ: " + day + month + " С " + time_beginning + " ДО " + time_end + " (МСК).</p>";
+        server_status_tooltip_ = "<p style=\"color:#ff0000\">Серверы игры отключены на профилактику<br>Время проф. работ: " + day + month + " с " + time_beginning + " до " + time_end + " (мск).</p>";
     }
 
     tech_work_message_data = "";

+ 5 - 10
src/Legacy/widgets/statuswidget.cpp

@@ -50,6 +50,7 @@ StatusWidget::StatusWidget(QWidget *parent)
     connect(ui->b_components_status, &TranslationComponents::needToPatch, this, &StatusWidget::onTranslationComponentsNeedToPatch);
     connect(ui->b_components_status, &TranslationComponents::noNeedToPatch, this, &StatusWidget::onTranslationComponentsNoNeedToPatch);
     connect(&PatchDownloader::instance(), &PatchDownloader::checkForUpdatesStatusChanged, this, [this](bool need_update){_need_to_update = need_update; updateButtonStatus();});
+    connect(&PatchInstaller::instance(), &PatchInstaller::finished, this, [this](){_need_to_install_patches = false; updateButtonStatus();});
     ui->b_components_status->hide();
 
     _components_status_opacity_effect = new QGraphicsOpacityEffect();
@@ -65,8 +66,6 @@ StatusWidget::~StatusWidget()
     _components_status_opacity_animation->stop();
     _components_status_opacity_animation->deleteLater();
     _components_status_opacity_effect->deleteLater();
-    random_tooltip_generator_timer_.stop();
-    process_completed_tooltip_hide_timer_.stop();
     delete ui;
 }
 
@@ -231,7 +230,6 @@ void StatusWidget::fadeBetweenToolTips(QString tooltip_id)
 }
 
 void StatusWidget::onPatchDownloaderStarted() {
-    process_completed_tooltip_hide_timer_.stop();
     all_patch_operations_finished_ = false;
     ui->game_button->setEnabled(false);
     setToolTipMessage("Проверка обновлений русификации...", E_PROCESS);
@@ -240,8 +238,7 @@ void StatusWidget::onPatchDownloaderStarted() {
 void StatusWidget::onPatchDownloaderFinished() {
     all_patch_operations_finished_ = true;
     ui->game_button->setEnabled(true);
-    setToolTipMessage("Скачивание данных русификации завершено!", E_PROCESS);
-    process_completed_tooltip_hide_timer_.start();
+    unsetToolTipMessage(E_PROCESS);
 }
 
 void StatusWidget::onPatchDownloaderProgressChanged(Downloader::Status status) {
@@ -258,17 +255,15 @@ void StatusWidget::onPatchDownloaderProgressChanged(Downloader::Status status) {
 }
 
 void StatusWidget::onPatchInstallerStarted() {
-    process_completed_tooltip_hide_timer_.stop();
     all_patch_operations_finished_ = false;
     ui->game_button->setEnabled(false);
-    setToolTipMessage("<p style=\"font-size: 22px; \">Подготовка русификатора...</p>", E_PROCESS);
+    setToolTipMessage("Начинаем установку компонент русификации...", E_PROCESS);
 }
 
 void StatusWidget::onPatchInstallerFinished() {
     all_patch_operations_finished_ = true;
     ui->game_button->setEnabled(true);
-    setToolTipMessage("<p style=\"font-size: 22px; \">Все операции выполнены!</p>", E_PROCESS);
-    process_completed_tooltip_hide_timer_.start();
+    unsetToolTipMessage(E_PROCESS);
 }
 
 void StatusWidget::onPatchInstallerProgressChanged(PatchInstaller::Status status) {
@@ -381,7 +376,7 @@ void StatusWidget::updateButtonStatus() {
         ui->game_button->setText("ОБНОВИТЬ");
         ui->game_button->setStyleSheet("QPushButton#game_button { \n	color: white;\n	border-image: url(:/buttons/button_big_yellow.png);\n}\n\nQPushButton#game_button:hover {\n	color: white;\n	border-image: url(:/buttons/button_big_yellow_over.png);\n}\n\nQPushButton#game_button:pressed {\n	color: white;\n	border-image: url(:/buttons/button_big_yellow_pressed.png);\n}\n\nQPushButton#game_button:disabled {\n	color: white;\n	border-image: url(:/buttons/button_big_disabled.png);\n}\n");
     } else if (_need_to_install_patches) {
-        setToolTipMessage("Выбранные компоненты требуют установки.\nНажмите \"Установить\", чтобы установить недостающие части русификации.", ToolTipState::E_INFO);
+        setToolTipMessage("Выбранные компоненты требуют установки.\nНажмите \"Установить\", чтобы начать их установку.", ToolTipState::E_INFO);
         ui->game_button->setText("установить");
         ui->game_button->setStyleSheet("QPushButton#game_button { \n	color: white;\n	border-image: url(:/buttons/button_big_yellow.png);\n}\n\nQPushButton#game_button:hover {\n	color: white;\n	border-image: url(:/buttons/button_big_yellow_over.png);\n}\n\nQPushButton#game_button:pressed {\n	color: white;\n	border-image: url(:/buttons/button_big_yellow_pressed.png);\n}\n\nQPushButton#game_button:disabled {\n	color: white;\n	border-image: url(:/buttons/button_big_disabled.png);\n}\n");
     } else {

+ 0 - 3
src/Legacy/widgets/statuswidget.h

@@ -96,9 +96,6 @@ private:
     ToolTipState tooltip_state_ = E_RANDOM;
     QMap<ToolTipState, QString> tooltip_messages_;
 
-    QTimer random_tooltip_generator_timer_;
-    QTimer process_completed_tooltip_hide_timer_;
-
     QGraphicsOpacityEffect* _components_status_opacity_effect;
     QPropertyAnimation* _components_status_opacity_animation;
     bool _need_to_install_patches = false;