From 851b01be1526b7c5829d0aec48cc15043fb22b6e Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 17 Jan 2022 01:53:22 -0800 Subject: [PATCH] Qt: Add optional emulation-related information on reset (closes #1780) --- CHANGES | 1 + src/platform/qt/CoreController.cpp | 9 +++ src/platform/qt/CoreController.h | 2 + src/platform/qt/SettingsView.cpp | 2 + src/platform/qt/SettingsView.ui | 118 ++++++++++++++++++++--------- src/platform/qt/Window.cpp | 8 ++ 6 files changed, 104 insertions(+), 36 deletions(-) diff --git a/CHANGES b/CHANGES index 0c31a3fd4..227e201bb 100644 --- a/CHANGES +++ b/CHANGES @@ -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) diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 8106195e7..86736e911 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #ifdef M_CORE_GBA #include @@ -92,7 +93,11 @@ CoreController::CoreController(mCore* core, QObject* parent) context->core->setVideoBuffer(context->core, reinterpret_cast(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; diff --git a/src/platform/qt/CoreController.h b/src/platform/qt/CoreController.h index be68407ac..ae7c37269 100644 --- a/src/platform/qt/CoreController.h +++ b/src/platform/qt/CoreController.h @@ -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; diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index 38350d671..4af948d4b 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -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()); diff --git a/src/platform/qt/SettingsView.ui b/src/platform/qt/SettingsView.ui index ea8a3b8e6..47e92ed29 100644 --- a/src/platform/qt/SettingsView.ui +++ b/src/platform/qt/SettingsView.ui @@ -594,6 +594,13 @@ + + + + When inactive: + + + @@ -612,6 +619,31 @@ + + + + When minimized: + + + + + + + + + Pause + + + + + + + Mute + + + + + @@ -667,11 +699,25 @@ - - - Show frame count in OSD + + + 20 - + + + + Show frame count in OSD + + + + + + + Show emulation info on reset + + + + @@ -734,38 +780,6 @@ - - - - - - Pause - - - - - - - Mute - - - - - - - - - When inactive: - - - - - - - When minimized: - - - @@ -2321,6 +2335,38 @@ + + showOSD + toggled(bool) + showFrameCounter + setEnabled(bool) + + + 374 + 391 + + + 418 + 431 + + + + + showOSD + toggled(bool) + showResetInfo + setEnabled(bool) + + + 374 + 391 + + + 418 + 470 + + + diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 72919db56..bc1bc14c3 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -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()) {