diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index 1f2c10c1dc..c724476ad7 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -24,6 +24,8 @@ #include "Common/Version.h" #include "Common/WorkQueueThread.h" #include "Core/Config/AchievementSettings.h" +#include "Core/Config/FreeLookSettings.h" +#include "Core/Config/MainSettings.h" #include "Core/Core.h" #include "Core/HW/Memmap.h" #include "Core/HW/VideoInterface.h" @@ -62,7 +64,7 @@ void AchievementManager::Init() [](const char* message, const rc_client_t* client) { INFO_LOG_FMT(ACHIEVEMENTS, "{}", message); }); - rc_client_set_hardcore_enabled(m_client, Config::Get(Config::RA_HARDCORE_ENABLED)); + SetHardcoreMode(); m_queue.Reset("AchievementManagerQueue", [](const std::function& func) { func(); }); m_image_queue.Reset("AchievementManagerImageQueue", [](const std::function& func) { func(); }); @@ -361,6 +363,13 @@ std::recursive_mutex& AchievementManager::GetLock() void AchievementManager::SetHardcoreMode() { rc_client_set_hardcore_enabled(m_client, Config::Get(Config::RA_HARDCORE_ENABLED)); + if (Config::Get(Config::RA_HARDCORE_ENABLED)) + { + if (Config::Get(Config::MAIN_EMULATION_SPEED) < 1.0f) + Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED, 1.0f); + Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, false); + Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, false); + } } bool AchievementManager::IsHardcoreModeActive() const diff --git a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp index 064b0dbb62..93b9f35af3 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp @@ -21,6 +21,7 @@ #include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h" #include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" +#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/NonDefaultQPushButton.h" #include "DolphinQt/QtUtils/SignalBlocking.h" #include "DolphinQt/Settings.h" @@ -36,7 +37,7 @@ AchievementSettingsWidget::AchievementSettingsWidget(QWidget* parent) : QWidget( // If hardcore is enabled when the emulator starts, make sure it turns off what it needs to if (Config::Get(Config::RA_HARDCORE_ENABLED)) - ToggleHardcore(); + UpdateHardcoreMode(); } void AchievementSettingsWidget::UpdateData(int login_failed_code) @@ -258,11 +259,7 @@ void AchievementSettingsWidget::ToggleRAIntegration() instance.Init(); else instance.Shutdown(); - if (Config::Get(Config::RA_HARDCORE_ENABLED)) - { - emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance())); - emit Settings::Instance().HardcoreStateChanged(); - } + UpdateHardcoreMode(); } void AchievementSettingsWidget::Login() @@ -276,24 +273,31 @@ void AchievementSettingsWidget::Login() void AchievementSettingsWidget::Logout() { - AchievementManager::GetInstance().Logout(); - SaveSettings(); + auto confirm = ModalMessageBox::question( + this, tr("Confirm Logout"), tr("Are you sure you want to log out of RetroAchievements?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::ApplicationModal); + if (confirm == QMessageBox::Yes) + { + AchievementManager::GetInstance().Logout(); + SaveSettings(); + } } void AchievementSettingsWidget::ToggleHardcore() { - SaveSettings(); - AchievementManager::GetInstance().SetHardcoreMode(); if (Config::Get(Config::RA_HARDCORE_ENABLED)) { - if (Config::Get(Config::MAIN_EMULATION_SPEED) < 1.0f) - Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED, 1.0f); - Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, false); - Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, false); - Settings::Instance().SetDebugModeEnabled(false); + auto confirm = ModalMessageBox::question( + this, tr("Confirm Hardcore Off"), tr("Are you sure you want to turn hardcore mode off?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::ApplicationModal); + if (confirm != QMessageBox::Yes) + { + SignalBlocking(m_common_hardcore_enabled_input)->setChecked(true); + return; + } } - emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance())); - emit Settings::Instance().HardcoreStateChanged(); + SaveSettings(); + UpdateHardcoreMode(); } void AchievementSettingsWidget::ToggleUnofficial() @@ -323,4 +327,15 @@ void AchievementSettingsWidget::ToggleProgress() SaveSettings(); } +void AchievementSettingsWidget::UpdateHardcoreMode() +{ + AchievementManager::GetInstance().SetHardcoreMode(); + if (Config::Get(Config::RA_HARDCORE_ENABLED)) + { + Settings::Instance().SetDebugModeEnabled(false); + } + emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance())); + emit Settings::Instance().HardcoreStateChanged(); +} + #endif // USE_RETRO_ACHIEVEMENTS diff --git a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h index 20a6d03c6d..92f360cac9 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h +++ b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h @@ -39,6 +39,8 @@ private: void ToggleDiscordPresence(); void ToggleProgress(); + void UpdateHardcoreMode(); + QGroupBox* m_common_box; QVBoxLayout* m_common_layout; ToolTipCheckBox* m_common_integration_enabled_input; diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 8ccf384506..e21f2c5252 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -273,6 +273,8 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters, #ifdef USE_RETRO_ACHIEVEMENTS AchievementManager::GetInstance().Init(); + if (AchievementManager::GetInstance().IsHardcoreModeActive()) + Settings::Instance().SetDebugModeEnabled(false); #endif // USE_RETRO_ACHIEVEMENTS #if defined(__unix__) || defined(__unix) || defined(__APPLE__)