Updated Unofficial and Encore settings to use rc_client

These settings now only are applied at game start and their tooltips have been updated to reflect this.
This commit is contained in:
LillyJadeKatrin 2024-04-03 16:31:18 -04:00
parent 0883aa114e
commit fd0de1b01f
5 changed files with 42 additions and 40 deletions

View file

@ -46,7 +46,6 @@ void AchievementManager::Init()
INFO_LOG_FMT(ACHIEVEMENTS, "{}", message); INFO_LOG_FMT(ACHIEVEMENTS, "{}", message);
}); });
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));
rc_client_set_unofficial_enabled(m_client, 1);
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(); });
@ -110,6 +109,8 @@ void AchievementManager::LoadGame(const std::string& file_path, const DiscIO::Vo
"Attempted to load game achievements without achievement client initialized."); "Attempted to load game achievements without achievement client initialized.");
return; return;
} }
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));
if (volume) if (volume)
{ {
std::lock_guard lg{m_lock}; std::lock_guard lg{m_lock};

View file

@ -17,12 +17,12 @@ const Info<std::string> RA_USERNAME{{System::Achievements, "Achievements", "User
const Info<std::string> RA_API_TOKEN{{System::Achievements, "Achievements", "ApiToken"}, ""}; const Info<std::string> RA_API_TOKEN{{System::Achievements, "Achievements", "ApiToken"}, ""};
const Info<bool> RA_HARDCORE_ENABLED{{System::Achievements, "Achievements", "HardcoreEnabled"}, const Info<bool> RA_HARDCORE_ENABLED{{System::Achievements, "Achievements", "HardcoreEnabled"},
true}; true};
const Info<bool> RA_PROGRESS_ENABLED{{System::Achievements, "Achievements", "ProgressEnabled"},
false};
const Info<bool> RA_BADGES_ENABLED{{System::Achievements, "Achievements", "BadgesEnabled"}, false};
const Info<bool> RA_UNOFFICIAL_ENABLED{{System::Achievements, "Achievements", "UnofficialEnabled"}, const Info<bool> RA_UNOFFICIAL_ENABLED{{System::Achievements, "Achievements", "UnofficialEnabled"},
false}; false};
const Info<bool> RA_ENCORE_ENABLED{{System::Achievements, "Achievements", "EncoreEnabled"}, false}; const Info<bool> RA_ENCORE_ENABLED{{System::Achievements, "Achievements", "EncoreEnabled"}, false};
const Info<bool> RA_PROGRESS_ENABLED{{System::Achievements, "Achievements", "ProgressEnabled"},
false};
const Info<bool> RA_BADGES_ENABLED{{System::Achievements, "Achievements", "BadgesEnabled"}, false};
} // namespace Config } // namespace Config
#endif // USE_RETRO_ACHIEVEMENTS #endif // USE_RETRO_ACHIEVEMENTS

View file

@ -15,10 +15,10 @@ extern const Info<std::string> RA_USERNAME;
extern const Info<std::string> RA_HOST_URL; extern const Info<std::string> RA_HOST_URL;
extern const Info<std::string> RA_API_TOKEN; extern const Info<std::string> RA_API_TOKEN;
extern const Info<bool> RA_HARDCORE_ENABLED; extern const Info<bool> RA_HARDCORE_ENABLED;
extern const Info<bool> RA_PROGRESS_ENABLED;
extern const Info<bool> RA_BADGES_ENABLED;
extern const Info<bool> RA_UNOFFICIAL_ENABLED; extern const Info<bool> RA_UNOFFICIAL_ENABLED;
extern const Info<bool> RA_ENCORE_ENABLED; extern const Info<bool> RA_ENCORE_ENABLED;
extern const Info<bool> RA_PROGRESS_ENABLED;
extern const Info<bool> RA_BADGES_ENABLED;
} // namespace Config } // namespace Config
#endif // USE_RETRO_ACHIEVEMENTS #endif // USE_RETRO_ACHIEVEMENTS

View file

@ -80,7 +80,13 @@ void AchievementSettingsWidget::CreateLayout()
tr("Enable unlocking unofficial achievements as well as official " tr("Enable unlocking unofficial achievements as well as official "
"achievements.<br><br>Unofficial achievements may be optional or unfinished achievements " "achievements.<br><br>Unofficial achievements may be optional or unfinished achievements "
"that have not been deemed official by RetroAchievements and may be useful for testing or " "that have not been deemed official by RetroAchievements and may be useful for testing or "
"simply for fun.")); "simply for fun.<br><br>Setting takes effect on next game load."));
m_common_encore_enabled_input = new ToolTipCheckBox(tr("Enable Encore Achievements"));
m_common_encore_enabled_input->SetDescription(
tr("Enable unlocking achievements in Encore Mode.<br><br>Encore Mode re-enables achievements "
"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_progress_enabled_input = new ToolTipCheckBox(tr("Enable Progress Notifications")); m_common_progress_enabled_input = new ToolTipCheckBox(tr("Enable Progress Notifications"));
m_common_progress_enabled_input->SetDescription( m_common_progress_enabled_input->SetDescription(
tr("Enable progress notifications on achievements.<br><br>Displays a brief popup message " tr("Enable progress notifications on achievements.<br><br>Displays a brief popup message "
@ -91,11 +97,6 @@ void AchievementSettingsWidget::CreateLayout()
tr("Enable achievement badges.<br><br>Displays icons for the player, game, and achievements. " tr("Enable achievement badges.<br><br>Displays icons for the player, game, and achievements. "
"Simple visual option, but will require a small amount of extra memory and time to " "Simple visual option, but will require a small amount of extra memory and time to "
"download the images.")); "download the images."));
m_common_encore_enabled_input = new ToolTipCheckBox(tr("Enable Encore Achievements"));
m_common_encore_enabled_input->SetDescription(tr(
"Enable unlocking achievements in Encore Mode.<br><br>Encore Mode re-enables achievements "
"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."));
m_common_layout->addWidget(m_common_integration_enabled_input); m_common_layout->addWidget(m_common_integration_enabled_input);
m_common_layout->addWidget(m_common_username_label); m_common_layout->addWidget(m_common_username_label);
@ -125,14 +126,14 @@ void AchievementSettingsWidget::ConnectWidgets()
connect(m_common_logout_button, &QPushButton::pressed, this, &AchievementSettingsWidget::Logout); connect(m_common_logout_button, &QPushButton::pressed, this, &AchievementSettingsWidget::Logout);
connect(m_common_hardcore_enabled_input, &QCheckBox::toggled, this, connect(m_common_hardcore_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleHardcore); &AchievementSettingsWidget::ToggleHardcore);
connect(m_common_progress_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleProgress);
connect(m_common_badges_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleBadges);
connect(m_common_unofficial_enabled_input, &QCheckBox::toggled, this, connect(m_common_unofficial_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleUnofficial); &AchievementSettingsWidget::ToggleUnofficial);
connect(m_common_encore_enabled_input, &QCheckBox::toggled, this, connect(m_common_encore_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleEncore); &AchievementSettingsWidget::ToggleEncore);
connect(m_common_progress_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleProgress);
connect(m_common_badges_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleBadges);
} }
void AchievementSettingsWidget::OnControllerInterfaceConfigure() void AchievementSettingsWidget::OnControllerInterfaceConfigure()
@ -172,19 +173,19 @@ void AchievementSettingsWidget::LoadSettings()
(hardcore_enabled || (Core::GetState(system) == Core::State::Uninitialized && (hardcore_enabled || (Core::GetState(system) == Core::State::Uninitialized &&
!system.GetMovie().IsPlayingInput()))); !system.GetMovie().IsPlayingInput())));
SignalBlocking(m_common_progress_enabled_input)
->setChecked(Config::Get(Config::RA_PROGRESS_ENABLED));
SignalBlocking(m_common_progress_enabled_input)->setEnabled(enabled);
SignalBlocking(m_common_badges_enabled_input)->setChecked(Config::Get(Config::RA_BADGES_ENABLED));
SignalBlocking(m_common_badges_enabled_input)->setEnabled(enabled);
SignalBlocking(m_common_unofficial_enabled_input) SignalBlocking(m_common_unofficial_enabled_input)
->setChecked(Config::Get(Config::RA_UNOFFICIAL_ENABLED)); ->setChecked(Config::Get(Config::RA_UNOFFICIAL_ENABLED));
SignalBlocking(m_common_unofficial_enabled_input)->setEnabled(enabled); SignalBlocking(m_common_unofficial_enabled_input)->setEnabled(enabled);
SignalBlocking(m_common_encore_enabled_input)->setChecked(Config::Get(Config::RA_ENCORE_ENABLED)); SignalBlocking(m_common_encore_enabled_input)->setChecked(Config::Get(Config::RA_ENCORE_ENABLED));
SignalBlocking(m_common_encore_enabled_input)->setEnabled(enabled); SignalBlocking(m_common_encore_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);
SignalBlocking(m_common_badges_enabled_input)->setChecked(Config::Get(Config::RA_BADGES_ENABLED));
SignalBlocking(m_common_badges_enabled_input)->setEnabled(enabled);
} }
void AchievementSettingsWidget::SaveSettings() void AchievementSettingsWidget::SaveSettings()
@ -194,12 +195,12 @@ void AchievementSettingsWidget::SaveSettings()
Config::SetBaseOrCurrent(Config::RA_ENABLED, m_common_integration_enabled_input->isChecked()); Config::SetBaseOrCurrent(Config::RA_ENABLED, m_common_integration_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_HARDCORE_ENABLED, Config::SetBaseOrCurrent(Config::RA_HARDCORE_ENABLED,
m_common_hardcore_enabled_input->isChecked()); m_common_hardcore_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_PROGRESS_ENABLED,
m_common_unofficial_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_BADGES_ENABLED, m_common_badges_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_UNOFFICIAL_ENABLED, Config::SetBaseOrCurrent(Config::RA_UNOFFICIAL_ENABLED,
m_common_unofficial_enabled_input->isChecked()); m_common_unofficial_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_ENCORE_ENABLED, m_common_encore_enabled_input->isChecked()); Config::SetBaseOrCurrent(Config::RA_ENCORE_ENABLED, m_common_encore_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());
Config::Save(); Config::Save();
} }
@ -243,6 +244,16 @@ void AchievementSettingsWidget::ToggleHardcore()
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance())); emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance()));
} }
void AchievementSettingsWidget::ToggleUnofficial()
{
SaveSettings();
}
void AchievementSettingsWidget::ToggleEncore()
{
SaveSettings();
}
void AchievementSettingsWidget::ToggleProgress() void AchievementSettingsWidget::ToggleProgress()
{ {
SaveSettings(); SaveSettings();
@ -255,14 +266,4 @@ void AchievementSettingsWidget::ToggleBadges()
AchievementManager::GetInstance().FetchGameBadges(); AchievementManager::GetInstance().FetchGameBadges();
} }
void AchievementSettingsWidget::ToggleUnofficial()
{
SaveSettings();
}
void AchievementSettingsWidget::ToggleEncore()
{
SaveSettings();
}
#endif // USE_RETRO_ACHIEVEMENTS #endif // USE_RETRO_ACHIEVEMENTS

View file

@ -33,10 +33,10 @@ private:
void Login(); void Login();
void Logout(); void Logout();
void ToggleHardcore(); void ToggleHardcore();
void ToggleProgress();
void ToggleBadges();
void ToggleUnofficial(); void ToggleUnofficial();
void ToggleEncore(); void ToggleEncore();
void ToggleProgress();
void ToggleBadges();
QGroupBox* m_common_box; QGroupBox* m_common_box;
QVBoxLayout* m_common_layout; QVBoxLayout* m_common_layout;
@ -49,10 +49,10 @@ private:
QPushButton* m_common_login_button; QPushButton* m_common_login_button;
QPushButton* m_common_logout_button; QPushButton* m_common_logout_button;
ToolTipCheckBox* m_common_hardcore_enabled_input; ToolTipCheckBox* m_common_hardcore_enabled_input;
ToolTipCheckBox* m_common_progress_enabled_input;
ToolTipCheckBox* m_common_badges_enabled_input;
ToolTipCheckBox* m_common_unofficial_enabled_input; ToolTipCheckBox* m_common_unofficial_enabled_input;
ToolTipCheckBox* m_common_encore_enabled_input; ToolTipCheckBox* m_common_encore_enabled_input;
ToolTipCheckBox* m_common_progress_enabled_input;
ToolTipCheckBox* m_common_badges_enabled_input;
}; };
#endif // USE_RETRO_ACHIEVEMENTS #endif // USE_RETRO_ACHIEVEMENTS