From 7a7e0ab2f59cf71266e2219d44c87d8f0b597a4b Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Sat, 17 Jun 2023 15:27:23 -0400 Subject: [PATCH] Fixed Leaderboard Scored message format Refactored the message displayed when a leaderboard is submitted to so that it properly generates and uses a FormattedValue. --- Source/Core/Core/AchievementManager.cpp | 21 +++++++++++++++++---- Source/Core/Core/AchievementManager.h | 10 ++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index ef23dcf163..74bd257311 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -585,7 +585,7 @@ void AchievementManager::ActivateDeactivateAchievement(AchievementId id, bool en rc_runtime_deactivate_achievement(&m_runtime, id); } -RichPresence AchievementManager::GenerateRichPresence() +AchievementManager::RichPresence AchievementManager::GenerateRichPresence() { RichPresence rp_buffer; Core::RunAsCPUThread([&] { @@ -716,9 +716,22 @@ void AchievementManager::HandleLeaderboardTriggeredEvent(const rc_runtime_event_ { if (m_game_data.leaderboards[ix].id == runtime_event->id) { - OSD::AddMessage(fmt::format("Scored {} on leaderboard: {}", runtime_event->value, - m_game_data.leaderboards[ix].title), - OSD::Duration::VERY_LONG, OSD::Color::YELLOW); + FormattedValue value{}; + rc_runtime_format_lboard_value(value.data(), static_cast(value.size()), + runtime_event->value, m_game_data.leaderboards[ix].format); + if (std::find(value.begin(), value.end(), '\0') == value.end()) + { + OSD::AddMessage(fmt::format("Scored {} on leaderboard: {}", + std::string_view{value.data(), value.size()}, + m_game_data.leaderboards[ix].title), + OSD::Duration::VERY_LONG, OSD::Color::YELLOW); + } + else + { + OSD::AddMessage(fmt::format("Scored {} on leaderboard: {}", value.data(), + m_game_data.leaderboards[ix].title), + OSD::Duration::VERY_LONG, OSD::Color::YELLOW); + } break; } } diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index 14b6b0ec77..a2e159c7e3 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -19,10 +19,6 @@ #include "Common/Event.h" #include "Common/WorkQueueThread.h" -using AchievementId = u32; -constexpr size_t RP_SIZE = 256; -using RichPresence = std::array; - namespace Core { class System; @@ -53,6 +49,12 @@ public: u32 soft_points; }; + using AchievementId = u32; + static constexpr size_t FORMAT_SIZE = 24; + using FormattedValue = std::array; + static constexpr size_t RP_SIZE = 256; + using RichPresence = std::array; + struct UnlockStatus { AchievementId game_data_index = 0;