mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Improve rendering of achievements with types other than normal
This commit is contained in:
1 parent
2b1fb469c9
commit
35a9dd643e
1 file changed
+13
-14
@@ -501,7 +501,7 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement
|
||||
dc.Flush();
|
||||
dc.Begin();
|
||||
|
||||
dc.SetFontStyle(dc.GetTheme().uiFont);
|
||||
dc.SetFontStyle(*GetTextStyle(dc, UI::TextSize::Normal));
|
||||
|
||||
char temp[512];
|
||||
|
||||
@@ -513,49 +513,47 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement
|
||||
{
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
std::string title = achievement->title;
|
||||
title.push_back(' ');
|
||||
std::string_view badge = "";
|
||||
|
||||
// Add simple display of the achievement types.
|
||||
// Needs refinement, but works.
|
||||
// See issue #19632
|
||||
switch (achievement->type) {
|
||||
case RC_CLIENT_ACHIEVEMENT_TYPE_MISSABLE:
|
||||
title += ApplySafeSubstitutions("[%1] ", ac->T("Missable"));
|
||||
badge = ac->T("Missable");
|
||||
break;
|
||||
case RC_CLIENT_ACHIEVEMENT_TYPE_PROGRESSION:
|
||||
title += ApplySafeSubstitutions("[%1] ", ac->T("Progression"));
|
||||
badge = ac->T("Progression");
|
||||
break;
|
||||
case RC_CLIENT_ACHIEVEMENT_TYPE_WIN:
|
||||
title += ApplySafeSubstitutions("[%1] ", ac->T("Win"));
|
||||
badge = ac->T("Win");
|
||||
break;
|
||||
}
|
||||
if (!title.empty() && title.back() == ' ') {
|
||||
title.pop_back();
|
||||
}
|
||||
|
||||
dc.DrawTextRect(title, bounds.Inset(iconSpace + 12.0f, 2.0f, padding, padding), fgColor, ALIGN_TOPLEFT);
|
||||
|
||||
dc.SetFontScale(0.66f, 0.66f);
|
||||
dc.SetFontStyle(*GetTextStyle(dc, UI::TextSize::Small));
|
||||
dc.DrawTextRectSqueeze(DeNull(achievement->description), bounds.Inset(iconSpace + 12.0f, 39.0f, padding, padding), fgColor, ALIGN_TOPLEFT);
|
||||
|
||||
dc.DrawTextRect(badge, bounds, fgColor, ALIGN_TOPRIGHT);
|
||||
|
||||
if (style == AchievementRenderStyle::LISTED && strlen(achievement->measured_progress) > 0) {
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
dc.SetFontStyle(*GetTextStyle(dc, UI::TextSize::Normal));
|
||||
dc.DrawTextRect(achievement->measured_progress, bounds.Inset(iconSpace + 12.0f, padding, padding + 100.0f, padding), fgColor, ALIGN_VCENTER | ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
// TODO: Draw measured_progress / measured_percent in a cute way
|
||||
snprintf(temp, sizeof(temp), "%d", achievement->points);
|
||||
|
||||
dc.SetFontScale(1.5f, 1.5f);
|
||||
dc.DrawTextRect(temp, bounds.Expand(-5.0f, -5.0f), fgColor, ALIGN_RIGHT | ALIGN_VCENTER);
|
||||
// The points number to the right.
|
||||
dc.SetFontStyle(*GetTextStyle(dc, UI::TextSize::Big));
|
||||
dc.DrawTextRect(temp, bounds.Expand(-5.0f, -5.0f), fgColor, ALIGN_RIGHT | (badge.empty() ? ALIGN_VCENTER : ALIGN_BOTTOMRIGHT));
|
||||
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
dc.Flush();
|
||||
break;
|
||||
}
|
||||
case AchievementRenderStyle::PROGRESS_INDICATOR:
|
||||
// TODO: Also render a progress bar.
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
dc.DrawTextRect(achievement->measured_progress, bounds.Inset(iconSpace + padding * 2.0f, padding, padding, padding), fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
// Show the unlocked icon.
|
||||
iconState = RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED;
|
||||
@@ -572,6 +570,7 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement
|
||||
if (g_iconCache.BindIconTexture(&dc, url)) {
|
||||
dc.Draw()->DrawTexRect(Bounds(bounds.x + padding, bounds.y + padding, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha));
|
||||
}
|
||||
dc.SetFontStyle(*GetTextStyle(dc, UI::TextSize::Normal));
|
||||
dc.Flush();
|
||||
dc.RebindTexture();
|
||||
dc.PopScissor();
|
||||
|
||||
Reference in new issue
Block a user