From 943db2376d534a1c57ef4e5dcf30cfe37b2d606b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 15 Aug 2026 20:06:49 +1000 Subject: [PATCH] Achivements: Add rich presence monitor debug setting --- src/core/fullscreenui_achievements.cpp | 43 ++++++++++++++++++- src/core/settings.cpp | 2 + src/core/settings.h | 2 + src/core/system.cpp | 1 + src/duckstation-qt/advancedsettingswidget.cpp | 4 ++ src/duckstation-qt/advancedsettingswidget.ui | 9 +++- 6 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/core/fullscreenui_achievements.cpp b/src/core/fullscreenui_achievements.cpp index 522f82fba..8d4ad4eed 100644 --- a/src/core/fullscreenui_achievements.cpp +++ b/src/core/fullscreenui_achievements.cpp @@ -576,7 +576,6 @@ void FullscreenUI::DrawIndicators(NotificationLayout& layout) const float spacing = ImCeil(10.0f * scale); const ImVec2 padding = ImVec2(ImCeil(16.0f * scale), ImCeil(10.0f * scale)); const float rounding = ImCeil(10.0f * scale); - const float image_size = ImCeil(50.0f * scale); const float font_size = ImCeil(LAYOUT_MEDIUM_FONT_SIZE * scale); const ImGuiIO& io = ImGui::GetIO(); const bool blur_background = g_gpu_settings.display_blur_message_backgrounds && !FullscreenUI::HasActiveWindow() && @@ -588,6 +587,7 @@ void FullscreenUI::DrawIndicators(NotificationLayout& layout) (g_gpu_settings.achievements_challenge_indicator_mode == AchievementChallengeIndicatorMode::PersistentIcon || g_gpu_settings.achievements_challenge_indicator_mode == AchievementChallengeIndicatorMode::TemporaryIcon)) { + const float image_size = ImCeil(50.0f * scale); const bool use_time_remaining = (g_gpu_settings.achievements_challenge_indicator_mode == AchievementChallengeIndicatorMode::TemporaryIcon); const float x_advance = image_size + spacing; @@ -926,6 +926,47 @@ void FullscreenUI::DrawIndicators(NotificationLayout& layout) } } } + + if (const std::string& rich_presence = Achievements::GetRichPresenceString(); + g_gpu_settings.achievements_rich_presence_monitor && !rich_presence.empty()) + { + const ImVec2 text_size = + UIStyle.Font->CalcTextSizeA(font_size, font_weight, FLT_MAX, 0.0f, IMSTR_START_END(rich_presence)); + + // If the measuring hasn't begun yet, we don't want to display nothing + if (text_size.x > 0.0f) + { + const ImVec4 left_background_color = DarkerColor(UIStyle.ToastBackgroundColor, 1.3f); + const ImVec4 right_background_color = DarkerColor(UIStyle.ToastBackgroundColor, 0.8f); + static constexpr float pinned_bg_opacity = 0.7f; + + // Add image width + const ImVec2 image_size = ImVec2(font_size, font_size); + const float image_spacing = LayoutScale(8.0f); + const float box_padded_width = image_size.x + image_spacing + text_size.x + padding.x * 2.0f; + const float box_padded_height = std::max(text_size.y, image_size.y) + padding.y * 2.0f; + ImVec2 box_min = layout.GetFixedPosition(box_padded_width, box_padded_height); + ImVec2 box_max = box_min + ImVec2(box_padded_width, box_padded_height); + + // NOTE: Not blurred since they're persistent. + DrawRoundedGradientRect(dl, box_min, box_max, + ImGui::GetColorU32(ModAlpha(left_background_color, pinned_bg_opacity)), + ImGui::GetColorU32(ModAlpha(right_background_color, pinned_bg_opacity)), rounding); + + box_min += padding; + box_max -= padding; + + if (GPUTexture* tex = FullscreenUI::GetCachedTexture(Achievements::RA_LOGO_SVG_ICON_NAME, image_size)) + dl->AddImage(tex, box_min, box_min + image_size); + + box_min.x += image_size.x + image_spacing; + + const ImRect text_clip_rect(box_min, box_max); + RenderShadowedTextClipped(dl, UIStyle.Font, font_size, font_weight, box_min, box_max, + ImGui::GetColorU32(UIStyle.ToastTextColor), rich_presence, &text_size, + ImVec2(0.0f, 0.5f), 0.0f, &text_clip_rect); + } + } } void FullscreenUI::UpdateAchievementOverlaysRunIdle() diff --git a/src/core/settings.cpp b/src/core/settings.cpp index f0ff20913..b6ff08f00 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -537,6 +537,7 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro achievements_leaderboard_trackers = si.GetBoolValue("Cheevos", "LeaderboardTrackers", true); achievements_sound_effects = si.GetBoolValue("Cheevos", "SoundEffects", true); achievements_prefetch_badges = si.GetBoolValue("Cheevos", "PrefetchBadges", true); + achievements_rich_presence_monitor = si.GetBoolValue("Cheevos", "RichPresenceMonitor", false); achievements_notification_location = ParseNotificationLocation(si.GetStringViewValue("Cheevos", "NotificationLocation")) .value_or(DEFAULT_ACHIEVEMENT_NOTIFICATION_LOCATION); @@ -888,6 +889,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_user_prefs, bool for_copy si.SetBoolValue("Cheevos", "LeaderboardTrackers", achievements_leaderboard_trackers); si.SetBoolValue("Cheevos", "SoundEffects", achievements_sound_effects); si.SetBoolValue("Cheevos", "PrefetchBadges", achievements_prefetch_badges); + si.SetBoolValue("Cheevos", "RichPresenceMonitor", achievements_rich_presence_monitor); si.SetStringValue("Cheevos", "NotificationLocation", GetNotificationLocationName(achievements_notification_location)); si.SetStringValue("Cheevos", "IndicatorLocation", GetNotificationLocationName(achievements_indicator_location)); si.SetStringValue("Cheevos", "ChallengeIndicatorMode", diff --git a/src/core/settings.h b/src/core/settings.h index de2f7daff..2ec2cc771 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -121,6 +121,8 @@ struct GPUSettings bool display_show_enhancements : 1 = false; bool display_auto_resize_window : 1 = false; + bool achievements_rich_presence_monitor : 1 = false; + NotificationLocation display_osd_message_location = DEFAULT_OSD_MESSAGE_LOCATION; // achievements diff --git a/src/core/system.cpp b/src/core/system.cpp index 06e64d068..34f1eeccc 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -4576,6 +4576,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings) g_settings.display_osd_margin != old_settings.display_osd_margin || g_settings.display_osd_message_duration != old_settings.display_osd_message_duration || g_settings.display_osd_message_location != old_settings.display_osd_message_location || + g_settings.achievements_rich_presence_monitor != old_settings.achievements_rich_presence_monitor || g_settings.achievements_notification_location != old_settings.achievements_notification_location || g_settings.achievements_indicator_location != old_settings.achievements_indicator_location || g_settings.achievements_challenge_indicator_mode != old_settings.achievements_challenge_indicator_mode || diff --git a/src/duckstation-qt/advancedsettingswidget.cpp b/src/duckstation-qt/advancedsettingswidget.cpp index 6480abb84..d711e3952 100644 --- a/src/duckstation-qt/advancedsettingswidget.cpp +++ b/src/duckstation-qt/advancedsettingswidget.cpp @@ -48,6 +48,7 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsWindow* dialog, QWidget* SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.showDebugMenu, "Main", "ShowDebugMenu", false); connect(m_ui.showDebugMenu, &QCheckBox::checkStateChanged, this, &AdvancedSettingsWidget::onShowDebugOptionsStateChanged); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.richPresenceMonitor, "Cheevos", "RichPresenceMonitor", false); SettingWidgetBinder::BindWidgetToFolderSetting( sif, m_ui.cacheDirectory, m_ui.cacheDirectoryBrowse, tr("Select Cache Directory"), m_ui.cacheDirectoryOpen, @@ -77,6 +78,9 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(SettingsWindow* dialog, QWidget* tr("Includes the elapsed time since the application start in file logs.")); dialog->registerWidgetHelp(m_ui.showDebugMenu, tr("Show Debug Menu"), tr("Unchecked"), tr("Shows a debug menu bar with additional statistics and quick settings.")); + dialog->registerWidgetHelp( + m_ui.richPresenceMonitor, tr("Rich Presence Monitor"), tr("Unchecked"), + tr("Always displays the current RetroAchievements rich presence string in the indicator area.")); dialog->registerWidgetHelp(m_ui.cacheDirectory, tr("Cache Directory"), tr("Default"), tr("Specifies the directory where compiled shaders and game list data will be stored.")); diff --git a/src/duckstation-qt/advancedsettingswidget.ui b/src/duckstation-qt/advancedsettingswidget.ui index 8c8fa59ea..9a82d8bd9 100644 --- a/src/duckstation-qt/advancedsettingswidget.ui +++ b/src/duckstation-qt/advancedsettingswidget.ui @@ -7,7 +7,7 @@ 0 0 634 - 484 + 514 @@ -120,6 +120,13 @@ + + + Rich Presence Monitor + + + + Enable RAIntegration