Skip to content

Commit

Permalink
Debugger: Prompt for HC restart on Boot and Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePLMonster committed Apr 6, 2024
1 parent 6534a83 commit 4fd1169
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
4 changes: 3 additions & 1 deletion pcsx2-qt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,9 @@ void MainWindow::onAchievementsHardcoreModeChanged(bool enabled)
m_ui.actionDebugger->setDisabled(enabled);
if (enabled)
{
if (m_debugger_window)
// If PauseOnEntry is enabled, we prompt the user to disable Hardcore Mode
// or cancel the action later, so we should keep the debugger around
if (m_debugger_window && !DebugInterface::getPauseOnEntry())
{
m_debugger_window->close();
m_debugger_window->deleteLater();
Expand Down
53 changes: 36 additions & 17 deletions pcsx2/VMManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "CDVD/IsoReader.h"
#include "Counters.h"
#include "DEV9/DEV9.h"
#include "DebugTools/DebugInterface.h"
#include "DebugTools/MIPSAnalyst.h"
#include "DebugTools/SymbolMap.h"
#include "Elfheader.h"
Expand Down Expand Up @@ -1320,34 +1321,52 @@ bool VMManager::Initialize(VMBootParameters boot_params)
Hle_ClearHostRoot();
}

// Check for resuming with hardcore mode.
// Check for resuming and 'Boot and Debug' with hardcore mode.
// Why do we need the boot param? Because we need some way of telling BootSystem() that
// the user allowed HC mode to be disabled, because otherwise we'll ResetHardcoreMode()
// and send ourselves into an infinite loop.
if (boot_params.disable_achievements_hardcore_mode)
Achievements::DisableHardcoreMode();
else
Achievements::ResetHardcoreMode();
if (!state_to_load.empty() && Achievements::IsHardcoreModeActive())
if (Achievements::IsHardcoreModeActive())
{
if (FullscreenUI::IsInitialized())
{
boot_params.elf_override = std::move(s_elf_override);
boot_params.save_state = std::move(state_to_load);
boot_params.disable_achievements_hardcore_mode = true;
s_elf_override = {};

Achievements::ConfirmHardcoreModeDisableAsync(TRANSLATE("VMManager", "Resuming state"),
[boot_params = std::move(boot_params)](bool approved) mutable {
if (approved && Initialize(std::move(boot_params)))
SetState(VMState::Running);
});
auto confirmHardcoreModeDisable = [&boot_params, &state_to_load](const char* trigger) mutable {
if (FullscreenUI::IsInitialized())
{
boot_params.elf_override = std::move(s_elf_override);
boot_params.save_state = std::move(state_to_load);
boot_params.disable_achievements_hardcore_mode = true;
s_elf_override = {};

Achievements::ConfirmHardcoreModeDisableAsync(trigger,
[boot_params = std::move(boot_params)](bool approved) mutable {
if (approved && Initialize(std::move(boot_params)))
SetState(VMState::Running);
});

return false;
}
else if (!Achievements::ConfirmHardcoreModeDisable(trigger))
{
return false;
}
return true;
};

return false;
if (!state_to_load.empty())
{
if (!confirmHardcoreModeDisable(TRANSLATE("VMManager", "Resuming state")))
{
return false;
}
}
else if (!Achievements::ConfirmHardcoreModeDisable(TRANSLATE("VMManager", "Resuming state")))
if (DebugInterface::getPauseOnEntry())
{
return false;
if (!confirmHardcoreModeDisable(TRANSLATE("VMManager", "Boot and Debug")))
{
return false;
}
}
}

Expand Down

0 comments on commit 4fd1169

Please sign in to comment.