diff --git a/Common/System/OSD.cpp b/Common/System/OSD.cpp index 1b26acd89ef2..e8cf697b2741 100644 --- a/Common/System/OSD.cpp +++ b/Common/System/OSD.cpp @@ -128,25 +128,36 @@ void OnScreenDisplay::ShowAchievementUnlocked(int achievementID) { entries_.insert(entries_.begin(), msg); } -void OnScreenDisplay::ShowAchievementProgress(int achievementID, float duration_s) { +void OnScreenDisplay::ShowAchievementProgress(int achievementID, bool show) { double now = time_now_d(); + // There can only be one of these at a time. for (auto &entry : sideEntries_) { - if (entry.numericID == achievementID && entry.type == OSDType::ACHIEVEMENT_PROGRESS) { - // Duplicate, let's just bump the timer. - entry.startTime = now; - entry.endTime = now + (double)duration_s; - // We're done. + if (entry.type == OSDType::ACHIEVEMENT_PROGRESS) { + if (!show) { + // Hide and eventually delete it. + entry.endTime = now + (double)FadeoutTime(); + // Found it, we're done. + return; + } + // Else update it. + entry.numericID = achievementID; + entry.endTime = now + forever_s; return; } } + if (!show) { + // Sanity check + return; + } + // OK, let's make a new side-entry. Entry entry; entry.numericID = achievementID; entry.type = OSDType::ACHIEVEMENT_PROGRESS; entry.startTime = now; - entry.endTime = now + (double)duration_s; + entry.endTime = now + forever_s; sideEntries_.insert(sideEntries_.begin(), entry); } diff --git a/Common/System/OSD.h b/Common/System/OSD.h index 823236469d0f..cecf0cae7998 100644 --- a/Common/System/OSD.h +++ b/Common/System/OSD.h @@ -44,7 +44,7 @@ class OnScreenDisplay { // Specialized achievement-related types. These go to the side notifications, not the top-middle. void ShowAchievementUnlocked(int achievementID); - void ShowAchievementProgress(int achievementID, float duration_s); + void ShowAchievementProgress(int achievementID, bool show); // call with show=false to hide. There can only be one of these. When hiding it's ok to not pass a valid achievementID. void ShowChallengeIndicator(int achievementID, bool show); // call with show=false to hide. void ShowLeaderboardTracker(int leaderboardTrackerID, const char *trackerText, bool show); // show=true is used both for create and update. diff --git a/Core/RetroAchievements.cpp b/Core/RetroAchievements.cpp index 4c3ea9771075..22b3c3bceecc 100644 --- a/Core/RetroAchievements.cpp +++ b/Core/RetroAchievements.cpp @@ -249,40 +249,52 @@ static void event_handler_callback(const rc_client_event_t *event, rc_client_t * g_OSD.Show(OSDType::MESSAGE_INFO, ApplySafeSubstitutions(ac->T("%1: Leaderboard attempt started"), event->leaderboard->title), DeNull(event->leaderboard->description), 3.0f); break; case RC_CLIENT_EVENT_LEADERBOARD_FAILED: - NOTICE_LOG(ACHIEVEMENTS, "Leaderboard attempt failed: %s", event->leaderboard->title); + INFO_LOG(ACHIEVEMENTS, "Leaderboard attempt failed: %s", event->leaderboard->title); g_OSD.Show(OSDType::MESSAGE_INFO, ApplySafeSubstitutions(ac->T("%1: Leaderboard attempt failed"), event->leaderboard->title), 3.0f); // A leaderboard attempt has failed. break; case RC_CLIENT_EVENT_LEADERBOARD_SUBMITTED: - NOTICE_LOG(ACHIEVEMENTS, "Leaderboard result submitted: %s", event->leaderboard->title); + INFO_LOG(ACHIEVEMENTS, "Leaderboard result submitted: %s", event->leaderboard->title); g_OSD.Show(OSDType::MESSAGE_SUCCESS, ApplySafeSubstitutions(ac->T("Submitted %1 for %2"), DeNull(event->leaderboard->tracker_value), DeNull(event->leaderboard->title)), DeNull(event->leaderboard->description), 3.0f); System_PostUIMessage("play_sound", "leaderboard_submitted"); break; case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_SHOW: - NOTICE_LOG(ACHIEVEMENTS, "Challenge indicator show: %s", event->achievement->title); + INFO_LOG(ACHIEVEMENTS, "Challenge indicator show: %s", event->achievement->title); g_OSD.ShowChallengeIndicator(event->achievement->id, true); g_activeChallenges.insert(event->achievement->id); // A challenge achievement has become active. The handler should show a small version of the achievement icon // to indicate the challenge is active. break; case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_HIDE: - NOTICE_LOG(ACHIEVEMENTS, "Challenge indicator hide: %s", event->achievement->title); + INFO_LOG(ACHIEVEMENTS, "Challenge indicator hide: %s", event->achievement->title); g_OSD.ShowChallengeIndicator(event->achievement->id, false); g_activeChallenges.erase(event->achievement->id); // The handler should hide the small version of the achievement icon that was shown by the corresponding RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_SHOW event. break; case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_SHOW: - NOTICE_LOG(ACHIEVEMENTS, "Progress indicator show: %s, progress: '%s' (%f)", event->achievement->title, event->achievement->measured_progress, event->achievement->measured_percent); + INFO_LOG(ACHIEVEMENTS, "Progress indicator show: %s, progress: '%s' (%f)", event->achievement->title, event->achievement->measured_progress, event->achievement->measured_percent); // An achievement that tracks progress has changed the amount of progress that has been made. // The handler should show a small version of the achievement icon along with the achievement->measured_progress text (for two seconds). // Only one progress indicator should be shown at a time. // If a progress indicator is already visible, it should be updated with the new icon and text, and the two second timer should be restarted. - g_OSD.ShowAchievementProgress(event->achievement->id, 2.0f); + g_OSD.ShowAchievementProgress(event->achievement->id, true); + break; + case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_UPDATE: + INFO_LOG(ACHIEVEMENTS, "Progress indicator update: %s, progress: '%s' (%f)", event->achievement->title, event->achievement->measured_progress, event->achievement->measured_percent); + g_OSD.ShowAchievementProgress(event->achievement->id, true); + break; + case RC_CLIENT_EVENT_ACHIEVEMENT_PROGRESS_INDICATOR_HIDE: + INFO_LOG(ACHIEVEMENTS, "Progress indicator hide"); + // An achievement that tracks progress has changed the amount of progress that has been made. + // The handler should show a small version of the achievement icon along with the achievement->measured_progress text (for two seconds). + // Only one progress indicator should be shown at a time. + // If a progress indicator is already visible, it should be updated with the new icon and text, and the two second timer should be restarted. + g_OSD.ShowAchievementProgress(0, false); break; case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_SHOW: - NOTICE_LOG(ACHIEVEMENTS, "Leaderboard tracker show: '%s' (id %d)", event->leaderboard_tracker->display, event->leaderboard_tracker->id); + INFO_LOG(ACHIEVEMENTS, "Leaderboard tracker show: '%s' (id %d)", event->leaderboard_tracker->display, event->leaderboard_tracker->id); // A leaderboard_tracker has become active. The handler should show the tracker text on screen. // Multiple active leaderboards may share a single tracker if they have the same definition and value. // As such, the leaderboard tracker IDs are unique amongst the leaderboard trackers, and have no correlation to the active leaderboard(s). @@ -291,12 +303,12 @@ static void event_handler_callback(const rc_client_event_t *event, rc_client_t * break; case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_HIDE: // A leaderboard_tracker has become inactive. The handler should hide the tracker text from the screen. - NOTICE_LOG(ACHIEVEMENTS, "Leaderboard tracker hide: '%s' (id %d)", event->leaderboard_tracker->display, event->leaderboard_tracker->id); + INFO_LOG(ACHIEVEMENTS, "Leaderboard tracker hide: '%s' (id %d)", event->leaderboard_tracker->display, event->leaderboard_tracker->id); g_OSD.ShowLeaderboardTracker(event->leaderboard_tracker->id, nullptr, false); break; case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_UPDATE: // A leaderboard_tracker value has been updated. The handler should update the tracker text on the screen. - NOTICE_LOG(ACHIEVEMENTS, "Leaderboard tracker update: '%s' (id %d)", event->leaderboard_tracker->display, event->leaderboard_tracker->id); + INFO_LOG(ACHIEVEMENTS, "Leaderboard tracker update: '%s' (id %d)", event->leaderboard_tracker->display, event->leaderboard_tracker->id); g_OSD.ShowLeaderboardTracker(event->leaderboard_tracker->id, event->leaderboard_tracker->display, true); break; case RC_CLIENT_EVENT_RESET: diff --git a/UI/RetroAchievementScreens.cpp b/UI/RetroAchievementScreens.cpp index 8ab19214ed27..8bc67c8d4483 100644 --- a/UI/RetroAchievementScreens.cpp +++ b/UI/RetroAchievementScreens.cpp @@ -675,14 +675,14 @@ void AchievementView::Click() { #ifdef _DEBUG static int type = 0; type++; - type = type % 4; + type = type % 5; switch (type) { case 0: g_OSD.ShowAchievementUnlocked(achievement_->id); break; - case 1: g_OSD.ShowAchievementProgress(achievement_->id, 2.0f); break; - case 2: g_OSD.ShowChallengeIndicator(achievement_->id, true); break; - case 3: g_OSD.ShowChallengeIndicator(achievement_->id, false); break; + case 1: g_OSD.ShowAchievementProgress(achievement_->id, true); break; + case 2: g_OSD.ShowAchievementProgress(achievement_->id, false); break; + case 3: g_OSD.ShowChallengeIndicator(achievement_->id, true); break; + case 4: g_OSD.ShowChallengeIndicator(achievement_->id, false); break; } - #endif } diff --git a/ext/rcheevos b/ext/rcheevos index 97db619aa4de..13333347f080 160000 --- a/ext/rcheevos +++ b/ext/rcheevos @@ -1 +1 @@ -Subproject commit 97db619aa4de15fe19887255e75899ae65d2e432 +Subproject commit 13333347f0809aa751856c849ffe751d612ae0a4