mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
Add Cheevos::GetAchievementProgressText
Measured achievements formatting is now up to rcheevos, not DuckStation
This commit is contained in:
parent
9c91af6dfa
commit
9414f68f51
|
@ -4,7 +4,6 @@
|
|||
#include "common/log.h"
|
||||
#include "common/md5_digest.h"
|
||||
#include "common/platform.h"
|
||||
#include "common/string.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common/timestamp.h"
|
||||
#include "common_host_interface.h"
|
||||
|
@ -1377,6 +1376,15 @@ std::pair<u32, u32> GetAchievementProgress(const Achievement& achievement)
|
|||
return result;
|
||||
}
|
||||
|
||||
TinyString GetAchievementProgressText(const Achievement& achievement)
|
||||
{
|
||||
TinyString result;
|
||||
rc_runtime_format_achievement_measured(&s_rcheevos_runtime, achievement.id, result.GetWriteableCharArray(),
|
||||
result.GetWritableBufferSize());
|
||||
result.UpdateSize();
|
||||
return result;
|
||||
}
|
||||
|
||||
void CheevosEventHandler(const rc_runtime_event_t* runtime_event)
|
||||
{
|
||||
static const char* events[] = {"RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED", "RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "common/string.h"
|
||||
#include "core/types.h"
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
@ -114,6 +115,7 @@ u32 GetLeaderboardCount();
|
|||
bool IsLeaderboardTimeType(const Leaderboard& leaderboard);
|
||||
|
||||
std::pair<u32, u32> GetAchievementProgress(const Achievement& achievement);
|
||||
TinyString GetAchievementProgressText(const Achievement& achievement);
|
||||
|
||||
void UnlockAchievement(u32 achievement_id, bool add_notification = true);
|
||||
void SubmitLeaderboard(u32 leaderboard_id, int value);
|
||||
|
|
|
@ -4101,7 +4101,6 @@ static void DrawAchievement(const Cheevos::Achievement& cheevo)
|
|||
const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
|
||||
const ImRect title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
|
||||
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);
|
||||
SmallString text;
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, cheevo.title.c_str(), cheevo.title.c_str() + cheevo.title.size(),
|
||||
|
@ -4129,7 +4128,7 @@ static void DrawAchievement(const Cheevos::Achievement& cheevo)
|
|||
dl->AddRectFilled(progress_bb.Min, ImVec2(progress_bb.Min.x + fraction * progress_bb.GetWidth(), progress_bb.Max.y),
|
||||
ImGui::GetColorU32(ImGuiFullscreen::UISecondaryColor()));
|
||||
|
||||
text.Format("%u / %u", progress.first, progress.second);
|
||||
const TinyString text(GetAchievementProgressText(cheevo));
|
||||
const ImVec2 text_size = ImGui::CalcTextSize(text);
|
||||
const ImVec2 text_pos(progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
||||
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f));
|
||||
|
|
Loading…
Reference in a new issue