From 546f787eb3b276f4ad2f5469f5a774dc83fbbe09 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 6 Oct 2019 02:54:51 -0700 Subject: [PATCH] Qt: Add option for disabling OSD messages --- CHANGES | 1 + src/platform/qt/Display.cpp | 4 ++ src/platform/qt/Display.h | 3 ++ src/platform/qt/DisplayGL.cpp | 14 ++++- src/platform/qt/DisplayGL.h | 3 ++ src/platform/qt/DisplayQt.cpp | 4 +- src/platform/qt/SettingsView.cpp | 2 + src/platform/qt/SettingsView.ui | 93 +++++++++++++++++++------------- src/platform/qt/Window.cpp | 9 ++++ 9 files changed, 93 insertions(+), 40 deletions(-) diff --git a/CHANGES b/CHANGES index 38407c923..2aff452c5 100644 --- a/CHANGES +++ b/CHANGES @@ -83,6 +83,7 @@ Misc: - Qt: Printer quality of life improvements (fixes mgba.io/i/1540) - Qt: Add copy and QoL improvements to graphic views (closes mgba.io/i/1541) - Qt: Show list of all sprites in sprite view + - Qt: Add option for disabling OSD messages 0.7.3: (2019-09-15) Emulation fixes: diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index bdbffcc0e..36b463545 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -75,6 +75,10 @@ void Display::interframeBlending(bool lock) { m_interframeBlending = lock; } +void Display::showOSDMessages(bool enable) { + m_showOSD = enable; +} + void Display::filter(bool filter) { m_filter = filter; } diff --git a/src/platform/qt/Display.h b/src/platform/qt/Display.h index 52db65a41..ce2a5cffc 100644 --- a/src/platform/qt/Display.h +++ b/src/platform/qt/Display.h @@ -44,6 +44,7 @@ public: bool isIntegerScalingLocked() const { return m_lockIntegerScaling; } bool hasInterframeBlending() const { return m_interframeBlending; } bool isFiltered() const { return m_filter; } + bool isShowOSD() const { return m_showOSD; } virtual void startDrawing(std::shared_ptr) = 0; virtual bool isDrawing() const = 0; @@ -66,6 +67,7 @@ public slots: virtual void lockAspectRatio(bool lock); virtual void lockIntegerScaling(bool lock); virtual void interframeBlending(bool enable); + virtual void showOSDMessages(bool enable); virtual void filter(bool filter); virtual void framePosted() = 0; virtual void setShaders(struct VDir*) = 0; @@ -85,6 +87,7 @@ private: static const int MOUSE_DISAPPEAR_TIMER = 1000; MessagePainter m_messagePainter; + bool m_showOSD = true; bool m_lockAspectRatio = false; bool m_lockIntegerScaling = false; bool m_interframeBlending = false; diff --git a/src/platform/qt/DisplayGL.cpp b/src/platform/qt/DisplayGL.cpp index 4a9122ccf..db1f2e42d 100644 --- a/src/platform/qt/DisplayGL.cpp +++ b/src/platform/qt/DisplayGL.cpp @@ -111,6 +111,7 @@ void DisplayGL::startDrawing(std::shared_ptr controller) { lockAspectRatio(isAspectRatioLocked()); lockIntegerScaling(isIntegerScalingLocked()); interframeBlending(hasInterframeBlending()); + showOSDMessages(isShowOSD()); filter(isFiltered()); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) messagePainter()->resize(size(), isAspectRatioLocked(), devicePixelRatioF()); @@ -184,6 +185,13 @@ void DisplayGL::interframeBlending(bool enable) { } } +void DisplayGL::showOSDMessages(bool enable) { + Display::showOSDMessages(enable); + if (m_drawThread) { + QMetaObject::invokeMethod(m_painter, "showOSD", Q_ARG(bool, enable)); + } +} + void DisplayGL::filter(bool filter) { Display::filter(filter); if (m_drawThread) { @@ -370,6 +378,10 @@ void PainterGL::interframeBlending(bool enable) { m_backend->interframeBlending = enable; } +void PainterGL::showOSD(bool enable) { + m_showOSD = enable; +} + void PainterGL::filter(bool filter) { m_backend->filter = filter; if (m_started && !m_active) { @@ -458,7 +470,7 @@ void PainterGL::performDraw() { m_backend->resized(m_backend, m_size.width() * r, m_size.height() * r); m_backend->drawFrame(m_backend); m_painter.endNativePainting(); - if (m_messagePainter) { + if (m_showOSD && m_messagePainter) { m_messagePainter->paint(&m_painter); } } diff --git a/src/platform/qt/DisplayGL.h b/src/platform/qt/DisplayGL.h index 5871f8840..3eb5d8eeb 100644 --- a/src/platform/qt/DisplayGL.h +++ b/src/platform/qt/DisplayGL.h @@ -56,6 +56,7 @@ public slots: void lockAspectRatio(bool lock) override; void lockIntegerScaling(bool lock) override; void interframeBlending(bool enable) override; + void showOSDMessages(bool enable) override; void filter(bool filter) override; void framePosted() override; void setShaders(struct VDir*) override; @@ -102,6 +103,7 @@ public slots: void lockAspectRatio(bool lock); void lockIntegerScaling(bool lock); void interframeBlending(bool enable); + void showOSD(bool enable); void filter(bool filter); void resizeContext(); @@ -127,6 +129,7 @@ private: bool m_started = false; std::shared_ptr m_context = nullptr; bool m_supportsShaders; + bool m_showOSD; VideoShader m_shader{}; VideoBackend* m_backend = nullptr; QSize m_size; diff --git a/src/platform/qt/DisplayQt.cpp b/src/platform/qt/DisplayQt.cpp index 30cb3a8e4..764bf88ca 100644 --- a/src/platform/qt/DisplayQt.cpp +++ b/src/platform/qt/DisplayQt.cpp @@ -122,5 +122,7 @@ void DisplayQt::paintEvent(QPaintEvent*) { } painter.drawImage(full, m_backing, QRect(0, 0, m_width, m_height)); painter.setOpacity(1); - messagePainter()->paint(&painter); + if (isShowOSD()) { + messagePainter()->paint(&painter); + } } diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index ff1485dc5..cf3bca860 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -377,6 +377,7 @@ void SettingsView::updateConfig() { saveSetting("lockAspectRatio", m_ui.lockAspectRatio); saveSetting("lockIntegerScaling", m_ui.lockIntegerScaling); saveSetting("interframeBlending", m_ui.interframeBlending); + saveSetting("showOSD", m_ui.showOSD); saveSetting("volume", m_ui.volume); saveSetting("mute", m_ui.mute); saveSetting("fastForwardVolume", m_ui.volumeFf); @@ -547,6 +548,7 @@ void SettingsView::reloadConfig() { loadSetting("lockAspectRatio", m_ui.lockAspectRatio); loadSetting("lockIntegerScaling", m_ui.lockIntegerScaling); loadSetting("interframeBlending", m_ui.interframeBlending); + loadSetting("showOSD", m_ui.showOSD, true); 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 e4050da5c..2dbb2fca7 100644 --- a/src/platform/qt/SettingsView.ui +++ b/src/platform/qt/SettingsView.ui @@ -562,7 +562,21 @@ - + + + + Pause when minimized + + + + + + + Qt::Horizontal + + + + Show FPS in title bar @@ -572,41 +586,21 @@ - + + + + Enable Discord Rich Presence + + + + Qt::Horizontal - - - - Qt::Horizontal - - - - - - - Automatically save cheats - - - true - - - - - - - Automatically load cheats - - - true - - - - + Automatically save state @@ -616,7 +610,7 @@ - + Automatically load state @@ -626,17 +620,40 @@ - - - - Enable Discord Rich Presence + + + + Qt::Horizontal - - + + - Pause when minimized + Automatically save cheats + + + true + + + + + + + Automatically load cheats + + + true + + + + + + + Show OSD messages + + + true diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 35abe2168..122eea673 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -738,6 +738,7 @@ void Window::gameStarted() { m_config->updateOption("lockIntegerScaling"); m_config->updateOption("lockAspectRatio"); m_config->updateOption("interframeBlending"); + m_config->updateOption("showOSD"); if (m_savedScale > 0) { resizeFrame(size * m_savedScale); } @@ -908,6 +909,7 @@ void Window::reloadDisplayDriver() { m_display->lockIntegerScaling(opts->lockIntegerScaling); m_display->interframeBlending(opts->interframeBlending); m_display->filter(opts->resampleVideo); + m_config->updateOption("showOSD"); #if defined(BUILD_GL) || defined(BUILD_GLES2) if (opts->shader) { struct VDir* shader = VDirOpen(opts->shader); @@ -1603,6 +1605,13 @@ void Window::setupMenu(QMenuBar* menubar) { } }, this); + ConfigOption* showOSD = m_config->addOption("showOSD"); + showOSD->connect([this](const QVariant& value) { + if (m_display) { + m_display->showOSDMessages(value.toBool()); + } + }, this); + m_actions.addHiddenAction(tr("Exit fullscreen"), "exitFullScreen", this, &Window::exitFullScreen, "frame", QKeySequence("Esc")); m_actions.addHeldAction(tr("GameShark Button (held)"), "holdGSButton", [this](bool held) {