all repos — mgba @ 546f787eb3b276f4ad2f5469f5a774dc83fbbe09

mGBA Game Boy Advance Emulator

Qt: Add option for disabling OSD messages
Vicki Pfau vi@endrift.com
Sun, 06 Oct 2019 02:54:51 -0700
commit

546f787eb3b276f4ad2f5469f5a774dc83fbbe09

parent

54b92bee16e9e61ad35ce4175688432e173b461d

M CHANGESCHANGES

@@ -83,6 +83,7 @@ - CMake: Don't use libzip on embedded platforms (fixes mgba.io/i/1527)

- 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:
M src/platform/qt/Display.cppsrc/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; }
M src/platform/qt/Display.hsrc/platform/qt/Display.h

@@ -44,6 +44,7 @@ bool isAspectRatioLocked() const { return m_lockAspectRatio; }

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<CoreController>) = 0; virtual bool isDrawing() const = 0;

@@ -66,6 +67,7 @@ virtual void forceDraw() = 0;

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 @@ static Driver s_driver;

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;
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -111,6 +111,7 @@

lockAspectRatio(isAspectRatioLocked()); lockIntegerScaling(isIntegerScalingLocked()); interframeBlending(hasInterframeBlending()); + showOSDMessages(isShowOSD()); filter(isFiltered()); #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) messagePainter()->resize(size(), isAspectRatioLocked(), devicePixelRatioF());

@@ -181,6 +182,13 @@ void DisplayGL::interframeBlending(bool enable) {

Display::interframeBlending(enable); if (m_drawThread) { QMetaObject::invokeMethod(m_painter, "interframeBlending", Q_ARG(bool, enable)); + } +} + +void DisplayGL::showOSDMessages(bool enable) { + Display::showOSDMessages(enable); + if (m_drawThread) { + QMetaObject::invokeMethod(m_painter, "showOSD", Q_ARG(bool, enable)); } }

@@ -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 @@ float r = m_surface->devicePixelRatio();

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); } }
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -56,6 +56,7 @@ void forceDraw() override;

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 @@ void resize(const QSize& size);

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 @@ bool m_active = false;

bool m_started = false; std::shared_ptr<CoreController> m_context = nullptr; bool m_supportsShaders; + bool m_showOSD; VideoShader m_shader{}; VideoBackend* m_backend = nullptr; QSize m_size;
M src/platform/qt/DisplayQt.cppsrc/platform/qt/DisplayQt.cpp

@@ -122,5 +122,7 @@ painter.setOpacity(0.5);

} painter.drawImage(full, m_backing, QRect(0, 0, m_width, m_height)); painter.setOpacity(1); - messagePainter()->paint(&painter); + if (isShowOSD()) { + messagePainter()->paint(&painter); + } }
M src/platform/qt/SettingsView.cppsrc/platform/qt/SettingsView.cpp

@@ -377,6 +377,7 @@ saveSetting("autofireThreshold", m_ui.autofireThreshold);

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 @@ loadSetting("autofireThreshold", m_ui.autofireThreshold);

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());
M src/platform/qt/SettingsView.uisrc/platform/qt/SettingsView.ui

@@ -562,7 +562,21 @@ <string>Pause when inactive</string>

</property> </widget> </item> - <item row="10" column="1"> + <item row="9" column="1"> + <widget class="QCheckBox" name="pauseOnMinimize"> + <property name="text"> + <string>Pause when minimized</string> + </property> + </widget> + </item> + <item row="10" column="0" colspan="2"> + <widget class="Line" name="line_17"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="11" column="1"> <widget class="QCheckBox" name="showFps"> <property name="text"> <string>Show FPS in title bar</string>

@@ -572,71 +586,74 @@ <bool>true</bool>

</property> </widget> </item> - <item row="12" column="0" colspan="2"> - <widget class="Line" name="line_13"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <item row="13" column="1"> + <widget class="QCheckBox" name="useDiscordPresence"> + <property name="text"> + <string>Enable Discord Rich Presence</string> </property> </widget> </item> - <item row="15" column="0" colspan="2"> - <widget class="Line" name="line_16"> + <item row="14" column="0" colspan="2"> + <widget class="Line" name="line_13"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="16" column="1"> - <widget class="QCheckBox" name="cheatAutosave"> + <item row="15" column="1"> + <widget class="QCheckBox" name="autosave"> <property name="text"> - <string>Automatically save cheats</string> + <string>Automatically save state</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> - <item row="17" column="1"> - <widget class="QCheckBox" name="cheatAutoload"> + <item row="16" column="1"> + <widget class="QCheckBox" name="autoload"> <property name="text"> - <string>Automatically load cheats</string> + <string>Automatically load state</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> - <item row="13" column="1"> - <widget class="QCheckBox" name="autosave"> + <item row="17" column="0" colspan="2"> + <widget class="Line" name="line_16"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="18" column="1"> + <widget class="QCheckBox" name="cheatAutosave"> <property name="text"> - <string>Automatically save state</string> + <string>Automatically save cheats</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> - <item row="14" column="1"> - <widget class="QCheckBox" name="autoload"> + <item row="19" column="1"> + <widget class="QCheckBox" name="cheatAutoload"> <property name="text"> - <string>Automatically load state</string> + <string>Automatically load cheats</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> - <item row="11" column="1"> - <widget class="QCheckBox" name="useDiscordPresence"> + <item row="12" column="1"> + <widget class="QCheckBox" name="showOSD"> <property name="text"> - <string>Enable Discord Rich Presence</string> + <string>Show OSD messages</string> </property> - </widget> - </item> - <item row="9" column="1"> - <widget class="QCheckBox" name="pauseOnMinimize"> - <property name="text"> - <string>Pause when minimized</string> + <property name="checked"> + <bool>true</bool> </property> </widget> </item>
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -738,6 +738,7 @@ m_screenWidget->setDimensions(size.width(), size.height());

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 @@ m_display->lockAspectRatio(opts->lockAspectRatio);

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);

@@ -1600,6 +1602,13 @@ updateTitle();

} else if (m_controller) { m_fpsTimer.start(); m_frameTimer.start(); + } + }, this); + + ConfigOption* showOSD = m_config->addOption("showOSD"); + showOSD->connect([this](const QVariant& value) { + if (m_display) { + m_display->showOSDMessages(value.toBool()); } }, this);