|
@@ -2,6 +2,8 @@
|
|
|
#include "ui_translationcomponents.h"
|
|
|
|
|
|
#include "models/patchinstaller.h"
|
|
|
+#include "models/patchdownloader.h"
|
|
|
+#include "models/settings.h"
|
|
|
|
|
|
TranslationComponents::TranslationComponents(QWidget *parent) :
|
|
|
QWidget(parent),
|
|
@@ -13,24 +15,34 @@ TranslationComponents::TranslationComponents(QWidget *parent) :
|
|
|
ui->texts_block_label->setTooltipParentWidget(parentWidget());
|
|
|
ui->texts_block_label->raise();
|
|
|
ui->texts_block_label->setTooltipText("Перевод всех текстовых элементов в игре: названий, квестов, меню и т.д.");
|
|
|
+ connect(ui->texts_block_switch, &SwitchButton::valueChanged, this, &TranslationComponents::onTextsChange);
|
|
|
|
|
|
ui->graphics_block_label->setTooltipParentWidget(parentWidget());
|
|
|
ui->graphics_block_label->raise();
|
|
|
ui->graphics_block_label->setTooltipText("Переведенные карты локаций и элементы графического интерфейса.");
|
|
|
+ connect(ui->graphics_block_switch, &SwitchButton::valueChanged, this, &TranslationComponents::onImagesChange);
|
|
|
|
|
|
ui->video_block_label->setTooltipParentWidget(parentWidget());
|
|
|
ui->video_block_label->raise();
|
|
|
ui->video_block_label->setTooltipText("Переведенные и озвученные видеоролики и кат-сцены.");
|
|
|
+ connect(ui->video_block_switch, &SwitchButton::valueChanged, this, &TranslationComponents::onVideosChange);
|
|
|
|
|
|
ui->audio_block_label->setTooltipParentWidget(parentWidget());
|
|
|
ui->audio_block_label->raise();
|
|
|
ui->audio_block_label->setTooltipText("Переведенные и озвученные реплики персонажей.");
|
|
|
+ connect(ui->audio_block_switch, &SwitchButton::valueChanged, this, &TranslationComponents::onSoundsChange);
|
|
|
|
|
|
ui->loadscreens_block_label->setTooltipParentWidget(parentWidget());
|
|
|
ui->loadscreens_block_label->raise();
|
|
|
ui->loadscreens_block_label->setTooltipText("Загрузочные экраны от команды Наследия");
|
|
|
+ connect(ui->loadscreens_block_switch, &SwitchButton::valueChanged, this, &TranslationComponents::onLoadscreensChange);
|
|
|
|
|
|
connect(&PatchInstaller::instance(), &PatchInstaller::successfullyInitialized, this, &TranslationComponents::resetSwitchesToDefault);
|
|
|
+ connect(&PatchInstaller::instance(), &PatchInstaller::started, this, &TranslationComponents::disableControls);
|
|
|
+ connect(&PatchInstaller::instance(), &PatchInstaller::finished, this, &TranslationComponents::enableControls);
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::started, this, &TranslationComponents::disableControls);
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, &TranslationComponents::enableControls);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
TranslationComponents::~TranslationComponents()
|
|
@@ -41,9 +53,89 @@ TranslationComponents::~TranslationComponents()
|
|
|
void TranslationComponents::resetSwitchesToDefault() {
|
|
|
PatchInstaller::AppliedPatchesInfo info = PatchInstaller::instance().getPatchesInfo();
|
|
|
|
|
|
+ Settings::setValue("Components/texts_main", info.texts_version != 0);
|
|
|
+ Settings::setValue("Components/texts_emotes", info.texts_version != 0);
|
|
|
+ Settings::setValue("Components/texts_items", info.texts_version != 0);
|
|
|
+ Settings::setValue("Components/texts_videos", info.videos_version != 0);
|
|
|
+ Settings::setValue("Components/maps", info.graphics_version != 0);
|
|
|
+ Settings::setValue("Components/textures", info.graphics_version != 0);
|
|
|
+ Settings::setValue("Components/sounds", info.audio_version != 0);
|
|
|
+ Settings::setValue("Components/videos", info.videos_version != 0);
|
|
|
+ Settings::setValue("Components/loadscreens", info.loadscreens_version != 0);
|
|
|
+
|
|
|
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);
|
|
|
}
|
|
|
+
|
|
|
+void TranslationComponents::disableControls() {
|
|
|
+ ui->texts_block_switch->setEnabled(false);
|
|
|
+ ui->graphics_block_switch->setEnabled(false);
|
|
|
+ ui->video_block_switch->setEnabled(false);
|
|
|
+ ui->audio_block_switch->setEnabled(false);
|
|
|
+ ui->loadscreens_block_switch->setEnabled(false);
|
|
|
+}
|
|
|
+
|
|
|
+void TranslationComponents::enableControls() {
|
|
|
+ ui->texts_block_switch->setEnabled(true);
|
|
|
+ ui->graphics_block_switch->setEnabled(true);
|
|
|
+ ui->video_block_switch->setEnabled(true);
|
|
|
+ ui->audio_block_switch->setEnabled(true);
|
|
|
+ ui->loadscreens_block_switch->setEnabled(true);
|
|
|
+}
|
|
|
+
|
|
|
+void TranslationComponents::onTextsChange(bool new_value) {
|
|
|
+ Settings::setValue("Components/texts_main", new_value);
|
|
|
+ Settings::setValue("Components/texts_emotes", new_value);
|
|
|
+ Settings::setValue("Components/texts_items", new_value);
|
|
|
+ checkIfSettingsDoNotMatchCurrentDatState();
|
|
|
+}
|
|
|
+
|
|
|
+void TranslationComponents::onImagesChange(bool new_value) {
|
|
|
+ Settings::setValue("Components/maps", new_value);
|
|
|
+ Settings::setValue("Components/textures", new_value);
|
|
|
+ checkIfSettingsDoNotMatchCurrentDatState();
|
|
|
+}
|
|
|
+
|
|
|
+void TranslationComponents::onVideosChange(bool new_value) {
|
|
|
+ Settings::setValue("Components/videos", new_value);
|
|
|
+ Settings::setValue("Components/texts_videos", new_value);
|
|
|
+ checkIfSettingsDoNotMatchCurrentDatState();
|
|
|
+}
|
|
|
+
|
|
|
+void TranslationComponents::onSoundsChange(bool new_value) {
|
|
|
+ Settings::setValue("Components/sounds", new_value);
|
|
|
+ checkIfSettingsDoNotMatchCurrentDatState();
|
|
|
+}
|
|
|
+
|
|
|
+void TranslationComponents::onLoadscreensChange(bool new_value) {
|
|
|
+ Settings::setValue("Components/loadscreens", new_value);
|
|
|
+ checkIfSettingsDoNotMatchCurrentDatState();
|
|
|
+}
|
|
|
+
|
|
|
+void TranslationComponents::checkIfSettingsDoNotMatchCurrentDatState() {
|
|
|
+ PatchInstaller::AppliedPatchesInfo info = PatchInstaller::instance().getPatchesInfo();
|
|
|
+ bool texts_enabled = info.texts_version != 0;
|
|
|
+ bool images_enabled = info.graphics_version != 0;
|
|
|
+ bool videos_enabled = info.videos_version != 0;
|
|
|
+ bool sounds_enabled = info.audio_version != 0;
|
|
|
+ bool loadscreens_enabled = info.loadscreens_version != 0;
|
|
|
+
|
|
|
+ bool match = Settings::getValue("Components/texts_main").toBool() == texts_enabled &&
|
|
|
+ Settings::getValue("Components/texts_emotes").toBool() == texts_enabled &&
|
|
|
+ Settings::getValue("Components/texts_items").toBool() == texts_enabled &&
|
|
|
+ Settings::getValue("Components/maps").toBool() == images_enabled &&
|
|
|
+ Settings::getValue("Components/textures").toBool() == images_enabled &&
|
|
|
+ Settings::getValue("Components/videos").toBool() == videos_enabled &&
|
|
|
+ Settings::getValue("Components/texts_videos").toBool() == videos_enabled &&
|
|
|
+ Settings::getValue("Components/sounds").toBool() == sounds_enabled &&
|
|
|
+ Settings::getValue("Components/loadscreens").toBool() == loadscreens_enabled;
|
|
|
+
|
|
|
+ if (!match) {
|
|
|
+ emit needToPatch();
|
|
|
+ } else {
|
|
|
+ emit noNeedToPatch();
|
|
|
+ }
|
|
|
+}
|