123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #include "translationcomponents.h"
- #include "ui_translationcomponents.h"
- #include "models/patchinstaller.h"
- #include "models/patchdownloader.h"
- #include "models/settings.h"
- TranslationComponents::TranslationComponents(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::TranslationComponents)
- {
- ui->setupUi(this);
- setAttribute(Qt::WA_StyledBackground, true);
- 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()
- {
- delete ui;
- }
- 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();
- }
- }
|