mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
synchronize pause/unpause across all instances
Some checks are pending
macOS / ${{ matrix.arch }} (arm64) (push) Waiting to run
macOS / ${{ matrix.arch }} (x86_64) (push) Waiting to run
macOS / Universal binary (push) Blocked by required conditions
Ubuntu / x86_64 (push) Waiting to run
Ubuntu / aarch64 (push) Waiting to run
Windows / build (push) Waiting to run
Some checks are pending
macOS / ${{ matrix.arch }} (arm64) (push) Waiting to run
macOS / ${{ matrix.arch }} (x86_64) (push) Waiting to run
macOS / Universal binary (push) Blocked by required conditions
Ubuntu / x86_64 (push) Waiting to run
Ubuntu / aarch64 (push) Waiting to run
Windows / build (push) Waiting to run
This commit is contained in:
parent
e6f0d77aa0
commit
e576538268
@ -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])
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -1349,7 +1349,7 @@ void MainWindow::updateRecentFilesMenu()
|
||||
Config::Save();
|
||||
loadRecentFilesMenu(false);
|
||||
|
||||
updateConfigInfoAll(Config_RecentFiles, emuInstance->getInstanceID());
|
||||
emuInstance->broadcastCommand(InstCmd_UpdateRecentFiles);
|
||||
}
|
||||
|
||||
void MainWindow::onClickRecentFile()
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user