2022-04-23 09:59:50 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-06-19 20:38:49 +01:00
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include "common/fs/fs.h"
|
|
|
|
#include "common/fs/path_util.h"
|
|
|
|
#include "common/settings.h"
|
|
|
|
#include "ui_configure_tas.h"
|
|
|
|
#include "yuzu/configuration/configure_tas.h"
|
|
|
|
#include "yuzu/uisettings.h"
|
|
|
|
|
|
|
|
ConfigureTasDialog::ConfigureTasDialog(QWidget* parent)
|
|
|
|
: QDialog(parent), ui(std::make_unique<Ui::ConfigureTas>()) {
|
|
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
setFocusPolicy(Qt::ClickFocus);
|
|
|
|
setWindowTitle(tr("TAS Configuration"));
|
|
|
|
|
|
|
|
connect(ui->tas_path_button, &QToolButton::pressed, this,
|
|
|
|
[this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); });
|
|
|
|
|
|
|
|
LoadConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigureTasDialog::~ConfigureTasDialog() = default;
|
|
|
|
|
|
|
|
void ConfigureTasDialog::LoadConfiguration() {
|
|
|
|
ui->tas_path_edit->setText(
|
|
|
|
QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::TASDir)));
|
2021-07-06 02:58:52 +01:00
|
|
|
ui->tas_enable->setChecked(Settings::values.tas_enable.GetValue());
|
|
|
|
ui->tas_loop_script->setChecked(Settings::values.tas_loop.GetValue());
|
|
|
|
ui->tas_pause_on_load->setChecked(Settings::values.pause_tas_on_load.GetValue());
|
2021-06-19 20:38:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureTasDialog::ApplyConfiguration() {
|
|
|
|
Common::FS::SetYuzuPath(Common::FS::YuzuPath::TASDir, ui->tas_path_edit->text().toStdString());
|
2021-07-06 02:58:52 +01:00
|
|
|
Settings::values.tas_enable.SetValue(ui->tas_enable->isChecked());
|
|
|
|
Settings::values.tas_loop.SetValue(ui->tas_loop_script->isChecked());
|
|
|
|
Settings::values.pause_tas_on_load.SetValue(ui->tas_pause_on_load->isChecked());
|
2021-06-19 20:38:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureTasDialog::SetDirectory(DirectoryTarget target, QLineEdit* edit) {
|
|
|
|
QString caption;
|
|
|
|
|
|
|
|
switch (target) {
|
|
|
|
case DirectoryTarget::TAS:
|
|
|
|
caption = tr("Select TAS Load Directory...");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString str = QFileDialog::getExistingDirectory(this, caption, edit->text());
|
|
|
|
|
2021-07-26 02:52:19 +01:00
|
|
|
if (str.isEmpty()) {
|
2021-06-19 20:38:49 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str.back() != QChar::fromLatin1('/')) {
|
|
|
|
str.append(QChar::fromLatin1('/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
edit->setText(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureTasDialog::changeEvent(QEvent* event) {
|
|
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
|
|
RetranslateUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
QDialog::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureTasDialog::RetranslateUI() {
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureTasDialog::HandleApplyButtonClicked() {
|
|
|
|
UISettings::values.configuration_applied = true;
|
|
|
|
ApplyConfiguration();
|
|
|
|
}
|