Qt: Clean up FPS target UI (fixes #436)

This commit is contained in:
Vicki Pfau 2018-09-16 13:38:23 -07:00
parent 981072a299
commit 12d77b6209
3 changed files with 18 additions and 9 deletions

View File

@ -84,6 +84,7 @@ Misc:
- Feature: Added loading savestates from command line - Feature: Added loading savestates from command line
- Qt: Allow pausing game at load (fixes mgba.io/i/1129) - Qt: Allow pausing game at load (fixes mgba.io/i/1129)
- Wii: Move audio handling to callbacks (fixes mgba.io/i/803) - Wii: Move audio handling to callbacks (fixes mgba.io/i/803)
- Qt: Clean up FPS target UI (fixes mgba.io/i/436)
0.6.3: (2017-04-14) 0.6.3: (2017-04-14)
Bugfixes: Bugfixes:

View File

@ -326,6 +326,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QDoubleSpinBox" name="fpsTarget"> <widget class="QDoubleSpinBox" name="fpsTarget">
<property name="decimals">
<number>4</number>
</property>
<property name="minimum"> <property name="minimum">
<double>0.010000000000000</double> <double>0.010000000000000</double>
</property> </property>

View File

@ -1409,17 +1409,22 @@ void Window::setupMenu(QMenuBar* menubar) {
QMenu* target = avMenu->addMenu(tr("FPS target")); QMenu* target = avMenu->addMenu(tr("FPS target"));
ConfigOption* fpsTargetOption = m_config->addOption("fpsTarget"); ConfigOption* fpsTargetOption = m_config->addOption("fpsTarget");
fpsTargetOption->connect([this](const QVariant& value) { QMap<double, QAction*> fpsTargets;
for (int fps : {15, 30, 45, 60, 90, 120, 240}) {
fpsTargets[fps] = fpsTargetOption->addValue(QString::number(fps), fps, target);
}
target->addSeparator();
double nativeGB = double(GBA_ARM7TDMI_FREQUENCY) / double(VIDEO_TOTAL_LENGTH);
fpsTargets[nativeGB] = fpsTargetOption->addValue(tr("Native (59.7275)"), nativeGB, target);
fpsTargetOption->connect([this, fpsTargets](const QVariant& value) {
reloadConfig(); reloadConfig();
for (auto iter = fpsTargets.begin(); iter != fpsTargets.end(); ++iter) {
bool enableSignals = iter.value()->blockSignals(true);
iter.value()->setChecked(abs(iter.key() - value.toDouble()) < 0.001);
iter.value()->blockSignals(enableSignals);
}
}, this); }, this);
fpsTargetOption->addValue(tr("15"), 15, target);
fpsTargetOption->addValue(tr("30"), 30, target);
fpsTargetOption->addValue(tr("45"), 45, target);
fpsTargetOption->addValue(tr("Native (59.7)"), float(GBA_ARM7TDMI_FREQUENCY) / float(VIDEO_TOTAL_LENGTH), target);
fpsTargetOption->addValue(tr("60"), 60, target);
fpsTargetOption->addValue(tr("90"), 90, target);
fpsTargetOption->addValue(tr("120"), 120, target);
fpsTargetOption->addValue(tr("240"), 240, target);
m_config->updateOption("fpsTarget"); m_config->updateOption("fpsTarget");
avMenu->addSeparator(); avMenu->addSeparator();