123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #include "translationcomponents.h"
- #include "ui_translationcomponents.h"
- #include "models/patchinstaller.h"
- #include "models/patchdownloader.h"
- #include "models/settings.h"
- #include "fonts.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::updateFontsSizes()
- {
- ui->sub_entry_3_title->setFont(crimson_12pt);
- ui->audio_block_label->setFont(crimson_12pt);
- ui->texts_block_label->setFont(crimson_12pt);
- ui->video_block_label->setFont(crimson_12pt);
- ui->graphics_block_label->setFont(crimson_12pt);
- ui->loadscreens_block_label->setFont(crimson_12pt);
- }
- void TranslationComponents::resizeEvent(QResizeEvent *)
- {
- updateFontsSizes();
- }
- void TranslationComponents::resetSwitchesToDefault() {
- PatchInstaller::AppliedPatchesInfo info = PatchInstaller::instance().getPatchesInfo();
- Settings::setValue("DatabaseDownload/text", info.texts_patch_hashsum != "");
- Settings::setValue("DatabaseDownload/font", info.texts_patch_hashsum != "");
- Settings::setValue("DatabaseDownload/image", info.images_patch_hashsum != "");
- Settings::setValue("DatabaseDownload/loadscreen", info.loadscreens_patch_hashsum != "");
- Settings::setValue("DatabaseDownload/texture", info.textures_patch_hashsum != "");
- Settings::setValue("DatabaseDownload/sound", info.sounds_patch_hashsum != "");
- Settings::setValue("DatabaseDownload/video", info.videos_patch_hashsum != "");
- ui->texts_block_switch->setValue(info.texts_patch_hashsum != 0 && info.fonts_patch_hashsum != 0);
- ui->graphics_block_switch->setValue(info.images_patch_hashsum != 0 && info.textures_patch_hashsum != 0);
- ui->video_block_switch->setValue(info.videos_patch_hashsum != 0);
- ui->audio_block_switch->setValue(info.sounds_patch_hashsum != 0);
- ui->loadscreens_block_switch->setValue(info.loadscreens_patch_hashsum != 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("DatabaseDownload/text", new_value);
- Settings::setValue("DatabaseDownload/font", new_value);
- checkIfSettingsDoNotMatchCurrentDatState();
- QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::checkForUpdates, Qt::QueuedConnection);
- }
- void TranslationComponents::onImagesChange(bool new_value) {
- Settings::setValue("DatabaseDownload/image", new_value);
- Settings::setValue("DatabaseDownload/texture", new_value);
- checkIfSettingsDoNotMatchCurrentDatState();
- QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::checkForUpdates, Qt::QueuedConnection);
- }
- void TranslationComponents::onVideosChange(bool new_value) {
- Settings::setValue("DatabaseDownload/video", new_value);
- checkIfSettingsDoNotMatchCurrentDatState();
- QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::checkForUpdates, Qt::QueuedConnection);
- }
- void TranslationComponents::onSoundsChange(bool new_value) {
- Settings::setValue("DatabaseDownload/sound", new_value);
- checkIfSettingsDoNotMatchCurrentDatState();
- QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::checkForUpdates, Qt::QueuedConnection);
- }
- void TranslationComponents::onLoadscreensChange(bool new_value) {
- Settings::setValue("DatabaseDownload/loadscreen", new_value);
- checkIfSettingsDoNotMatchCurrentDatState();
- QMetaObject::invokeMethod(&PatchDownloader::instance(), &PatchDownloader::checkForUpdates, Qt::QueuedConnection);
- }
- void TranslationComponents::checkIfSettingsDoNotMatchCurrentDatState() {
- PatchInstaller::AppliedPatchesInfo info = PatchInstaller::instance().getPatchesInfo();
- bool texts_enabled = info.texts_patch_hashsum != "";
- bool images_enabled = info.images_patch_hashsum != "";
- bool sounds_enabled = info.sounds_patch_hashsum != "";
- bool loadscreens_enabled = info.loadscreens_patch_hashsum != "";
- bool textures_enabled = info.textures_patch_hashsum != "";
- bool fonts_enabled = info.fonts_patch_hashsum != "";
- bool videos_enabled = info.videos_patch_hashsum != "";
- bool match = Settings::getValue("DatabaseDownload/text").toBool() == texts_enabled &&
- Settings::getValue("DatabaseDownload/font").toBool() == fonts_enabled &&
- Settings::getValue("DatabaseDownload/image").toBool() == images_enabled &&
- Settings::getValue("DatabaseDownload/loadscreen").toBool() == loadscreens_enabled &&
- Settings::getValue("DatabaseDownload/texture").toBool() == textures_enabled &&
- Settings::getValue("DatabaseDownload/sound").toBool() == sounds_enabled &&
- Settings::getValue("DatabaseDownload/video").toBool() == videos_enabled;
- if (!match) {
- emit needToPatch();
- } else {
- emit noNeedToPatch();
- }
- }
|