2017-12-06 03:31:43 +00:00
|
|
|
#include "MainWindow.hpp"
|
|
|
|
#include "ui_MainWindow.h"
|
|
|
|
#include <QFontDatabase>
|
2018-01-03 23:53:01 +00:00
|
|
|
#include <QMessageBox>
|
2019-06-29 18:02:33 +00:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QLabel>
|
2018-01-03 00:24:45 +00:00
|
|
|
#include "EscapeSequenceParser.hpp"
|
2017-12-06 03:31:43 +00:00
|
|
|
#include "FileDirDialog.hpp"
|
2018-01-10 06:19:48 +00:00
|
|
|
#include "ExtractZip.hpp"
|
2017-12-06 03:31:43 +00:00
|
|
|
|
2018-01-02 05:56:25 +00:00
|
|
|
#if _WIN32
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <shellapi.h>
|
2018-01-10 06:19:48 +00:00
|
|
|
#include <TlHelp32.h>
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
static void KillProcessTree(QProcess& proc) {
|
|
|
|
Q_PID pid = proc.pid();
|
|
|
|
if (!pid)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DWORD myprocID = pid->dwProcessId;
|
|
|
|
PROCESSENTRY32 pe = {};
|
|
|
|
pe.dwSize = sizeof(PROCESSENTRY32);
|
|
|
|
|
|
|
|
HANDLE hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
|
|
|
|
|
|
|
if (::Process32First(hSnap, &pe)) {
|
|
|
|
BOOL bContinue = TRUE;
|
|
|
|
|
|
|
|
// kill child processes
|
|
|
|
while (bContinue) {
|
|
|
|
// only kill child processes
|
|
|
|
if (pe.th32ParentProcessID == myprocID) {
|
|
|
|
HANDLE hChildProc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
|
|
|
|
|
|
|
|
if (hChildProc) {
|
|
|
|
::TerminateProcess(hChildProc, 1);
|
|
|
|
::CloseHandle(hChildProc);
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
2018-12-08 05:19:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bContinue = ::Process32Next(hSnap, &pe);
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
2018-12-08 05:19:40 +00:00
|
|
|
}
|
2018-01-10 06:19:48 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
proc.close();
|
|
|
|
proc.terminate();
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
|
|
|
#else
|
2018-12-08 05:19:40 +00:00
|
|
|
static void KillProcessTree(QProcess& proc) {
|
|
|
|
proc.close();
|
|
|
|
proc.terminate();
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
2018-01-02 05:56:25 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-28 01:35:51 +00:00
|
|
|
const QStringList MainWindow::skUpdateTracks = {QStringLiteral("stable"), QStringLiteral("dev")};
|
2019-06-29 18:02:33 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
MainWindow::MainWindow(QWidget* parent)
|
|
|
|
: QMainWindow(parent)
|
2019-08-26 00:50:17 +00:00
|
|
|
, m_ui(std::make_unique<Ui::MainWindow>())
|
2018-12-08 05:19:40 +00:00
|
|
|
, m_fileMgr(_SYS_STR("urde"))
|
|
|
|
, m_cvarManager(m_fileMgr)
|
|
|
|
, m_cvarCommons(m_cvarManager)
|
|
|
|
, m_heclProc(this)
|
2020-04-18 10:08:11 +00:00
|
|
|
, m_dlManager(this) {
|
2019-08-28 01:35:51 +00:00
|
|
|
if (m_settings.value(QStringLiteral("urde_arguments")).isNull()) {
|
|
|
|
m_settings.setValue(QStringLiteral("urde_arguments"), QStringList{QStringLiteral("--no-shader-warmup")});
|
|
|
|
}
|
|
|
|
if (m_settings.value(QStringLiteral("update_track")).isNull()) {
|
|
|
|
m_settings.setValue(QStringLiteral("update_track"), QStringLiteral("stable"));
|
|
|
|
}
|
2019-01-26 23:22:16 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->setupUi(this);
|
|
|
|
m_ui->heclTabs->setCurrentIndex(0);
|
|
|
|
|
|
|
|
m_ui->aboutIcon->setPixmap(QApplication::windowIcon().pixmap(256, 256));
|
|
|
|
|
|
|
|
QFont mFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
|
|
|
mFont.setPointSize(m_ui->currentBinaryLabel->font().pointSize());
|
|
|
|
m_ui->currentBinaryLabel->setFont(mFont);
|
|
|
|
m_ui->recommendedBinaryLabel->setFont(mFont);
|
|
|
|
mFont.setPointSize(10);
|
|
|
|
m_ui->processOutput->setFont(mFont);
|
|
|
|
m_cursor = QTextCursor(m_ui->processOutput->document());
|
2020-04-18 21:16:08 +00:00
|
|
|
connect(m_ui->saveLogButton, &QPushButton::pressed, this, [this] {
|
2020-09-04 07:33:46 +00:00
|
|
|
QString defaultFileName = QStringLiteral("urde-") + QDateTime::currentDateTime().toString(Qt::DateFormat::ISODate) +
|
|
|
|
QStringLiteral(".log");
|
2020-04-18 21:16:08 +00:00
|
|
|
defaultFileName.replace(QLatin1Char(':'), QLatin1Char('-'));
|
|
|
|
const QString fileName =
|
|
|
|
QFileDialog::getSaveFileName(this, tr("Save Log"), defaultFileName, QStringLiteral("*.log"));
|
|
|
|
if (fileName.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QFile file = QFile(fileName);
|
|
|
|
if (file.open(QFile::OpenModeFlag::WriteOnly | QFile::OpenModeFlag::Truncate | QFile::OpenModeFlag::Text)) {
|
|
|
|
QTextStream stream(&file);
|
|
|
|
stream << m_ui->processOutput->toPlainText();
|
|
|
|
stream.flush();
|
|
|
|
file.close();
|
|
|
|
} else {
|
|
|
|
QMessageBox::critical(this, tr("Save Log"), tr("Failed to open log file"));
|
|
|
|
}
|
|
|
|
});
|
2018-12-08 05:19:40 +00:00
|
|
|
|
2019-08-30 06:38:10 +00:00
|
|
|
m_updateURDEButton = new QPushButton(tr("Update URDE"), m_ui->centralwidget);
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->gridLayout->addWidget(m_updateURDEButton, 2, 3, 1, 1);
|
|
|
|
m_updateURDEButton->hide();
|
|
|
|
QPalette pal = m_updateURDEButton->palette();
|
|
|
|
pal.setColor(QPalette::Button, QColor(53, 53, 72));
|
|
|
|
m_updateURDEButton->setPalette(pal);
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(m_updateURDEButton, &QPushButton::clicked, this, &MainWindow::onUpdateURDEPressed);
|
2019-08-28 01:35:51 +00:00
|
|
|
qDebug() << "Stored track " << m_settings.value(QStringLiteral("update_track"));
|
|
|
|
const int index = skUpdateTracks.indexOf(m_settings.value(QStringLiteral("update_track")).toString());
|
2019-06-29 18:02:33 +00:00
|
|
|
m_ui->devTrackWarning->setVisible(index == 1);
|
|
|
|
m_ui->updateTrackComboBox->setCurrentIndex(index);
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(m_ui->updateTrackComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
|
|
|
&MainWindow::onUpdateTrackChanged);
|
2018-12-08 05:19:40 +00:00
|
|
|
|
|
|
|
m_dlManager.connectWidgets(m_ui->downloadProgressBar, m_ui->downloadErrorLabel,
|
|
|
|
std::bind(&MainWindow::onIndexDownloaded, this, std::placeholders::_1),
|
|
|
|
std::bind(&MainWindow::onBinaryDownloaded, this, std::placeholders::_1),
|
|
|
|
std::bind(&MainWindow::onBinaryFailed, this));
|
|
|
|
|
2020-04-18 10:08:11 +00:00
|
|
|
initOptions();
|
2018-12-08 05:19:40 +00:00
|
|
|
initSlots();
|
|
|
|
|
|
|
|
m_dlManager.fetchIndex();
|
|
|
|
|
|
|
|
setPath(m_settings.value(QStringLiteral("working_dir")).toString());
|
2017-12-06 03:31:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-14 18:50:14 +00:00
|
|
|
MainWindow::~MainWindow() { KillProcessTree(m_heclProc); }
|
2017-12-06 03:31:43 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onExtract() {
|
2019-08-30 06:38:10 +00:00
|
|
|
if (m_path.isEmpty()) {
|
2018-12-08 05:19:40 +00:00
|
|
|
return;
|
2019-08-30 06:38:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString imgPath =
|
|
|
|
QFileDialog::getOpenFileName(this, tr("Extract Image"), m_path, tr("Images (*.iso *.wbfs *.gcm)"));
|
|
|
|
if (imgPath.isEmpty()) {
|
2018-12-08 05:19:40 +00:00
|
|
|
return;
|
2019-08-30 06:38:10 +00:00
|
|
|
}
|
2018-12-08 05:19:40 +00:00
|
|
|
|
|
|
|
m_ui->processOutput->clear();
|
|
|
|
KillProcessTree(m_heclProc);
|
|
|
|
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
|
|
|
m_heclProc.setWorkingDirectory(m_path);
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
2019-08-28 01:35:51 +00:00
|
|
|
env.insert(QStringLiteral("TERM"), QStringLiteral("xterm-color"));
|
|
|
|
env.insert(QStringLiteral("ConEmuANSI"), QStringLiteral("ON"));
|
2018-12-08 05:19:40 +00:00
|
|
|
m_heclProc.setProcessEnvironment(env);
|
2019-08-26 03:19:55 +00:00
|
|
|
disconnect(&m_heclProc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), nullptr, nullptr);
|
|
|
|
connect(&m_heclProc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, &MainWindow::onExtractFinished);
|
2019-08-28 01:35:51 +00:00
|
|
|
|
|
|
|
const QStringList heclProcArguments{
|
|
|
|
QStringLiteral("extract"), QStringLiteral("-y"), QStringLiteral("-g"), QStringLiteral("-o"), m_path, imgPath};
|
|
|
|
m_heclProc.start(m_heclPath, heclProcArguments, QIODevice::ReadOnly | QIODevice::Unbuffered);
|
2018-12-08 05:19:40 +00:00
|
|
|
|
|
|
|
m_ui->heclTabs->setCurrentIndex(0);
|
|
|
|
|
|
|
|
disableOperations();
|
2020-04-14 18:50:14 +00:00
|
|
|
m_ui->extractBtn->setText(tr("&Cancel"));
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->extractBtn->setEnabled(true);
|
2019-08-26 00:21:03 +00:00
|
|
|
disconnect(m_ui->extractBtn, &QPushButton::clicked, nullptr, nullptr);
|
|
|
|
connect(m_ui->extractBtn, &QPushButton::clicked, this, &MainWindow::doHECLTerminate);
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 03:19:55 +00:00
|
|
|
void MainWindow::onExtractFinished(int returnCode, QProcess::ExitStatus) {
|
2018-12-08 05:19:40 +00:00
|
|
|
m_cursor.movePosition(QTextCursor::End);
|
|
|
|
m_cursor.insertBlock();
|
2019-08-26 00:21:03 +00:00
|
|
|
disconnect(m_ui->extractBtn, &QPushButton::clicked, nullptr, nullptr);
|
|
|
|
connect(m_ui->extractBtn, &QPushButton::clicked, this, &MainWindow::onExtract);
|
2018-12-08 05:19:40 +00:00
|
|
|
checkDownloadedBinary();
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onPackage() {
|
|
|
|
if (m_path.isEmpty())
|
|
|
|
return;
|
|
|
|
m_ui->processOutput->clear();
|
|
|
|
KillProcessTree(m_heclProc);
|
|
|
|
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
|
|
|
m_heclProc.setWorkingDirectory(m_path);
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
2019-08-28 01:35:51 +00:00
|
|
|
env.insert(QStringLiteral("TERM"), QStringLiteral("xterm-color"));
|
|
|
|
env.insert(QStringLiteral("ConEmuANSI"), QStringLiteral("ON"));
|
2018-12-08 05:19:40 +00:00
|
|
|
m_heclProc.setProcessEnvironment(env);
|
2019-08-26 03:19:55 +00:00
|
|
|
disconnect(&m_heclProc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), nullptr, nullptr);
|
|
|
|
connect(&m_heclProc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, &MainWindow::onPackageFinished);
|
2019-08-28 01:35:51 +00:00
|
|
|
|
|
|
|
const QStringList heclProcArguments{QStringLiteral("package"), QStringLiteral("-y"), QStringLiteral("-g")};
|
|
|
|
m_heclProc.start(m_heclPath, heclProcArguments, QIODevice::ReadOnly | QIODevice::Unbuffered);
|
2018-12-08 05:19:40 +00:00
|
|
|
|
|
|
|
m_ui->heclTabs->setCurrentIndex(0);
|
|
|
|
|
|
|
|
disableOperations();
|
2020-04-14 18:50:14 +00:00
|
|
|
m_ui->packageBtn->setText(tr("&Cancel"));
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->packageBtn->setEnabled(true);
|
2019-08-26 00:21:03 +00:00
|
|
|
disconnect(m_ui->packageBtn, &QPushButton::clicked, nullptr, nullptr);
|
|
|
|
connect(m_ui->packageBtn, &QPushButton::clicked, this, &MainWindow::doHECLTerminate);
|
2018-12-08 05:19:40 +00:00
|
|
|
|
|
|
|
QSize size = QWidget::size();
|
|
|
|
if (size.width() < 1100)
|
|
|
|
size.setWidth(1100);
|
|
|
|
resize(size);
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 03:19:55 +00:00
|
|
|
void MainWindow::onPackageFinished(int returnCode, QProcess::ExitStatus) {
|
2018-12-08 05:19:40 +00:00
|
|
|
m_cursor.movePosition(QTextCursor::End);
|
|
|
|
m_cursor.insertBlock();
|
2019-08-26 00:21:03 +00:00
|
|
|
disconnect(m_ui->packageBtn, &QPushButton::clicked, nullptr, nullptr);
|
|
|
|
connect(m_ui->packageBtn, &QPushButton::clicked, this, &MainWindow::onPackage);
|
2018-12-08 05:19:40 +00:00
|
|
|
checkDownloadedBinary();
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onLaunch() {
|
|
|
|
if (m_path.isEmpty())
|
|
|
|
return;
|
|
|
|
m_ui->processOutput->clear();
|
|
|
|
KillProcessTree(m_heclProc);
|
|
|
|
m_heclProc.setProcessChannelMode(QProcess::ProcessChannelMode::MergedChannels);
|
|
|
|
m_heclProc.setWorkingDirectory(m_path);
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
2019-08-28 01:35:51 +00:00
|
|
|
env.insert(QStringLiteral("TERM"), QStringLiteral("xterm-color"));
|
|
|
|
env.insert(QStringLiteral("ConEmuANSI"), QStringLiteral("ON"));
|
2018-12-08 05:19:40 +00:00
|
|
|
m_heclProc.setProcessEnvironment(env);
|
2019-08-26 03:19:55 +00:00
|
|
|
disconnect(&m_heclProc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), nullptr, nullptr);
|
|
|
|
connect(&m_heclProc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, &MainWindow::onLaunchFinished);
|
2019-08-28 01:35:51 +00:00
|
|
|
|
|
|
|
const auto heclProcArguments = QStringList{m_path + QStringLiteral("/out")}
|
2020-04-14 06:52:36 +00:00
|
|
|
<< QStringLiteral("-l")
|
2019-08-28 01:35:51 +00:00
|
|
|
<< m_settings.value(QStringLiteral("urde_arguments"))
|
|
|
|
.toStringList()
|
|
|
|
.join(QLatin1Char{' '})
|
|
|
|
.split(QLatin1Char{' '});
|
|
|
|
m_heclProc.start(m_urdePath, heclProcArguments, QIODevice::ReadOnly | QIODevice::Unbuffered);
|
2018-12-08 05:19:40 +00:00
|
|
|
|
|
|
|
m_ui->heclTabs->setCurrentIndex(0);
|
|
|
|
|
|
|
|
disableOperations();
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 03:19:55 +00:00
|
|
|
void MainWindow::onLaunchFinished(int returnCode, QProcess::ExitStatus) {
|
2018-12-08 05:19:40 +00:00
|
|
|
m_cursor.movePosition(QTextCursor::End);
|
|
|
|
m_cursor.insertBlock();
|
|
|
|
checkDownloadedBinary();
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::doHECLTerminate() { KillProcessTree(m_heclProc); }
|
2017-12-06 03:31:43 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onReturnPressed() {
|
|
|
|
if (sender() == m_ui->pathEdit)
|
|
|
|
setPath(m_ui->pathEdit->text());
|
2017-12-06 03:31:43 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onIndexDownloaded(const QStringList& index) {
|
|
|
|
int bestVersion = 0;
|
|
|
|
m_ui->binaryComboBox->clear();
|
|
|
|
for (const QString& str : index) {
|
|
|
|
URDEVersion version(str);
|
|
|
|
if (m_ui->sysReqTable->willRun(version))
|
|
|
|
bestVersion = m_ui->binaryComboBox->count();
|
|
|
|
m_ui->binaryComboBox->addItem(version.fileString(false), QVariant::fromValue(version));
|
|
|
|
}
|
|
|
|
m_ui->binaryComboBox->setCurrentIndex(bestVersion);
|
|
|
|
m_recommendedVersion = m_ui->binaryComboBox->itemData(bestVersion).value<URDEVersion>();
|
|
|
|
m_ui->recommendedBinaryLabel->setText(m_recommendedVersion.fileString(false));
|
|
|
|
m_ui->binaryComboBox->setEnabled(true);
|
|
|
|
|
|
|
|
if (!m_path.isEmpty()) {
|
|
|
|
checkDownloadedBinary();
|
|
|
|
m_ui->downloadButton->setEnabled(true);
|
|
|
|
}
|
2017-12-27 00:48:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onDownloadPressed() {
|
|
|
|
m_updateURDEButton->hide();
|
|
|
|
QString filename = m_ui->binaryComboBox->currentData().value<URDEVersion>().fileString(true);
|
|
|
|
disableOperations();
|
|
|
|
m_ui->downloadButton->setEnabled(false);
|
2019-08-28 01:35:51 +00:00
|
|
|
m_dlManager.fetchBinary(filename, m_path + QLatin1Char{'/'} + filename);
|
2017-12-27 00:48:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onUpdateURDEPressed() {
|
2020-04-18 10:08:11 +00:00
|
|
|
m_ui->heclTabs->setCurrentIndex(2);
|
2018-12-08 05:19:40 +00:00
|
|
|
onDownloadPressed();
|
2017-12-26 04:27:18 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onBinaryDownloaded(QuaZip& file) {
|
2019-08-30 06:38:10 +00:00
|
|
|
const bool err = !ExtractZip::extractDir(file, m_path);
|
2018-01-10 06:19:48 +00:00
|
|
|
|
2019-08-30 06:38:10 +00:00
|
|
|
if (err) {
|
|
|
|
m_ui->downloadErrorLabel->setText(tr("Error extracting zip"));
|
|
|
|
} else {
|
|
|
|
m_ui->downloadErrorLabel->setText(tr("Download successful"), true);
|
|
|
|
}
|
2018-01-10 06:19:48 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->downloadButton->setEnabled(true);
|
|
|
|
checkDownloadedBinary();
|
2018-01-10 06:19:48 +00:00
|
|
|
|
2019-08-30 06:38:10 +00:00
|
|
|
if (!err && m_ui->extractBtn->isEnabled()) {
|
|
|
|
m_ui->downloadErrorLabel->setText(tr("Download successful - Press 'Extract' to continue."), true);
|
|
|
|
}
|
|
|
|
if (!err && !m_ui->sysReqTable->isBlenderVersionOk()) {
|
2020-06-14 00:09:17 +00:00
|
|
|
m_ui->downloadErrorLabel->setText(tr("Blender 2.83 must be installed. Please download via Steam or blender.org."));
|
2019-08-30 06:38:10 +00:00
|
|
|
}
|
2017-12-27 00:48:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::onBinaryFailed() {
|
|
|
|
m_ui->downloadButton->setEnabled(true);
|
|
|
|
checkDownloadedBinary();
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::disableOperations() {
|
|
|
|
m_ui->extractBtn->setEnabled(false);
|
|
|
|
m_ui->packageBtn->setEnabled(false);
|
|
|
|
m_ui->launchBtn->setEnabled(false);
|
|
|
|
m_ui->pathEdit->setEnabled(false);
|
|
|
|
m_ui->browseBtn->setEnabled(false);
|
|
|
|
m_ui->downloadButton->setEnabled(false);
|
2020-04-15 06:13:11 +00:00
|
|
|
m_ui->warpBtn->setEnabled(false);
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::enableOperations() {
|
|
|
|
disableOperations();
|
|
|
|
m_ui->pathEdit->setEnabled(true);
|
|
|
|
m_ui->browseBtn->setEnabled(true);
|
2018-01-03 23:53:01 +00:00
|
|
|
|
2020-04-15 06:13:11 +00:00
|
|
|
if (hecl::com_enableCheats->toBoolean()) {
|
|
|
|
m_ui->warpBtn->show();
|
|
|
|
} else {
|
|
|
|
m_ui->warpBtn->hide();
|
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
if (m_path.isEmpty())
|
|
|
|
return;
|
2018-01-02 00:58:38 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->downloadButton->setEnabled(true);
|
2018-01-03 23:53:01 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
if (m_heclPath.isEmpty())
|
|
|
|
return;
|
2018-01-10 06:19:48 +00:00
|
|
|
|
2020-04-14 18:50:14 +00:00
|
|
|
m_ui->extractBtn->setText(tr("&Extract"));
|
|
|
|
m_ui->packageBtn->setText(tr("&Package"));
|
|
|
|
m_ui->launchBtn->setText(tr("&Launch"));
|
2018-01-02 00:58:38 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->extractBtn->setEnabled(true);
|
2020-04-18 10:08:11 +00:00
|
|
|
if (QFile::exists(m_path + QStringLiteral("/out/files/version.yaml"))) {
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->packageBtn->setEnabled(true);
|
2020-04-15 06:13:11 +00:00
|
|
|
if (isPackageComplete()) {
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->launchBtn->setEnabled(true);
|
2020-04-15 06:13:11 +00:00
|
|
|
if (hecl::com_enableCheats->toBoolean()) {
|
|
|
|
m_ui->warpBtn->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
2018-12-08 05:19:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-30 06:38:10 +00:00
|
|
|
if (!m_ui->sysReqTable->isBlenderVersionOk()) {
|
2020-06-14 00:09:17 +00:00
|
|
|
insertContinueNote(tr("Blender 2.83 must be installed. Please download via Steam or blender.org."));
|
2019-08-30 06:38:10 +00:00
|
|
|
} else if (m_ui->launchBtn->isEnabled()) {
|
2019-08-28 01:35:51 +00:00
|
|
|
insertContinueNote(tr("Package complete - Press 'Launch' to start URDE."));
|
2019-08-30 06:38:10 +00:00
|
|
|
} else if (m_ui->packageBtn->isEnabled()) {
|
2019-08-28 01:35:51 +00:00
|
|
|
insertContinueNote(tr("Extract complete - Press 'Package' to continue."));
|
2019-08-30 06:38:10 +00:00
|
|
|
} else if (m_ui->extractBtn->isEnabled()) {
|
2019-08-28 01:35:51 +00:00
|
|
|
insertContinueNote(tr("Press 'Extract' to begin."));
|
2019-08-30 06:38:10 +00:00
|
|
|
}
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
bool MainWindow::isPackageComplete() const {
|
2020-04-14 18:50:14 +00:00
|
|
|
return QFile::exists(m_path + QStringLiteral("/out/files/AudioGrp.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/GGuiSys.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Metroid1.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Metroid2.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Metroid3.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Metroid4.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/metroid5.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Metroid6.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Metroid7.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Metroid8.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/MidiData.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/MiscData.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/NoARAM.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/SamGunFx.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/SamusGun.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/SlideShow.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/TestAnim.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/Tweaks.upak")) &&
|
|
|
|
QFile::exists(m_path + QStringLiteral("/out/files/URDE.upak"));
|
2018-01-14 06:42:13 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
static bool GetDLPackage(const QString& path, QString& dlPackage) {
|
|
|
|
QProcess proc;
|
2019-08-28 01:35:51 +00:00
|
|
|
proc.start(path, {QStringLiteral("--dlpackage")}, QIODevice::ReadOnly);
|
2018-12-08 05:19:40 +00:00
|
|
|
if (proc.waitForStarted()) {
|
|
|
|
proc.waitForFinished();
|
|
|
|
if (proc.exitCode() == 100)
|
|
|
|
dlPackage = QString::fromUtf8(proc.readLine()).trimmed();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
bool MainWindow::checkDownloadedBinary() {
|
|
|
|
m_updateURDEButton->hide();
|
2017-12-27 00:48:34 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
m_urdePath = QString();
|
|
|
|
m_heclPath = QString();
|
2018-01-02 00:58:38 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
if (m_path.isEmpty()) {
|
2020-04-18 10:08:11 +00:00
|
|
|
m_ui->heclTabs->setCurrentIndex(2);
|
2019-08-30 06:38:10 +00:00
|
|
|
m_ui->downloadErrorLabel->setText(tr("Set working directory to continue."), true);
|
2018-12-08 05:19:40 +00:00
|
|
|
enableOperations();
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-02 00:58:38 +00:00
|
|
|
|
2017-12-27 00:48:34 +00:00
|
|
|
#if __APPLE__
|
2019-08-28 01:35:51 +00:00
|
|
|
QString urdePath = m_path + QStringLiteral("/URDE.app/Contents/MacOS/urde");
|
|
|
|
QString heclPath = m_path + QStringLiteral("/URDE.app/Contents/MacOS/hecl");
|
|
|
|
QString visigenPath = m_path + QStringLiteral("/URDE.app/Contents/MacOS/visigen");
|
2017-12-27 00:48:34 +00:00
|
|
|
#elif _WIN32
|
2019-08-28 01:35:51 +00:00
|
|
|
QString urdePath = m_path + QStringLiteral("/urde.exe");
|
|
|
|
QString heclPath = m_path + QStringLiteral("/hecl.exe");
|
|
|
|
QString visigenPath = m_path + QStringLiteral("/visigen.exe");
|
2017-12-27 00:48:34 +00:00
|
|
|
#else
|
2019-08-28 01:35:51 +00:00
|
|
|
QString urdePath = m_path + QStringLiteral("/urde");
|
|
|
|
QString heclPath = m_path + QStringLiteral("/hecl");
|
|
|
|
QString visigenPath = m_path + QStringLiteral("/visigen");
|
2020-04-14 19:35:46 +00:00
|
|
|
if (!QFileInfo::exists(urdePath) || !QFileInfo::exists(heclPath) || !QFileInfo::exists(visigenPath)) {
|
|
|
|
const QString dir = QApplication::instance()->applicationDirPath();
|
|
|
|
urdePath = dir + QStringLiteral("/urde");
|
|
|
|
heclPath = dir + QStringLiteral("/hecl");
|
|
|
|
visigenPath = dir + QStringLiteral("/visigen");
|
|
|
|
}
|
2017-12-27 00:48:34 +00:00
|
|
|
#endif
|
2018-12-08 05:19:40 +00:00
|
|
|
urdePath = QFileInfo(urdePath).absoluteFilePath();
|
|
|
|
heclPath = QFileInfo(heclPath).absoluteFilePath();
|
|
|
|
visigenPath = QFileInfo(visigenPath).absoluteFilePath();
|
|
|
|
|
|
|
|
QString urdeDlPackage, heclDlPackage, visigenDlPackage;
|
|
|
|
if (GetDLPackage(urdePath, urdeDlPackage) && GetDLPackage(heclPath, heclDlPackage) &&
|
|
|
|
GetDLPackage(visigenPath, visigenDlPackage)) {
|
|
|
|
if (!urdeDlPackage.isEmpty() && urdeDlPackage == heclDlPackage && urdeDlPackage == visigenDlPackage) {
|
|
|
|
URDEVersion v(urdeDlPackage);
|
|
|
|
m_ui->currentBinaryLabel->setText(v.fileString(false));
|
|
|
|
if (m_recommendedVersion.isValid() && v.isValid() && m_recommendedVersion.getVersion() > v.getVersion()) {
|
|
|
|
m_updateURDEButton->show();
|
|
|
|
}
|
|
|
|
} else {
|
2019-08-30 06:38:10 +00:00
|
|
|
m_ui->currentBinaryLabel->setText(tr("unknown -- re-download recommended"));
|
2017-12-27 00:48:34 +00:00
|
|
|
}
|
2018-12-08 05:19:40 +00:00
|
|
|
|
|
|
|
m_urdePath = urdePath;
|
|
|
|
m_heclPath = heclPath;
|
|
|
|
m_ui->downloadErrorLabel->setText({}, true);
|
|
|
|
enableOperations();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-04-14 18:50:14 +00:00
|
|
|
m_ui->currentBinaryLabel->setText(tr("none"));
|
2020-04-18 10:08:11 +00:00
|
|
|
m_ui->heclTabs->setCurrentIndex(2);
|
2020-04-14 18:50:14 +00:00
|
|
|
m_ui->downloadErrorLabel->setText(tr("Press 'Download' to fetch latest URDE binary."), true);
|
|
|
|
enableOperations();
|
2018-12-08 05:19:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::setPath(const QString& path) {
|
2019-08-30 06:38:10 +00:00
|
|
|
const QFileInfo finfo(path);
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
QString usePath;
|
2019-08-30 06:38:10 +00:00
|
|
|
if (!path.isEmpty()) {
|
2018-12-08 05:19:40 +00:00
|
|
|
usePath = finfo.absoluteFilePath();
|
2019-08-30 06:38:10 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
if (!usePath.isEmpty() && !finfo.exists()) {
|
2019-08-30 06:38:10 +00:00
|
|
|
if (QMessageBox::question(this, tr("Make Directory"), tr("%1 does not exist. Create it now?").arg(usePath)) ==
|
|
|
|
QMessageBox::Yes) {
|
2018-12-08 05:19:40 +00:00
|
|
|
QDir().mkpath(usePath);
|
2019-08-30 06:38:10 +00:00
|
|
|
} else {
|
2018-12-08 05:19:40 +00:00
|
|
|
usePath = QString();
|
2019-08-30 06:38:10 +00:00
|
|
|
}
|
2018-12-08 05:19:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!usePath.isEmpty() && !finfo.isDir()) {
|
2019-08-30 06:38:10 +00:00
|
|
|
QMessageBox::warning(this, tr("Directory Error"), tr("%1 is not a directory").arg(usePath), QMessageBox::Ok,
|
|
|
|
QMessageBox::NoButton);
|
2018-12-08 05:19:40 +00:00
|
|
|
usePath = QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_path = usePath;
|
|
|
|
m_settings.setValue(QStringLiteral("working_dir"), m_path);
|
|
|
|
|
|
|
|
if (!m_path.isEmpty()) {
|
|
|
|
m_ui->pathEdit->setText(m_path);
|
|
|
|
m_ui->downloadButton->setToolTip(QString());
|
|
|
|
m_ui->downloadButton->setEnabled(m_ui->binaryComboBox->isEnabled());
|
|
|
|
} else {
|
2019-08-30 06:38:10 +00:00
|
|
|
m_ui->downloadButton->setToolTip(tr("Working directory must be set"));
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->downloadButton->setEnabled(false);
|
2019-08-30 06:38:10 +00:00
|
|
|
m_ui->currentBinaryLabel->setText(tr("none"));
|
2018-12-08 05:19:40 +00:00
|
|
|
}
|
2018-01-02 00:58:38 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->sysReqTable->updateFreeDiskSpace(m_path);
|
|
|
|
checkDownloadedBinary();
|
2017-12-27 00:48:34 +00:00
|
|
|
}
|
2017-12-26 04:27:18 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::initSlots() {
|
2020-06-24 15:44:00 +00:00
|
|
|
connect(&m_heclProc, &QProcess::readyRead, [this]() {
|
2019-08-28 01:35:51 +00:00
|
|
|
const QByteArray bytes = m_heclProc.readAll();
|
|
|
|
setTextTermFormatting(QString::fromUtf8(bytes));
|
2018-12-08 05:19:40 +00:00
|
|
|
});
|
2018-01-03 23:53:01 +00:00
|
|
|
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(m_ui->extractBtn, &QPushButton::clicked, this, &MainWindow::onExtract);
|
|
|
|
connect(m_ui->packageBtn, &QPushButton::clicked, this, &MainWindow::onPackage);
|
|
|
|
connect(m_ui->launchBtn, &QPushButton::clicked, this, &MainWindow::onLaunch);
|
2018-01-03 23:53:01 +00:00
|
|
|
|
2020-06-24 15:44:00 +00:00
|
|
|
connect(m_ui->browseBtn, &QPushButton::clicked, [this]() {
|
2018-12-08 05:19:40 +00:00
|
|
|
FileDirDialog dialog(this);
|
|
|
|
dialog.setDirectory(m_path);
|
2019-08-28 01:35:51 +00:00
|
|
|
dialog.setWindowTitle(tr("Select Working Directory"));
|
2018-12-08 05:19:40 +00:00
|
|
|
int res = dialog.exec();
|
|
|
|
if (res == QFileDialog::Rejected)
|
|
|
|
return;
|
2018-01-02 00:58:38 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
if (dialog.selectedFiles().size() <= 0)
|
|
|
|
return;
|
2018-01-02 00:58:38 +00:00
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
setPath(dialog.selectedFiles().at(0));
|
|
|
|
});
|
2020-09-04 07:33:46 +00:00
|
|
|
connect(m_ui->pathEdit, &QLineEdit::editingFinished, [this]() {
|
|
|
|
setPath(m_ui->pathEdit->text());
|
|
|
|
});
|
2017-12-26 04:27:18 +00:00
|
|
|
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(m_ui->downloadButton, &QPushButton::clicked, this, &MainWindow::onDownloadPressed);
|
2017-12-06 03:31:43 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::setTextTermFormatting(const QString& text) {
|
|
|
|
m_inContinueNote = false;
|
|
|
|
|
2020-04-18 10:08:11 +00:00
|
|
|
m_cursor.beginEditBlock();
|
2019-08-28 01:35:51 +00:00
|
|
|
QRegExp const escapeSequenceExpression(QStringLiteral(R"(\x1B\[([\d;\?FA]+)([mlh]?))"));
|
2018-12-08 05:19:40 +00:00
|
|
|
QTextCharFormat defaultTextCharFormat = m_cursor.charFormat();
|
|
|
|
int offset = escapeSequenceExpression.indexIn(text);
|
|
|
|
ReturnInsert(m_cursor, text.mid(0, offset));
|
|
|
|
QTextCharFormat textCharFormat = defaultTextCharFormat;
|
|
|
|
while (offset >= 0) {
|
|
|
|
int previousOffset = offset + escapeSequenceExpression.matchedLength();
|
|
|
|
QStringList captures = escapeSequenceExpression.capturedTexts();
|
2019-08-28 01:35:51 +00:00
|
|
|
if (captures.size() >= 3 && captures[2] == QStringLiteral("m")) {
|
|
|
|
QStringList capturedTexts = captures[1].split(QLatin1Char{';'});
|
2018-12-08 05:19:40 +00:00
|
|
|
QListIterator<QString> i(capturedTexts);
|
|
|
|
while (i.hasNext()) {
|
|
|
|
bool ok = false;
|
|
|
|
int attribute = i.next().toInt(&ok);
|
|
|
|
Q_ASSERT(ok);
|
|
|
|
ParseEscapeSequence(attribute, i, textCharFormat, defaultTextCharFormat);
|
|
|
|
}
|
2019-08-28 01:35:51 +00:00
|
|
|
} else if (captures.size() >= 2 &&
|
|
|
|
(captures[1].endsWith(QLatin1Char{'F'}) || captures[1].endsWith(QLatin1Char{'A'}))) {
|
2018-12-08 05:19:40 +00:00
|
|
|
int lineCount = captures[1].chopped(1).toInt();
|
|
|
|
if (!lineCount)
|
|
|
|
lineCount = 1;
|
|
|
|
for (int i = 0; i < lineCount; ++i) {
|
|
|
|
m_cursor.movePosition(QTextCursor::PreviousBlock);
|
|
|
|
m_cursor.select(QTextCursor::BlockUnderCursor);
|
|
|
|
m_cursor.removeSelectedText();
|
|
|
|
m_cursor.insertBlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
offset = escapeSequenceExpression.indexIn(text, previousOffset);
|
|
|
|
if (offset < 0) {
|
|
|
|
ReturnInsert(m_cursor, text.mid(previousOffset), textCharFormat);
|
|
|
|
} else {
|
|
|
|
ReturnInsert(m_cursor, text.mid(previousOffset, offset - previousOffset), textCharFormat);
|
2017-12-06 03:31:43 +00:00
|
|
|
}
|
2018-12-08 05:19:40 +00:00
|
|
|
}
|
|
|
|
m_cursor.setCharFormat(defaultTextCharFormat);
|
2020-04-18 10:08:11 +00:00
|
|
|
m_cursor.endEditBlock();
|
2018-12-08 05:19:40 +00:00
|
|
|
m_ui->processOutput->ensureCursorVisible();
|
2018-01-02 00:58:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void MainWindow::insertContinueNote(const QString& text) {
|
|
|
|
if (m_inContinueNote)
|
|
|
|
return;
|
|
|
|
m_inContinueNote = true;
|
|
|
|
|
|
|
|
m_cursor.movePosition(QTextCursor::End);
|
|
|
|
QTextCharFormat textCharFormat = m_cursor.charFormat();
|
|
|
|
textCharFormat.setForeground(QColor(0, 255, 0));
|
|
|
|
m_cursor.insertText(text, textCharFormat);
|
|
|
|
m_cursor.insertBlock();
|
|
|
|
m_ui->processOutput->ensureCursorVisible();
|
2017-12-06 03:31:43 +00:00
|
|
|
}
|
2020-04-14 06:52:01 +00:00
|
|
|
|
2020-04-14 18:50:14 +00:00
|
|
|
void MainWindow::onUpdateTrackChanged(int index) {
|
2019-08-28 01:35:51 +00:00
|
|
|
qDebug() << "Track changed from " << m_settings.value(QStringLiteral("update_track")) << " to "
|
|
|
|
<< skUpdateTracks[index];
|
|
|
|
m_settings.setValue(QStringLiteral("update_track"), skUpdateTracks[index]);
|
2019-06-29 18:02:33 +00:00
|
|
|
m_dlManager.fetchIndex();
|
|
|
|
m_ui->devTrackWarning->setVisible(index == 1);
|
|
|
|
}
|
2020-04-18 10:08:11 +00:00
|
|
|
|
|
|
|
void MainWindow::initOptions() {
|
|
|
|
initGraphicsApiOption(m_ui->metalOption, CurPlatform != Platform::MacOS, DEFAULT_GRAPHICS_API == "Metal"sv);
|
|
|
|
initGraphicsApiOption(m_ui->vulkanOption, CurPlatform == Platform::MacOS, DEFAULT_GRAPHICS_API == "Vulkan"sv);
|
|
|
|
initGraphicsApiOption(m_ui->d3d11Option, CurPlatform != Platform::Win32, DEFAULT_GRAPHICS_API == "D3D11"sv);
|
|
|
|
initNumberComboOption(m_ui->anistropicFilteringBox, m_cvarCommons.m_texAnisotropy);
|
|
|
|
initNumberComboOption(m_ui->antialiasingBox, m_cvarCommons.m_drawSamples);
|
|
|
|
initCheckboxOption(m_ui->deepColor, m_cvarCommons.m_deepColor);
|
|
|
|
|
|
|
|
m_ui->developerModeBox->setToolTip(QString::fromUtf8(hecl::com_developer->rawHelp().data()));
|
|
|
|
m_ui->developerModeBox->setChecked(hecl::com_developer->toBoolean());
|
|
|
|
m_ui->developerOptionsGroup->setVisible(hecl::com_developer->toBoolean());
|
|
|
|
connect(m_ui->developerModeBox, &QCheckBox::stateChanged, this, [this](int state) {
|
|
|
|
bool isChecked = state == Qt::Checked;
|
|
|
|
if (hecl::com_enableCheats->toBoolean() && !isChecked) {
|
|
|
|
m_ui->enableCheatsBox->setChecked(false);
|
2020-04-18 21:16:08 +00:00
|
|
|
// m_ui->tweaksOptionsGroup->setVisible(false);
|
2020-04-18 10:08:11 +00:00
|
|
|
m_ui->warpBtn->setVisible(false);
|
|
|
|
}
|
|
|
|
m_ui->developerOptionsGroup->setVisible(isChecked);
|
|
|
|
hecl::CVarManager::instance()->setDeveloperMode(isChecked, true);
|
|
|
|
m_cvarManager.serialize();
|
|
|
|
});
|
|
|
|
|
|
|
|
m_ui->enableCheatsBox->setToolTip(QString::fromUtf8(hecl::com_enableCheats->rawHelp().data()));
|
|
|
|
m_ui->enableCheatsBox->setChecked(hecl::com_enableCheats->toBoolean());
|
2020-04-18 21:16:08 +00:00
|
|
|
m_ui->tweaksOptionsGroup->setVisible(false); // hecl::com_enableCheats->toBoolean()
|
2020-04-18 10:08:11 +00:00
|
|
|
m_ui->warpBtn->setVisible(hecl::com_enableCheats->toBoolean());
|
|
|
|
connect(m_ui->enableCheatsBox, &QCheckBox::stateChanged, this, [this](int state) {
|
|
|
|
bool isChecked = state == Qt::Checked;
|
|
|
|
if (!hecl::com_developer->toBoolean() && isChecked) {
|
|
|
|
m_ui->developerModeBox->setChecked(true);
|
|
|
|
m_ui->developerOptionsGroup->setVisible(true);
|
|
|
|
}
|
2020-04-18 21:16:08 +00:00
|
|
|
// m_ui->tweaksOptionsGroup->setVisible(isChecked);
|
2020-04-18 10:08:11 +00:00
|
|
|
m_ui->warpBtn->setVisible(isChecked);
|
|
|
|
hecl::CVarManager::instance()->setCheatsEnabled(isChecked, true);
|
|
|
|
m_cvarManager.serialize();
|
|
|
|
});
|
|
|
|
|
|
|
|
initCheckboxOption(m_ui->developerModeBox, hecl::com_developer);
|
|
|
|
initCheckboxOption(m_ui->enableCheatsBox, hecl::com_enableCheats);
|
|
|
|
initCheckboxOption(m_ui->variableDtBox, m_cvarCommons.m_variableDt);
|
|
|
|
initCheckboxOption(m_ui->areaInfoOverlayBox, m_cvarCommons.m_debugOverlayAreaInfo);
|
|
|
|
initCheckboxOption(m_ui->playerInfoOverlayBox, m_cvarCommons.m_debugOverlayPlayerInfo);
|
|
|
|
initCheckboxOption(m_ui->worldInfoOverlayBox, m_cvarCommons.m_debugOverlayWorldInfo);
|
|
|
|
initCheckboxOption(m_ui->frameCounterBox, m_cvarCommons.m_debugOverlayShowFrameCounter);
|
|
|
|
initCheckboxOption(m_ui->inGameTimeBox, m_cvarCommons.m_debugOverlayShowInGameTime);
|
|
|
|
initCheckboxOption(m_ui->resourceStatsOverlayBox, m_cvarCommons.m_debugOverlayShowResourceStats);
|
|
|
|
initCheckboxOption(m_ui->logScriptingBox,
|
|
|
|
// TODO centralize
|
|
|
|
hecl::CVarManager::instance()->findOrMakeCVar(
|
|
|
|
"stateManager.logScripting"sv, "Prints object communication to the console", false,
|
|
|
|
hecl::CVar::EFlags::ReadOnly | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Game));
|
2020-04-18 21:53:27 +00:00
|
|
|
initCheckboxOption(m_ui->skipSplashScreensBox,
|
|
|
|
// TODO centralize
|
|
|
|
hecl::CVarManager::instance()->findOrMakeCVar(
|
|
|
|
"tweak.game.SplashScreensDisabled"sv, "Skip splash screens on game startup", false,
|
|
|
|
hecl::CVar::EFlags::ReadOnly | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Game));
|
2020-04-18 21:16:08 +00:00
|
|
|
|
|
|
|
m_launchOptionsModel.setStringList(QSettings().value(QStringLiteral("urde_arguments")).toStringList());
|
|
|
|
m_ui->launchOptionsList->setModel(&m_launchOptionsModel);
|
|
|
|
|
|
|
|
connect(m_ui->launchOptionAddButton, &QPushButton::clicked, this, [this] {
|
|
|
|
int row = m_launchOptionsModel.rowCount();
|
|
|
|
if (m_launchOptionsModel.insertRow(row)) {
|
|
|
|
QModelIndex index = m_launchOptionsModel.index(row);
|
|
|
|
m_ui->launchOptionsList->selectionModel()->select(index, QItemSelectionModel::SelectionFlag::ClearAndSelect);
|
|
|
|
m_ui->launchOptionsList->edit(index);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
connect(m_ui->launchOptionDeleteButton, &QPushButton::clicked, this, [this] {
|
|
|
|
QItemSelectionModel* selection = m_ui->launchOptionsList->selectionModel();
|
|
|
|
if (selection == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QModelIndexList list = selection->selectedRows();
|
|
|
|
for (QModelIndex index : list) {
|
|
|
|
m_launchOptionsModel.removeRow(index.row());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
connect(&m_launchOptionsModel, &QStringListModel::dataChanged, this,
|
|
|
|
[this]() { QSettings().setValue(QStringLiteral("urde_arguments"), m_launchOptionsModel.stringList()); });
|
|
|
|
connect(&m_launchOptionsModel, &QStringListModel::rowsRemoved, this,
|
|
|
|
[this]() { QSettings().setValue(QStringLiteral("urde_arguments"), m_launchOptionsModel.stringList()); });
|
2020-04-18 10:08:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::initNumberComboOption(QComboBox* action, hecl::CVar* cvar) {
|
|
|
|
QString itemString;
|
|
|
|
for (int i = 0; !(itemString = action->itemText(i)).isEmpty(); ++i) {
|
|
|
|
if (itemString.toInt() == cvar->toSigned()) {
|
|
|
|
action->setCurrentIndex(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
action->setToolTip(QString::fromUtf8(cvar->rawHelp().data()));
|
2020-06-24 15:44:00 +00:00
|
|
|
connect(action, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
|
|
[this, action, cvar](const int i) {
|
|
|
|
cvar->fromInteger(action->itemText(i).toInt());
|
2020-04-18 10:08:11 +00:00
|
|
|
m_cvarManager.serialize();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::initCheckboxOption(QCheckBox* action, hecl::CVar* cvar) {
|
|
|
|
action->setToolTip(QString::fromUtf8(cvar->rawHelp().data()));
|
|
|
|
action->setChecked(cvar->toBoolean());
|
|
|
|
connect(action, &QCheckBox::stateChanged, this, [this, cvar](int state) {
|
|
|
|
cvar->fromBoolean(state == Qt::Checked);
|
|
|
|
m_cvarManager.serialize();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::initGraphicsApiOption(QRadioButton* action, bool hidden, bool isDefault) {
|
|
|
|
if (hidden) {
|
|
|
|
action->hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const std::string& currApi = m_cvarCommons.getGraphicsApi();
|
|
|
|
action->setChecked(action->text().compare(QString::fromUtf8(currApi.data()), Qt::CaseInsensitive) == 0 ||
|
|
|
|
(isDefault && currApi.empty()));
|
|
|
|
connect(action, &QRadioButton::toggled, this, [this, action](bool checked) {
|
|
|
|
if (checked) {
|
|
|
|
m_cvarCommons.setGraphicsApi(action->text().toStdString());
|
|
|
|
m_cvarCommons.serialize();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|