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.
This commit is contained in:
LillyJadeKatrin 2023-05-23 09:04:14 -04:00
parent 1841089054
commit 57290a45e8
2 changed files with 15 additions and 0 deletions

View File

@ -340,6 +340,7 @@ AchievementManager::ResponseType AchievementManager::VerifyCredentials(const std
.username = username.c_str(), .api_token = api_token.c_str(), .password = password.c_str()}; .username = username.c_str(), .api_token = api_token.c_str(), .password = password.c_str()};
ResponseType r_type = Request<rc_api_login_request_t, rc_api_login_response_t>( ResponseType r_type = Request<rc_api_login_request_t, rc_api_login_response_t>(
login_request, &login_data, rc_api_init_login_request, rc_api_process_login_response); 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) if (r_type == ResponseType::SUCCESS)
Config::SetBaseOrCurrent(Config::RA_API_TOKEN, login_data.api_token); Config::SetBaseOrCurrent(Config::RA_API_TOKEN, login_data.api_token);
rc_api_destroy_login_response(&login_data); 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), m_game_data.achievements[game_data_index].points),
OSD::Duration::VERY_LONG, OSD::Duration::VERY_LONG,
(hardcore_mode_enabled) ? OSD::Color::YELLOW : OSD::Color::CYAN); (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), ActivateDeactivateAchievement(runtime_event->id, Config::Get(Config::RA_ACHIEVEMENTS_ENABLED),
Config::Get(Config::RA_UNOFFICIAL_ENABLED), Config::Get(Config::RA_UNOFFICIAL_ENABLED),
Config::Get(Config::RA_ENCORE_ENABLED)); Config::Get(Config::RA_ENCORE_ENABLED));

View File

@ -104,6 +104,7 @@ private:
rc_runtime_t m_runtime{}; rc_runtime_t m_runtime{};
Core::System* m_system{}; Core::System* m_system{};
bool m_is_runtime_initialized = false; bool m_is_runtime_initialized = false;
std::string m_display_name;
std::array<char, HASH_LENGTH> m_game_hash{}; std::array<char, HASH_LENGTH> m_game_hash{};
u32 m_game_id = 0; u32 m_game_id = 0;
rc_api_fetch_game_data_response_t m_game_data{}; rc_api_fetch_game_data_response_t m_game_data{};