Qt: Add settings for rewind
This commit is contained in:
parent
516d685dd0
commit
689b62e065
|
@ -4,6 +4,7 @@
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
#include "settingwidgetbinder.h"
|
#include "settingwidgetbinder.h"
|
||||||
#include <QtWidgets/QMessageBox>
|
#include <QtWidgets/QMessageBox>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface, QWidget* parent,
|
EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface, QWidget* parent,
|
||||||
SettingsDialog* dialog)
|
SettingsDialog* dialog)
|
||||||
|
@ -13,6 +14,10 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
|
||||||
|
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToHostRefreshRate, "Main",
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToHostRefreshRate, "Main",
|
||||||
"SyncToHostRefreshRate", false);
|
"SyncToHostRefreshRate", false);
|
||||||
|
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);
|
||||||
|
|
||||||
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
|
QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed);
|
||||||
const int emulation_speed_index =
|
const int emulation_speed_index =
|
||||||
|
@ -36,6 +41,12 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
|
||||||
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(m_ui.turboSpeed, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
&EmulationSettingsWidget::onTurboSpeedIndexChanged);
|
&EmulationSettingsWidget::onTurboSpeedIndexChanged);
|
||||||
|
|
||||||
|
connect(m_ui.rewindEnable, &QCheckBox::stateChanged, this, &EmulationSettingsWidget::updateRewindSummaryLabel);
|
||||||
|
connect(m_ui.rewindSaveFrequency, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
||||||
|
&EmulationSettingsWidget::updateRewindSummaryLabel);
|
||||||
|
connect(m_ui.rewindSaveSlots, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||||
|
&EmulationSettingsWidget::updateRewindSummaryLabel);
|
||||||
|
|
||||||
dialog->registerWidgetHelp(
|
dialog->registerWidgetHelp(
|
||||||
m_ui.emulationSpeed, tr("Emulation Speed"), "100%",
|
m_ui.emulationSpeed, tr("Emulation Speed"), "100%",
|
||||||
tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, "
|
tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, "
|
||||||
|
@ -54,6 +65,8 @@ EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface
|
||||||
"potentially increasing the emulation speed by less than 1%. Sync To Host Refresh Rate will not take effect if "
|
"potentially increasing the emulation speed by less than 1%. Sync To Host Refresh Rate will not take effect if "
|
||||||
"the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays "
|
"the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays "
|
||||||
"should disable this option."));
|
"should disable this option."));
|
||||||
|
|
||||||
|
updateRewindSummaryLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
EmulationSettingsWidget::~EmulationSettingsWidget() = default;
|
EmulationSettingsWidget::~EmulationSettingsWidget() = default;
|
||||||
|
@ -81,3 +94,33 @@ void EmulationSettingsWidget::onTurboSpeedIndexChanged(int index)
|
||||||
m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f);
|
m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f);
|
||||||
m_host_interface->applySettings();
|
m_host_interface->applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmulationSettingsWidget::updateRewindSummaryLabel()
|
||||||
|
{
|
||||||
|
if (m_ui.rewindEnable->isChecked())
|
||||||
|
{
|
||||||
|
const u32 frames = static_cast<u32>(m_ui.rewindSaveSlots->value());
|
||||||
|
const float frequency = static_cast<float>(m_ui.rewindSaveFrequency->value());
|
||||||
|
const float duration =
|
||||||
|
((frequency <= std::numeric_limits<float>::epsilon()) ? (1.0f / 60.0f) : frequency) * static_cast<float>(frames);
|
||||||
|
|
||||||
|
u64 ram_usage, vram_usage;
|
||||||
|
System::CalculateRewindMemoryUsage(frames, &ram_usage, &vram_usage);
|
||||||
|
|
||||||
|
m_ui.rewindSummary->setText(
|
||||||
|
tr("Rewind for %1 frames, lasting %2 seconds will require up to %3MB of RAM and %4MB of VRAM.")
|
||||||
|
.arg(frames)
|
||||||
|
.arg(duration)
|
||||||
|
.arg(ram_usage / 1048576)
|
||||||
|
.arg(vram_usage / 1048576));
|
||||||
|
m_ui.rewindSaveFrequency->setEnabled(true);
|
||||||
|
m_ui.rewindSaveSlots->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ui.rewindSummary->setText(
|
||||||
|
tr("Rewind is not enabled. Please note that enabling rewind may significantly increase system requirements."));
|
||||||
|
m_ui.rewindSaveFrequency->setEnabled(false);
|
||||||
|
m_ui.rewindSaveSlots->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ private Q_SLOTS:
|
||||||
void onEmulationSpeedIndexChanged(int index);
|
void onEmulationSpeedIndexChanged(int index);
|
||||||
void onFastForwardSpeedIndexChanged(int index);
|
void onFastForwardSpeedIndexChanged(int index);
|
||||||
void onTurboSpeedIndexChanged(int index);
|
void onTurboSpeedIndexChanged(int index);
|
||||||
|
void updateRewindSummaryLabel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>648</width>
|
<width>672</width>
|
||||||
<height>456</height>
|
<height>518</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -72,6 +72,72 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Rewind</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="rewindEnable">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable Rewinding</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rewind Save Frequency:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="rewindSaveFrequency">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> Seconds</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>3600.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rewind Buffer Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="rewindSaveSlots">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> Frames</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>10000</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="rewindSummary">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
Loading…
Reference in New Issue