Qt: Add optional emulation-related information on reset (closes #1780)

This commit is contained in:
Vicki Pfau 2022-01-17 01:53:22 -08:00
parent 006dba7d69
commit 851b01be15
6 changed files with 104 additions and 36 deletions

View File

@ -34,6 +34,7 @@ Misc:
- Qt: Save converter now supports importing GameShark Advance saves
- Qt: Save positions of multiplayer windows (closes mgba.io/i/2128)
- Qt: Add optional frame counter to OSD (closes mgba.io/i/1728)
- Qt: Add optional emulation-related information on reset (closes mgba.io/i/1780)
- Windows: Attach to console if present
0.9.3: (2021-12-17)

View File

@ -15,6 +15,7 @@
#include <QMutexLocker>
#include <mgba/core/serialize.h>
#include <mgba/core/version.h>
#include <mgba/feature/video-logger.h>
#ifdef M_CORE_GBA
#include <mgba/internal/gba/gba.h>
@ -92,7 +93,11 @@ CoreController::CoreController(mCore* core, QObject* parent)
context->core->setVideoBuffer(context->core, reinterpret_cast<color_t*>(controller->m_activeBuffer.data()), controller->screenDimensions().width());
}
QString message(tr("Reset r%1-%2 %3").arg(gitRevision).arg(QLatin1String(gitCommitShort)).arg(controller->m_crc32, 8, 16, QLatin1Char('0')));
QMetaObject::invokeMethod(controller, "didReset");
if (controller->m_showResetInfo) {
QMetaObject::invokeMethod(controller, "statusPosted", Q_ARG(const QString&, message));
}
controller->finishFrame();
};
@ -479,6 +484,10 @@ void CoreController::setSync(bool sync) {
}
}
void CoreController::showResetInfo(bool enable) {
m_showResetInfo = enable;
}
void CoreController::setRewinding(bool rewind) {
if (!m_threadContext.core->opts.rewindEnable) {
return;

View File

@ -134,6 +134,7 @@ public slots:
void setPaused(bool paused);
void frameAdvance();
void setSync(bool enable);
void showResetInfo(bool enable);
void setRewinding(bool);
void rewind(int count = 0);
@ -237,6 +238,7 @@ private:
uint32_t m_crc32;
QString m_internalTitle;
QString m_dbTitle;
bool m_showResetInfo = false;
QByteArray m_activeBuffer;
QByteArray m_completeBuffer;

View File

@ -451,6 +451,7 @@ void SettingsView::updateConfig() {
saveSetting("interframeBlending", m_ui.interframeBlending);
saveSetting("showOSD", m_ui.showOSD);
saveSetting("showFrameCounter", m_ui.showFrameCounter);
saveSetting("showResetInfo", m_ui.showResetInfo);
saveSetting("volume", m_ui.volume);
saveSetting("mute", m_ui.mute);
saveSetting("fastForwardVolume", m_ui.volumeFf);
@ -670,6 +671,7 @@ void SettingsView::reloadConfig() {
loadSetting("interframeBlending", m_ui.interframeBlending);
loadSetting("showOSD", m_ui.showOSD, true);
loadSetting("showFrameCounter", m_ui.showFrameCounter);
loadSetting("showResetInfo", m_ui.showResetInfo);
loadSetting("volume", m_ui.volume, 0x100);
loadSetting("mute", m_ui.mute, false);
loadSetting("fastForwardVolume", m_ui.volumeFf, m_ui.volume->value());

View File

@ -594,6 +594,13 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_41">
<property name="text">
<string>When inactive:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
@ -612,6 +619,31 @@
</item>
</layout>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_42">
<property name="text">
<string>When minimized:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<widget class="QCheckBox" name="pauseOnMinimize">
<property name="text">
<string>Pause</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="muteOnMinimize">
<property name="text">
<string>Mute</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" column="0" colspan="2">
<widget class="Line" name="line_17">
<property name="orientation">
@ -667,11 +699,25 @@
</widget>
</item>
<item row="16" column="1">
<widget class="QCheckBox" name="showFrameCounter">
<property name="text">
<string>Show frame count in OSD</string>
<layout class="QVBoxLayout" name="osdDisplay">
<property name="leftMargin">
<number>20</number>
</property>
</widget>
<item>
<widget class="QCheckBox" name="showFrameCounter">
<property name="text">
<string>Show frame count in OSD</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showResetInfo">
<property name="text">
<string>Show emulation info on reset</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="17" column="1">
<widget class="QCheckBox" name="useDiscordPresence">
@ -734,38 +780,6 @@
</property>
</widget>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<widget class="QCheckBox" name="pauseOnMinimize">
<property name="text">
<string>Pause</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="muteOnMinimize">
<property name="text">
<string>Mute</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_41">
<property name="text">
<string>When inactive:</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_42">
<property name="text">
<string>When minimized:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="update">
@ -2321,6 +2335,38 @@
</hint>
</hints>
</connection>
<connection>
<sender>showOSD</sender>
<signal>toggled(bool)</signal>
<receiver>showFrameCounter</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>374</x>
<y>391</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>431</y>
</hint>
</hints>
</connection>
<connection>
<sender>showOSD</sender>
<signal>toggled(bool)</signal>
<receiver>showResetInfo</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>374</x>
<y>391</y>
</hint>
<hint type="destinationlabel">
<x>418</x>
<y>470</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="gbColors"/>

View File

@ -1712,6 +1712,13 @@ void Window::setupMenu(QMenuBar* menubar) {
}
}, this);
ConfigOption* showResetInfo = m_config->addOption("showResetInfo");
showResetInfo->connect([this](const QVariant& value) {
if (m_controller) {
m_controller->showResetInfo(value.toBool());
}
}, this);
ConfigOption* videoScale = m_config->addOption("videoScale");
videoScale->connect([this](const QVariant& value) {
if (m_display) {
@ -2012,6 +2019,7 @@ void Window::setController(CoreController* controller, const QString& fname) {
m_controller->loadConfig(m_config);
m_config->updateOption("showOSD");
m_config->updateOption("showFrameCounter");
m_config->updateOption("showResetInfo");
m_controller->start();
if (!m_pendingState.isEmpty()) {