Refactored AchievementProgress UpdateData to Re-Sort

When AchievementProgress::UpdateData(false) is called, it will now empty itself and reinsert all existing boxes, re-sorted into their current buckets, and call UpdateProgress on them all.
This commit is contained in:
LillyJadeKatrin
2024-06-19 22:54:24 -04:00
parent 75c2360aea
commit 9b9e6c4582
2 changed files with 43 additions and 21 deletions

View File

@ -62,6 +62,9 @@ AchievementBox::AchievementBox(QWidget* parent, rc_client_achievement_t* achieve
void AchievementBox::UpdateData()
{
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
// rc_client guarantees m_achievement will be valid as long as the game is loaded
if (!AchievementManager::GetInstance().IsGameLoaded())
return;
const auto& badge = AchievementManager::GetInstance().GetAchievementBadge(
m_achievement->id, m_achievement->state != RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED);
@ -92,6 +95,11 @@ void AchievementBox::UpdateData()
void AchievementBox::UpdateProgress()
{
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
// rc_client guarantees m_achievement will be valid as long as the game is loaded
if (!AchievementManager::GetInstance().IsGameLoaded())
return;
if (m_achievement->measured_percent > 0.000)
{
m_progress_bar->setRange(0, 100);