diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index 3906b186..a848fc3e 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -241,11 +241,24 @@ void EmuInstance::deleteAllWindows() } -void EmuInstance::updateConfigInfo(int kind) +void EmuInstance::broadcastCommand(int cmd) { - switch (kind) + broadcastInstanceCommand(cmd, instanceID); +} + +void EmuInstance::handleCommand(int cmd) +{ + switch (cmd) { - case Config_RecentFiles: + case InstCmd_Pause: + emuThread->emuPause(false); + break; + + case InstCmd_Unpause: + emuThread->emuUnpause(false); + break; + + case InstCmd_UpdateRecentFiles: for (int i = 0; i < kMaxWindows; i++) { if (windowList[i]) diff --git a/src/frontend/qt_sdl/EmuInstance.h b/src/frontend/qt_sdl/EmuInstance.h index a7ecddf8..61090496 100644 --- a/src/frontend/qt_sdl/EmuInstance.h +++ b/src/frontend/qt_sdl/EmuInstance.h @@ -92,7 +92,8 @@ public: Config::Table& getGlobalConfig() { return globalCfg; } Config::Table& getLocalConfig() { return localCfg; } - void updateConfigInfo(int kind); + void broadcastCommand(int cmd); + void handleCommand(int cmd); std::string instanceFileSuffix(); diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp index 1bf22c36..583ed91c 100644 --- a/src/frontend/qt_sdl/EmuThread.cpp +++ b/src/frontend/qt_sdl/EmuThread.cpp @@ -70,7 +70,6 @@ EmuThread::EmuThread(EmuInstance* inst, QObject* parent) : QThread(parent) void EmuThread::attachWindow(MainWindow* window) { - //connect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); connect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString))); connect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); @@ -89,7 +88,6 @@ void EmuThread::attachWindow(MainWindow* window) void EmuThread::detachWindow(MainWindow* window) { - //disconnect(this, SIGNAL(windowUpdate()), window->panel, SLOT(repaint())); disconnect(this, SIGNAL(windowTitleChange(QString)), window, SLOT(onTitleUpdate(QString))); disconnect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart())); disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop())); @@ -676,24 +674,30 @@ void EmuThread::emuRun() waitMessage(); } -void EmuThread::emuPause() +void EmuThread::emuPause(bool broadcast) { sendMessage(msg_EmuPause); waitMessage(); + + if (broadcast) + emuInstance->broadcastCommand(InstCmd_Pause); } -void EmuThread::emuUnpause() +void EmuThread::emuUnpause(bool broadcast) { sendMessage(msg_EmuUnpause); waitMessage(); + + if (broadcast) + emuInstance->broadcastCommand(InstCmd_Unpause); } -void EmuThread::emuTogglePause() +void EmuThread::emuTogglePause(bool broadcast) { if (emuStatus == emuStatus_Paused) - emuUnpause(); + emuUnpause(broadcast); else - emuPause(); + emuPause(broadcast); } void EmuThread::emuStop(bool external) diff --git a/src/frontend/qt_sdl/EmuThread.h b/src/frontend/qt_sdl/EmuThread.h index 57f389af..19e1a3a6 100644 --- a/src/frontend/qt_sdl/EmuThread.h +++ b/src/frontend/qt_sdl/EmuThread.h @@ -104,9 +104,9 @@ public: // to be called from the UI thread void emuRun(); - void emuPause(); - void emuUnpause(); - void emuTogglePause(); + void emuPause(bool broadcast = true); + void emuUnpause(bool broadcast = true); + void emuTogglePause(bool broadcast = true); void emuStop(bool external); void emuExit(); void emuFrameStep(); diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index a231a6f8..442274b5 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -1349,7 +1349,7 @@ void MainWindow::updateRecentFilesMenu() Config::Save(); loadRecentFilesMenu(false); - updateConfigInfoAll(Config_RecentFiles, emuInstance->getInstanceID()); + emuInstance->broadcastCommand(InstCmd_UpdateRecentFiles); } void MainWindow::onClickRecentFile() diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index a4cc965e..69485a8e 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -168,14 +168,14 @@ int numEmuInstances() } -void updateConfigInfoAll(int kind, int sourceinst) +void broadcastInstanceCommand(int cmd, int sourceinst) { for (int i = 0; i < kMaxEmuInstances; i++) { if (i == sourceinst) continue; if (!emuInstances[i]) continue; - emuInstances[i]->updateConfigInfo(kind); + emuInstances[i]->handleCommand(cmd); } } diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index b247d1fd..cd5a08f1 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -33,7 +33,10 @@ enum { - Config_RecentFiles, + InstCmd_Pause, + InstCmd_Unpause, + + InstCmd_UpdateRecentFiles, }; class MelonApplication : public QApplication @@ -55,7 +58,7 @@ void deleteEmuInstance(int id); void deleteAllEmuInstances(int first = 0); int numEmuInstances(); -void updateConfigInfoAll(int kind, int sourceinst); +void broadcastInstanceCommand(int cmd, int sourceinst); void setMPInterface(melonDS::MPInterfaceType type);