Qt: Prompt user to enable HC mode on achievement login

This commit is contained in:
Stenzek 2023-12-04 22:34:48 +10:00 committed by Connor McLaughlin
parent 971929777d
commit e2dcabcbea
2 changed files with 55 additions and 0 deletions

View File

@ -91,6 +91,48 @@ void AchievementLoginDialog::processLoginResult(bool result, const QString& mess
return;
}
if (m_reason == Achievements::LoginRequestReason::UserInitiated)
{
if (!Host::GetBaseBoolSettingValue("Achievements", "Enabled", false) &&
QMessageBox::question(this, tr("Enable Achievements"),
tr("Achievement tracking is not currently enabled. Your login will have no effect until "
"after tracking is enabled.\n\nDo you want to enable tracking now?"),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
Host::SetBaseBoolSettingValue("Achievements", "Enabled", true);
Host::CommitBaseSettingChanges();
g_emu_thread->applySettings();
}
if (!Host::GetBaseBoolSettingValue("Achievements", "ChallengeMode", false) &&
QMessageBox::question(
this, tr("Enable Hardcore Mode"),
tr("Hardcore mode is not currently enabled. Enabling hardcore mode allows you to set times, scores, and "
"participate in game-specific leaderboards.\n\nHowever, hardcore mode also prevents the usage of save "
"states, cheats and slowdown functionality.\n\nDo you want to enable hardcore mode?"),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
Host::SetBaseBoolSettingValue("Achievements", "ChallengeMode", true);
Host::CommitBaseSettingChanges();
g_emu_thread->applySettings();
bool has_active_game;
{
auto lock = Achievements::GetLock();
has_active_game = Achievements::HasActiveGame();
}
if (has_active_game &&
QMessageBox::question(this, tr("Reset System"),
tr("Hardcore mode will not be enabled until the system is reset. Do you want to reset the system now?")) ==
QMessageBox::Yes)
{
g_emu_thread->resetVM();
}
}
}
done(0);
}

View File

@ -194,6 +194,19 @@ void AchievementSettingsWidget::onLoginLogoutPressed()
return;
updateLoginState();
// Login can enable achievements/hardcore.
if (!m_ui.enable->isChecked() && Host::GetBaseBoolSettingValue("Achievements", "Enabled", false))
{
QSignalBlocker sb(m_ui.enable);
m_ui.enable->setChecked(true);
updateEnableState();
}
if (!m_ui.hardcoreMode->isChecked() && Host::GetBaseBoolSettingValue("Achievements", "ChallengeMode", false))
{
QSignalBlocker sb(m_ui.hardcoreMode);
m_ui.hardcoreMode->setChecked(true);
}
}
void AchievementSettingsWidget::onViewProfilePressed()