From 57290a45e864dde336810089aec538adbb24f97f Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Tue, 23 May 2023 09:04:14 -0400 Subject: [PATCH] Added Notification Popups for Game Mastery Added OnScreenDisplay messages to HandleAchievementTriggeredEvent to display an extra congratulations message if the player has completed (unlocked all achievements in casual) or mastered (unlocked all achievements in challenge) the game. This also uses the display name retrieved when verifying credentials, which has now been added as a member field on AchievementManager. --- Source/Core/Core/AchievementManager.cpp | 14 ++++++++++++++ Source/Core/Core/AchievementManager.h | 1 + 2 files changed, 15 insertions(+) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index 10caf88387..81c3493dca 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -340,6 +340,7 @@ AchievementManager::ResponseType AchievementManager::VerifyCredentials(const std .username = username.c_str(), .api_token = api_token.c_str(), .password = password.c_str()}; ResponseType r_type = Request( login_request, &login_data, rc_api_init_login_request, rc_api_process_login_response); + m_display_name = login_data.display_name; if (r_type == ResponseType::SUCCESS) Config::SetBaseOrCurrent(Config::RA_API_TOKEN, login_data.api_token); rc_api_destroy_login_response(&login_data); @@ -546,6 +547,19 @@ void AchievementManager::HandleAchievementTriggeredEvent(const rc_runtime_event_ m_game_data.achievements[game_data_index].points), OSD::Duration::VERY_LONG, (hardcore_mode_enabled) ? OSD::Color::YELLOW : OSD::Color::CYAN); + PointSpread spread = TallyScore(); + if (spread.hard_points == spread.total_points) + { + OSD::AddMessage( + fmt::format("Congratulations! {} has mastered {}", m_display_name, m_game_data.title), + OSD::Duration::VERY_LONG, OSD::Color::YELLOW); + } + else if (spread.hard_points + spread.soft_points == spread.total_points) + { + OSD::AddMessage( + fmt::format("Congratulations! {} has completed {}", m_display_name, m_game_data.title), + OSD::Duration::VERY_LONG, OSD::Color::CYAN); + } ActivateDeactivateAchievement(runtime_event->id, Config::Get(Config::RA_ACHIEVEMENTS_ENABLED), Config::Get(Config::RA_UNOFFICIAL_ENABLED), Config::Get(Config::RA_ENCORE_ENABLED)); diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index da11f930ce..8e01b9220e 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -104,6 +104,7 @@ private: rc_runtime_t m_runtime{}; Core::System* m_system{}; bool m_is_runtime_initialized = false; + std::string m_display_name; std::array m_game_hash{}; u32 m_game_id = 0; rc_api_fetch_game_data_response_t m_game_data{};