UI: Massive revamp, new features and improvements
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "emulationsettingswidget.h"
|
||||
#include "common/make_array.h"
|
||||
#include "core/system.h"
|
||||
#include "qtutils.h"
|
||||
#include "settingsdialog.h"
|
||||
@@ -6,37 +7,60 @@
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <limits>
|
||||
|
||||
EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface, QWidget* parent,
|
||||
SettingsDialog* dialog)
|
||||
: QWidget(parent), m_host_interface(host_interface)
|
||||
EmulationSettingsWidget::EmulationSettingsWidget(SettingsDialog* dialog, QWidget* parent)
|
||||
: QWidget(parent), m_dialog(dialog)
|
||||
{
|
||||
SettingsInterface* sif = dialog->getSettingsInterface();
|
||||
|
||||
m_ui.setupUi(this);
|
||||
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.rewindEnable, "Main", "RewindEnable", false);
|
||||
SettingWidgetBinder::BindWidgetToFloatSetting(m_host_interface, m_ui.rewindSaveFrequency, "Main", "RewindFrequency",
|
||||
10.0f);
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.rewindSaveSlots, "Main", "RewindSaveSlots", 10);
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.runaheadFrames, "Main", "RunaheadFrameCount", 0);
|
||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.rewindEnable, "Main", "RewindEnable", false);
|
||||
SettingWidgetBinder::BindWidgetToFloatSetting(sif, m_ui.rewindSaveFrequency, "Main", "RewindFrequency", 10.0f);
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.rewindSaveSlots, "Main", "RewindSaveSlots", 10);
|
||||
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.runaheadFrames, "Main", "RunaheadFrameCount", 0);
|
||||
|
||||
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
|
||||
const int emulation_speed_index =
|
||||
m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "EmulationSpeed", 1.0f)));
|
||||
if (emulation_speed_index >= 0)
|
||||
m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index);
|
||||
const float effective_emulation_speed = m_dialog->getEffectiveFloatValue("Main", "EmulationSpeed", 1.0f);
|
||||
fillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed, effective_emulation_speed);
|
||||
if (m_dialog->isPerGameSettings() && !m_dialog->getFloatValue("Main", "EmulationSpeed", std::nullopt).has_value())
|
||||
{
|
||||
m_ui.emulationSpeed->setCurrentIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int emulation_speed_index = m_ui.emulationSpeed->findData(QVariant(effective_emulation_speed));
|
||||
if (emulation_speed_index >= 0)
|
||||
m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index);
|
||||
}
|
||||
connect(m_ui.emulationSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&EmulationSettingsWidget::onEmulationSpeedIndexChanged);
|
||||
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed);
|
||||
const int fast_forward_speed_index =
|
||||
m_ui.fastForwardSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "FastForwardSpeed", 0.0f)));
|
||||
if (fast_forward_speed_index >= 0)
|
||||
m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index);
|
||||
|
||||
const float effective_fast_forward_speed = m_dialog->getEffectiveFloatValue("Main", "FastForwardSpeed", 0.0f);
|
||||
fillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed, effective_fast_forward_speed);
|
||||
if (m_dialog->isPerGameSettings() && !m_dialog->getFloatValue("Main", "FastForwardSpeed", std::nullopt).has_value())
|
||||
{
|
||||
m_ui.emulationSpeed->setCurrentIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int fast_forward_speed_index = m_ui.fastForwardSpeed->findData(QVariant(effective_fast_forward_speed));
|
||||
if (fast_forward_speed_index >= 0)
|
||||
m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index);
|
||||
}
|
||||
connect(m_ui.fastForwardSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&EmulationSettingsWidget::onFastForwardSpeedIndexChanged);
|
||||
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.turboSpeed);
|
||||
const int turbo_speed_index =
|
||||
m_ui.turboSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "TurboSpeed", 0.0f)));
|
||||
if (turbo_speed_index >= 0)
|
||||
m_ui.turboSpeed->setCurrentIndex(turbo_speed_index);
|
||||
|
||||
const float effective_turbo_speed = m_dialog->getEffectiveFloatValue("Main", "TurboSpeed", 0.0f);
|
||||
fillComboBoxWithEmulationSpeeds(m_ui.turboSpeed, effective_turbo_speed);
|
||||
if (m_dialog->isPerGameSettings() && !m_dialog->getFloatValue("Main", "TurboSpeed", std::nullopt).has_value())
|
||||
{
|
||||
m_ui.emulationSpeed->setCurrentIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int turbo_speed_index = m_ui.turboSpeed->findData(QVariant(effective_turbo_speed));
|
||||
if (turbo_speed_index >= 0)
|
||||
m_ui.turboSpeed->setCurrentIndex(turbo_speed_index);
|
||||
}
|
||||
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&EmulationSettingsWidget::onTurboSpeedIndexChanged);
|
||||
|
||||
@@ -62,46 +86,87 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
|
||||
dialog->registerWidgetHelp(
|
||||
m_ui.rewindEnable, tr("Rewinding"), tr("Unchecked"),
|
||||
tr("<b>Enable Rewinding:</b> Saves state periodically so you can rewind any mistakes while playing.<br> "
|
||||
"<b>Rewind Save Frequency:</b> How often a rewind state will be created. Higher frequencies have greater system requirements.<br> "
|
||||
"<b>Rewind Buffer Size:</b> How many saves will be kept for rewinding. Higher values have greater memory requirements."));
|
||||
"<b>Rewind Save Frequency:</b> How often a rewind state will be created. Higher frequencies have greater system "
|
||||
"requirements.<br> "
|
||||
"<b>Rewind Buffer Size:</b> How many saves will be kept for rewinding. Higher values have greater memory "
|
||||
"requirements."));
|
||||
dialog->registerWidgetHelp(
|
||||
m_ui.runaheadFrames, tr("Runahead"), tr("Disabled"),
|
||||
tr("Simulates the system ahead of time and rolls back/replays to reduce input lag. Very high system requirements."));
|
||||
tr(
|
||||
"Simulates the system ahead of time and rolls back/replays to reduce input lag. Very high system requirements."));
|
||||
|
||||
updateRewind();
|
||||
}
|
||||
|
||||
EmulationSettingsWidget::~EmulationSettingsWidget() = default;
|
||||
|
||||
void EmulationSettingsWidget::fillComboBoxWithEmulationSpeeds(QComboBox* cb, float global_value)
|
||||
{
|
||||
if (m_dialog->isPerGameSettings())
|
||||
{
|
||||
if (global_value == 0.0f)
|
||||
cb->addItem(tr("Use Global Setting [Unlimited]"));
|
||||
else
|
||||
cb->addItem(tr("Use Global Setting [%1%]").arg(static_cast<u32>(global_value * 100.0f)));
|
||||
}
|
||||
|
||||
cb->addItem(tr("Unlimited"), QVariant(0.0f));
|
||||
|
||||
static constexpr auto speeds = make_array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 250, 300, 350,
|
||||
400, 450, 500, 600, 700, 800, 900, 1000);
|
||||
for (const int speed : speeds)
|
||||
{
|
||||
cb->addItem(tr("%1% [%2 FPS (NTSC) / %3 FPS (PAL)]").arg(speed).arg((60 * speed) / 100).arg((50 * speed) / 100),
|
||||
QVariant(static_cast<float>(speed) / 100.0f));
|
||||
}
|
||||
}
|
||||
|
||||
void EmulationSettingsWidget::onEmulationSpeedIndexChanged(int index)
|
||||
{
|
||||
if (m_dialog->isPerGameSettings() && index == 0)
|
||||
{
|
||||
m_dialog->removeSettingValue("Main", "EmulationSpeed");
|
||||
return;
|
||||
}
|
||||
|
||||
bool okay;
|
||||
const float value = m_ui.emulationSpeed->currentData().toFloat(&okay);
|
||||
m_host_interface->SetFloatSettingValue("Main", "EmulationSpeed", okay ? value : 1.0f);
|
||||
m_host_interface->applySettings();
|
||||
m_dialog->setFloatSettingValue("Main", "EmulationSpeed", okay ? value : 1.0f);
|
||||
}
|
||||
|
||||
void EmulationSettingsWidget::onFastForwardSpeedIndexChanged(int index)
|
||||
{
|
||||
if (m_dialog->isPerGameSettings() && index == 0)
|
||||
{
|
||||
m_dialog->removeSettingValue("Main", "FastForwardSpeed");
|
||||
return;
|
||||
}
|
||||
|
||||
bool okay;
|
||||
const float value = m_ui.fastForwardSpeed->currentData().toFloat(&okay);
|
||||
m_host_interface->SetFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f);
|
||||
m_host_interface->applySettings();
|
||||
m_dialog->setFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f);
|
||||
}
|
||||
|
||||
void EmulationSettingsWidget::onTurboSpeedIndexChanged(int index)
|
||||
{
|
||||
if (m_dialog->isPerGameSettings() && index == 0)
|
||||
{
|
||||
m_dialog->removeSettingValue("Main", "TurboSpeed");
|
||||
return;
|
||||
}
|
||||
|
||||
bool okay;
|
||||
const float value = m_ui.turboSpeed->currentData().toFloat(&okay);
|
||||
m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f);
|
||||
m_host_interface->applySettings();
|
||||
m_dialog->setFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f);
|
||||
}
|
||||
|
||||
void EmulationSettingsWidget::updateRewind()
|
||||
{
|
||||
m_ui.rewindEnable->setEnabled(!runaheadEnabled());
|
||||
const bool rewind_enabled = m_dialog->getEffectiveBoolValue("Main", "RewindEnable", false);
|
||||
const bool runahead_enabled = m_dialog->getIntValue("Main", "RunaheadFrameCount", 0) > 0;
|
||||
m_ui.rewindEnable->setEnabled(!runahead_enabled);
|
||||
|
||||
if (m_ui.rewindEnable->isEnabled() && m_ui.rewindEnable->isChecked())
|
||||
if (!runahead_enabled && rewind_enabled)
|
||||
{
|
||||
const u32 frames = static_cast<u32>(m_ui.rewindSaveSlots->value());
|
||||
const float frequency = static_cast<float>(m_ui.rewindSaveFrequency->value());
|
||||
@@ -121,7 +186,7 @@ void EmulationSettingsWidget::updateRewind()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_ui.rewindEnable->isEnabled())
|
||||
if (runahead_enabled)
|
||||
{
|
||||
m_ui.rewindSummary->setText(tr(
|
||||
"Rewind is disabled because runahead is enabled. Runahead will significantly increase system requirements."));
|
||||
|
||||
Reference in New Issue
Block a user