Achievements: Improve summary popup

Put hardcore mode notice on its own line, rather than in
parenthesis in the title.
This commit is contained in:
Stenzek 2025-02-09 18:24:05 +10:00
parent 46ae3e55ea
commit 5fb5dcdd70
No known key found for this signature in database
1 changed files with 19 additions and 16 deletions

View File

@ -84,6 +84,7 @@ static constexpr u32 LEADERBOARD_ALL_FETCH_SIZE = 20;
static constexpr float LOGIN_NOTIFICATION_TIME = 5.0f; static constexpr float LOGIN_NOTIFICATION_TIME = 5.0f;
static constexpr float ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME = 5.0f; static constexpr float ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME = 5.0f;
static constexpr float ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME_HC = 10.0f;
static constexpr float GAME_COMPLETE_NOTIFICATION_TIME = 20.0f; static constexpr float GAME_COMPLETE_NOTIFICATION_TIME = 20.0f;
static constexpr float LEADERBOARD_STARTED_NOTIFICATION_TIME = 3.0f; static constexpr float LEADERBOARD_STARTED_NOTIFICATION_TIME = 3.0f;
static constexpr float LEADERBOARD_FAILED_NOTIFICATION_TIME = 3.0f; static constexpr float LEADERBOARD_FAILED_NOTIFICATION_TIME = 3.0f;
@ -1334,16 +1335,10 @@ void Achievements::DisplayAchievementSummary()
{ {
if (g_settings.achievements_notifications) if (g_settings.achievements_notifications)
{ {
std::string title; SmallString summary;
if (IsHardcoreModeActive())
title = fmt::format(TRANSLATE_FS("Achievements", "{} (Hardcore Mode)"), s_state.game_title);
else
title = s_state.game_title;
std::string summary;
if (s_state.game_summary.num_core_achievements > 0) if (s_state.game_summary.num_core_achievements > 0)
{ {
summary = fmt::format( summary.format(
TRANSLATE_FS("Achievements", "{0}, {1}."), TRANSLATE_FS("Achievements", "{0}, {1}."),
SmallString::from_format(TRANSLATE_PLURAL_FS("Achievements", "You have unlocked {} of %n achievements", SmallString::from_format(TRANSLATE_PLURAL_FS("Achievements", "You have unlocked {} of %n achievements",
"Achievement popup", s_state.game_summary.num_core_achievements), "Achievement popup", s_state.game_summary.num_core_achievements),
@ -1351,20 +1346,28 @@ void Achievements::DisplayAchievementSummary()
SmallString::from_format(TRANSLATE_PLURAL_FS("Achievements", "and earned {} of %n points", "Achievement popup", SmallString::from_format(TRANSLATE_PLURAL_FS("Achievements", "and earned {} of %n points", "Achievement popup",
s_state.game_summary.points_core), s_state.game_summary.points_core),
s_state.game_summary.points_unlocked)); s_state.game_summary.points_unlocked));
if (IsHardcoreModeActive())
{
summary.append('\n');
summary.append(
TRANSLATE_SV("Achievements", "Hardcore mode is enabled. Cheats and save states are unavailable."));
}
} }
else else
{ {
summary = TRANSLATE_STR("Achievements", "This game has no achievements."); summary.assign(TRANSLATE_SV("Achievements", "This game has no achievements."));
} }
GPUThread::RunOnThread( GPUThread::RunOnThread([title = s_state.game_title, summary = std::string(summary.view()), icon = s_state.game_icon,
[title = std::move(title), summary = std::move(summary), icon = s_state.game_icon]() mutable { time = IsHardcoreModeActive() ? ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME_HC :
if (!FullscreenUI::Initialize()) ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME]() mutable {
return; if (!FullscreenUI::Initialize())
return;
ImGuiFullscreen::AddNotification("achievement_summary", ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME, std::move(title), ImGuiFullscreen::AddNotification("achievement_summary", time, std::move(title), std::move(summary),
std::move(summary), std::move(icon)); std::move(icon));
}); });
} }
// Technically not going through the resource API, but since we're passing this to something else, we can't. // Technically not going through the resource API, but since we're passing this to something else, we can't.