diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index ab1afe4321..bf714f0e65 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -111,6 +111,7 @@ void AchievementManager::LoadGame(const std::string& file_path, const DiscIO::Vo } rc_client_set_unofficial_enabled(m_client, Config::Get(Config::RA_UNOFFICIAL_ENABLED)); rc_client_set_encore_mode_enabled(m_client, Config::Get(Config::RA_ENCORE_ENABLED)); + rc_client_set_spectator_mode_enabled(m_client, Config::Get(Config::RA_SPECTATOR_ENABLED)); if (volume) { std::lock_guard lg{m_lock}; @@ -256,6 +257,11 @@ bool AchievementManager::IsHardcoreModeActive() const return rc_client_is_processing_required(m_client); } +void AchievementManager::SetSpectatorMode() +{ + rc_client_set_spectator_mode_enabled(m_client, Config::Get(Config::RA_SPECTATOR_ENABLED)); +} + std::string_view AchievementManager::GetPlayerDisplayName() const { if (!HasAPIToken()) diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index 2a3658e662..757daeb86d 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -105,6 +105,7 @@ public: std::recursive_mutex& GetLock(); void SetHardcoreMode(); bool IsHardcoreModeActive() const; + void SetSpectatorMode(); std::string_view GetPlayerDisplayName() const; u32 GetPlayerScore() const; const BadgeStatus& GetPlayerBadge() const; diff --git a/Source/Core/Core/Config/AchievementSettings.cpp b/Source/Core/Core/Config/AchievementSettings.cpp index 5bd08b5677..38a5bb6166 100644 --- a/Source/Core/Core/Config/AchievementSettings.cpp +++ b/Source/Core/Core/Config/AchievementSettings.cpp @@ -20,6 +20,8 @@ const Info RA_HARDCORE_ENABLED{{System::Achievements, "Achievements", "Har const Info RA_UNOFFICIAL_ENABLED{{System::Achievements, "Achievements", "UnofficialEnabled"}, false}; const Info RA_ENCORE_ENABLED{{System::Achievements, "Achievements", "EncoreEnabled"}, false}; +const Info RA_SPECTATOR_ENABLED{{System::Achievements, "Achievements", "SpectatorEnabled"}, + false}; const Info RA_PROGRESS_ENABLED{{System::Achievements, "Achievements", "ProgressEnabled"}, false}; const Info RA_BADGES_ENABLED{{System::Achievements, "Achievements", "BadgesEnabled"}, false}; diff --git a/Source/Core/Core/Config/AchievementSettings.h b/Source/Core/Core/Config/AchievementSettings.h index 96a85cae85..e448054214 100644 --- a/Source/Core/Core/Config/AchievementSettings.h +++ b/Source/Core/Core/Config/AchievementSettings.h @@ -17,6 +17,7 @@ extern const Info RA_API_TOKEN; extern const Info RA_HARDCORE_ENABLED; extern const Info RA_UNOFFICIAL_ENABLED; extern const Info RA_ENCORE_ENABLED; +extern const Info RA_SPECTATOR_ENABLED; extern const Info RA_PROGRESS_ENABLED; extern const Info RA_BADGES_ENABLED; } // namespace Config diff --git a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp index 8d68f9cab6..cc6a4c1c50 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp @@ -87,6 +87,13 @@ void AchievementSettingsWidget::CreateLayout() "the player has already unlocked on the site so that the player will be notified if they " "meet the unlock conditions again, useful for custom speedrun criteria or simply for fun." "

Setting takes effect on next game load.")); + m_common_spectator_enabled_input = new ToolTipCheckBox(tr("Enable Spectator Mode")); + m_common_spectator_enabled_input->SetDescription( + tr("Enable unlocking achievements in Spectator Mode.

While in Spectator Mode, " + "achievements and leaderboards will be processed and displayed on screen, but will not be " + "submitted to the server.

If this is on at game launch, it will not be turned off " + "until game close, because a RetroAchievements session will not be created.

If " + "this is off at game launch, it can be toggled freely while the game is running.")); m_common_progress_enabled_input = new ToolTipCheckBox(tr("Enable Progress Notifications")); m_common_progress_enabled_input->SetDescription( tr("Enable progress notifications on achievements.

Displays a brief popup message " @@ -110,6 +117,7 @@ void AchievementSettingsWidget::CreateLayout() m_common_layout->addWidget(m_common_hardcore_enabled_input); m_common_layout->addWidget(m_common_unofficial_enabled_input); m_common_layout->addWidget(m_common_encore_enabled_input); + m_common_layout->addWidget(m_common_spectator_enabled_input); m_common_layout->addWidget(new QLabel(tr("Display Settings"))); m_common_layout->addWidget(m_common_progress_enabled_input); m_common_layout->addWidget(m_common_badges_enabled_input); @@ -130,6 +138,8 @@ void AchievementSettingsWidget::ConnectWidgets() &AchievementSettingsWidget::ToggleUnofficial); connect(m_common_encore_enabled_input, &QCheckBox::toggled, this, &AchievementSettingsWidget::ToggleEncore); + connect(m_common_spectator_enabled_input, &QCheckBox::toggled, this, + &AchievementSettingsWidget::ToggleSpectator); connect(m_common_progress_enabled_input, &QCheckBox::toggled, this, &AchievementSettingsWidget::ToggleProgress); connect(m_common_badges_enabled_input, &QCheckBox::toggled, this, @@ -180,6 +190,10 @@ void AchievementSettingsWidget::LoadSettings() SignalBlocking(m_common_encore_enabled_input)->setChecked(Config::Get(Config::RA_ENCORE_ENABLED)); SignalBlocking(m_common_encore_enabled_input)->setEnabled(enabled); + SignalBlocking(m_common_spectator_enabled_input) + ->setChecked(Config::Get(Config::RA_SPECTATOR_ENABLED)); + SignalBlocking(m_common_spectator_enabled_input)->setEnabled(enabled); + SignalBlocking(m_common_progress_enabled_input) ->setChecked(Config::Get(Config::RA_PROGRESS_ENABLED)); SignalBlocking(m_common_progress_enabled_input)->setEnabled(enabled); @@ -198,6 +212,8 @@ void AchievementSettingsWidget::SaveSettings() Config::SetBaseOrCurrent(Config::RA_UNOFFICIAL_ENABLED, m_common_unofficial_enabled_input->isChecked()); Config::SetBaseOrCurrent(Config::RA_ENCORE_ENABLED, m_common_encore_enabled_input->isChecked()); + Config::SetBaseOrCurrent(Config::RA_SPECTATOR_ENABLED, + m_common_spectator_enabled_input->isChecked()); Config::SetBaseOrCurrent(Config::RA_PROGRESS_ENABLED, m_common_progress_enabled_input->isChecked()); Config::SetBaseOrCurrent(Config::RA_BADGES_ENABLED, m_common_badges_enabled_input->isChecked()); @@ -254,6 +270,12 @@ void AchievementSettingsWidget::ToggleEncore() SaveSettings(); } +void AchievementSettingsWidget::ToggleSpectator() +{ + SaveSettings(); + AchievementManager::GetInstance().SetSpectatorMode(); +} + void AchievementSettingsWidget::ToggleProgress() { SaveSettings(); diff --git a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h index 1ae2bf0fde..68ba658b8f 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h +++ b/Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.h @@ -35,6 +35,7 @@ private: void ToggleHardcore(); void ToggleUnofficial(); void ToggleEncore(); + void ToggleSpectator(); void ToggleProgress(); void ToggleBadges(); @@ -51,6 +52,7 @@ private: ToolTipCheckBox* m_common_hardcore_enabled_input; ToolTipCheckBox* m_common_unofficial_enabled_input; ToolTipCheckBox* m_common_encore_enabled_input; + ToolTipCheckBox* m_common_spectator_enabled_input; ToolTipCheckBox* m_common_progress_enabled_input; ToolTipCheckBox* m_common_badges_enabled_input; };