Achivements: Add rich presence monitor debug setting

pull/3782/head
Stenzek 1 month ago
parent 527b402c65
commit 943db2376d
No known key found for this signature in database

@ -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()

@ -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",

@ -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

@ -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 ||

@ -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."));

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>634</width>
<height>484</height>
<height>514</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -120,6 +120,13 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="richPresenceMonitor">
<property name="text">
<string>Rich Presence Monitor</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="useRAIntegration">
<property name="text">
<string>Enable RAIntegration</string>

Loading…
Cancel
Save