2017-06-27 18:00:23 +02:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-06-27 18:00:23 +02:00
|
|
|
|
2018-07-07 00:40:15 +02:00
|
|
|
#include "DolphinQt/Config/Graphics/SoftwareRendererWidget.h"
|
2017-06-27 18:00:23 +02:00
|
|
|
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#include "Core/Config/GraphicsSettings.h"
|
2020-05-04 01:21:51 +02:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2017-06-27 18:00:23 +02:00
|
|
|
#include "Core/ConfigManager.h"
|
2019-06-08 16:02:01 -07:00
|
|
|
#include "Core/Core.h"
|
2018-05-28 03:48:04 +02:00
|
|
|
|
2018-07-07 00:40:15 +02:00
|
|
|
#include "DolphinQt/Config/Graphics/GraphicsBool.h"
|
|
|
|
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
|
2020-10-20 20:03:15 -05:00
|
|
|
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
|
2018-07-07 00:40:15 +02:00
|
|
|
#include "DolphinQt/Settings.h"
|
2018-05-28 03:48:04 +02:00
|
|
|
|
2017-06-27 18:00:23 +02:00
|
|
|
#include "UICommon/VideoUtils.h"
|
2018-05-28 03:48:04 +02:00
|
|
|
|
2017-06-27 18:00:23 +02:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
|
2020-10-20 20:03:15 -05:00
|
|
|
SoftwareRendererWidget::SoftwareRendererWidget(GraphicsWindow* parent)
|
2017-06-27 18:00:23 +02:00
|
|
|
{
|
|
|
|
CreateWidgets();
|
|
|
|
LoadSettings();
|
|
|
|
ConnectWidgets();
|
|
|
|
AddDescriptions();
|
2020-05-04 01:21:51 +02:00
|
|
|
emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)));
|
2019-06-08 16:02:01 -07:00
|
|
|
|
|
|
|
connect(parent, &GraphicsWindow::BackendChanged, [this] { LoadSettings(); });
|
2022-08-08 11:25:19 +10:00
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
|
|
|
|
OnEmulationStateChanged(state != Core::State::Uninitialized);
|
|
|
|
});
|
2019-06-08 16:02:01 -07:00
|
|
|
OnEmulationStateChanged(Core::GetState() != Core::State::Uninitialized);
|
2017-06-27 18:00:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SoftwareRendererWidget::CreateWidgets()
|
|
|
|
{
|
|
|
|
auto* main_layout = new QVBoxLayout;
|
|
|
|
|
|
|
|
auto* rendering_box = new QGroupBox(tr("Rendering"));
|
|
|
|
auto* rendering_layout = new QGridLayout();
|
2020-10-20 20:03:15 -05:00
|
|
|
m_backend_combo = new ToolTipComboBox();
|
2017-06-27 18:00:23 +02:00
|
|
|
|
|
|
|
rendering_box->setLayout(rendering_layout);
|
|
|
|
rendering_layout->addWidget(new QLabel(tr("Backend:")), 1, 1);
|
|
|
|
rendering_layout->addWidget(m_backend_combo, 1, 2);
|
|
|
|
|
2020-10-21 21:34:38 +02:00
|
|
|
for (const auto& backend : VideoBackendBase::GetAvailableBackends())
|
2017-06-27 18:00:23 +02:00
|
|
|
m_backend_combo->addItem(tr(backend->GetDisplayName().c_str()));
|
|
|
|
|
|
|
|
main_layout->addWidget(rendering_box);
|
2017-09-14 18:48:20 +02:00
|
|
|
main_layout->addStretch();
|
2017-06-27 18:00:23 +02:00
|
|
|
|
|
|
|
setLayout(main_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoftwareRendererWidget::ConnectWidgets()
|
|
|
|
{
|
2019-07-30 09:35:46 -04:00
|
|
|
connect(m_backend_combo, qOverload<int>(&QComboBox::currentIndexChanged),
|
2017-06-27 18:00:23 +02:00
|
|
|
[this](int) { SaveSettings(); });
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoftwareRendererWidget::LoadSettings()
|
|
|
|
{
|
2020-10-21 21:34:38 +02:00
|
|
|
for (const auto& backend : VideoBackendBase::GetAvailableBackends())
|
2017-06-27 18:00:23 +02:00
|
|
|
{
|
2020-05-04 01:21:51 +02:00
|
|
|
if (backend->GetName() == Config::Get(Config::MAIN_GFX_BACKEND))
|
|
|
|
{
|
2017-06-27 18:00:23 +02:00
|
|
|
m_backend_combo->setCurrentIndex(
|
|
|
|
m_backend_combo->findText(tr(backend->GetDisplayName().c_str())));
|
2020-05-04 01:21:51 +02:00
|
|
|
}
|
2017-06-27 18:00:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoftwareRendererWidget::SaveSettings()
|
|
|
|
{
|
2020-10-21 21:34:38 +02:00
|
|
|
for (const auto& backend : VideoBackendBase::GetAvailableBackends())
|
2017-06-27 18:00:23 +02:00
|
|
|
{
|
|
|
|
if (tr(backend->GetDisplayName().c_str()) == m_backend_combo->currentText())
|
|
|
|
{
|
|
|
|
const auto backend_name = backend->GetName();
|
2020-05-04 01:21:51 +02:00
|
|
|
if (backend_name != Config::Get(Config::MAIN_GFX_BACKEND))
|
2017-06-27 18:00:23 +02:00
|
|
|
emit BackendChanged(QString::fromStdString(backend_name));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoftwareRendererWidget::AddDescriptions()
|
|
|
|
{
|
2020-10-20 20:03:15 -05:00
|
|
|
static const char TR_BACKEND_DESCRIPTION[] = QT_TR_NOOP(
|
|
|
|
"Selects what graphics API to use internally.<br>The software renderer is extremely "
|
|
|
|
"slow and only useful for debugging, so you'll want to use either Direct3D or "
|
|
|
|
"OpenGL. Different games and different GPUs will behave differently on each "
|
|
|
|
"backend, so for the best emulation experience it's recommended to try both and "
|
|
|
|
"choose the one that's less problematic.<br><br><dolphin_emphasis>If unsure, select "
|
|
|
|
"OpenGL.</dolphin_emphasis>");
|
|
|
|
|
|
|
|
m_backend_combo->SetTitle(tr("Backend"));
|
2020-11-30 14:04:08 +01:00
|
|
|
m_backend_combo->SetDescription(tr(TR_BACKEND_DESCRIPTION));
|
2017-06-27 18:00:23 +02:00
|
|
|
}
|
2019-06-08 16:02:01 -07:00
|
|
|
|
|
|
|
void SoftwareRendererWidget::OnEmulationStateChanged(bool running)
|
|
|
|
{
|
|
|
|
m_backend_combo->setEnabled(!running);
|
|
|
|
}
|