diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 44981003f2..9c2a435cb0 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -42,6 +42,8 @@ namespace osu.Game.Beatmaps.Drawables private readonly Mod[]? mods; + private readonly bool showTooltip; + private Drawable background = null!; private readonly Container iconContainer; @@ -61,13 +63,15 @@ namespace osu.Game.Beatmaps.Drawables /// Creates a new . Will use provided beatmap's for initial value. /// /// The beatmap to be displayed in the tooltip, and to be used for the initial star rating value. - /// The mods type beat + /// An array of mods to account for in the calculations /// An optional ruleset to be used for the icon display, in place of the beatmap's ruleset. - public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null) + /// Whether to display a tooltip on hover. Defaults to false. + public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null, bool showTooltip = false) : this(ruleset ?? beatmap.Ruleset) { this.beatmap = beatmap; this.mods = mods; + this.showTooltip = showTooltip; Current.Value = new StarDifficulty(beatmap.StarRating, 0); } @@ -134,6 +138,6 @@ namespace osu.Game.Beatmaps.Drawables GetCustomTooltip() => new DifficultyIconTooltip(); DifficultyIconTooltipContent IHasCustomTooltip. - TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods) : null)!; + TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, showTooltip) : null)!; } } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index a4ba2a27f6..c5e276e6b4 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -31,6 +31,9 @@ namespace osu.Game.Beatmaps.Drawables private OsuSpriteText maxCombo; private OsuSpriteText length; + private FillFlowContainer difficultyFillFlowContainer; + private FillFlowContainer miscFillFlowContainer; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -69,21 +72,16 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.Centre, }, // Difficulty stats - new FillFlowContainer + difficultyFillFlowContainer = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Alpha = 0, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(5), Children = new Drawable[] { - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), - }, circleSize = new OsuSpriteText { Anchor = Anchor.Centre, @@ -111,21 +109,16 @@ namespace osu.Game.Beatmaps.Drawables } }, // Misc stats - new FillFlowContainer + miscFillFlowContainer = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Alpha = 0, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(5), Children = new Drawable[] { - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), - }, length = new OsuSpriteText { Anchor = Anchor.Centre, @@ -164,6 +157,13 @@ namespace osu.Game.Beatmaps.Drawables starRating.Current.BindTarget = displayedContent.Difficulty; difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; + // Don't show difficulty stats if showTooltip is false + if (!displayedContent.ShowTooltip) return; + + // Show the difficulty stats if showTooltip is true + difficultyFillFlowContainer.Show(); + miscFillFlowContainer.Show(); + double rate = 1; if (displayedContent.Mods != null) @@ -195,7 +195,7 @@ namespace osu.Game.Beatmaps.Drawables // Misc row length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString("mm\\:ss"); - bpm.Text = " BPM: " + bpmAdjusted; + bpm.Text = " BPM: " + Math.Round(bpmAdjusted, 0); maxCombo.Text = " Max Combo: " + displayedContent.BeatmapInfo.TotalObjectCount; } @@ -212,13 +212,15 @@ namespace osu.Game.Beatmaps.Drawables public readonly IBindable Difficulty; public readonly IRulesetInfo Ruleset; public readonly Mod[] Mods; + public readonly bool ShowTooltip; - public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods) + public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods, bool showTooltip = false) { BeatmapInfo = beatmapInfo; Difficulty = difficulty; Ruleset = rulesetInfo; Mods = mods; + ShowTooltip = showTooltip; } } } diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs index eb23ed6f8f..2a6387871f 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs @@ -283,7 +283,7 @@ namespace osu.Game.Screens.OnlinePlay } if (beatmap != null) - difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods) { Size = new Vector2(icon_height) }; + difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods, true) { Size = new Vector2(icon_height) }; else difficultyIconContainer.Clear();