mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-29 19:15:38 +00:00
Achievements: Add leaderboard toggle (+ some minor fixes)
This commit is contained in:
parent
3760849ac4
commit
d26fef3e4e
|
@ -344,6 +344,7 @@ void Settings::Load(SettingsInterface& si)
|
||||||
achievements_use_first_disc_from_playlist = si.GetBoolValue("Cheevos", "UseFirstDiscFromPlaylist", true);
|
achievements_use_first_disc_from_playlist = si.GetBoolValue("Cheevos", "UseFirstDiscFromPlaylist", true);
|
||||||
achievements_rich_presence = si.GetBoolValue("Cheevos", "RichPresence", true);
|
achievements_rich_presence = si.GetBoolValue("Cheevos", "RichPresence", true);
|
||||||
achievements_challenge_mode = si.GetBoolValue("Cheevos", "ChallengeMode", false);
|
achievements_challenge_mode = si.GetBoolValue("Cheevos", "ChallengeMode", false);
|
||||||
|
achievements_leaderboards = si.GetBoolValue("Cheevos", "Leaderboards", true);
|
||||||
achievements_sound_effects = si.GetBoolValue("Cheevos", "SoundEffects", true);
|
achievements_sound_effects = si.GetBoolValue("Cheevos", "SoundEffects", true);
|
||||||
|
|
||||||
log_level = ParseLogLevelName(si.GetStringValue("Logging", "LogLevel", GetLogLevelName(DEFAULT_LOG_LEVEL)).c_str())
|
log_level = ParseLogLevelName(si.GetStringValue("Logging", "LogLevel", GetLogLevelName(DEFAULT_LOG_LEVEL)).c_str())
|
||||||
|
@ -529,6 +530,7 @@ void Settings::Save(SettingsInterface& si) const
|
||||||
si.SetBoolValue("Cheevos", "UseFirstDiscFromPlaylist", achievements_use_first_disc_from_playlist);
|
si.SetBoolValue("Cheevos", "UseFirstDiscFromPlaylist", achievements_use_first_disc_from_playlist);
|
||||||
si.SetBoolValue("Cheevos", "RichPresence", achievements_rich_presence);
|
si.SetBoolValue("Cheevos", "RichPresence", achievements_rich_presence);
|
||||||
si.SetBoolValue("Cheevos", "ChallengeMode", achievements_challenge_mode);
|
si.SetBoolValue("Cheevos", "ChallengeMode", achievements_challenge_mode);
|
||||||
|
si.SetBoolValue("Cheevos", "Leaderboards", achievements_leaderboards);
|
||||||
si.SetBoolValue("Cheevos", "SoundEffects", achievements_sound_effects);
|
si.SetBoolValue("Cheevos", "SoundEffects", achievements_sound_effects);
|
||||||
|
|
||||||
si.SetStringValue("Logging", "LogLevel", GetLogLevelName(log_level));
|
si.SetStringValue("Logging", "LogLevel", GetLogLevelName(log_level));
|
||||||
|
|
|
@ -173,6 +173,7 @@ struct Settings
|
||||||
bool achievements_use_first_disc_from_playlist : 1;
|
bool achievements_use_first_disc_from_playlist : 1;
|
||||||
bool achievements_rich_presence : 1;
|
bool achievements_rich_presence : 1;
|
||||||
bool achievements_challenge_mode : 1;
|
bool achievements_challenge_mode : 1;
|
||||||
|
bool achievements_leaderboards : 1;
|
||||||
bool achievements_sound_effects : 1;
|
bool achievements_sound_effects : 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ AchievementSettingsWidget::AchievementSettingsWidget(SettingsDialog* dialog, QWi
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.unofficialTestMode, "Cheevos", "UnofficialTestMode", false);
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.unofficialTestMode, "Cheevos", "UnofficialTestMode", false);
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.useFirstDiscFromPlaylist, "Cheevos",
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.useFirstDiscFromPlaylist, "Cheevos",
|
||||||
"UseFirstDiscFromPlaylist", true);
|
"UseFirstDiscFromPlaylist", true);
|
||||||
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.leaderboards, "Cheevos", "Leaderboards", true);
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.soundEffects, "Cheevos", "SoundEffects", true);
|
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.soundEffects, "Cheevos", "SoundEffects", true);
|
||||||
|
|
||||||
dialog->registerWidgetHelp(m_ui.enable, tr("Enable Achievements"), tr("Unchecked"),
|
dialog->registerWidgetHelp(m_ui.enable, tr("Enable Achievements"), tr("Unchecked"),
|
||||||
|
@ -46,10 +47,16 @@ AchievementSettingsWidget::AchievementSettingsWidget(SettingsDialog* dialog, QWi
|
||||||
tr("\"Challenge\" mode for achievements. Disables save state, cheats, and slowdown "
|
tr("\"Challenge\" mode for achievements. Disables save state, cheats, and slowdown "
|
||||||
"functions, but you receive double the achievement points."));
|
"functions, but you receive double the achievement points."));
|
||||||
dialog->registerWidgetHelp(
|
dialog->registerWidgetHelp(
|
||||||
m_ui.challengeMode, tr("Enable Sound Effects"), tr("Checked"),
|
m_ui.soundEffects, tr("Enable Sound Effects"), tr("Checked"),
|
||||||
tr("Plays sound effects for events such as achievement unlocks and leaderboard submissions."));
|
tr("Plays sound effects for events such as achievement unlocks and leaderboard submissions."));
|
||||||
|
dialog->registerWidgetHelp(
|
||||||
|
m_ui.leaderboards, tr("Enable Leaderboards"), tr("Checked"),
|
||||||
|
tr("Enables tracking and submission of leaderboards in supported games. If leaderboards "
|
||||||
|
"are disabled, you will still be able to view the leaderboard and scores, but no scores will be uploaded."));
|
||||||
|
|
||||||
connect(m_ui.enable, &QCheckBox::stateChanged, this, &AchievementSettingsWidget::updateEnableState);
|
connect(m_ui.enable, &QCheckBox::stateChanged, this, &AchievementSettingsWidget::updateEnableState);
|
||||||
|
connect(m_ui.challengeMode, &QCheckBox::stateChanged, this, &AchievementSettingsWidget::updateEnableState);
|
||||||
|
connect(m_ui.challengeMode, &QCheckBox::stateChanged, this, &AchievementSettingsWidget::onChallengeModeStateChanged);
|
||||||
|
|
||||||
if (!m_dialog->isPerGameSettings())
|
if (!m_dialog->isPerGameSettings())
|
||||||
{
|
{
|
||||||
|
@ -80,10 +87,40 @@ AchievementSettingsWidget::~AchievementSettingsWidget() = default;
|
||||||
void AchievementSettingsWidget::updateEnableState()
|
void AchievementSettingsWidget::updateEnableState()
|
||||||
{
|
{
|
||||||
const bool enabled = m_dialog->getEffectiveBoolValue("Cheevos", "Enabled", false);
|
const bool enabled = m_dialog->getEffectiveBoolValue("Cheevos", "Enabled", false);
|
||||||
|
const bool challenge = m_dialog->getEffectiveBoolValue("Cheevos", "ChallengeMode", false);
|
||||||
m_ui.testMode->setEnabled(enabled);
|
m_ui.testMode->setEnabled(enabled);
|
||||||
m_ui.useFirstDiscFromPlaylist->setEnabled(enabled);
|
m_ui.useFirstDiscFromPlaylist->setEnabled(enabled);
|
||||||
m_ui.richPresence->setEnabled(enabled);
|
m_ui.richPresence->setEnabled(enabled);
|
||||||
m_ui.challengeMode->setEnabled(enabled);
|
m_ui.challengeMode->setEnabled(enabled);
|
||||||
|
m_ui.leaderboards->setEnabled(enabled && challenge);
|
||||||
|
m_ui.unofficialTestMode->setEnabled(enabled);
|
||||||
|
m_ui.soundEffects->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AchievementSettingsWidget::onChallengeModeStateChanged()
|
||||||
|
{
|
||||||
|
if (!QtHost::IsSystemValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const bool enabled = m_dialog->getEffectiveBoolValue("Cheevos", "Enabled", false);
|
||||||
|
const bool challenge = m_dialog->getEffectiveBoolValue("Cheevos", "ChallengeMode", false);
|
||||||
|
if (!enabled || !challenge)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// don't bother prompting if the game doesn't have achievements
|
||||||
|
auto lock = Achievements::GetLock();
|
||||||
|
if (!Achievements::HasActiveGame())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (QMessageBox::question(
|
||||||
|
QtUtils::GetRootWidget(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)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_emu_thread->resetSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementSettingsWidget::updateLoginState()
|
void AchievementSettingsWidget::updateLoginState()
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateEnableState();
|
void updateEnableState();
|
||||||
|
void onChallengeModeStateChanged();
|
||||||
void onLoginLogoutPressed();
|
void onLoginLogoutPressed();
|
||||||
void onViewProfilePressed();
|
void onViewProfilePressed();
|
||||||
void onAchievementsRefreshed(quint32 id, const QString& game_info_string, quint32 total, quint32 points);
|
void onAchievementsRefreshed(quint32 id, const QString& game_info_string, quint32 total, quint32 points);
|
||||||
|
|
|
@ -39,27 +39,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QCheckBox" name="challengeMode">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable Hardcore Mode</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QCheckBox" name="useFirstDiscFromPlaylist">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use First Disc From Playlist</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QCheckBox" name="testMode">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable Test Mode</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QCheckBox" name="unofficialTestMode">
|
<widget class="QCheckBox" name="unofficialTestMode">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -74,13 +53,41 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="1">
|
||||||
|
<widget class="QCheckBox" name="testMode">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable Test Mode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="challengeMode">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable Hardcore Mode</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
<widget class="QCheckBox" name="soundEffects">
|
<widget class="QCheckBox" name="soundEffects">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable Sound Effects</string>
|
<string>Enable Sound Effects</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="useFirstDiscFromPlaylist">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use First Disc From Playlist</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="leaderboards">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable Leaderboards</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -404,6 +404,11 @@ bool Achievements::ChallengeModeActive()
|
||||||
return s_challenge_mode;
|
return s_challenge_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Achievements::LeaderboardsActive()
|
||||||
|
{
|
||||||
|
return ChallengeModeActive() && g_settings.achievements_leaderboards;
|
||||||
|
}
|
||||||
|
|
||||||
bool Achievements::IsTestModeActive()
|
bool Achievements::IsTestModeActive()
|
||||||
{
|
{
|
||||||
return g_settings.achievements_test_mode;
|
return g_settings.achievements_test_mode;
|
||||||
|
@ -485,11 +490,11 @@ void Achievements::UpdateSettings(const Settings& old_config)
|
||||||
if (g_settings.achievements_challenge_mode != old_config.achievements_challenge_mode)
|
if (g_settings.achievements_challenge_mode != old_config.achievements_challenge_mode)
|
||||||
{
|
{
|
||||||
// Hardcore mode can only be enabled through reset (ResetChallengeMode()).
|
// Hardcore mode can only be enabled through reset (ResetChallengeMode()).
|
||||||
if (s_challenge_mode && !old_config.achievements_challenge_mode)
|
if (s_challenge_mode && !g_settings.achievements_challenge_mode)
|
||||||
{
|
{
|
||||||
ResetChallengeMode();
|
ResetChallengeMode();
|
||||||
}
|
}
|
||||||
else if (g_settings.achievements_challenge_mode)
|
else if (!s_challenge_mode && g_settings.achievements_challenge_mode)
|
||||||
{
|
{
|
||||||
Host::AddKeyedOSDMessage(
|
Host::AddKeyedOSDMessage(
|
||||||
"challenge_mode_reset",
|
"challenge_mode_reset",
|
||||||
|
@ -1013,14 +1018,8 @@ void Achievements::DisplayAchievementSummary()
|
||||||
if (GetLeaderboardCount() > 0)
|
if (GetLeaderboardCount() > 0)
|
||||||
{
|
{
|
||||||
summary.push_back('\n');
|
summary.push_back('\n');
|
||||||
if (ChallengeModeActive())
|
if (LeaderboardsActive())
|
||||||
{
|
summary.append("Leaderboard submission is enabled.");
|
||||||
summary.append(Host::TranslateString("Achievements", "Leaderboards are enabled."));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
summary.append(Host::TranslateString("Achievements", "Leaderboards are disabled because hardcore mode is off."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Host::RunOnCPUThread([title = std::move(title), summary = std::move(summary), icon = s_game_icon]() {
|
Host::RunOnCPUThread([title = std::move(title), summary = std::move(summary), icon = s_game_icon]() {
|
||||||
|
@ -1822,6 +1821,13 @@ void Achievements::SubmitLeaderboard(u32 leaderboard_id, int value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!LeaderboardsActive())
|
||||||
|
{
|
||||||
|
Log_WarningPrintf("Skipping sending leaderboard %u result to server because leaderboards are disabled.",
|
||||||
|
leaderboard_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_lock lock(s_achievements_mutex);
|
std::unique_lock lock(s_achievements_mutex);
|
||||||
|
|
||||||
s_submitting_lboard_id = leaderboard_id;
|
s_submitting_lboard_id = leaderboard_id;
|
||||||
|
|
|
@ -72,6 +72,7 @@ static ALWAYS_INLINE bool IsUsingRAIntegration()
|
||||||
bool IsActive();
|
bool IsActive();
|
||||||
bool IsLoggedIn();
|
bool IsLoggedIn();
|
||||||
bool ChallengeModeActive();
|
bool ChallengeModeActive();
|
||||||
|
bool LeaderboardsActive();
|
||||||
bool IsTestModeActive();
|
bool IsTestModeActive();
|
||||||
bool IsUnofficialTestModeActive();
|
bool IsUnofficialTestModeActive();
|
||||||
bool IsRichPresenceEnabled();
|
bool IsRichPresenceEnabled();
|
||||||
|
|
|
@ -3572,6 +3572,9 @@ void FullscreenUI::DrawAchievementsSettingsPage()
|
||||||
DrawToggleSetting(bsi, ICON_FA_LIST_OL " Leaderboards",
|
DrawToggleSetting(bsi, ICON_FA_LIST_OL " Leaderboards",
|
||||||
"Enables tracking and submission of leaderboards in supported games.", "Cheevos", "Leaderboards",
|
"Enables tracking and submission of leaderboards in supported games.", "Cheevos", "Leaderboards",
|
||||||
true, enabled && challenge);
|
true, enabled && challenge);
|
||||||
|
DrawToggleSetting(bsi, ICON_FA_HEADPHONES " Sound Effects",
|
||||||
|
"Plays sound effects for events such as achievement unlocks and leaderboard submissions.",
|
||||||
|
"Cheevos", "SoundEffects", true, enabled);
|
||||||
DrawToggleSetting(bsi, ICON_FA_MEDAL " Test Unofficial Achievements",
|
DrawToggleSetting(bsi, ICON_FA_MEDAL " Test Unofficial Achievements",
|
||||||
"When enabled, DuckStation will list achievements from unofficial sets. These achievements are not "
|
"When enabled, DuckStation will list achievements from unofficial sets. These achievements are not "
|
||||||
"tracked by RetroAchievements.",
|
"tracked by RetroAchievements.",
|
||||||
|
|
Loading…
Reference in a new issue