Qt: Move emulation speed settings to console settings

This commit is contained in:
Connor McLaughlin 2021-01-11 02:12:20 +10:00
parent 54f5563321
commit fdeef65676
6 changed files with 173 additions and 177 deletions

View file

@ -35,6 +35,28 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromLoadImageToRAM, "CDROM", "LoadImageToRAM", SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromLoadImageToRAM, "CDROM", "LoadImageToRAM",
false); false);
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);
connect(m_ui.emulationSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConsoleSettingsWidget::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);
connect(m_ui.fastForwardSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConsoleSettingsWidget::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);
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConsoleSettingsWidget::onTurboSpeedIndexChanged);
dialog->registerWidgetHelp( dialog->registerWidgetHelp(
m_ui.cdromLoadImageToRAM, tr("Preload Image to RAM"), tr("Unchecked"), m_ui.cdromLoadImageToRAM, tr("Preload Image to RAM"), tr("Unchecked"),
tr("Loads the game image into RAM. Useful for network paths that may become unreliable during gameplay. In some " tr("Loads the game image into RAM. Useful for network paths that may become unreliable during gameplay. In some "
@ -43,6 +65,16 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
m_ui.cdromReadSpeedup, tr("CDROM Read Speedup"), tr("None (Double Speed"), m_ui.cdromReadSpeedup, tr("CDROM Read Speedup"), tr("None (Double Speed"),
tr("Speeds up CD-ROM reads by the specified factor. Only applies to double-speed reads, and is ignored when audio " tr("Speeds up CD-ROM reads by the specified factor. Only applies to double-speed reads, and is ignored when audio "
"is playing. May improve loading speeds in some games, at the cost of breaking others.")); "is playing. May improve loading speeds in some games, at the cost of breaking others."));
dialog->registerWidgetHelp(
m_ui.emulationSpeed, tr("Emulation Speed"), "100%",
tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, "
"and if not, the emulator will run as fast as it can manage."));
dialog->registerWidgetHelp(
m_ui.fastForwardSpeed, tr("Fast Forward Speed"), "100%",
tr("Sets the fast forward speed. This speed will be used when the fast forward hotkey is pressed/toggled."));
dialog->registerWidgetHelp(
m_ui.turboSpeed, tr("Turbo Speed"), "100%",
tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled."));
m_ui.cpuClockSpeed->setEnabled(m_ui.enableCPUClockSpeedControl->checkState() == Qt::Checked); m_ui.cpuClockSpeed->setEnabled(m_ui.enableCPUClockSpeedControl->checkState() == Qt::Checked);
m_ui.cdromReadSpeedup->setCurrentIndex(m_host_interface->GetIntSettingValue("CDROM", "ReadSpeedup", 1) - 1); m_ui.cdromReadSpeedup->setCurrentIndex(m_host_interface->GetIntSettingValue("CDROM", "ReadSpeedup", 1) - 1);
@ -118,3 +150,27 @@ void ConsoleSettingsWidget::calculateCPUClockValue()
m_ui.cpuClockSpeed->setValue(static_cast<int>(percent)); m_ui.cpuClockSpeed->setValue(static_cast<int>(percent));
updateCPUClockSpeedLabel(); updateCPUClockSpeedLabel();
} }
void ConsoleSettingsWidget::onEmulationSpeedIndexChanged(int index)
{
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();
}
void ConsoleSettingsWidget::onFastForwardSpeedIndexChanged(int index)
{
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();
}
void ConsoleSettingsWidget::onTurboSpeedIndexChanged(int index)
{
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();
}

View file

@ -20,6 +20,9 @@ private Q_SLOTS:
void onCPUClockSpeedValueChanged(int value); void onCPUClockSpeedValueChanged(int value);
void updateCPUClockSpeedLabel(); void updateCPUClockSpeedLabel();
void onCDROMReadSpeedupValueChanged(int value); void onCDROMReadSpeedupValueChanged(int value);
void onEmulationSpeedIndexChanged(int index);
void onFastForwardSpeedIndexChanged(int index);
void onTurboSpeedIndexChanged(int index);
private: private:
void calculateCPUClockValue(); void calculateCPUClockValue();

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>648</width> <width>648</width>
<height>401</height> <height>456</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -45,12 +45,51 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Speed Control</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="emulationSpeed"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Fast Forward Speed:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="fastForwardSpeed"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Turbo Speed:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="turboSpeed"/>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string>CPU Emulation</string> <string>CPU Emulation</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
@ -61,16 +100,9 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="cpuExecutionMode"/> <widget class="QComboBox" name="cpuExecutionMode"/>
</item> </item>
</layout> <item row="1" column="0" colspan="2">
</widget> <layout class="QVBoxLayout" name="verticalLayout_2">
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>CPU Clock Speed Control</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QCheckBox" name="enableCPUClockSpeedControl"> <widget class="QCheckBox" name="enableCPUClockSpeedControl">
@ -104,7 +136,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QSlider" name="cpuClockSpeed"> <widget class="QSlider" name="cpuClockSpeed">
<property name="minimum"> <property name="minimum">
<number>10</number> <number>10</number>
@ -127,6 +159,8 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
@ -135,27 +169,6 @@
<string>CD-ROM Emulation</string> <string>CD-ROM Emulation</string>
</property> </property>
<layout class="QFormLayout" name="formLayout_4"> <layout class="QFormLayout" name="formLayout_4">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="cdromReadThread">
<property name="text">
<string>Use Read Thread (Asynchronous)</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="cdromRegionCheck">
<property name="text">
<string>Enable Region Check</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="cdromLoadImageToRAM">
<property name="text">
<string>Preload Image To RAM</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -217,6 +230,31 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="cdromReadThread">
<property name="text">
<string>Use Read Thread (Asynchronous)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cdromRegionCheck">
<property name="text">
<string>Enable Region Check</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cdromLoadImageToRAM">
<property name="text">
<string>Preload Image To RAM</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View file

@ -38,29 +38,6 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
m_host_interface, m_ui.controllerBackend, "Main", "ControllerBackend", &ControllerInterface::ParseBackendName, m_host_interface, m_ui.controllerBackend, "Main", "ControllerBackend", &ControllerInterface::ParseBackendName,
&ControllerInterface::GetBackendName, ControllerInterface::GetDefaultBackend()); &ControllerInterface::GetBackendName, ControllerInterface::GetDefaultBackend());
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);
connect(m_ui.emulationSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&GeneralSettingsWidget::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);
connect(m_ui.fastForwardSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&GeneralSettingsWidget::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);
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&GeneralSettingsWidget::onTurboSpeedIndexChanged);
dialog->registerWidgetHelp( dialog->registerWidgetHelp(
m_ui.confirmPowerOff, tr("Confirm Power Off"), tr("Checked"), m_ui.confirmPowerOff, tr("Confirm Power Off"), tr("Checked"),
tr("Determines whether a prompt will be displayed to confirm shutting down the emulator/game " tr("Determines whether a prompt will be displayed to confirm shutting down the emulator/game "
@ -90,16 +67,6 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
m_ui.applyGameSettings, tr("Apply Per-Game Settings"), tr("Checked"), m_ui.applyGameSettings, tr("Apply Per-Game Settings"), tr("Checked"),
tr("When enabled, per-game settings will be applied, and incompatible enhancements will be disabled. You should " tr("When enabled, per-game settings will be applied, and incompatible enhancements will be disabled. You should "
"leave this option enabled except when testing enhancements with incompatible games.")); "leave this option enabled except when testing enhancements with incompatible games."));
dialog->registerWidgetHelp(
m_ui.emulationSpeed, tr("Emulation Speed"), "100%",
tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, "
"and if not, the emulator will run as fast as it can manage."));
dialog->registerWidgetHelp(
m_ui.fastForwardSpeed, tr("Fast Forward Speed"), "100%",
tr("Sets the fast forward speed. This speed will be used when the fast forward hotkey is pressed/toggled."));
dialog->registerWidgetHelp(
m_ui.turboSpeed, tr("Turbo Speed"), "100%",
tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled."));
dialog->registerWidgetHelp(m_ui.controllerBackend, tr("Controller Backend"), dialog->registerWidgetHelp(m_ui.controllerBackend, tr("Controller Backend"),
qApp->translate("ControllerInterface", ControllerInterface::GetBackendName( qApp->translate("ControllerInterface", ControllerInterface::GetBackendName(
ControllerInterface::GetDefaultBackend())), ControllerInterface::GetDefaultBackend())),
@ -149,27 +116,3 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW
} }
GeneralSettingsWidget::~GeneralSettingsWidget() = default; GeneralSettingsWidget::~GeneralSettingsWidget() = default;
void GeneralSettingsWidget::onEmulationSpeedIndexChanged(int index)
{
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();
}
void GeneralSettingsWidget::onFastForwardSpeedIndexChanged(int index)
{
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();
}
void GeneralSettingsWidget::onTurboSpeedIndexChanged(int index)
{
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();
}

View file

@ -15,11 +15,6 @@ public:
explicit GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog); explicit GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog);
~GeneralSettingsWidget(); ~GeneralSettingsWidget();
private Q_SLOTS:
void onEmulationSpeedIndexChanged(int index);
void onFastForwardSpeedIndexChanged(int index);
void onTurboSpeedIndexChanged(int index);
private: private:
Ui::GeneralSettingsWidget m_ui; Ui::GeneralSettingsWidget m_ui;

View file

@ -105,45 +105,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Speed Control</string>
</property>
<layout class="QGridLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="emulationSpeed"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Fast Forward Speed:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="fastForwardSpeed"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Turbo Speed:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="turboSpeed"/>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">