1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 11:13:19 +01:00

Improve Restart function

Don't erase boot args
Should now work correctly with game launchers
This commit is contained in:
Nekotekina 2018-01-03 00:45:52 +03:00
parent 7050575fdb
commit af3e1fc580
4 changed files with 14 additions and 7 deletions

View File

@ -920,7 +920,7 @@ void Emulator::Resume()
GetCallbacks().on_resume(); GetCallbacks().on_resume();
} }
void Emulator::Stop() void Emulator::Stop(bool restart)
{ {
if (m_state.exchange(system_state::stopped) == system_state::stopped) if (m_state.exchange(system_state::stopped) == system_state::stopped)
{ {
@ -928,7 +928,7 @@ void Emulator::Stop()
return; return;
} }
const bool do_exit = !m_force_boot && g_cfg.misc.autoexit; const bool do_exit = !restart && !m_force_boot && g_cfg.misc.autoexit;
LOG_NOTICE(GENERAL, "Stopping emulator..."); LOG_NOTICE(GENERAL, "Stopping emulator...");
@ -992,6 +992,12 @@ void Emulator::Stop()
jit_finalize(); jit_finalize();
#endif #endif
if (restart)
{
return Load();
}
// Boot arg cleanup (preserved in the case restarting)
argv.clear(); argv.clear();
envp.clear(); envp.clear();
data.clear(); data.clear();

View File

@ -262,7 +262,8 @@ public:
void Run(); void Run();
bool Pause(); bool Pause();
void Resume(); void Resume();
void Stop(); void Stop(bool restart = false);
void Restart() { Stop(true); }
bool IsRunning() const { return m_state == system_state::running; } bool IsRunning() const { return m_state == system_state::running; }
bool IsPaused() const { return m_state == system_state::paused; } bool IsPaused() const { return m_state == system_state::paused; }

View File

@ -87,7 +87,7 @@ void gs_frame::keyPressEvent(QKeyEvent *keyEvent)
if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.IsStopped())) { Emu.Stop(); return; } if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.IsStopped())) { Emu.Stop(); return; }
break; break;
case Qt::Key_R: case Qt::Key_R:
if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.GetBoot().empty())) { Emu.SetForceBoot(true); Emu.Stop(); Emu.Load(); return; } if (keyEvent->modifiers() == Qt::ControlModifier && (!Emu.GetBoot().empty())) { Emu.Restart(); return; }
break; break;
case Qt::Key_E: case Qt::Key_E:
if (keyEvent->modifiers() == Qt::ControlModifier) if (keyEvent->modifiers() == Qt::ControlModifier)

View File

@ -172,7 +172,7 @@ void main_window::CreateThumbnailToolbar()
RepaintThumbnailIcons(); RepaintThumbnailIcons();
connect(m_thumb_stop, &QWinThumbnailToolButton::clicked, [=]() { Emu.Stop(); }); connect(m_thumb_stop, &QWinThumbnailToolButton::clicked, [=]() { Emu.Stop(); });
connect(m_thumb_restart, &QWinThumbnailToolButton::clicked, [=]() { Emu.SetForceBoot(true); Emu.Stop(); Emu.Load(); }); connect(m_thumb_restart, &QWinThumbnailToolButton::clicked, [=]() { Emu.Restart(); });
connect(m_thumb_playPause, &QWinThumbnailToolButton::clicked, Pause); connect(m_thumb_playPause, &QWinThumbnailToolButton::clicked, Pause);
#endif #endif
} }
@ -1093,7 +1093,7 @@ void main_window::CreateConnects()
connect(ui->exitAct, &QAction::triggered, this, &QWidget::close); connect(ui->exitAct, &QAction::triggered, this, &QWidget::close);
connect(ui->sysPauseAct, &QAction::triggered, Pause); connect(ui->sysPauseAct, &QAction::triggered, Pause);
connect(ui->sysStopAct, &QAction::triggered, [=]() { Emu.Stop(); }); connect(ui->sysStopAct, &QAction::triggered, [=]() { Emu.Stop(); });
connect(ui->sysRebootAct, &QAction::triggered, [=]() { Emu.SetForceBoot(true); Emu.Stop(); Emu.Load(); }); connect(ui->sysRebootAct, &QAction::triggered, [=]() { Emu.Restart(); });
connect(ui->sysSendOpenMenuAct, &QAction::triggered, [=] connect(ui->sysSendOpenMenuAct, &QAction::triggered, [=]
{ {
@ -1515,7 +1515,7 @@ void main_window::keyPressEvent(QKeyEvent *keyEvent)
case Qt::Key_E: if (Emu.IsPaused()) Emu.Resume(); else if (Emu.IsReady()) Emu.Run(); return; case Qt::Key_E: if (Emu.IsPaused()) Emu.Resume(); else if (Emu.IsReady()) Emu.Run(); return;
case Qt::Key_P: if (Emu.IsRunning()) Emu.Pause(); return; case Qt::Key_P: if (Emu.IsRunning()) Emu.Pause(); return;
case Qt::Key_S: if (!Emu.IsStopped()) Emu.Stop(); return; case Qt::Key_S: if (!Emu.IsStopped()) Emu.Stop(); return;
case Qt::Key_R: if (!Emu.GetBoot().empty()) { Emu.SetForceBoot(true); Emu.Stop(); Emu.Run(); } return; case Qt::Key_R: if (!Emu.GetBoot().empty()) Emu.Restart(); return;
} }
} }
} }