Start implementing options tab; bug fixes & logging performance improvement

This commit is contained in:
Luke Street 2020-04-18 06:08:11 -04:00
parent 3487423d78
commit 2b6851f7bf
10 changed files with 333 additions and 422 deletions

View File

@ -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/$<$<CONFIG:Debug>:debug/>lib/Qt5VulkanSupport$<$<CONFIG:Debug>:d>.lib)
elseif(APPLE)
target_sources(hecl-gui PRIVATE platforms/mac/mainicon.icns)
set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES

View File

@ -1,7 +1,7 @@
#include "CVarDialog.hpp"
#include "ui_CVarDialog.h"
#include <QSettings>
#include <utility>
#include <array>
enum class CVarType {
String,

View File

@ -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);
}
}

View File

@ -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);

View File

@ -1,189 +0,0 @@
#include "LaunchMenu.hpp"
#include "hecl/CVarCommons.hpp"
#include "ArgumentEditor.hpp"
#include <QList>
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<QAction*>(sender())->text();
apiStr = apiStr.remove(QLatin1Char{'&'});
m_commons.setGraphicsApi(apiStr.toStdString());
m_commons.serialize();
}
void LaunchMenu::msaaTriggered() {
m_commons.setSamples(qobject_cast<QAction*>(sender())->text().toUInt());
m_commons.serialize();
}
void LaunchMenu::anisoTriggered() {
m_commons.setAnisotropy(qobject_cast<QAction*>(sender())->text().toUInt());
m_commons.serialize();
}
void LaunchMenu::deepColorTriggered() {
m_commons.setDeepColor(qobject_cast<QAction*>(sender())->isChecked());
m_commons.serialize();
}
void LaunchMenu::developerModeTriggered() {
const bool isChecked = qobject_cast<QAction*>(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<QAction*>(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<QAction*>(sender());
hecl::CVar* cVar = hecl::CVarManager::instance()->findCVar(action->data().toString().toStdString());
if (cVar != nullptr) {
cVar->fromBoolean(action->isChecked());
m_commons.serialize();
}
}

View File

@ -1,57 +0,0 @@
#pragma once
#include <QMenu>
#include <hecl/CVar.hpp>
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();
};

View File

@ -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<void (QComboBox::*)(const QString&)>(&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();
}
});
}

View File

@ -5,10 +5,12 @@
#include <QMainWindow>
#include <QProcess>
#include <QTextCursor>
#include <QCheckBox>
#include <QComboBox>
#include <QRadioButton>
#include "Common.hpp"
#include "DownloadManager.hpp"
#include "LaunchMenu.hpp"
#include <hecl/CVarCommons.hpp>
#include <hecl/Runtime.hpp>
@ -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);
};

View File

@ -78,6 +78,9 @@
</item>
<item row="1" column="0">
<widget class="QTabWidget" name="heclTabs">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="dataTab">
<attribute name="title">
<string>&amp;Data</string>
@ -191,7 +194,20 @@
<string>Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<item row="5" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QGroupBox" name="graphicsOptionsGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
@ -203,15 +219,91 @@
<string>Graphics</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="4" column="1">
<widget class="QComboBox" name="anistropicFilteringBox">
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="antialiasingLabel">
<property name="text">
<string>Anti-Aliasing</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="antialiasingBox"/>
<widget class="QComboBox" name="antialiasingBox">
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="deepColor">
<property name="text">
<string>Deep Color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="anistropicFilteringLabel">
<property name="text">
<string>Anistropic Filtering</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="graphicsApiBox">
<item>
<widget class="QRadioButton" name="vulkanOption">
<widget class="QRadioButton" name="d3d11Option">
<property name="text">
<string>Vulkan</string>
<string>D3D11</string>
</property>
</widget>
</item>
@ -223,42 +315,40 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="d3d11Option">
<widget class="QRadioButton" name="vulkanOption">
<property name="text">
<string>D3D11</string>
<string>Vulkan</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="anistropicFilteringBox"/>
</item>
<item row="3" column="1">
<widget class="QLabel" name="anistropicFilteringLabel">
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="experimentalOptionsGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Experimental</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QCheckBox" name="variableDtBox">
<property name="text">
<string>Anistropic Filtering</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="antialiasingLabel">
<property name="text">
<string>Anti-Aliasing</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="deepColor">
<property name="text">
<string>Deep Color</string>
<string>Variable Delta Time</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QGroupBox" name="gameOptionsGroup">
<property name="title">
<string>Game</string>
@ -282,19 +372,6 @@
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="developerOptionsGroup">
<property name="title">
<string>Developer</string>
@ -342,32 +419,17 @@
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="experimentalOptionsGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Experimental</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QCheckBox" name="variableDtBox">
<item>
<widget class="QCheckBox" name="logScriptingBox">
<property name="text">
<string>Variable Delta Time</string>
<string>Log Scripting</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" rowspan="5">
<item row="0" column="1" rowspan="4">
<widget class="QGroupBox" name="launchOptionsGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -379,14 +441,21 @@
<string>Launch Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="2">
<item row="0" column="0">
<widget class="QPushButton" name="launchOptionAddButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="launchOptionDeleteButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<item row="1" column="0" colspan="2">
<widget class="QListView" name="launchOptionsList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -396,19 +465,17 @@
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="1" rowspan="2">
<widget class="QGroupBox" name="tweaksOptionsGroup">
<property name="title">
<string>Tweaks</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QPushButton" name="launchOptionAddButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="launchOptionEditButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
<widget class="QListView" name="tweaksOptionsList"/>
</item>
</layout>
</widget>
@ -996,7 +1063,7 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:600;&quot;&gt;About HECL Frontend&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt;&quot;&gt;&lt;br /&gt;The HECL frontend UI is designed and built by &lt;/span&gt;&lt;a href=&quot;https://axiodl.com&quot;&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt; text-decoration: underline; color:#007af4;&quot;&gt;Axiomatic Data Laboratories&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt;&quot;&gt; Copyright 2020&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:600;&quot;&gt;Authors:&lt;/span&gt;&lt;span style=&quot; font-family:'Noto Sans'; font-size:10pt;&quot;&gt;&lt;br /&gt;Phillip &amp;quot;Antidote&amp;quot; Stephens&lt;br /&gt;Jack &amp;quot;jackoalan&amp;quot; Andersen&lt;br /&gt;Luke &amp;quot;encounter&amp;quot; Street&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Courier New'; font-size:10pt;&quot;&gt;The MIT License&lt;/span&gt;&lt;/p&gt;
@ -1067,12 +1134,9 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QPushButton" name="launchBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
@ -1080,58 +1144,9 @@ p, li { white-space: pre-wrap; }
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="launchBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Launch</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="launchMenuBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>15</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
<property name="text">
<string>&amp;Launch</string>
</property>
</widget>
</item>
<item>

View File

@ -1,3 +1,8 @@
#if _WIN32
#include <QtPlugin>
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#endif
#include <QApplication>
#include <QStyleFactory>
#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();
}