mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:47:46 +08:00
Substitute two jank interdependent bool flags for single tri-state enums
This commit is contained in:
parent
47db317df8
commit
d06c67ad8f
@ -50,18 +50,12 @@ namespace osu.Game.Tests.Visual.Beatmaps
|
||||
fill.Add(difficultyIcon = new DifficultyIcon(beatmapInfo, rulesetInfo)
|
||||
{
|
||||
Scale = new Vector2(2),
|
||||
ShowTooltip = true,
|
||||
ShowExtendedTooltip = true
|
||||
});
|
||||
}, 10);
|
||||
|
||||
AddStep("hide extended tooltip", () => difficultyIcon.ShowExtendedTooltip = false);
|
||||
|
||||
AddStep("hide tooltip", () => difficultyIcon.ShowTooltip = false);
|
||||
|
||||
AddStep("show tooltip", () => difficultyIcon.ShowTooltip = true);
|
||||
|
||||
AddStep("show extended tooltip", () => difficultyIcon.ShowExtendedTooltip = true);
|
||||
AddStep("no tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.None);
|
||||
AddStep("basic tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.StarRating);
|
||||
AddStep("extended tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.Extended);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,14 +32,9 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to display a tooltip on hover. Only works if a beatmap was provided at construction time.
|
||||
/// Which type of tooltip to show. Only works if a beatmap was provided at construction time.
|
||||
/// </summary>
|
||||
public bool ShowTooltip { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to include the difficulty stats in the tooltip or not. Defaults to false. Has no effect if <see cref="ShowTooltip"/> is false.
|
||||
/// </summary>
|
||||
public bool ShowExtendedTooltip { get; set; }
|
||||
public DifficultyIconTooltipType TooltipType { get; set; } = DifficultyIconTooltipType.StarRating;
|
||||
|
||||
private readonly IBeatmapInfo? beatmap;
|
||||
|
||||
@ -138,6 +133,24 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
GetCustomTooltip() => new DifficultyIconTooltip();
|
||||
|
||||
DifficultyIconTooltipContent IHasCustomTooltip<DifficultyIconTooltipContent>.
|
||||
TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, ShowExtendedTooltip) : null)!;
|
||||
TooltipContent => (TooltipType != DifficultyIconTooltipType.None && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, TooltipType) : null)!;
|
||||
}
|
||||
|
||||
public enum DifficultyIconTooltipType
|
||||
{
|
||||
/// <summary>
|
||||
/// No tooltip.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Star rating only.
|
||||
/// </summary>
|
||||
StarRating,
|
||||
|
||||
/// <summary>
|
||||
/// Star rating, OD, HP, CS, AR, length, BPM, and max combo.
|
||||
/// </summary>
|
||||
Extended,
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
starRating.Current.BindTarget = displayedContent.Difficulty;
|
||||
difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName;
|
||||
|
||||
if (!displayedContent.ShowExtendedTooltip)
|
||||
if (displayedContent.TooltipType == DifficultyIconTooltipType.StarRating)
|
||||
{
|
||||
difficultyFillFlowContainer.Hide();
|
||||
miscFillFlowContainer.Hide();
|
||||
@ -166,15 +166,18 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
public readonly IBindable<StarDifficulty> Difficulty;
|
||||
public readonly IRulesetInfo Ruleset;
|
||||
public readonly Mod[]? Mods;
|
||||
public readonly bool ShowExtendedTooltip;
|
||||
public readonly DifficultyIconTooltipType TooltipType;
|
||||
|
||||
public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable<StarDifficulty> difficulty, IRulesetInfo rulesetInfo, Mod[]? mods, bool showExtendedTooltip = false)
|
||||
public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable<StarDifficulty> difficulty, IRulesetInfo rulesetInfo, Mod[]? mods, DifficultyIconTooltipType tooltipType)
|
||||
{
|
||||
if (tooltipType == DifficultyIconTooltipType.None)
|
||||
throw new ArgumentOutOfRangeException(nameof(tooltipType), tooltipType, "Cannot instantiate a tooltip without a type");
|
||||
|
||||
BeatmapInfo = beatmapInfo;
|
||||
Difficulty = difficulty;
|
||||
Ruleset = rulesetInfo;
|
||||
Mods = mods;
|
||||
ShowExtendedTooltip = showExtendedTooltip;
|
||||
TooltipType = tooltipType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
},
|
||||
icon = new DifficultyIcon(beatmapInfo, ruleset)
|
||||
{
|
||||
ShowTooltip = false,
|
||||
TooltipType = DifficultyIconTooltipType.None,
|
||||
Current = { Value = new StarDifficulty(beatmapInfo.StarRating, 0) },
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -285,7 +285,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods)
|
||||
{
|
||||
Size = new Vector2(icon_height),
|
||||
ShowExtendedTooltip = true
|
||||
TooltipType = DifficultyIconTooltipType.Extended,
|
||||
};
|
||||
}
|
||||
else
|
||||
|
@ -122,7 +122,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
difficultyIcon = new DifficultyIcon(beatmapInfo)
|
||||
{
|
||||
ShowTooltip = false,
|
||||
TooltipType = DifficultyIconTooltipType.None,
|
||||
Scale = new Vector2(1.8f),
|
||||
},
|
||||
new FillFlowContainer
|
||||
|
Loading…
Reference in New Issue
Block a user