VMManager: Fix title updates when switching GS dumps

This commit is contained in:
Stenzek 2023-06-19 18:07:00 +10:00 committed by Connor McLaughlin
parent 89b97456b7
commit 0e4bf501f1
3 changed files with 21 additions and 13 deletions

View File

@ -2452,20 +2452,8 @@ void MainWindow::doStartFile(std::optional<CDVD_SourceType> source, const QStrin
void MainWindow::doDiscChange(CDVD_SourceType source, const QString& path) void MainWindow::doDiscChange(CDVD_SourceType source, const QString& path)
{ {
const bool is_gs_dump = VMManager::IsGSDumpFileName(path.toStdString());
if (is_gs_dump != GSDumpReplayer::IsReplayingDump())
{
QMessageBox::critical(this, tr("Error"), tr("Cannot switch from game to GS dump or vice versa."));
return;
}
else if (is_gs_dump)
{
Host::RunOnCPUThread([path = path.toStdString()]() { GSDumpReplayer::ChangeDump(path.c_str()); });
return;
}
bool reset_system = false; bool reset_system = false;
if (!m_was_disc_change_request) if (!m_was_disc_change_request && !GSDumpReplayer::IsReplayingDump())
{ {
QMessageBox message(QMessageBox::Question, tr("Confirm Disc Change"), QMessageBox message(QMessageBox::Question, tr("Confirm Disc Change"),
tr("Do you want to swap discs or boot the new image (via system reset)?"), QMessageBox::NoButton, this); tr("Do you want to swap discs or boot the new image (via system reset)?"), QMessageBox::NoButton, this);

View File

@ -126,6 +126,12 @@ bool GSDumpReplayer::ChangeDump(const char* filename)
{ {
Console.WriteLn("(GSDumpReplayer) Switching to '%s'...", filename); Console.WriteLn("(GSDumpReplayer) Switching to '%s'...", filename);
if (!VMManager::IsGSDumpFileName(filename))
{
Host::ReportFormattedErrorAsync("GSDumpReplayer", "'%s' is not a GS dump.", filename);
return false;
}
std::unique_ptr<GSDumpFile> new_dump(GSDumpFile::OpenGSDump(filename)); std::unique_ptr<GSDumpFile> new_dump(GSDumpFile::OpenGSDump(filename));
if (!new_dump || !new_dump->ReadFile()) if (!new_dump || !new_dump->ReadFile())
{ {

View File

@ -1663,6 +1663,20 @@ void VMManager::FrameAdvance(u32 num_frames /*= 1*/)
bool VMManager::ChangeDisc(CDVD_SourceType source, std::string path) bool VMManager::ChangeDisc(CDVD_SourceType source, std::string path)
{ {
if (GSDumpReplayer::IsReplayingDump())
{
if (!GSDumpReplayer::ChangeDump(path.c_str()))
return false;
UpdateDiscDetails(false);
return true;
}
else if (IsGSDumpFileName(path))
{
Host::ReportErrorAsync("Error", "Cannot change from game to GS dump without shutting down first.");
return false;
}
const CDVD_SourceType old_type = CDVDsys_GetSourceType(); const CDVD_SourceType old_type = CDVDsys_GetSourceType();
const std::string old_path(CDVDsys_GetFile(old_type)); const std::string old_path(CDVDsys_GetFile(old_type));