Merge pull request #12954 from LillyJadeKatrin/retroachievements-confirm

Achievements Confirmation Dialogs
This commit is contained in:
JMC47 2024-10-28 12:54:37 -04:00 committed by GitHub
commit 1012803f2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 18 deletions

View File

@ -24,6 +24,8 @@
#include "Common/Version.h" #include "Common/Version.h"
#include "Common/WorkQueueThread.h" #include "Common/WorkQueueThread.h"
#include "Core/Config/AchievementSettings.h" #include "Core/Config/AchievementSettings.h"
#include "Core/Config/FreeLookSettings.h"
#include "Core/Config/MainSettings.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/HW/Memmap.h" #include "Core/HW/Memmap.h"
#include "Core/HW/VideoInterface.h" #include "Core/HW/VideoInterface.h"
@ -62,7 +64,7 @@ void AchievementManager::Init()
[](const char* message, const rc_client_t* client) { [](const char* message, const rc_client_t* client) {
INFO_LOG_FMT(ACHIEVEMENTS, "{}", message); 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<void()>& func) { func(); }); m_queue.Reset("AchievementManagerQueue", [](const std::function<void()>& func) { func(); });
m_image_queue.Reset("AchievementManagerImageQueue", m_image_queue.Reset("AchievementManagerImageQueue",
[](const std::function<void()>& func) { func(); }); [](const std::function<void()>& func) { func(); });
@ -361,6 +363,13 @@ std::recursive_mutex& AchievementManager::GetLock()
void AchievementManager::SetHardcoreMode() void AchievementManager::SetHardcoreMode()
{ {
rc_client_set_hardcore_enabled(m_client, Config::Get(Config::RA_HARDCORE_ENABLED)); 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 bool AchievementManager::IsHardcoreModeActive() const

View File

@ -21,6 +21,7 @@
#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h" #include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" #include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h" #include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
#include "DolphinQt/QtUtils/SignalBlocking.h" #include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.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 hardcore is enabled when the emulator starts, make sure it turns off what it needs to
if (Config::Get(Config::RA_HARDCORE_ENABLED)) if (Config::Get(Config::RA_HARDCORE_ENABLED))
ToggleHardcore(); UpdateHardcoreMode();
} }
void AchievementSettingsWidget::UpdateData(int login_failed_code) void AchievementSettingsWidget::UpdateData(int login_failed_code)
@ -258,11 +259,7 @@ void AchievementSettingsWidget::ToggleRAIntegration()
instance.Init(); instance.Init();
else else
instance.Shutdown(); instance.Shutdown();
if (Config::Get(Config::RA_HARDCORE_ENABLED)) UpdateHardcoreMode();
{
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance()));
emit Settings::Instance().HardcoreStateChanged();
}
} }
void AchievementSettingsWidget::Login() void AchievementSettingsWidget::Login()
@ -276,24 +273,31 @@ void AchievementSettingsWidget::Login()
void AchievementSettingsWidget::Logout() void AchievementSettingsWidget::Logout()
{ {
AchievementManager::GetInstance().Logout(); auto confirm = ModalMessageBox::question(
SaveSettings(); 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() void AchievementSettingsWidget::ToggleHardcore()
{ {
SaveSettings();
AchievementManager::GetInstance().SetHardcoreMode();
if (Config::Get(Config::RA_HARDCORE_ENABLED)) if (Config::Get(Config::RA_HARDCORE_ENABLED))
{ {
if (Config::Get(Config::MAIN_EMULATION_SPEED) < 1.0f) auto confirm = ModalMessageBox::question(
Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED, 1.0f); this, tr("Confirm Hardcore Off"), tr("Are you sure you want to turn hardcore mode off?"),
Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, false); QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::ApplicationModal);
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, false); if (confirm != QMessageBox::Yes)
Settings::Instance().SetDebugModeEnabled(false); {
SignalBlocking(m_common_hardcore_enabled_input)->setChecked(true);
return;
}
} }
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance())); SaveSettings();
emit Settings::Instance().HardcoreStateChanged(); UpdateHardcoreMode();
} }
void AchievementSettingsWidget::ToggleUnofficial() void AchievementSettingsWidget::ToggleUnofficial()
@ -323,4 +327,15 @@ void AchievementSettingsWidget::ToggleProgress()
SaveSettings(); 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 #endif // USE_RETRO_ACHIEVEMENTS

View File

@ -39,6 +39,8 @@ private:
void ToggleDiscordPresence(); void ToggleDiscordPresence();
void ToggleProgress(); void ToggleProgress();
void UpdateHardcoreMode();
QGroupBox* m_common_box; QGroupBox* m_common_box;
QVBoxLayout* m_common_layout; QVBoxLayout* m_common_layout;
ToolTipCheckBox* m_common_integration_enabled_input; ToolTipCheckBox* m_common_integration_enabled_input;

View File

@ -273,6 +273,8 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
#ifdef USE_RETRO_ACHIEVEMENTS #ifdef USE_RETRO_ACHIEVEMENTS
AchievementManager::GetInstance().Init(); AchievementManager::GetInstance().Init();
if (AchievementManager::GetInstance().IsHardcoreModeActive())
Settings::Instance().SetDebugModeEnabled(false);
#endif // USE_RETRO_ACHIEVEMENTS #endif // USE_RETRO_ACHIEVEMENTS
#if defined(__unix__) || defined(__unix) || defined(__APPLE__) #if defined(__unix__) || defined(__unix) || defined(__APPLE__)