From 6daa04c6f4134641604f7bbfb7043bcfa618c239 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Wed, 2 Feb 2022 11:42:39 +0100 Subject: [PATCH] added option for automatic pause/continue of emulation depending on focus (resolves #870) --- Changes.txt | 2 ++ docs/graphics/options_emulation.png | Bin 3429 -> 3606 bytes docs/index.html | 9 +++++++++ src/emucore/EventHandler.cxx | 9 +++++++++ src/emucore/Settings.cxx | 3 +++ src/gui/EmulationDialog.cxx | 17 +++++++++++++++-- src/gui/EmulationDialog.hxx | 1 + 7 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Changes.txt b/Changes.txt index aa88d0d7b..76ce4b1e2 100644 --- a/Changes.txt +++ b/Changes.txt @@ -25,6 +25,8 @@ - Added option to show/hide file extensions. - Extended context menu and shortcuts. + * Added option to automatically pause emulation when focus is lost. + * Added option to toggle autofire mode. * Added another oddball TIA glitch option for score mode color. diff --git a/docs/graphics/options_emulation.png b/docs/graphics/options_emulation.png index b924a7bbc308c9ac7b26d71c78dd552fe1f65e97..032ce64469aa61ad4d070826fb8ffe4cec68b203 100644 GIT binary patch literal 3606 zcmZu!c{tQ<_aBXIY*Vz@8lgyJZxVwfMYbAQvy}*$BxJ@e;+4c>7m)`^W#88sM#Ruy zFl8(=#AKbXHys)`slkfIXbFG(JucOD{_=7wdTQ_pB{`@=oZLYJX@20 zsPzR}7tlbSbl*yiii#OZCZmxzqD>HOvaH^e2!%P0A!pX7+4dkVQ@lAtQl5pqo0P39OB z9v37u7z>46;EJfFy!CrW8?Bw=VZaT+dLz|~;=l_g`z8yaAkt2K+)9L=VK3d%i5(_2H-s9s0%g8?;#!rUNMmRTw z?n>2nTr{5Pjso&nf#p>y>z$r0xTRSt$3%8vuM3lb(;pMU(&mX@|0>ldT)6axB z9iGBmk(g>qq->nq_*HoVA=)B>FuUU{AMN(M7R+AS=3{k&*DzuKBDz^OorK~1#Tk&Q zLwECL#ZOSb7T1e?bEm(Kg4t9b;>8 z@%c8!ezu-L!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}%C`R)ks(M7k(?v~EPdrU8@;;G{#=!PK zy?JTyNQ`8`LYUM;(pciKFZXfaTJDtu&Mq6wHEAFWS<3u$Cm^+v)P9dSyFykD0bDLx zFa+@0mDC)~=ESShkGk^D6-GA71w0xu5y!e>2Baxgcw*kLzaXT)TQk53HDC$-9h@_6 zFeb%FVIZEE-cHh8mUP@QLqTNS)#LL1()qvUbq8+u)2Y*%_PI|5D8VjBj&f^2fwK^f{q*aOi`}eJ#|Aa~8%m>}%-}`l{9pUFEs#;{e;E z2jbO-)qAoAR7BkW)r6Fw6|Vu!h3at94UOs6>*kbLj?(5Ez)fAOt98}N4{9*HFcWcm z5-t^g-hA>Z?I@;rAjV|)Y4eTugNi3rsII+VBDPF@>t6*wAja5FW7mHqSpzg9L7wm2 zZl-=~{>}j!=pb2~hT4gqWUqibQTCZLk6UlNA3DDSM_H^g|0e#Q8$ezDlIJu2Hg`m_ zV~rf~`N2GyvQHQ&{PF21^1;VeDCC@OBZQXKxHJg~!JTBy3evP&jWv3W8E6Zu-1C_C zkB9sy4Z$yGVo0`n=}q{44Aj7ZTn&<#jE}x}wjttPnK5@M@w~}L!TU#jhu2JQ9x<;i zgncL{qUjvYjfZOhMoTjbXW6lUIMiMeO^alKZTKra_ixIg@(0DxQTnUJq9 z&LJ3jqkHzUmUUjVVCN^IWF?d5@XCC1aWa7M-#dsGxYLp62+EBY)~A6k|jF19+YWHDvuZ>1Q?^6?Uc0`BZ!N9# cW$%F@Tnh>TXR>qle?B0Kb2g^WjJ + +
-autopause <1|0>
+ Enable or disable automatic pause/continue of emulation, when + Stella loses/gains focus. +
-pausedim <1|0>
Enable or disable emulation dimming in pause mode. @@ -3966,6 +3971,10 @@ Multi-threadingEnable multi-threaded rendering-threads Fast SuperCharger loadSkip progress loading bars for SuperCharger ROMs-fastscbios Show UI messagesOverlay UI messages onscreen-uimessages + + Automatic pauseEnable or disable automatic pause/continue of emulation, + when Stella loses/gains focus.-autopause + Confirm exiting...Display a popup when emulation is exited-confirmexit When entering/exiting emulation: diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index b41ddaab4..3640e1c8c 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -376,6 +376,15 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int) enterMenuMode(EventHandlerState::OPTIONSMENU); break; #endif + case SystemEvent::WINDOW_FOCUS_GAINED: + if(myOSystem.settings().getBool("autopause") && myState == EventHandlerState::PAUSE) + setState(EventHandlerState::EMULATION); + break; + case SystemEvent::WINDOW_FOCUS_LOST: + if(myOSystem.settings().getBool("autopause") && myState == EventHandlerState::EMULATION) + setState(EventHandlerState::PAUSE); + break; + default: // handle other events as testing requires // cerr << "handleSystemEvent: " << e << endl; break; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index ec74d98da..ecec07215 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -184,6 +184,8 @@ Settings::Settings() setPermanent("dialogfont", "medium"); setPermanent("dialogpos", 0); setPermanent("confirmexit", false); + setPermanent("autopause", false); + // Misc options setPermanent("loglevel", int(Logger::Level::INFO)); @@ -624,6 +626,7 @@ void Settings::usage() const << " large16>\n" << " -dialogpos <0..4> Display all dialogs at given positions\n" << " -confirmexit <0|1> Display a confirm dialog when exiting emulation\n" + << " -autopause <0|1> Pause/continue emulation when focus is lost/gained\n" << " -listdelay Time to wait between keypresses in list widgets\n" << " (300-1000)\n" << " -mwheel Number of lines the mouse wheel will scroll in\n" diff --git a/src/gui/EmulationDialog.cxx b/src/gui/EmulationDialog.cxx index a04ceb6e0..fab449f07 100644 --- a/src/gui/EmulationDialog.cxx +++ b/src/gui/EmulationDialog.cxx @@ -81,7 +81,7 @@ EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, // Set real dimensions _w = 37 * fontWidth + HBORDER * 2 + CheckboxWidget::prefixSize(_font); - _h = 12 * (lineHeight + VGAP) + VGAP * 7 + VBORDER * 3 + _th + buttonHeight; + _h = 13 * (lineHeight + VGAP) + VGAP * 7 + VBORDER * 3 + _th + buttonHeight; xpos = HBORDER; ypos = VBORDER + _th; @@ -122,8 +122,14 @@ EmulationDialog::EmulationDialog(OSystem& osystem, DialogContainer& parent, wid.push_back(myUIMessages); ypos += lineHeight + VGAP; - // Confirm dialog when exiting emulation + // Automatically pause emulation when focus is lost xpos = HBORDER; ypos += VGAP * 3; + myAutoPauseWidget = new CheckboxWidget(this, _font, xpos, ypos, "Automatic pause"); + myAutoPauseWidget->setToolTip("Check for automatic pause/continue of\nemulation when Stella loses/gains focus."); + wid.push_back(myAutoPauseWidget); + + // Confirm dialog when exiting emulation + ypos += lineHeight + VGAP; myConfirmExitWidget = new CheckboxWidget(this, _font, xpos, ypos, "Confirm exiting emulation"); wid.push_back(myConfirmExitWidget); @@ -186,6 +192,9 @@ void EmulationDialog::loadConfig() // Multi-threaded rendering myUseThreads->setState(settings.getBool("threads")); + // Automatically pause emulation when focus is lost + myAutoPauseWidget->setState(settings.getBool("autopause")); + // Confirm dialog when exiting emulation myConfirmExitWidget->setState(settings.getBool("confirmexit")); @@ -222,6 +231,9 @@ void EmulationDialog::saveConfig() // Multi-threaded rendering settings.setValue("threads", myUseThreads->getState()); + // Automatically pause emulation when focus is lost + settings.setValue("autopause", myAutoPauseWidget->getState()); + // Confirm dialog when exiting emulation settings.setValue("confirmexit", myConfirmExitWidget->getState()); @@ -254,6 +266,7 @@ void EmulationDialog::setDefaults() myUIMessages->setState(true); myFastSCBios->setState(true); myUseThreads->setState(false); + myAutoPauseWidget->setState(false); myConfirmExitWidget->setState(false); mySaveOnExitGroup->setSelected(0); diff --git a/src/gui/EmulationDialog.hxx b/src/gui/EmulationDialog.hxx index 13603c5d3..fb736fe44 100644 --- a/src/gui/EmulationDialog.hxx +++ b/src/gui/EmulationDialog.hxx @@ -43,6 +43,7 @@ class EmulationDialog : public Dialog CheckboxWidget* myUIMessages{nullptr}; CheckboxWidget* myFastSCBios{nullptr}; CheckboxWidget* myUseThreads{nullptr}; + CheckboxWidget* myAutoPauseWidget{nullptr}; CheckboxWidget* myConfirmExitWidget{nullptr}; RadioButtonGroup* mySaveOnExitGroup{nullptr}; CheckboxWidget* myAutoSlotWidget{nullptr};