Avoid tooltip display

This commit is contained in:
Dean Herbert 2021-01-26 19:11:19 +09:00
parent b036f0165a
commit a5f3418e56
3 changed files with 16 additions and 16 deletions

View File

@ -50,7 +50,7 @@ namespace osu.Game.Tournament.Components
if (modIcon == null)
return;
AddInternal(new ModIcon(modIcon)
AddInternal(new ModIcon(modIcon, false)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -236,13 +236,13 @@ namespace osu.Game.Overlays.Mods
{
iconsContainer.AddRange(new[]
{
backgroundIcon = new PassThroughTooltipModIcon(Mods[1])
backgroundIcon = new ModIcon(Mods[1], false)
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
Position = new Vector2(1.5f),
},
foregroundIcon = new PassThroughTooltipModIcon(Mods[0])
foregroundIcon = new ModIcon(Mods[0], false)
{
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
@ -252,7 +252,7 @@ namespace osu.Game.Overlays.Mods
}
else
{
iconsContainer.Add(foregroundIcon = new PassThroughTooltipModIcon(Mod)
iconsContainer.Add(foregroundIcon = new ModIcon(Mod, false)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
@ -297,15 +297,5 @@ namespace osu.Game.Overlays.Mods
Mod = mod;
}
private class PassThroughTooltipModIcon : ModIcon
{
public override string TooltipText => null;
public PassThroughTooltipModIcon(Mod mod)
: base(mod)
{
}
}
}
}

View File

@ -16,6 +16,9 @@ using osu.Framework.Bindables;
namespace osu.Game.Rulesets.UI
{
/// <summary>
/// Display the specified mod at a fixed size.
/// </summary>
public class ModIcon : Container, IHasTooltip
{
public readonly BindableBool Selected = new BindableBool();
@ -28,9 +31,10 @@ namespace osu.Game.Rulesets.UI
private readonly ModType type;
public virtual string TooltipText => mod.IconTooltip;
public virtual string TooltipText => showTooltip ? mod.IconTooltip : null;
private Mod mod;
private readonly bool showTooltip;
public Mod Mod
{
@ -42,9 +46,15 @@ namespace osu.Game.Rulesets.UI
}
}
public ModIcon(Mod mod)
/// <summary>
/// Construct a new instance.
/// </summary>
/// <param name="mod">The mod to be displayed</param>
/// <param name="showTooltip">Whether a tooltip describing the mod should display on hover.</param>
public ModIcon(Mod mod, bool showTooltip = true)
{
this.mod = mod ?? throw new ArgumentNullException(nameof(mod));
this.showTooltip = showTooltip;
type = mod.Type;