diff --git a/hecl-gui/CMakeLists.txt b/hecl-gui/CMakeLists.txt index 131bc54f3..1dbf3ce81 100644 --- a/hecl-gui/CMakeLists.txt +++ b/hecl-gui/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) -find_package(Qt5 COMPONENTS Network Widgets Xml REQUIRED) +find_package(Qt5 COMPONENTS Network Widgets Xml Gui REQUIRED) file(GLOB QUAZIP_SRCS quazip/quazip/*.c quazip/quazip/*.cpp quazip/quazip/*.h) list(REMOVE_ITEM QUAZIP_SRCS @@ -34,8 +34,6 @@ add_executable(hecl-gui WIN32 MACOSX_BUNDLE FileDirDialog.hpp FindBlender.cpp FindBlender.hpp - LaunchMenu.cpp - LaunchMenu.hpp MainWindow.cpp MainWindow.hpp MainWindow.ui @@ -73,17 +71,15 @@ target_compile_definitions(hecl-gui PRIVATE ) target_link_libraries(hecl-gui PRIVATE + Qt5::Core + Qt5::Gui Qt5::Network Qt5::Widgets Qt5::Xml - athena-core hecl-light - logvisor - xxhash - z zeus - RetroDataSpec + ${ZLIB_LIBRARIES} ) target_include_directories(hecl-gui PRIVATE quazip/quazip) @@ -111,6 +107,8 @@ if(WIN32) platforms/win/hecl-gui.manifest platforms/win/hecl-gui.rc ) + # FIXME hack to fix static link with outdated Qt cmake files + target_link_libraries(hecl-gui PRIVATE C:/vcpkg/installed/x64-windows-static/$<$:debug/>lib/Qt5VulkanSupport$<$:d>.lib) elseif(APPLE) target_sources(hecl-gui PRIVATE platforms/mac/mainicon.icns) set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES diff --git a/hecl-gui/CVarDialog.cpp b/hecl-gui/CVarDialog.cpp index 72738c70a..7a02d41e1 100644 --- a/hecl-gui/CVarDialog.cpp +++ b/hecl-gui/CVarDialog.cpp @@ -1,7 +1,7 @@ #include "CVarDialog.hpp" #include "ui_CVarDialog.h" -#include #include +#include enum class CVarType { String, diff --git a/hecl-gui/Common.cpp b/hecl-gui/Common.cpp index cceaf931b..6e1cc1073 100644 --- a/hecl-gui/Common.cpp +++ b/hecl-gui/Common.cpp @@ -92,39 +92,74 @@ VectorISA StringToVectorISA(const QString& str) { URDEVersion::URDEVersion(const QString& filename) { int idx; QString useFilename = filename; - if ((idx = filename.indexOf(QLatin1Char{'.'})) >= 0) { + if ((idx = filename.lastIndexOf(QLatin1Char{'.'})) >= 0) { m_extension = QString(filename).remove(0, idx); useFilename.truncate(idx); } const QStringList list = useFilename.split(QLatin1Char{'-'}); - if (list.size() >= 2) { - m_version = list[1].toInt(); - } - if (list.size() >= 3) { - m_platform = StringToPlatform(list[2]); - } - if (list.size() >= 4) { - m_architecture = StringToArchitecture(list[3]); - } - if (list.size() >= 5) { - m_vectorISA = StringToVectorISA(list[4]); + enum { + version, + platform, + architecture, + vectorISA, + extra + } state = version; + for (size_t i = 1; i < list.size(); ++i) { + if (state == version) { + if (m_version.isEmpty()) { + m_version = list[i]; + continue; + } + bool ok; + int patch = list[i].toInt(&ok); + if (ok) { + m_version += QLatin1Char('-') + QString::number(patch); + continue; + } + state = platform; + } + if (state == platform) { + state = architecture; + Platform platValue = StringToPlatform(list[i]); + if (platValue != Platform::Invalid) { + m_platform = platValue; + continue; + } + } + if (state == architecture) { + state = vectorISA; + Architecture archValue = StringToArchitecture(list[i]); + if (archValue != Architecture::Invalid) { + m_architecture = archValue; + continue; + } + } + if (state == vectorISA) { + state = extra; + VectorISA isa = StringToVectorISA(list[i]); + if (isa != VectorISA::Invalid) { + m_vectorISA = isa; + continue; + } + } + m_extra += QLatin1Char('-') + list[i]; } } QString URDEVersion::fileString(bool withExtension) const { - if (m_version < 0) { + if (m_version.isEmpty()) { return {}; } if (withExtension && !m_extension.isEmpty()) { - return QStringLiteral("urde-%1-%2-%3-%4%5") - .arg(QString::number(m_version), PlatformToString(m_platform), ArchitectureToString(m_architecture), - VectorISAToString(m_vectorISA), m_extension); + return QStringLiteral("urde-%1-%2-%3-%4%5%6") + .arg(m_version, PlatformToString(m_platform), ArchitectureToString(m_architecture), + VectorISAToString(m_vectorISA), m_extra, m_extension); } else { - return QStringLiteral("urde-%1-%2-%3-%4") - .arg(QString::number(m_version), PlatformToString(m_platform), ArchitectureToString(m_architecture), - VectorISAToString(m_vectorISA)); + return QStringLiteral("urde-%1-%2-%3-%4%5") + .arg(m_version, PlatformToString(m_platform), ArchitectureToString(m_architecture), + VectorISAToString(m_vectorISA), m_extra); } } diff --git a/hecl-gui/Common.hpp b/hecl-gui/Common.hpp index 73cfdede3..5a3201edd 100644 --- a/hecl-gui/Common.hpp +++ b/hecl-gui/Common.hpp @@ -30,21 +30,23 @@ QString VectorISAToString(VectorISA visa); VectorISA StringToVectorISA(const QString& str); class URDEVersion { - int m_version = -1; + QString m_version{}; Platform m_platform = CurPlatform; Architecture m_architecture = CurArchitecture; VectorISA m_vectorISA = VectorISA::Invalid; - QString m_extension; + QString m_extension{}; + QString m_extra{}; public: URDEVersion() = default; explicit URDEVersion(const QString& filename); - bool isValid() const { return m_version >= 0; } + bool isValid() const { return !m_version.isEmpty(); } QString fileString(bool withExtension) const; - int getVersion() const { return m_version; } + QString getVersion() const { return m_version; } Platform getPlatform() const { return m_platform; } Architecture getArchitecture() const { return m_architecture; } VectorISA getVectorISA() const { return m_vectorISA; } + QString getExtra() const { return m_extra; } }; Q_DECLARE_METATYPE(URDEVersion); diff --git a/hecl-gui/LaunchMenu.cpp b/hecl-gui/LaunchMenu.cpp deleted file mode 100644 index dc8453c8c..000000000 --- a/hecl-gui/LaunchMenu.cpp +++ /dev/null @@ -1,189 +0,0 @@ -#include "LaunchMenu.hpp" -#include "hecl/CVarCommons.hpp" -#include "ArgumentEditor.hpp" -#include - -LaunchMenu::LaunchMenu(hecl::CVarCommons& commons, QWidget* parent) -: QMenu(tr("Launch Menu"), parent) -, m_commons(commons) -, m_apiMenu(tr("Graphics API"), this) -, m_msaaMenu(tr("Anti-Aliasing"), this) -, m_anisoMenu(tr("Anisotropic Filtering"), this) -, m_experimentalMenu(tr("Experimental Features"), this) -, m_developerMenu(tr("Developer Options"), this) -, m_apiGroup(this) -, m_msaaGroup(this) -, m_anisoGroup(this) { - setToolTipsVisible(true); -#ifdef _WIN32 - initApiAction(QStringLiteral("D3D11")); - initApiAction(QStringLiteral("Vulkan")); -#elif defined(__APPLE__) - initApiAction(QStringLiteral("Metal")); -#else - initApiAction(QStringLiteral("Vulkan")); -#endif - - initMsaaAction(QStringLiteral("1")); - initMsaaAction(QStringLiteral("2")); - initMsaaAction(QStringLiteral("4")); - initMsaaAction(QStringLiteral("8")); - initMsaaAction(QStringLiteral("16")); - - initAnisoAction(QStringLiteral("1")); - initAnisoAction(QStringLiteral("2")); - initAnisoAction(QStringLiteral("4")); - initAnisoAction(QStringLiteral("8")); - initAnisoAction(QStringLiteral("16")); - - m_apiMenu.addActions(m_apiGroup.actions()); - m_msaaMenu.addActions(m_msaaGroup.actions()); - m_anisoMenu.addActions(m_anisoGroup.actions()); - initExperimentalMenu(); - initDeveloperMenu(); - addMenu(&m_apiMenu)->setToolTip(QString::fromUtf8(m_commons.m_graphicsApi->rawHelp().data())); - addMenu(&m_msaaMenu)->setToolTip(QString::fromUtf8(m_commons.m_drawSamples->rawHelp().data())); - addMenu(&m_anisoMenu)->setToolTip(QString::fromUtf8(m_commons.m_texAnisotropy->rawHelp().data())); - addMenu(&m_experimentalMenu); - m_developerMenuAction = addMenu(&m_developerMenu); - m_developerMenuAction->setVisible(hecl::com_developer->toBoolean()); - const QAction* argumentEditor = addAction(tr("Edit Runtime Arguments")); - connect(argumentEditor, &QAction::triggered, this, &LaunchMenu::editRuntimeArgs); - initDeepColor(); - initDeveloperMode(); - initCheats(); -} - -LaunchMenu::~LaunchMenu() = default; - -void LaunchMenu::initApiAction(const QString& action) { - QAction* act = m_apiGroup.addAction(action); - connect(act, &QAction::triggered, this, &LaunchMenu::apiTriggered); - act->setCheckable(true); - if (action.compare(QString::fromStdString(m_commons.getGraphicsApi()), Qt::CaseInsensitive) == 0) { - act->setChecked(true); - } -} - -void LaunchMenu::initMsaaAction(const QString& action) { - QAction* act = m_msaaGroup.addAction(action); - connect(act, &QAction::triggered, this, &LaunchMenu::msaaTriggered); - act->setCheckable(true); - if (action.compare(QString::number(m_commons.getSamples()), Qt::CaseInsensitive) == 0) { - act->setChecked(true); - } -} - -void LaunchMenu::initAnisoAction(const QString& action) { - QAction* act = m_anisoGroup.addAction(action); - connect(act, &QAction::triggered, this, &LaunchMenu::anisoTriggered); - act->setCheckable(true); - if (action.compare(QString::number(m_commons.getAnisotropy()), Qt::CaseInsensitive) == 0) { - act->setChecked(true); - } -} - -void LaunchMenu::initDeepColor() { - QAction* act = addAction(tr("Deep Color")); - act->setToolTip(QString::fromUtf8(m_commons.m_deepColor->rawHelp().data())); - act->setCheckable(true); - act->setChecked(m_commons.getDeepColor()); - connect(act, &QAction::triggered, this, &LaunchMenu::deepColorTriggered); -} - -void LaunchMenu::initDeveloperMode() { - m_developerMode = addAction(tr("Developer Mode")); - m_developerMode->setToolTip(QString::fromUtf8(hecl::com_developer->rawHelp().data())); - m_developerMode->setCheckable(true); - m_developerMode->setChecked(hecl::com_developer->toBoolean()); - connect(m_developerMode, &QAction::triggered, this, &LaunchMenu::developerModeTriggered); -} - -void LaunchMenu::initCheats() { - m_enableCheats = addAction(tr("Enable Cheats")); - m_enableCheats->setToolTip(QString::fromUtf8(hecl::com_enableCheats->rawHelp().data())); - m_enableCheats->setCheckable(true); - m_enableCheats->setChecked(hecl::com_enableCheats->toBoolean()); - connect(m_enableCheats, &QAction::triggered, this, &LaunchMenu::cheatsTriggered); -} - -void LaunchMenu::initExperimentalMenu() { - initCVarAction(m_experimentalMenu.addAction(tr("Variable delta time")), m_commons.m_variableDt); -} - -void LaunchMenu::initDeveloperMenu() { - initCVarAction(m_developerMenu.addAction(tr("Area Info Overlay")), m_commons.m_debugOverlayAreaInfo); - initCVarAction(m_developerMenu.addAction(tr("Player Info Overlay")), m_commons.m_debugOverlayPlayerInfo); - initCVarAction(m_developerMenu.addAction(tr("World Info Overlay")), m_commons.m_debugOverlayWorldInfo); - initCVarAction(m_developerMenu.addAction(tr("Show Frame Counter")), m_commons.m_debugOverlayShowFrameCounter); - initCVarAction(m_developerMenu.addAction(tr("Show In-Game time")), m_commons.m_debugOverlayShowInGameTime); - initCVarAction(m_developerMenu.addAction(tr("Show Resource Stats")), m_commons.m_debugOverlayShowResourceStats); -} - -void LaunchMenu::apiTriggered() { - QString apiStr = qobject_cast(sender())->text(); - apiStr = apiStr.remove(QLatin1Char{'&'}); - m_commons.setGraphicsApi(apiStr.toStdString()); - m_commons.serialize(); -} - -void LaunchMenu::msaaTriggered() { - m_commons.setSamples(qobject_cast(sender())->text().toUInt()); - m_commons.serialize(); -} - -void LaunchMenu::anisoTriggered() { - m_commons.setAnisotropy(qobject_cast(sender())->text().toUInt()); - m_commons.serialize(); -} - -void LaunchMenu::deepColorTriggered() { - m_commons.setDeepColor(qobject_cast(sender())->isChecked()); - m_commons.serialize(); -} - -void LaunchMenu::developerModeTriggered() { - const bool isChecked = qobject_cast(sender())->isChecked(); - - if (hecl::com_enableCheats->toBoolean() && !isChecked) { - m_enableCheats->setChecked(false); - } - m_developerMenuAction->setVisible(isChecked); - - hecl::CVarManager::instance()->setDeveloperMode(isChecked, true); - m_commons.serialize(); -} - -void LaunchMenu::cheatsTriggered() { - const bool isChecked = qobject_cast(sender())->isChecked(); - - if (!hecl::com_developer->toBoolean() && isChecked) { - m_developerMode->setChecked(true); - m_developerMenuAction->setVisible(true); - } - - hecl::CVarManager::instance()->setCheatsEnabled(isChecked, true); - m_commons.serialize(); -} - -void LaunchMenu::editRuntimeArgs() { - ArgumentEditor editor(this); - editor.exec(); -} - -void LaunchMenu::initCVarAction(QAction* action, hecl::CVar* cvar) const { - action->setData(QString::fromUtf8(cvar->name().data())); - action->setToolTip(QString::fromUtf8(cvar->rawHelp().data())); - action->setCheckable(true); - action->setChecked(cvar->toBoolean()); - connect(action, &QAction::triggered, this, &LaunchMenu::cvarTriggered); -} - -void LaunchMenu::cvarTriggered() { - auto* action = qobject_cast(sender()); - hecl::CVar* cVar = hecl::CVarManager::instance()->findCVar(action->data().toString().toStdString()); - if (cVar != nullptr) { - cVar->fromBoolean(action->isChecked()); - m_commons.serialize(); - } -} diff --git a/hecl-gui/LaunchMenu.hpp b/hecl-gui/LaunchMenu.hpp deleted file mode 100644 index eb311fb21..000000000 --- a/hecl-gui/LaunchMenu.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include -#include - -namespace hecl { -struct CVarCommons; -} // namespace hecl - -class QAction; - -class LaunchMenu : public QMenu { - Q_OBJECT - hecl::CVarCommons& m_commons; - - QMenu m_apiMenu; - QMenu m_msaaMenu; - QMenu m_anisoMenu; - QMenu m_experimentalMenu; - QMenu m_developerMenu; - - QActionGroup m_apiGroup; - QActionGroup m_msaaGroup; - QActionGroup m_anisoGroup; - - QAction* m_developerMode = nullptr; - QAction* m_developerMenuAction = nullptr; - QAction* m_enableCheats = nullptr; - QAction* m_variableDt = nullptr; - - QAction* m_debugOverlayAreaInfo = nullptr; - QAction* m_debugOverlayPlayerInfo = nullptr; - - void initApiAction(const QString& action); - void initMsaaAction(const QString& action); - void initAnisoAction(const QString& action); - void initDeepColor(); - void initDeveloperMode(); - void initCheats(); - void initExperimentalMenu(); - void initDeveloperMenu(); - void initCVarAction(QAction* action, hecl::CVar* cvar) const; - -public: - explicit LaunchMenu(hecl::CVarCommons& commons, QWidget* parent = Q_NULLPTR); - ~LaunchMenu() override; - -public slots: - void apiTriggered(); - void msaaTriggered(); - void anisoTriggered(); - void deepColorTriggered(); - void developerModeTriggered(); - void cheatsTriggered(); - void editRuntimeArgs(); - void cvarTriggered(); -}; diff --git a/hecl-gui/MainWindow.cpp b/hecl-gui/MainWindow.cpp index 493af62f3..8eb58a044 100644 --- a/hecl-gui/MainWindow.cpp +++ b/hecl-gui/MainWindow.cpp @@ -62,8 +62,7 @@ MainWindow::MainWindow(QWidget* parent) , m_cvarManager(m_fileMgr) , m_cvarCommons(m_cvarManager) , m_heclProc(this) -, m_dlManager(this) -, m_launchMenu(m_cvarCommons, this) { +, m_dlManager(this) { if (m_settings.value(QStringLiteral("urde_arguments")).isNull()) { m_settings.setValue(QStringLiteral("urde_arguments"), QStringList{QStringLiteral("--no-shader-warmup")}); } @@ -103,6 +102,7 @@ MainWindow::MainWindow(QWidget* parent) std::bind(&MainWindow::onBinaryDownloaded, this, std::placeholders::_1), std::bind(&MainWindow::onBinaryFailed, this)); + initOptions(); initSlots(); m_dlManager.fetchIndex(); @@ -263,7 +263,7 @@ void MainWindow::onDownloadPressed() { } void MainWindow::onUpdateURDEPressed() { - m_ui->heclTabs->setCurrentIndex(1); + m_ui->heclTabs->setCurrentIndex(2); onDownloadPressed(); } @@ -326,7 +326,7 @@ void MainWindow::enableOperations() { m_ui->launchBtn->setText(tr("&Launch")); m_ui->extractBtn->setEnabled(true); - if (QFile::exists(m_path + QStringLiteral("/MP1/URDE/texture_cache.yaml"))) { + if (QFile::exists(m_path + QStringLiteral("/out/files/version.yaml"))) { m_ui->packageBtn->setEnabled(true); if (isPackageComplete()) { m_ui->launchBtn->setEnabled(true); @@ -388,7 +388,7 @@ bool MainWindow::checkDownloadedBinary() { m_heclPath = QString(); if (m_path.isEmpty()) { - m_ui->heclTabs->setCurrentIndex(1); + m_ui->heclTabs->setCurrentIndex(2); m_ui->downloadErrorLabel->setText(tr("Set working directory to continue."), true); enableOperations(); return false; @@ -438,7 +438,7 @@ bool MainWindow::checkDownloadedBinary() { } m_ui->currentBinaryLabel->setText(tr("none")); - m_ui->heclTabs->setCurrentIndex(1); + m_ui->heclTabs->setCurrentIndex(2); m_ui->downloadErrorLabel->setText(tr("Press 'Download' to fetch latest URDE binary."), true); enableOperations(); return false; @@ -493,7 +493,6 @@ void MainWindow::initSlots() { 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); - m_ui->launchMenuBtn->setMenu(&m_launchMenu); connect(m_ui->browseBtn, &QPushButton::clicked, [=]() { FileDirDialog dialog(this); @@ -515,6 +514,7 @@ void MainWindow::initSlots() { void MainWindow::setTextTermFormatting(const QString& text) { m_inContinueNote = false; + m_cursor.beginEditBlock(); QRegExp const escapeSequenceExpression(QStringLiteral(R"(\x1B\[([\d;\?FA]+)([mlh]?))")); QTextCharFormat defaultTextCharFormat = m_cursor.charFormat(); int offset = escapeSequenceExpression.indexIn(text); @@ -552,6 +552,7 @@ void MainWindow::setTextTermFormatting(const QString& text) { } } m_cursor.setCharFormat(defaultTextCharFormat); + m_cursor.endEditBlock(); m_ui->processOutput->ensureCursorVisible(); } @@ -575,3 +576,99 @@ void MainWindow::onUpdateTrackChanged(int index) { m_dlManager.fetchIndex(); m_ui->devTrackWarning->setVisible(index == 1); } + +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); + m_ui->tweaksOptionsGroup->setVisible(false); + 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()); + m_ui->tweaksOptionsGroup->setVisible(hecl::com_enableCheats->toBoolean()); + 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); + } + m_ui->tweaksOptionsGroup->setVisible(isChecked); + 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)); +} + +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())); + connect(action, static_cast(&QComboBox::currentIndexChanged), this, + [this, cvar](const QString& value) { + cvar->fromInteger(value.toInt()); + 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(); + } + }); +} diff --git a/hecl-gui/MainWindow.hpp b/hecl-gui/MainWindow.hpp index ccad1d904..000d7ff76 100644 --- a/hecl-gui/MainWindow.hpp +++ b/hecl-gui/MainWindow.hpp @@ -5,10 +5,12 @@ #include #include #include +#include +#include +#include #include "Common.hpp" #include "DownloadManager.hpp" -#include "LaunchMenu.hpp" #include #include @@ -20,7 +22,7 @@ class QuaZip; namespace Ui { class MainWindow; -} +} // namespace Ui class MainWindow : public QMainWindow { static const QStringList skUpdateTracks; @@ -35,7 +37,6 @@ class MainWindow : public QMainWindow { QString m_heclPath; QProcess m_heclProc; DownloadManager m_dlManager; - LaunchMenu m_launchMenu; QSettings m_settings; URDEVersion m_recommendedVersion; QPushButton* m_updateURDEButton; @@ -71,4 +72,8 @@ private: void disableOperations(); void enableOperations(); bool isPackageComplete() const; + void initOptions(); + void initGraphicsApiOption(QRadioButton* action, bool hidden, bool isDefault); + void initNumberComboOption(QComboBox* action, hecl::CVar* cvar); + void initCheckboxOption(QCheckBox* action, hecl::CVar* cvar); }; diff --git a/hecl-gui/MainWindow.ui b/hecl-gui/MainWindow.ui index a036b88ac..ed44cfd0a 100644 --- a/hecl-gui/MainWindow.ui +++ b/hecl-gui/MainWindow.ui @@ -78,6 +78,9 @@ + + 1 + &Data @@ -191,7 +194,20 @@ Options - + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -203,15 +219,91 @@ Graphics + + + + + 1 + + + + + 2 + + + + + 4 + + + + + 8 + + + + + 16 + + + + + + + + Anti-Aliasing + + + - + + + + 1 + + + + + 2 + + + + + 4 + + + + + 8 + + + + + 16 + + + + + + + + Deep Color + + + + + + + Anistropic Filtering + + - + - Vulkan + D3D11 @@ -223,42 +315,40 @@ - + - D3D11 + Vulkan - - - - - + + + + + + + + 0 + 0 + + + + Experimental + + + + - Anistropic Filtering - - - - - - - Anti-Aliasing - - - - - - - Deep Color + Variable Delta Time - + Game @@ -282,19 +372,6 @@ - - - Qt::Vertical - - - - 20 - 40 - - - - - Developer @@ -342,32 +419,17 @@ - - - - - - - - 0 - 0 - - - - Experimental - - - - + + - Variable Delta Time + Log Scripting - + @@ -379,14 +441,21 @@ Launch Options - + + + + Add + + + + Delete - + @@ -396,19 +465,17 @@ + + + + + + + Tweaks + + - - - Add - - - - - - - Edit - - + @@ -996,7 +1063,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans'; font-size:10pt; font-weight:600;">About HECL Frontend</span></p> <p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans'; font-size:10pt;"><br />The HECL frontend UI is designed and built by </span><a href="https://axiodl.com"><span style=" font-family:'Noto Sans'; font-size:10pt; text-decoration: underline; color:#007af4;">Axiomatic Data Laboratories</span></a><span style=" font-family:'Noto Sans'; font-size:10pt;"> Copyright 2020<br /><br /></span><span style=" font-family:'Noto Sans'; font-size:10pt; font-weight:600;">Authors:</span><span style=" font-family:'Noto Sans'; font-size:10pt;"><br />Phillip &quot;Antidote&quot; Stephens<br />Jack &quot;jackoalan&quot; Andersen<br />Luke &quot;encounter&quot; Street</span></p> <p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New'; font-size:10pt;">The MIT License</span></p> @@ -1067,12 +1134,9 @@ p, li { white-space: pre-wrap; } - - - - 0 - 0 - + + + false @@ -1080,58 +1144,9 @@ p, li { white-space: pre-wrap; } 16777215 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - false - - - - 16777215 - 16777215 - - - - &Launch - - - - - - - - 0 - 0 - - - - - 15 - 16777215 - - - - - - - - + + &Launch + diff --git a/hecl-gui/main.cpp b/hecl-gui/main.cpp index 8eaa1ad13..e4afa3ad6 100644 --- a/hecl-gui/main.cpp +++ b/hecl-gui/main.cpp @@ -1,3 +1,8 @@ +#if _WIN32 +#include +Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); +#endif + #include #include #include "MainWindow.hpp" @@ -56,9 +61,9 @@ int main(int argc, char* argv[]) { darkPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(42, 130, 218, 53)); darkPalette.setColor(QPalette::HighlightedText, Qt::white); darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(255, 255, 255, 120)); - a.setPalette(darkPalette); + QApplication::setPalette(darkPalette); MainWindow w; w.show(); - return a.exec(); + return QApplication::exec(); }