mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-26 15:49:50 -06:00
Handle Game Completed Client Event
This commit is contained in:
@ -828,6 +828,25 @@ void AchievementManager::HandleAchievementProgressIndicatorShowEvent(
|
|||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AchievementManager::HandleGameCompletedEvent(const rc_client_event_t* client_event,
|
||||||
|
rc_client_t* client)
|
||||||
|
{
|
||||||
|
auto* user_info = rc_client_get_user_info(client);
|
||||||
|
auto* game_info = rc_client_get_game_info(client);
|
||||||
|
if (!user_info || !game_info)
|
||||||
|
{
|
||||||
|
WARN_LOG_FMT(ACHIEVEMENTS, "Received Game Completed event when game not running.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool hardcore = rc_client_get_hardcore_enabled(client);
|
||||||
|
OSD::AddMessage(fmt::format("Congratulations! {} has {} {}", user_info->display_name,
|
||||||
|
hardcore ? "mastered" : "completed", game_info->title),
|
||||||
|
OSD::Duration::VERY_LONG, hardcore ? OSD::Color::YELLOW : OSD::Color::CYAN,
|
||||||
|
(Config::Get(Config::RA_BADGES_ENABLED)) ?
|
||||||
|
DecodeBadgeToOSDIcon(AchievementManager::GetInstance().m_game_badge.badge) :
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@ -1047,6 +1066,9 @@ void AchievementManager::EventHandler(const rc_client_event_t* event, rc_client_
|
|||||||
// OnScreenDisplay messages disappear over time, so this is unnecessary
|
// OnScreenDisplay messages disappear over time, so this is unnecessary
|
||||||
// unless the display algorithm changes in the future.
|
// unless the display algorithm changes in the future.
|
||||||
break;
|
break;
|
||||||
|
case RC_CLIENT_EVENT_GAME_COMPLETED:
|
||||||
|
HandleGameCompletedEvent(event, client);
|
||||||
|
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;
|
||||||
|
@ -193,6 +193,7 @@ private:
|
|||||||
static void HandleAchievementChallengeIndicatorShowEvent(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);
|
static void HandleAchievementChallengeIndicatorHideEvent(const rc_client_event_t* client_event);
|
||||||
static void HandleAchievementProgressIndicatorShowEvent(const rc_client_event_t* client_event);
|
static void HandleAchievementProgressIndicatorShowEvent(const rc_client_event_t* client_event);
|
||||||
|
static void HandleGameCompletedEvent(const rc_client_event_t* client_event, rc_client_t* client);
|
||||||
|
|
||||||
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,
|
||||||
|
Reference in New Issue
Block a user