Add toggle button for badges to achievement settings

Button toggles whether badges are downloaded. When turned on, makes a call to AchievementManager to download badges.
This commit is contained in:
LillyJadeKatrin 2023-06-15 04:49:56 -04:00
parent 80d77cfdad
commit 63c407ad7c
2 changed files with 20 additions and 1 deletions

View File

@ -75,6 +75,11 @@ void AchievementSettingsWidget::CreateLayout()
"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."));
m_common_badges_enabled_input = new ToolTipCheckBox(tr("Enable Achievement Badges"));
m_common_badges_enabled_input->SetDescription(
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 "
"download the images."));
m_common_encore_enabled_input = new ToolTipCheckBox(tr("Enable Encore Achievements")); m_common_encore_enabled_input = new ToolTipCheckBox(tr("Enable Encore Achievements"));
m_common_encore_enabled_input->SetDescription(tr( m_common_encore_enabled_input->SetDescription(tr(
"Enable unlocking achievements in Encore Mode.<br><br>Encore Mode re-enables achievements " "Enable unlocking achievements in Encore Mode.<br><br>Encore Mode re-enables achievements "
@ -92,6 +97,7 @@ void AchievementSettingsWidget::CreateLayout()
m_common_layout->addWidget(m_common_achievements_enabled_input); m_common_layout->addWidget(m_common_achievements_enabled_input);
m_common_layout->addWidget(m_common_leaderboards_enabled_input); m_common_layout->addWidget(m_common_leaderboards_enabled_input);
m_common_layout->addWidget(m_common_rich_presence_enabled_input); m_common_layout->addWidget(m_common_rich_presence_enabled_input);
m_common_layout->addWidget(m_common_badges_enabled_input);
m_common_layout->addWidget(m_common_unofficial_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_encore_enabled_input);
@ -111,6 +117,8 @@ void AchievementSettingsWidget::ConnectWidgets()
&AchievementSettingsWidget::ToggleLeaderboards); &AchievementSettingsWidget::ToggleLeaderboards);
connect(m_common_rich_presence_enabled_input, &QCheckBox::toggled, this, connect(m_common_rich_presence_enabled_input, &QCheckBox::toggled, this,
&AchievementSettingsWidget::ToggleRichPresence); &AchievementSettingsWidget::ToggleRichPresence);
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,
@ -157,6 +165,9 @@ void AchievementSettingsWidget::LoadSettings()
->setChecked(Config::Get(Config::RA_RICH_PRESENCE_ENABLED)); ->setChecked(Config::Get(Config::RA_RICH_PRESENCE_ENABLED));
SignalBlocking(m_common_rich_presence_enabled_input)->setEnabled(enabled); SignalBlocking(m_common_rich_presence_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 && achievements_enabled); SignalBlocking(m_common_unofficial_enabled_input)->setEnabled(enabled && achievements_enabled);
@ -176,6 +187,7 @@ void AchievementSettingsWidget::SaveSettings()
m_common_leaderboards_enabled_input->isChecked()); m_common_leaderboards_enabled_input->isChecked());
Config::SetBaseOrCurrent(Config::RA_RICH_PRESENCE_ENABLED, Config::SetBaseOrCurrent(Config::RA_RICH_PRESENCE_ENABLED,
m_common_rich_presence_enabled_input->isChecked()); m_common_rich_presence_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());
@ -224,6 +236,12 @@ void AchievementSettingsWidget::ToggleRichPresence()
AchievementManager::GetInstance()->ActivateDeactivateRichPresence(); AchievementManager::GetInstance()->ActivateDeactivateRichPresence();
} }
void AchievementSettingsWidget::ToggleBadges()
{
SaveSettings();
AchievementManager::GetInstance()->FetchBadges();
}
void AchievementSettingsWidget::ToggleUnofficial() void AchievementSettingsWidget::ToggleUnofficial()
{ {
SaveSettings(); SaveSettings();

View File

@ -36,7 +36,7 @@ private:
void ToggleLeaderboards(); void ToggleLeaderboards();
void ToggleRichPresence(); void ToggleRichPresence();
void ToggleHardcore(); void ToggleHardcore();
void ToggleBadgeIcons(); void ToggleBadges();
void ToggleUnofficial(); void ToggleUnofficial();
void ToggleEncore(); void ToggleEncore();
@ -55,6 +55,7 @@ private:
ToolTipCheckBox* m_common_achievements_enabled_input; ToolTipCheckBox* m_common_achievements_enabled_input;
ToolTipCheckBox* m_common_leaderboards_enabled_input; ToolTipCheckBox* m_common_leaderboards_enabled_input;
ToolTipCheckBox* m_common_rich_presence_enabled_input; ToolTipCheckBox* m_common_rich_presence_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;
}; };