Achievements: Show notification when challenge fails

If mode is set to notifications.
pull/3556/head
Stenzek 2 months ago
parent d7ed9a736d
commit c3e5075c60
No known key found for this signature in database

@ -79,6 +79,8 @@ static constexpr float ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME = 5.0f;
static constexpr float ACHIEVEMENT_SUMMARY_NOTIFICATION_TIME_HC = 10.0f;
static constexpr float ACHIEVEMENT_SUMMARY_UNSUPPORTED_TIME = 12.0f;
static constexpr float GAME_COMPLETE_NOTIFICATION_TIME = 20.0f;
static constexpr float CHALLENGE_STARTED_NOTIFICATION_TIME = 5.0f;
static constexpr float CHALLENGE_FAILED_NOTIFICATION_TIME = 5.0f;
static constexpr float LEADERBOARD_STARTED_NOTIFICATION_TIME = 3.0f;
static constexpr float LEADERBOARD_FAILED_NOTIFICATION_TIME = 3.0f;
@ -1729,16 +1731,18 @@ void Achievements::HandleAchievementChallengeIndicatorShowEvent(const rc_client_
// we still track these even if the option is disabled, so that they can be displayed in the pause menu
if (g_settings.achievements_challenge_indicator_mode == AchievementChallengeIndicatorMode::Notification)
{
std::string description = fmt::format(TRANSLATE_FS("Achievements", "Challenge Started: {}"),
event->achievement->description ? event->achievement->description : "");
GPUThread::RunOnThread([title = std::string(event->achievement->title), description = std::move(description),
badge_path, id = event->achievement->id]() mutable {
if (!FullscreenUI::Initialize())
return;
std::string title = fmt::format(TRANSLATE_FS("Achievements", "Challenge Started: {}"),
event->achievement->title ? event->achievement->title : "");
GPUThread::RunOnThread(
[title = std::move(title),
description = std::string(event->achievement->description ? event->achievement->description : ""), badge_path,
id = event->achievement->id]() mutable {
if (!FullscreenUI::Initialize())
return;
ImGuiFullscreen::AddNotification(fmt::format("AchievementChallenge{}", id), LEADERBOARD_STARTED_NOTIFICATION_TIME,
std::move(title), std::move(description), std::move(badge_path));
});
ImGuiFullscreen::AddNotification(fmt::format("AchievementChallenge{}", id), CHALLENGE_STARTED_NOTIFICATION_TIME,
std::move(title), std::move(description), std::move(badge_path));
});
}
s_state.active_challenge_indicators.push_back(
@ -1761,6 +1765,23 @@ void Achievements::HandleAchievementChallengeIndicatorHideEvent(const rc_client_
DEV_LOG("Hide challenge indicator for {} ({})", event->achievement->id, event->achievement->title);
if (g_settings.achievements_challenge_indicator_mode == AchievementChallengeIndicatorMode::Notification &&
event->achievement->state == RC_CLIENT_ACHIEVEMENT_STATE_ACTIVE)
{
std::string title = fmt::format(TRANSLATE_FS("Achievements", "Challenge Failed: {}"),
event->achievement->title ? event->achievement->title : "");
std::string badge_path = GetAchievementBadgePath(event->achievement, false);
GPUThread::RunOnThread(
[title = std::move(title),
description = std::string(event->achievement->description ? event->achievement->description : ""),
badge_path = std::move(badge_path), id = event->achievement->id]() mutable {
if (!FullscreenUI::Initialize())
return;
ImGuiFullscreen::AddNotification(fmt::format("AchievementChallenge{}", id), CHALLENGE_FAILED_NOTIFICATION_TIME,
std::move(title), std::move(description), std::move(badge_path));
});
}
if (g_settings.achievements_challenge_indicator_mode == AchievementChallengeIndicatorMode::Notification ||
g_settings.achievements_challenge_indicator_mode == AchievementChallengeIndicatorMode::Disabled)
{

@ -4148,7 +4148,7 @@ void ImGuiFullscreen::DrawNotifications(ImVec2& position, float spacing)
const float vertical_spacing = ImGuiFullscreen::LayoutScale(4.0f);
const float badge_size = ImGuiFullscreen::LayoutScale(48.0f);
const float min_width = ImGuiFullscreen::LayoutScale(200.0f);
const float max_width = ImGuiFullscreen::LayoutScale(800.0f);
const float max_width = ImGuiFullscreen::LayoutScale(600.0f);
const float max_text_width = max_width - badge_size - (horizontal_padding * 2.0f) - horizontal_spacing;
const float min_height = (vertical_padding * 2.0f) + badge_size;
const float shadow_size = ImGuiFullscreen::LayoutScale(2.0f);

Loading…
Cancel
Save