Skip to content

Commit

Permalink
Add Spectator Mode to achievement settings
Browse files Browse the repository at this point in the history
Spectator Mode is a new mode added by rc_client that allows for achievement and leaderboard functionality, but does not submit this data to the site, partially allowing for offline achievements. It effectively replaces the former settings for disabling achievements, leaderboards, and RP, which are now always active internally as long as the client is active.
  • Loading branch information
LillyJadeKatrin committed Apr 17, 2024
1 parent 84c8606 commit 7041c96
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/Core/Core/AchievementManager.cpp
Expand Up @@ -107,6 +107,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};
Expand Down Expand Up @@ -249,6 +250,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 AchievementManager::GetPlayerDisplayName() const
{
if (!HasAPIToken())
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/AchievementManager.h
Expand Up @@ -105,6 +105,7 @@ class AchievementManager
std::recursive_mutex& GetLock();
void SetHardcoreMode();
bool IsHardcoreModeActive() const;
void SetSpectatorMode();
std::string GetPlayerDisplayName() const;
u32 GetPlayerScore() const;
const BadgeStatus& GetPlayerBadge() const;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/Config/AchievementSettings.cpp
Expand Up @@ -20,6 +20,8 @@ const Info<bool> RA_HARDCORE_ENABLED{{System::Achievements, "Achievements", "Har
const Info<bool> RA_UNOFFICIAL_ENABLED{{System::Achievements, "Achievements", "UnofficialEnabled"},
false};
const Info<bool> RA_ENCORE_ENABLED{{System::Achievements, "Achievements", "EncoreEnabled"}, false};
const Info<bool> RA_SPECTATOR_ENABLED{{System::Achievements, "Achievements", "SpectatorEnabled"},
false};
const Info<bool> RA_PROGRESS_ENABLED{{System::Achievements, "Achievements", "ProgressEnabled"},
false};
const Info<bool> RA_BADGES_ENABLED{{System::Achievements, "Achievements", "BadgesEnabled"}, false};
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Config/AchievementSettings.h
Expand Up @@ -17,6 +17,7 @@ extern const Info<std::string> RA_API_TOKEN;
extern const Info<bool> RA_HARDCORE_ENABLED;
extern const Info<bool> RA_UNOFFICIAL_ENABLED;
extern const Info<bool> RA_ENCORE_ENABLED;
extern const Info<bool> RA_SPECTATOR_ENABLED;
extern const Info<bool> RA_PROGRESS_ENABLED;
extern const Info<bool> RA_BADGES_ENABLED;
} // namespace Config
Expand Down
22 changes: 22 additions & 0 deletions Source/Core/DolphinQt/Achievements/AchievementSettingsWidget.cpp
Expand Up @@ -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."
"<br><br>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.<br><br>While in Spectator Mode, "
"achievements and leaderboards will be processed and displayed on screen, but will not be "
"submitted to the server.<br><br>If this is on at game launch, it will not be turned off "
"until game close, because a RetroAchievements session will not be created.<br><br>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.<br><br>Displays a brief popup message "
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -179,6 +189,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);
Expand All @@ -197,6 +211,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());
Expand Down Expand Up @@ -253,6 +269,12 @@ void AchievementSettingsWidget::ToggleEncore()
SaveSettings();
}

void AchievementSettingsWidget::ToggleSpectator()
{
SaveSettings();
AchievementManager::GetInstance().SetSpectatorMode();
}

void AchievementSettingsWidget::ToggleProgress()
{
SaveSettings();
Expand Down
Expand Up @@ -35,6 +35,7 @@ class AchievementSettingsWidget final : public QWidget
void ToggleHardcore();
void ToggleUnofficial();
void ToggleEncore();
void ToggleSpectator();
void ToggleProgress();
void ToggleBadges();

Expand All @@ -51,6 +52,7 @@ class AchievementSettingsWidget final : public QWidget
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;
};
Expand Down

0 comments on commit 7041c96

Please sign in to comment.