1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #include "gamesettings.h"
- #include "ui_gamesettings.h"
- #include "models/settings.h"
- #include "models/filesystem.h"
- #include "models/patchinstaller.h"
- #include "models/patchdownloader.h"
- #include "legacyapplication.h"
- #include <QFileDialog>
- GameSettings::GameSettings(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::GameSettings)
- {
- 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()
- {
- delete ui;
- }
- void GameSettings::setActualParametersValues()
- {
- QString game_path = Settings::getValue("Lotro/game_path").toString();
- if (game_path == "none") {
- game_path = "(не выбрана)";
- }
- ui->game_folder_path->setText(game_path);
- QString original_locale = Settings::getValue("Lotro/original_locale").toString();
- int index = 0;
- if (original_locale == "English")
- index = 0;
- if (original_locale == "DE")
- index = 1;
- if (original_locale == "FR")
- index = 2;
- ui->lotro_base_language_combobox->setCurrentIndex(index);
- }
- void GameSettings::on_change_folder_button_clicked()
- {
- QStringList known_paths = FileSystem::recognizeRegistryLotroPath();
- QString template_path = known_paths.empty() ? "" : known_paths[0];
- QString str = QFileDialog::getOpenFileName(0, "Расположение игры", template_path, "LotroLauncher.exe");
- if (str.isEmpty()) {
- return;
- }
- QString game_folder= str.replace("/LotroLauncher.exe", "").replace("\\", "/").replace("//", "/") + "/";
- ui->game_folder_path->setText(game_folder);
- Settings::setValue("Lotro/game_path", game_folder);
- QMetaObject::invokeMethod(&PatchInstaller::instance(), &PatchInstaller::deinit, Qt::QueuedConnection);
- QMetaObject::invokeMethod(&LegacyApplication::instance(), &LegacyApplication::InitModules, Qt::DirectConnection);
- }
- void GameSettings::on_lotro_base_language_combobox_currentIndexChanged(int index)
- {
- QString value = "English";
- if (index == 0)
- value = "English";
- if (index == 1)
- value = "DE";
- if (index == 2)
- value = "FR";
- Settings::setValue("Lotro/original_locale", value);
- QMetaObject::invokeMethod(&PatchInstaller::instance(), &PatchInstaller::deinit, Qt::QueuedConnection);
- QMetaObject::invokeMethod(&LegacyApplication::instance(), &LegacyApplication::InitModules, Qt::DirectConnection);
- }
- void GameSettings::onPatchTotalOperationsStarted() {
- 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);
- }
|