Merge pull request #12030 from LillyJadeKatrin/retroachievements-bugfix-3

RetroAchievements - Fixed Leaderboard Scored message format
This commit is contained in:
Admiral H. Curtiss 2023-08-28 23:28:37 +02:00 committed by GitHub
commit 357db03fc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 8 deletions

View File

@ -585,7 +585,7 @@ void AchievementManager::ActivateDeactivateAchievement(AchievementId id, bool en
rc_runtime_deactivate_achievement(&m_runtime, id); rc_runtime_deactivate_achievement(&m_runtime, id);
} }
RichPresence AchievementManager::GenerateRichPresence() AchievementManager::RichPresence AchievementManager::GenerateRichPresence()
{ {
RichPresence rp_buffer; RichPresence rp_buffer;
Core::RunAsCPUThread([&] { Core::RunAsCPUThread([&] {
@ -716,9 +716,22 @@ void AchievementManager::HandleLeaderboardTriggeredEvent(const rc_runtime_event_
{ {
if (m_game_data.leaderboards[ix].id == runtime_event->id) if (m_game_data.leaderboards[ix].id == runtime_event->id)
{ {
OSD::AddMessage(fmt::format("Scored {} on leaderboard: {}", runtime_event->value, FormattedValue value{};
rc_runtime_format_lboard_value(value.data(), static_cast<int>(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), m_game_data.leaderboards[ix].title),
OSD::Duration::VERY_LONG, OSD::Color::YELLOW); 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; break;
} }
} }

View File

@ -19,10 +19,6 @@
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/WorkQueueThread.h" #include "Common/WorkQueueThread.h"
using AchievementId = u32;
constexpr size_t RP_SIZE = 256;
using RichPresence = std::array<char, RP_SIZE>;
namespace Core namespace Core
{ {
class System; class System;
@ -53,6 +49,12 @@ public:
u32 soft_points; u32 soft_points;
}; };
using AchievementId = u32;
static constexpr size_t FORMAT_SIZE = 24;
using FormattedValue = std::array<char, FORMAT_SIZE>;
static constexpr size_t RP_SIZE = 256;
using RichPresence = std::array<char, RP_SIZE>;
struct UnlockStatus struct UnlockStatus
{ {
AchievementId game_data_index = 0; AchievementId game_data_index = 0;