2018-01-10 06:19:48 +00:00
|
|
|
#include "LaunchMenu.hpp"
|
|
|
|
#include "hecl/CVarCommons.hpp"
|
|
|
|
|
2018-01-15 13:17:08 +00:00
|
|
|
extern hecl::BoolCVar* hecl::com_developer;
|
|
|
|
|
2018-01-10 06:19:48 +00:00
|
|
|
LaunchMenu::LaunchMenu(hecl::CVarCommons& commons, QWidget* parent)
|
|
|
|
: QMenu("Launch Menu", parent),
|
|
|
|
m_commons(commons),
|
|
|
|
m_apiMenu("Graphics API", this),
|
|
|
|
m_msaaMenu("Anti-Aliasing", this),
|
|
|
|
m_anisoMenu("Anisotropic Filtering", this),
|
|
|
|
m_apiGroup(this),
|
|
|
|
m_msaaGroup(this),
|
|
|
|
m_anisoGroup(this)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
initApiAction(QStringLiteral("D3D11"));
|
|
|
|
initApiAction(QStringLiteral("Vulkan"));
|
|
|
|
initApiAction(QStringLiteral("OpenGL"));
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
initApiAction(QStringLiteral("Metal"));
|
|
|
|
initApiAction(QStringLiteral("OpenGL"));
|
|
|
|
#else
|
|
|
|
initApiAction(QStringLiteral("OpenGL"));
|
|
|
|
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"));
|
|
|
|
|
2018-01-15 13:17:08 +00:00
|
|
|
initDeveloperMode();
|
2018-01-10 06:19:48 +00:00
|
|
|
m_apiMenu.addActions(m_apiGroup.actions());
|
|
|
|
m_msaaMenu.addActions(m_msaaGroup.actions());
|
|
|
|
m_anisoMenu.addActions(m_anisoGroup.actions());
|
|
|
|
addMenu(&m_apiMenu);
|
|
|
|
addMenu(&m_msaaMenu);
|
|
|
|
addMenu(&m_anisoMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchMenu::initApiAction(const QString& action)
|
|
|
|
{
|
|
|
|
QAction* act = m_apiGroup.addAction(action);
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(apiTriggered()));
|
|
|
|
act->setCheckable(true);
|
|
|
|
if (!action.compare(QString::fromStdString(m_commons.getGraphicsApi()), Qt::CaseInsensitive))
|
|
|
|
act->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchMenu::initMsaaAction(const QString& action)
|
|
|
|
{
|
|
|
|
QAction* act = m_msaaGroup.addAction(action);
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(msaaTriggered()));
|
|
|
|
act->setCheckable(true);
|
|
|
|
if (!action.compare(QString::number(m_commons.getSamples()), Qt::CaseInsensitive))
|
|
|
|
act->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchMenu::initAnisoAction(const QString& action)
|
|
|
|
{
|
|
|
|
QAction* act = m_anisoGroup.addAction(action);
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(anisoTriggered()));
|
|
|
|
act->setCheckable(true);
|
|
|
|
if (!action.compare(QString::number(m_commons.getAnisotropy()), Qt::CaseInsensitive))
|
|
|
|
act->setChecked(true);
|
|
|
|
}
|
|
|
|
|
2018-01-15 13:17:08 +00:00
|
|
|
void LaunchMenu::initDeveloperMode()
|
|
|
|
{
|
|
|
|
QAction* act = addAction("&Developer Mode");
|
|
|
|
act->setCheckable(true);
|
|
|
|
act->setChecked(hecl::com_developer->value());
|
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(developerModeTriggered()));
|
|
|
|
}
|
|
|
|
|
2018-01-10 06:19:48 +00:00
|
|
|
void LaunchMenu::apiTriggered()
|
|
|
|
{
|
|
|
|
m_commons.setGraphicsApi(qobject_cast<QAction*>(sender())->text().toStdString());
|
|
|
|
m_commons.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchMenu::msaaTriggered()
|
|
|
|
{
|
2018-01-15 13:17:08 +00:00
|
|
|
m_commons.setSamples(qobject_cast<QAction*>(sender())->text().toUInt());
|
2018-01-10 06:19:48 +00:00
|
|
|
m_commons.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchMenu::anisoTriggered()
|
|
|
|
{
|
2018-01-15 13:17:08 +00:00
|
|
|
m_commons.setAnisotropy(qobject_cast<QAction*>(sender())->text().toUInt());
|
|
|
|
m_commons.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LaunchMenu::developerModeTriggered()
|
|
|
|
{
|
|
|
|
hecl::CVarManager::instance()->setDeveloperMode(qobject_cast<QAction*>(sender())->isChecked(), true);
|
2018-01-10 06:19:48 +00:00
|
|
|
m_commons.serialize();
|
|
|
|
}
|