mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:13:34 +08:00
Added a BaseDrawableFlag without a tooltip, and used it.
The BaseDrawableFlag is used in a BaseUpdateableFlag so the tooltip is not shown, the ClickableUpdateableFlag still shows the tooltip.
This commit is contained in:
parent
cd7e0bf620
commit
b2f74325ef
29
osu.Game/Users/Drawables/BaseDrawableFlag.cs
Normal file
29
osu.Game/Users/Drawables/BaseDrawableFlag.cs
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
|
||||
namespace osu.Game.Users.Drawables
|
||||
{
|
||||
public partial class BaseDrawableFlag : Sprite
|
||||
{
|
||||
protected readonly CountryCode CountryCode;
|
||||
|
||||
public BaseDrawableFlag(CountryCode countryCode)
|
||||
{
|
||||
CountryCode = countryCode;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore ts)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(ts);
|
||||
|
||||
string textureName = CountryCode == CountryCode.Unknown ? "__" : CountryCode.ToString();
|
||||
Texture = ts.Get($@"Flags/{textureName}") ?? ts.Get(@"Flags/__");
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,8 @@ namespace osu.Game.Users.Drawables
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DrawableFlag(countryCode)
|
||||
// This is a BaseDrawableFlag which does not show a tooltip.
|
||||
new BaseDrawableFlag(countryCode)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
|
@ -34,6 +34,7 @@ namespace osu.Game.Users.Drawables
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// This is a DrawableFlag which implements IHasTooltip, so a tooltip is shown.
|
||||
new DrawableFlag(countryCode)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
|
@ -5,29 +5,23 @@ using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Localisation;
|
||||
|
||||
namespace osu.Game.Users.Drawables
|
||||
{
|
||||
public partial class DrawableFlag : Sprite, IHasTooltip
|
||||
public partial class DrawableFlag : BaseDrawableFlag, IHasTooltip
|
||||
{
|
||||
private readonly CountryCode countryCode;
|
||||
public LocalisableString TooltipText => CountryCode == CountryCode.Unknown ? string.Empty : CountryCode.GetDescription();
|
||||
|
||||
public LocalisableString TooltipText => countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription();
|
||||
|
||||
public DrawableFlag(CountryCode countryCode)
|
||||
{
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
public DrawableFlag(CountryCode countryCode) : base(countryCode) { }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore ts)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(ts);
|
||||
|
||||
string textureName = countryCode == CountryCode.Unknown ? "__" : countryCode.ToString();
|
||||
string textureName = CountryCode == CountryCode.Unknown ? "__" : CountryCode.ToString();
|
||||
Texture = ts.Get($@"Flags/{textureName}") ?? ts.Get(@"Flags/__");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user