1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 19:04:06 +08:00

Revert "Added a BaseDrawableFlag without a tooltip, and used it."

This reverts commit b2f74325ef.
This commit is contained in:
yesseruser 2023-11-22 15:25:17 +01:00
parent 33de27499a
commit 7bc304f20e
4 changed files with 11 additions and 36 deletions

View File

@ -1,29 +0,0 @@
// 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/__");
}
}
}

View File

@ -34,8 +34,7 @@ namespace osu.Game.Users.Drawables
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
// This is a BaseDrawableFlag which does not show a tooltip. new DrawableFlag(countryCode)
new BaseDrawableFlag(countryCode)
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
}, },

View File

@ -34,7 +34,6 @@ namespace osu.Game.Users.Drawables
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
// This is a DrawableFlag which implements IHasTooltip, so a tooltip is shown.
new DrawableFlag(countryCode) new DrawableFlag(countryCode)
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both

View File

@ -5,23 +5,29 @@ using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation; using osu.Framework.Localisation;
namespace osu.Game.Users.Drawables namespace osu.Game.Users.Drawables
{ {
public partial class DrawableFlag : BaseDrawableFlag, IHasTooltip public partial class DrawableFlag : Sprite, IHasTooltip
{ {
public LocalisableString TooltipText => CountryCode == CountryCode.Unknown ? string.Empty : CountryCode.GetDescription(); private readonly CountryCode countryCode;
public DrawableFlag(CountryCode countryCode) : base(countryCode) { } public LocalisableString TooltipText => countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription();
public DrawableFlag(CountryCode countryCode)
{
this.countryCode = countryCode;
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore ts) private void load(TextureStore ts)
{ {
ArgumentNullException.ThrowIfNull(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/__"); Texture = ts.Get($@"Flags/{textureName}") ?? ts.Get(@"Flags/__");
} }
} }