Handle Achievement Challenge Indicator Show/Hide Client Events
Also deletes the corresponding runtime-based events from the old event handler.
This commit is contained in:
parent
7895b739ee
commit
a70733f74f
|
@ -237,12 +237,6 @@ void AchievementManager::AchievementEventHandler(const rc_runtime_event_t* runti
|
||||||
case RC_RUNTIME_EVENT_ACHIEVEMENT_PROGRESS_UPDATED:
|
case RC_RUNTIME_EVENT_ACHIEVEMENT_PROGRESS_UPDATED:
|
||||||
HandleAchievementProgressUpdatedEvent(runtime_event);
|
HandleAchievementProgressUpdatedEvent(runtime_event);
|
||||||
break;
|
break;
|
||||||
case RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED:
|
|
||||||
HandleAchievementPrimedEvent(runtime_event);
|
|
||||||
break;
|
|
||||||
case RC_RUNTIME_EVENT_ACHIEVEMENT_UNPRIMED:
|
|
||||||
HandleAchievementUnprimedEvent(runtime_event);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,34 +768,6 @@ void AchievementManager::HandleAchievementProgressUpdatedEvent(
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AchievementManager::HandleAchievementPrimedEvent(const rc_runtime_event_t* runtime_event)
|
|
||||||
{
|
|
||||||
if (!Config::Get(Config::RA_BADGES_ENABLED))
|
|
||||||
return;
|
|
||||||
auto it = m_unlock_map.find(runtime_event->id);
|
|
||||||
if (it == m_unlock_map.end())
|
|
||||||
{
|
|
||||||
ERROR_LOG_FMT(ACHIEVEMENTS, "Invalid achievement primed event with id {}.", runtime_event->id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_active_challenges[it->second.unlocked_badge.name] =
|
|
||||||
DecodeBadgeToOSDIcon(it->second.unlocked_badge.badge);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AchievementManager::HandleAchievementUnprimedEvent(const rc_runtime_event_t* runtime_event)
|
|
||||||
{
|
|
||||||
if (!Config::Get(Config::RA_BADGES_ENABLED))
|
|
||||||
return;
|
|
||||||
auto it = m_unlock_map.find(runtime_event->id);
|
|
||||||
if (it == m_unlock_map.end())
|
|
||||||
{
|
|
||||||
ERROR_LOG_FMT(ACHIEVEMENTS, "Invalid achievement unprimed event with id {}.",
|
|
||||||
runtime_event->id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_active_challenges.erase(it->second.unlocked_badge.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AchievementManager::HandleAchievementTriggeredEvent(const rc_client_event_t* client_event)
|
void AchievementManager::HandleAchievementTriggeredEvent(const rc_client_event_t* client_event)
|
||||||
{
|
{
|
||||||
OSD::AddMessage(fmt::format("Unlocked: {} ({})", client_event->achievement->title,
|
OSD::AddMessage(fmt::format("Unlocked: {} ({})", client_event->achievement->title,
|
||||||
|
@ -865,6 +831,28 @@ void AchievementManager::HandleLeaderboardTrackerHideEvent(const rc_client_event
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AchievementManager::HandleAchievementChallengeIndicatorShowEvent(
|
||||||
|
const rc_client_event_t* client_event)
|
||||||
|
{
|
||||||
|
if (Config::Get(Config::RA_BADGES_ENABLED))
|
||||||
|
{
|
||||||
|
auto& unlocked_badges = AchievementManager::GetInstance().m_unlocked_badges;
|
||||||
|
if (const auto unlocked_iter = unlocked_badges.find(client_event->achievement->id);
|
||||||
|
unlocked_iter != unlocked_badges.end())
|
||||||
|
{
|
||||||
|
AchievementManager::GetInstance().m_active_challenges[client_event->achievement->badge_name] =
|
||||||
|
DecodeBadgeToOSDIcon(unlocked_iter->second.badge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AchievementManager::HandleAchievementChallengeIndicatorHideEvent(
|
||||||
|
const rc_client_event_t* client_event)
|
||||||
|
{
|
||||||
|
AchievementManager::GetInstance().m_active_challenges.erase(
|
||||||
|
client_event->achievement->badge_name);
|
||||||
|
}
|
||||||
|
|
||||||
// Every RetroAchievements API call, with only a partial exception for fetch_image, follows
|
// Every RetroAchievements API call, with only a partial exception for fetch_image, follows
|
||||||
// the same design pattern (here, X is the name of the call):
|
// the same design pattern (here, X is the name of the call):
|
||||||
// Create a specific rc_api_X_request_t struct and populate with the necessary values
|
// Create a specific rc_api_X_request_t struct and populate with the necessary values
|
||||||
|
@ -1070,6 +1058,12 @@ void AchievementManager::EventHandlerV2(const rc_client_event_t* event, rc_clien
|
||||||
case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_HIDE:
|
case RC_CLIENT_EVENT_LEADERBOARD_TRACKER_HIDE:
|
||||||
HandleLeaderboardTrackerHideEvent(event);
|
HandleLeaderboardTrackerHideEvent(event);
|
||||||
break;
|
break;
|
||||||
|
case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_SHOW:
|
||||||
|
HandleAchievementChallengeIndicatorShowEvent(event);
|
||||||
|
break;
|
||||||
|
case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_HIDE:
|
||||||
|
HandleAchievementChallengeIndicatorHideEvent(event);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
INFO_LOG_FMT(ACHIEVEMENTS, "Event triggered of unhandled type {}", event->type);
|
INFO_LOG_FMT(ACHIEVEMENTS, "Event triggered of unhandled type {}", event->type);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -185,8 +185,6 @@ private:
|
||||||
void DisplayWelcomeMessage();
|
void DisplayWelcomeMessage();
|
||||||
|
|
||||||
void HandleAchievementProgressUpdatedEvent(const rc_runtime_event_t* runtime_event);
|
void HandleAchievementProgressUpdatedEvent(const rc_runtime_event_t* runtime_event);
|
||||||
void HandleAchievementPrimedEvent(const rc_runtime_event_t* runtime_event);
|
|
||||||
void HandleAchievementUnprimedEvent(const rc_runtime_event_t* runtime_event);
|
|
||||||
|
|
||||||
static void HandleAchievementTriggeredEvent(const rc_client_event_t* client_event);
|
static void HandleAchievementTriggeredEvent(const rc_client_event_t* client_event);
|
||||||
static void HandleLeaderboardStartedEvent(const rc_client_event_t* client_event);
|
static void HandleLeaderboardStartedEvent(const rc_client_event_t* client_event);
|
||||||
|
@ -195,6 +193,8 @@ private:
|
||||||
static void HandleLeaderboardTrackerUpdateEvent(const rc_client_event_t* client_event);
|
static void HandleLeaderboardTrackerUpdateEvent(const rc_client_event_t* client_event);
|
||||||
static void HandleLeaderboardTrackerShowEvent(const rc_client_event_t* client_event);
|
static void HandleLeaderboardTrackerShowEvent(const rc_client_event_t* client_event);
|
||||||
static void HandleLeaderboardTrackerHideEvent(const rc_client_event_t* client_event);
|
static void HandleLeaderboardTrackerHideEvent(const rc_client_event_t* client_event);
|
||||||
|
static void HandleAchievementChallengeIndicatorShowEvent(const rc_client_event_t* client_event);
|
||||||
|
static void HandleAchievementChallengeIndicatorHideEvent(const rc_client_event_t* client_event);
|
||||||
|
|
||||||
template <typename RcRequest, typename RcResponse>
|
template <typename RcRequest, typename RcResponse>
|
||||||
ResponseType Request(RcRequest rc_request, RcResponse* rc_response,
|
ResponseType Request(RcRequest rc_request, RcResponse* rc_response,
|
||||||
|
|
Loading…
Reference in New Issue