mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Added error checking and logging to AchievementManager::GetAchievementProgress.
This commit is contained in:
parent
b2e016f012
commit
c8b1379113
@ -688,12 +688,25 @@ AchievementManager::GetUnlockStatus(AchievementId achievement_id) const
|
||||
return m_unlock_map.at(achievement_id);
|
||||
}
|
||||
|
||||
void AchievementManager::GetAchievementProgress(AchievementId achievement_id, u32* value,
|
||||
u32* target)
|
||||
AchievementManager::ResponseType
|
||||
AchievementManager::GetAchievementProgress(AchievementId achievement_id, u32* value, u32* target)
|
||||
{
|
||||
if (!IsGameLoaded())
|
||||
return;
|
||||
rc_runtime_get_achievement_measured(&m_runtime, achievement_id, value, target);
|
||||
{
|
||||
ERROR_LOG_FMT(
|
||||
ACHIEVEMENTS,
|
||||
"Attempted to request measured data for achievement ID {} when no game is running.",
|
||||
achievement_id);
|
||||
return ResponseType::INVALID_REQUEST;
|
||||
}
|
||||
int result = rc_runtime_get_achievement_measured(&m_runtime, achievement_id, value, target);
|
||||
if (result == 0)
|
||||
{
|
||||
WARN_LOG_FMT(ACHIEVEMENTS, "Failed to get measured data for achievement ID {}.",
|
||||
achievement_id);
|
||||
return ResponseType::MALFORMED_OBJECT;
|
||||
}
|
||||
return ResponseType::SUCCESS;
|
||||
}
|
||||
|
||||
AchievementManager::RichPresence AchievementManager::GetRichPresence()
|
||||
|
@ -111,7 +111,8 @@ public:
|
||||
rc_api_fetch_game_data_response_t* GetGameData();
|
||||
const BadgeStatus& GetGameBadge() const;
|
||||
const UnlockStatus& GetUnlockStatus(AchievementId achievement_id) const;
|
||||
void GetAchievementProgress(AchievementId achievement_id, u32* value, u32* target);
|
||||
AchievementManager::ResponseType GetAchievementProgress(AchievementId achievement_id, u32* value,
|
||||
u32* target);
|
||||
RichPresence GetRichPresence();
|
||||
|
||||
void CloseGame();
|
||||
|
@ -105,8 +105,9 @@ AchievementProgressWidget::CreateAchievementBox(const rc_api_achievement_definit
|
||||
a_progress_bar->setSizePolicy(sp_retain);
|
||||
unsigned int value = 0;
|
||||
unsigned int target = 0;
|
||||
AchievementManager::GetInstance()->GetAchievementProgress(achievement->id, &value, &target);
|
||||
if (target > 0)
|
||||
if (AchievementManager::GetInstance()->GetAchievementProgress(achievement->id, &value, &target) ==
|
||||
AchievementManager::ResponseType::SUCCESS &&
|
||||
target > 0)
|
||||
{
|
||||
a_progress_bar->setRange(0, target);
|
||||
a_progress_bar->setValue(value);
|
||||
|
Loading…
Reference in New Issue
Block a user