run Reset through EmuThread too

This commit is contained in:
Arisotura 2024-06-14 23:24:04 +02:00
parent 32a5aa07ba
commit 0cf003999a
4 changed files with 31 additions and 15 deletions

View File

@ -75,8 +75,7 @@ void EmuThread::attachWindow(MainWindow* window)
connect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart()));
connect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));
connect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool)));
connect(this, SIGNAL(windowEmuReset()), window->actReset, SLOT(trigger()));
connect(this, SIGNAL(windowEmuFrameStep()), window->actFrameStep, SLOT(trigger()));
connect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
connect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger()));
connect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
connect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
@ -91,8 +90,7 @@ void EmuThread::detachWindow(MainWindow* window)
disconnect(this, SIGNAL(windowEmuStart()), window, SLOT(onEmuStart()));
disconnect(this, SIGNAL(windowEmuStop()), window, SLOT(onEmuStop()));
disconnect(this, SIGNAL(windowEmuPause(bool)), window, SLOT(onEmuPause(bool)));
disconnect(this, SIGNAL(windowEmuReset()), window->actReset, SLOT(trigger()));
disconnect(this, SIGNAL(windowEmuFrameStep()), window->actFrameStep, SLOT(trigger()));
disconnect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
disconnect(this, SIGNAL(windowLimitFPSChange()), window->actLimitFramerate, SLOT(trigger()));
disconnect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
disconnect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
@ -158,8 +156,8 @@ void EmuThread::run()
if (emuInstance->hotkeyPressed(HK_FastForwardToggle)) emit windowLimitFPSChange();
if (emuInstance->hotkeyPressed(HK_Pause)) emuTogglePause();
if (emuInstance->hotkeyPressed(HK_Reset)) emit windowEmuReset();
if (emuInstance->hotkeyPressed(HK_FrameStep)) emit windowEmuFrameStep();
if (emuInstance->hotkeyPressed(HK_Reset)) emuReset();
if (emuInstance->hotkeyPressed(HK_FrameStep)) emuFrameStep();
if (emuInstance->hotkeyPressed(HK_FullscreenToggle)) emit windowFullscreenToggle();
@ -541,6 +539,18 @@ void EmuThread::handleMessages()
emuStatus = emuStatus_FrameStep;
break;
case msg_EmuReset:
emuInstance->reset();
emuStatus = emuStatus_Running;
emuPauseStack = emuPauseStackRunning;
emuActive = true;
emuInstance->audioEnable();
emit windowEmuReset();
emuInstance->osdAddMessage(0, "Reset");
break;
case msg_InitGL:
emuInstance->initOpenGL();
useOpenGL = true;
@ -620,6 +630,12 @@ void EmuThread::emuFrameStep()
waitAllMessages();
}
void EmuThread::emuReset()
{
sendMessage(msg_EmuReset);
waitMessage();
}
bool EmuThread::emuIsRunning()
{
return emuStatus == emuStatus_Running;

View File

@ -64,6 +64,7 @@ public:
msg_EmuUnpause,
msg_EmuStop,
msg_EmuFrameStep,
msg_EmuReset,
msg_InitGL,
msg_DeInitGL,
@ -97,6 +98,7 @@ public:
void emuStop(bool external);
void emuExit();
void emuFrameStep();
void emuReset();
bool emuIsRunning();
bool emuIsActive();
@ -116,7 +118,6 @@ signals:
void windowEmuStop();
void windowEmuPause(bool pause);
void windowEmuReset();
void windowEmuFrameStep();
void windowLimitFPSChange();

View File

@ -1605,14 +1605,7 @@ void MainWindow::onReset()
{
if (!emuThread->emuIsActive()) return;
emuThread->emuPause();
actUndoStateLoad->setEnabled(false);
emuInstance->reset();
emuInstance->osdAddMessage(0, "Reset");
emuThread->emuRun();
emuThread->emuReset();
}
void MainWindow::onStop()
@ -2088,6 +2081,11 @@ void MainWindow::onEmuPause(bool pause)
actPause->setChecked(pause);
}
void MainWindow::onEmuReset()
{
actUndoStateLoad->setEnabled(false);
}
void MainWindow::onUpdateVideoSettings(bool glchange)
{
if (glchange)

View File

@ -209,6 +209,7 @@ private slots:
void onEmuStart();
void onEmuStop();
void onEmuPause(bool pause);
void onEmuReset();
void onUpdateVideoSettings(bool glchange);