2018-01-10 06:19:48 +00:00
|
|
|
#include "LaunchMenu.hpp"
|
|
|
|
#include "hecl/CVarCommons.hpp"
|
2019-01-26 23:22:16 +00:00
|
|
|
#include "ArgumentEditor.hpp"
|
|
|
|
#include <QList>
|
2018-01-10 06:19:48 +00:00
|
|
|
|
2018-01-22 02:42:06 +00:00
|
|
|
extern hecl::CVar* hecl::com_developer;
|
2018-01-15 13:17:08 +00:00
|
|
|
|
2018-01-10 06:19:48 +00:00
|
|
|
LaunchMenu::LaunchMenu(hecl::CVarCommons& commons, QWidget* parent)
|
2019-08-28 01:35:51 +00:00
|
|
|
: QMenu(tr("Launch Menu"), parent)
|
2018-12-08 05:19:40 +00:00
|
|
|
, m_commons(commons)
|
2019-08-28 01:35:51 +00:00
|
|
|
, m_apiMenu(tr("Graphics API"), this)
|
|
|
|
, m_msaaMenu(tr("Anti-Aliasing"), this)
|
|
|
|
, m_anisoMenu(tr("Anisotropic Filtering"), this)
|
2018-12-08 05:19:40 +00:00
|
|
|
, m_apiGroup(this)
|
|
|
|
, m_msaaGroup(this)
|
|
|
|
, m_anisoGroup(this) {
|
2019-01-26 23:22:16 +00:00
|
|
|
setToolTipsVisible(true);
|
2018-01-10 06:19:48 +00:00
|
|
|
#ifdef _WIN32
|
2018-12-08 05:19:40 +00:00
|
|
|
initApiAction(QStringLiteral("D3D11"));
|
|
|
|
initApiAction(QStringLiteral("Vulkan"));
|
|
|
|
initApiAction(QStringLiteral("OpenGL"));
|
2018-01-10 06:19:48 +00:00
|
|
|
#elif defined(__APPLE__)
|
2018-12-08 05:19:40 +00:00
|
|
|
initApiAction(QStringLiteral("Metal"));
|
|
|
|
initApiAction(QStringLiteral("OpenGL"));
|
2018-01-10 06:19:48 +00:00
|
|
|
#else
|
2018-12-08 05:19:40 +00:00
|
|
|
initApiAction(QStringLiteral("OpenGL"));
|
|
|
|
initApiAction(QStringLiteral("Vulkan"));
|
2018-01-10 06:19:48 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
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());
|
2019-08-28 01:35:51 +00:00
|
|
|
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()));
|
|
|
|
const QAction* argumentEditor = addAction(tr("Edit Runtime Arguments"));
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(argumentEditor, &QAction::triggered, this, &LaunchMenu::editRuntimeArgs);
|
2018-12-08 05:19:40 +00:00
|
|
|
initDeepColor();
|
|
|
|
initDeveloperMode();
|
2019-01-26 23:22:16 +00:00
|
|
|
initCheats();
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 01:35:51 +00:00
|
|
|
LaunchMenu::~LaunchMenu() = default;
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::initApiAction(const QString& action) {
|
|
|
|
QAction* act = m_apiGroup.addAction(action);
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(act, &QAction::triggered, this, &LaunchMenu::apiTriggered);
|
2018-12-08 05:19:40 +00:00
|
|
|
act->setCheckable(true);
|
|
|
|
if (!action.compare(QString::fromStdString(m_commons.getGraphicsApi()), Qt::CaseInsensitive))
|
|
|
|
act->setChecked(true);
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::initMsaaAction(const QString& action) {
|
|
|
|
QAction* act = m_msaaGroup.addAction(action);
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(act, &QAction::triggered, this, &LaunchMenu::msaaTriggered);
|
2018-12-08 05:19:40 +00:00
|
|
|
act->setCheckable(true);
|
|
|
|
if (!action.compare(QString::number(m_commons.getSamples()), Qt::CaseInsensitive))
|
|
|
|
act->setChecked(true);
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::initAnisoAction(const QString& action) {
|
|
|
|
QAction* act = m_anisoGroup.addAction(action);
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(act, &QAction::triggered, this, &LaunchMenu::anisoTriggered);
|
2018-12-08 05:19:40 +00:00
|
|
|
act->setCheckable(true);
|
|
|
|
if (!action.compare(QString::number(m_commons.getAnisotropy()), Qt::CaseInsensitive))
|
|
|
|
act->setChecked(true);
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::initDeepColor() {
|
2019-08-28 01:35:51 +00:00
|
|
|
QAction* act = addAction(tr("Deep Color"));
|
|
|
|
act->setToolTip(QString::fromUtf8(m_commons.m_deepColor->rawHelp().data()));
|
2018-12-08 05:19:40 +00:00
|
|
|
act->setCheckable(true);
|
|
|
|
act->setChecked(m_commons.getDeepColor());
|
2019-08-26 00:21:03 +00:00
|
|
|
connect(act, &QAction::triggered, this, &LaunchMenu::deepColorTriggered);
|
2018-01-16 06:41:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::initDeveloperMode() {
|
2019-08-28 01:35:51 +00:00
|
|
|
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);
|
2018-01-15 13:17:08 +00:00
|
|
|
}
|
|
|
|
|
2019-01-26 23:22:16 +00:00
|
|
|
void LaunchMenu::initCheats() {
|
2019-08-28 01:35:51 +00:00
|
|
|
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);
|
2019-01-26 23:22:16 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::apiTriggered() {
|
|
|
|
QString apiStr = qobject_cast<QAction*>(sender())->text();
|
2019-08-28 01:35:51 +00:00
|
|
|
apiStr = apiStr.remove(QLatin1Char{'&'});
|
2018-12-08 05:19:40 +00:00
|
|
|
m_commons.setGraphicsApi(apiStr.toStdString());
|
|
|
|
m_commons.serialize();
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::msaaTriggered() {
|
|
|
|
m_commons.setSamples(qobject_cast<QAction*>(sender())->text().toUInt());
|
|
|
|
m_commons.serialize();
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::anisoTriggered() {
|
|
|
|
m_commons.setAnisotropy(qobject_cast<QAction*>(sender())->text().toUInt());
|
|
|
|
m_commons.serialize();
|
2018-01-15 13:17:08 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::deepColorTriggered() {
|
|
|
|
m_commons.setDeepColor(qobject_cast<QAction*>(sender())->isChecked());
|
|
|
|
m_commons.serialize();
|
2018-01-16 06:41:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:19:40 +00:00
|
|
|
void LaunchMenu::developerModeTriggered() {
|
2019-08-28 01:35:51 +00:00
|
|
|
const bool isChecked = qobject_cast<QAction*>(sender())->isChecked();
|
|
|
|
|
2019-01-26 23:22:16 +00:00
|
|
|
if (hecl::com_enableCheats->toBoolean() && !isChecked) {
|
2019-08-28 01:35:51 +00:00
|
|
|
m_enableCheats->setChecked(false);
|
2019-01-26 23:22:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
hecl::CVarManager::instance()->setDeveloperMode(isChecked, true);
|
2018-12-08 05:19:40 +00:00
|
|
|
m_commons.serialize();
|
2018-01-10 06:19:48 +00:00
|
|
|
}
|
2019-01-26 23:22:16 +00:00
|
|
|
|
|
|
|
void LaunchMenu::cheatsTriggered() {
|
2019-08-28 01:35:51 +00:00
|
|
|
const bool isChecked = qobject_cast<QAction*>(sender())->isChecked();
|
|
|
|
|
2019-01-26 23:22:16 +00:00
|
|
|
if (!hecl::com_developer->toBoolean() && isChecked) {
|
2019-08-28 01:35:51 +00:00
|
|
|
m_developerMode->setChecked(false);
|
2019-01-26 23:22:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
hecl::CVarManager::instance()->setCheatsEnabled(isChecked, true);
|
|
|
|
m_commons.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchMenu::editRuntimeArgs() {
|
|
|
|
ArgumentEditor editor(this);
|
|
|
|
editor.exec();
|
|
|
|
}
|