mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 07:35:41 +00:00
Achievements: Display points in list window
This commit is contained in:
parent
e54dc9872b
commit
78b4fbb515
|
@ -1897,7 +1897,7 @@ std::pair<u32, u32> Achievements::GetAchievementProgress(const Achievement& achi
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Achievements::GetAchievementProgressText(const Achievement& achievement)
|
TinyString Achievements::GetAchievementProgressText(const Achievement& achievement)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
rc_runtime_format_achievement_measured(&s_rcheevos_runtime, achievement.id, buf, std::size(buf));
|
rc_runtime_format_achievement_measured(&s_rcheevos_runtime, achievement.id, buf, std::size(buf));
|
||||||
|
|
|
@ -147,7 +147,7 @@ u32 GetPrimedAchievementCount();
|
||||||
|
|
||||||
const Achievement* GetAchievementByID(u32 id);
|
const Achievement* GetAchievementByID(u32 id);
|
||||||
std::pair<u32, u32> GetAchievementProgress(const Achievement& achievement);
|
std::pair<u32, u32> GetAchievementProgress(const Achievement& achievement);
|
||||||
std::string GetAchievementProgressText(const Achievement& achievement);
|
TinyString GetAchievementProgressText(const Achievement& achievement);
|
||||||
const std::string& GetAchievementBadgePath(const Achievement& achievement, bool download_if_missing = true);
|
const std::string& GetAchievementBadgePath(const Achievement& achievement, bool download_if_missing = true);
|
||||||
std::string GetAchievementBadgeURL(const Achievement& achievement);
|
std::string GetAchievementBadgeURL(const Achievement& achievement);
|
||||||
|
|
||||||
|
|
|
@ -5347,7 +5347,6 @@ void FullscreenUI::DrawAchievement(const Achievements::Achievement& cheevo)
|
||||||
|
|
||||||
ImRect bb;
|
ImRect bb;
|
||||||
bool visible, hovered;
|
bool visible, hovered;
|
||||||
bool pressed =
|
|
||||||
MenuButtonFrame(id_str.c_str(), true,
|
MenuButtonFrame(id_str.c_str(), true,
|
||||||
!is_measured ? LAYOUT_MENU_BUTTON_HEIGHT :
|
!is_measured ? LAYOUT_MENU_BUTTON_HEIGHT :
|
||||||
LAYOUT_MENU_BUTTON_HEIGHT + progress_height_unscaled + progress_spacing_unscaled,
|
LAYOUT_MENU_BUTTON_HEIGHT + progress_height_unscaled + progress_spacing_unscaled,
|
||||||
|
@ -5368,23 +5367,40 @@ void FullscreenUI::DrawAchievement(const Achievements::Achievement& cheevo)
|
||||||
}
|
}
|
||||||
|
|
||||||
const float midpoint = bb.Min.y + g_large_font->FontSize + LayoutScale(4.0f);
|
const float midpoint = bb.Min.y + g_large_font->FontSize + LayoutScale(4.0f);
|
||||||
|
const auto points_text = TinyString::FromFmt("{} point{}", cheevo.points, cheevo.points != 1 ? "s" : "");
|
||||||
|
const ImVec2 points_template_size(g_medium_font->CalcTextSizeA(g_medium_font->FontSize, FLT_MAX, 0.0f, "XXX points"));
|
||||||
|
const ImVec2 points_size(g_medium_font->CalcTextSizeA(g_medium_font->FontSize, FLT_MAX, 0.0f,
|
||||||
|
points_text.GetCharArray(),
|
||||||
|
points_text.GetCharArray() + points_text.GetLength()));
|
||||||
|
const float points_template_start = bb.Max.x - points_template_size.x;
|
||||||
|
const float points_start = points_template_start + ((points_template_size.x - points_size.x) * 0.5f);
|
||||||
|
const char* lock_text = cheevo.locked ? ICON_FA_LOCK : ICON_FA_LOCK_OPEN;
|
||||||
|
const ImVec2 lock_size(g_large_font->CalcTextSizeA(g_large_font->FontSize, FLT_MAX, 0.0f, lock_text));
|
||||||
|
|
||||||
const float text_start_x = bb.Min.x + image_size.x + LayoutScale(15.0f);
|
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 title_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(points_start, midpoint));
|
||||||
const ImRect summary_bb(ImVec2(text_start_x, midpoint), bb.Max);
|
const ImRect summary_bb(ImVec2(text_start_x, midpoint), ImVec2(points_start, bb.Max.y));
|
||||||
|
const ImRect points_bb(ImVec2(points_start, midpoint), bb.Max);
|
||||||
|
const ImRect lock_bb(ImVec2(points_template_start + ((points_template_size.x - lock_size.x) * 0.5f), bb.Min.y),
|
||||||
|
ImVec2(bb.Max.x, midpoint));
|
||||||
|
|
||||||
ImGui::PushFont(g_large_font);
|
ImGui::PushFont(g_large_font);
|
||||||
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, cheevo.title.c_str(), cheevo.title.c_str() + cheevo.title.size(),
|
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, cheevo.title.c_str(), cheevo.title.c_str() + cheevo.title.size(),
|
||||||
nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
nullptr, ImVec2(0.0f, 0.0f), &title_bb);
|
||||||
|
ImGui::RenderTextClipped(lock_bb.Min, lock_bb.Max, lock_text, nullptr, &lock_size, ImVec2(0.0f, 0.0f), &lock_bb);
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
ImGui::PushFont(g_medium_font);
|
||||||
if (!cheevo.description.empty())
|
if (!cheevo.description.empty())
|
||||||
{
|
{
|
||||||
ImGui::PushFont(g_medium_font);
|
|
||||||
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, cheevo.description.c_str(),
|
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, cheevo.description.c_str(),
|
||||||
cheevo.description.c_str() + cheevo.description.size(), nullptr, ImVec2(0.0f, 0.0f),
|
cheevo.description.c_str() + cheevo.description.size(), nullptr, ImVec2(0.0f, 0.0f),
|
||||||
&summary_bb);
|
&summary_bb);
|
||||||
ImGui::PopFont();
|
|
||||||
}
|
}
|
||||||
|
ImGui::RenderTextClipped(points_bb.Min, points_bb.Max, points_text.GetCharArray(),
|
||||||
|
points_text.GetCharArray() + points_text.GetLength(), &points_size, ImVec2(0.0f, 0.0f),
|
||||||
|
&points_bb);
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
if (is_measured)
|
if (is_measured)
|
||||||
{
|
{
|
||||||
|
@ -5398,33 +5414,13 @@ void FullscreenUI::DrawAchievement(const Achievements::Achievement& cheevo)
|
||||||
dl->AddRectFilled(progress_bb.Min, ImVec2(progress_bb.Min.x + fraction * progress_bb.GetWidth(), progress_bb.Max.y),
|
dl->AddRectFilled(progress_bb.Min, ImVec2(progress_bb.Min.x + fraction * progress_bb.GetWidth(), progress_bb.Max.y),
|
||||||
ImGui::GetColorU32(ImGuiFullscreen::UISecondaryColor));
|
ImGui::GetColorU32(ImGuiFullscreen::UISecondaryColor));
|
||||||
|
|
||||||
const std::string text(Achievements::GetAchievementProgressText(cheevo));
|
const auto text = Achievements::GetAchievementProgressText(cheevo);
|
||||||
const ImVec2 text_size = ImGui::CalcTextSize(text.c_str());
|
const ImVec2 text_size = ImGui::CalcTextSize(text.GetCharArray(), text.GetCharArray() + text.GetLength());
|
||||||
const ImVec2 text_pos(progress_bb.Min.x + ((progress_bb.Max.x - progress_bb.Min.x) / 2.0f) - (text_size.x / 2.0f),
|
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));
|
progress_bb.Min.y + ((progress_bb.Max.y - progress_bb.Min.y) / 2.0f) - (text_size.y / 2.0f));
|
||||||
dl->AddText(g_medium_font, g_medium_font->FontSize, text_pos,
|
dl->AddText(g_medium_font, g_medium_font->FontSize, text_pos,
|
||||||
ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryTextColor), text.c_str(), text.c_str() + text.size());
|
ImGui::GetColorU32(ImGuiFullscreen::UIPrimaryTextColor), text.GetCharArray(),
|
||||||
}
|
text.GetCharArray() + text.GetLength());
|
||||||
|
|
||||||
#if 0
|
|
||||||
// The API doesn't seem to send us this :(
|
|
||||||
if (!cheevo.locked)
|
|
||||||
{
|
|
||||||
ImGui::PushFont(g_medium_font);
|
|
||||||
|
|
||||||
const ImRect time_bb(ImVec2(text_start_x, bb.Min.y),
|
|
||||||
ImVec2(bb.Max.x, bb.Min.y + g_medium_font->FontSize + LayoutScale(4.0f)));
|
|
||||||
text.Format("Unlocked 21 Feb, 2019 @ 3:14am");
|
|
||||||
ImGui::RenderTextClipped(time_bb.Min, time_bb.Max, text.GetCharArray(), text.GetCharArray() + text.GetLength(),
|
|
||||||
nullptr, ImVec2(1.0f, 0.0f), &time_bb);
|
|
||||||
ImGui::PopFont();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (pressed)
|
|
||||||
{
|
|
||||||
// TODO: What should we do here?
|
|
||||||
// Display information or something..
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,7 @@ ImFont* ImGuiManager::AddFixedFont(float size)
|
||||||
|
|
||||||
bool ImGuiManager::AddIconFonts(float size)
|
bool ImGuiManager::AddIconFonts(float size)
|
||||||
{
|
{
|
||||||
static constexpr ImWchar range_fa[] = { 0xf002,0xf002,0xf005,0xf005,0xf007,0xf007,0xf00c,0xf00e,0xf011,0xf011,0xf013,0xf013,0xf017,0xf017,0xf019,0xf019,0xf021,0xf021,0xf025,0xf025,0xf027,0xf028,0xf02d,0xf02e,0xf030,0xf030,0xf03a,0xf03a,0xf03d,0xf03d,0xf049,0xf04c,0xf050,0xf050,0xf059,0xf059,0xf05e,0xf05e,0xf065,0xf065,0xf067,0xf067,0xf071,0xf071,0xf075,0xf075,0xf077,0xf078,0xf07b,0xf07c,0xf084,0xf085,0xf091,0xf091,0xf0a0,0xf0a0,0xf0ac,0xf0ad,0xf0c5,0xf0c5,0xf0c7,0xf0c8,0xf0cb,0xf0cb,0xf0d0,0xf0d0,0xf0e2,0xf0e2,0xf0eb,0xf0eb,0xf0f1,0xf0f1,0xf0f3,0xf0f3,0xf0fe,0xf0fe,0xf110,0xf110,0xf119,0xf119,0xf11b,0xf11c,0xf140,0xf140,0xf144,0xf144,0xf14a,0xf14a,0xf15b,0xf15b,0xf188,0xf188,0xf191,0xf192,0xf1dd,0xf1de,0xf1e6,0xf1e6,0xf1eb,0xf1eb,0xf1f8,0xf1f8,0xf1fc,0xf1fc,0xf242,0xf242,0xf245,0xf245,0xf26c,0xf26c,0xf279,0xf279,0xf2d0,0xf2d0,0xf2db,0xf2db,0xf2f2,0xf2f2,0xf2f5,0xf2f5,0xf410,0xf410,0xf466,0xf466,0xf500,0xf500,0xf51f,0xf51f,0xf545,0xf545,0xf548,0xf548,0xf552,0xf552,0xf57a,0xf57a,0xf5a2,0xf5a2,0xf5e7,0xf5e7,0xf65d,0xf65e,0xf6a9,0xf6a9,0xf7c2,0xf7c2,0xf807,0xf807,0xf815,0xf815,0xf818,0xf818,0xf84c,0xf84c,0xf8cc,0xf8cc,0x0,0x0 };
|
static constexpr ImWchar range_fa[] = { 0xf002,0xf002,0xf005,0xf005,0xf007,0xf007,0xf00c,0xf00e,0xf011,0xf011,0xf013,0xf013,0xf017,0xf017,0xf019,0xf019,0xf021,0xf021,0xf023,0xf023,0xf025,0xf025,0xf027,0xf028,0xf02d,0xf02e,0xf030,0xf030,0xf03a,0xf03a,0xf03d,0xf03d,0xf049,0xf04c,0xf050,0xf050,0xf059,0xf059,0xf05e,0xf05e,0xf065,0xf065,0xf067,0xf067,0xf071,0xf071,0xf075,0xf075,0xf077,0xf078,0xf07b,0xf07c,0xf084,0xf085,0xf091,0xf091,0xf0a0,0xf0a0,0xf0ac,0xf0ad,0xf0c5,0xf0c5,0xf0c7,0xf0c8,0xf0cb,0xf0cb,0xf0d0,0xf0d0,0xf0e2,0xf0e2,0xf0eb,0xf0eb,0xf0f1,0xf0f1,0xf0f3,0xf0f3,0xf0fe,0xf0fe,0xf110,0xf110,0xf119,0xf119,0xf11b,0xf11c,0xf140,0xf140,0xf144,0xf144,0xf14a,0xf14a,0xf15b,0xf15b,0xf188,0xf188,0xf191,0xf192,0xf1dd,0xf1de,0xf1e6,0xf1e6,0xf1eb,0xf1eb,0xf1f8,0xf1f8,0xf1fc,0xf1fc,0xf242,0xf242,0xf245,0xf245,0xf26c,0xf26c,0xf279,0xf279,0xf2d0,0xf2d0,0xf2db,0xf2db,0xf2f2,0xf2f2,0xf2f5,0xf2f5,0xf3c1,0xf3c1,0xf410,0xf410,0xf466,0xf466,0xf500,0xf500,0xf51f,0xf51f,0xf545,0xf545,0xf548,0xf548,0xf552,0xf552,0xf57a,0xf57a,0xf5a2,0xf5a2,0xf5e7,0xf5e7,0xf65d,0xf65e,0xf6a9,0xf6a9,0xf7c2,0xf7c2,0xf807,0xf807,0xf815,0xf815,0xf818,0xf818,0xf84c,0xf84c,0xf8cc,0xf8cc,0x0,0x0 };
|
||||||
|
|
||||||
ImFontConfig cfg;
|
ImFontConfig cfg;
|
||||||
cfg.MergeMode = true;
|
cfg.MergeMode = true;
|
||||||
|
|
Loading…
Reference in a new issue