Browse Source

Connected translation components swithces with lotro dat info (mocked)

Ivan Arkhipov 3 years ago
parent
commit
ff64dbaf87

+ 4 - 0
src/Legacy/models/patchinstaller.cpp

@@ -62,6 +62,10 @@ void PatchInstaller::deinit() {
     emit deinitialized();
 }
 
+PatchInstaller::AppliedPatchesInfo PatchInstaller::getPatchesInfo() {
+    return { false, false, 0, 100, 100, 100, 100 };
+}
+
 void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* database) {
     if (!Settings::getValue("DatabaseNeedInstall/" + patch_name).toBool()) {
         return;

+ 12 - 0
src/Legacy/models/patchinstaller.h

@@ -18,6 +18,16 @@ public:
         size_t finished_parts = 0;
     };
 
+    struct AppliedPatchesInfo {
+        bool patched_by_old_legacy;
+        bool has_no_patch_mark;
+        unsigned long long texts_version;
+        unsigned long long graphics_version;
+        unsigned long long videos_version;
+        unsigned long long audio_version;
+        unsigned long long loadscreens_version;
+    };
+
 
 public:
     static PatchInstaller& instance() {
@@ -27,6 +37,8 @@ public:
     bool initialised();
     ~PatchInstaller();
 
+    AppliedPatchesInfo getPatchesInfo(); // TODO: Implement
+
 //    TODO: bool NotPatched();
 
 

+ 8 - 4
src/Legacy/widgets/gamesettings.cpp

@@ -4,6 +4,7 @@
 #include "models/settings.h"
 #include "models/filesystem.h"
 #include "models/patchinstaller.h"
+#include "models/patchdownloader.h"
 
 #include <QFileDialog>
 
@@ -14,6 +15,11 @@ GameSettings::GameSettings(QWidget *parent) :
     ui->setupUi(this);
     setAttribute(Qt::WA_StyledBackground, true);
     setActualParametersValues();
+
+    connect(&PatchInstaller::instance(), &PatchInstaller::started, this, &GameSettings::onPatchTotalOperationsStarted);
+    connect(&PatchInstaller::instance(), &PatchInstaller::finished, this, &GameSettings::onPatchTotalOperationsFinished);
+    connect(&PatchDownloader::instance(), &PatchDownloader::started, this, &GameSettings::onPatchTotalOperationsStarted);
+    connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, &GameSettings::onPatchTotalOperationsFinished);
 }
 
 GameSettings::~GameSettings()
@@ -79,13 +85,11 @@ void GameSettings::on_lotro_base_language_combobox_currentIndexChanged(int index
 
 
 void GameSettings::onPatchTotalOperationsStarted() {
-    ui->change_folder_button->setDisabled(true);
-    ui->lotro_base_language_combobox->setDisabled(true);
+    ui->change_folder_button->setEnabled(false);
+    ui->lotro_base_language_combobox->setEnabled(false);
 }
 
 void GameSettings::onPatchTotalOperationsFinished() {
     ui->change_folder_button->setEnabled(true);
     ui->lotro_base_language_combobox->setEnabled(true);
 }
-
-

+ 38 - 52
src/Legacy/widgets/switchbutton.cpp

@@ -140,43 +140,9 @@ void SwitchButton::paintEvent(QPaintEvent*)
 
 void SwitchButton::mousePressEvent(QMouseEvent*)
 {
-  if (!_enabled)
-    return;
-
-  __btn_move->stop();
-  __back_move->stop();
-
-  __btn_move->setDuration(_duration);
-  __back_move->setDuration(_duration);
-
-  int hback = 20;
-  QSize initial_size(hback, hback);
-  QSize final_size(width() - 4, hback);
-
-  int xi = 2;
-  int y  = 2;
-  int xf = width() - 22;
-
-  if (_value)
-  {
-    final_size = QSize(hback, hback);
-    initial_size = QSize(width() - 4, hback);
-
-    xi = xf;
-    xf = 2;
-  }
-
-  __btn_move->setStartValue(QPoint(xi, y));
-  __btn_move->setEndValue(QPoint(xf, y));
-
-  __back_move->setStartValue(initial_size);
-  __back_move->setEndValue(final_size);
-
-  __btn_move->start();
-  __back_move->start();
-
   // Assigning new current value
   _value = !_value;
+  _update();
   emit valueChanged(_value);
 }
 
@@ -204,14 +170,13 @@ void SwitchButton::setDuration(int time)
 
 void SwitchButton::setValue(bool flag)
 {
-  if (flag == value())
-    return;
-  else
-  {
+    if (flag == value()) {
+        return;
+    }
+
     _value = flag;
     _update();
-    setEnabled(_enabled);
-  }
+    repaint();
 }
 
 bool SwitchButton::value() const
@@ -221,20 +186,41 @@ bool SwitchButton::value() const
 
 void SwitchButton::_update()
 {
-  int hback = 20;
-  QSize final_size(width() - 4, hback);
+    if (!_enabled) {
+        return;
+    }
 
-  int y = 2;
-  int xf = width() - 22;
+    __btn_move->stop();
+    __back_move->stop();
 
-  if (_value)
-  {
-    final_size = QSize(hback, hback);
-    xf = 2;
-  }
+    __btn_move->setDuration(_duration);
+    __back_move->setDuration(_duration);
+
+    int hback = 20;
+    QSize initial_size(hback, hback);
+    QSize final_size(width() - 4, hback);
+
+    int xi = 2;
+    int y  = 2;
+    int xf = width() - 22;
+
+    if (!_value)
+    {
+      final_size = QSize(hback, hback);
+      initial_size = QSize(width() - 4, hback);
+
+      xi = xf;
+      xf = 2;
+    }
+
+    __btn_move->setStartValue(QPoint(xi, y));
+    __btn_move->setEndValue(QPoint(xf, y));
+
+    __back_move->setStartValue(initial_size);
+    __back_move->setEndValue(final_size);
 
-  _circle->move(QPoint(xf, y));
-  _background->resize(final_size);
+    __btn_move->start();
+    __back_move->start();
 }
 
 SwitchButton::SwitchBackground::SwitchBackground(QWidget* parent, QColor color, bool rect)

+ 14 - 0
src/Legacy/widgets/translationcomponents.cpp

@@ -1,6 +1,8 @@
 #include "translationcomponents.h"
 #include "ui_translationcomponents.h"
 
+#include "models/patchinstaller.h"
+
 TranslationComponents::TranslationComponents(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::TranslationComponents)
@@ -27,9 +29,21 @@ TranslationComponents::TranslationComponents(QWidget *parent) :
     ui->loadscreens_block_label->setTooltipParentWidget(parentWidget());
     ui->loadscreens_block_label->raise();
     ui->loadscreens_block_label->setTooltipText("Загрузочные экраны от команды Наследия");
+
+    connect(&PatchInstaller::instance(), &PatchInstaller::successfullyInitialized, this, &TranslationComponents::resetSwitchesToDefault);
 }
 
 TranslationComponents::~TranslationComponents()
 {
     delete ui;
 }
+
+void TranslationComponents::resetSwitchesToDefault() {
+    PatchInstaller::AppliedPatchesInfo info = PatchInstaller::instance().getPatchesInfo();
+
+    ui->texts_block_switch->setValue(info.texts_version != 0);
+    ui->graphics_block_switch->setValue(info.graphics_version != 0);
+    ui->video_block_switch->setValue(info.videos_version != 0);
+    ui->audio_block_switch->setValue(info.audio_version != 0);
+    ui->loadscreens_block_switch->setValue(info.loadscreens_version != 0);
+}

+ 4 - 0
src/Legacy/widgets/translationcomponents.h

@@ -7,6 +7,7 @@ namespace Ui {
 class TranslationComponents;
 }
 
+
 class TranslationComponents : public QWidget
 {
     Q_OBJECT
@@ -15,6 +16,9 @@ public:
     explicit TranslationComponents(QWidget *parent = nullptr);
     ~TranslationComponents();
 
+public slots:
+    void resetSwitchesToDefault();
+
 private:
     Ui::TranslationComponents *ui;
 };