From d5be4bf8d40d6bcf16fb039a174555b446e8a441 Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Mon, 12 May 2025 14:51:14 +0300 Subject: [PATCH] Fix mod tooltip not handling settings changes to same mod instance --- osu.Game/Rulesets/UI/ModTooltip.cs | 43 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/osu.Game/Rulesets/UI/ModTooltip.cs b/osu.Game/Rulesets/UI/ModTooltip.cs index 07bb30e15a..6f60390798 100644 --- a/osu.Game/Rulesets/UI/ModTooltip.cs +++ b/osu.Game/Rulesets/UI/ModTooltip.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; +using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; @@ -101,36 +102,38 @@ namespace osu.Game.Rulesets.UI }; } - private Mod? displayedContent; + private (LocalisableString setting, LocalisableString value)[]? displayedSettings; public void SetContent(Mod content) { - if (content == displayedContent) - return; - - displayedContent = content; nameText.Text = content.Name; - settingsLabelsFlow.Clear(); - settingsValuesFlow.Clear(); - if (content.SettingDescription.Any()) + if (displayedSettings == null || !displayedSettings.SequenceEqual(content.SettingDescription)) { - settingsLabelsFlow.Show(); - settingsValuesFlow.Show(); + displayedSettings = content.SettingDescription.ToArray(); - foreach (var part in content.SettingDescription) + settingsLabelsFlow.Clear(); + settingsValuesFlow.Clear(); + + if (displayedSettings.Any()) { - settingsLabelsFlow.AddText(part.setting); - settingsLabelsFlow.NewLine(); + settingsLabelsFlow.Show(); + settingsValuesFlow.Show(); - settingsValuesFlow.AddText(part.value); - settingsValuesFlow.NewLine(); + foreach (var part in displayedSettings) + { + settingsLabelsFlow.AddText(part.setting); + settingsLabelsFlow.NewLine(); + + settingsValuesFlow.AddText(part.value); + settingsValuesFlow.NewLine(); + } + } + else + { + settingsLabelsFlow.Hide(); + settingsValuesFlow.Hide(); } - } - else - { - settingsLabelsFlow.Hide(); - settingsValuesFlow.Hide(); } }