1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 14:42:56 +08:00

Created and implemened a BaseUpdateableFlag.

The tooltip still shows.
This commit is contained in:
yesseruser 2023-11-21 19:27:33 +01:00
parent 671177e871
commit cd7e0bf620
3 changed files with 48 additions and 14 deletions

View File

@ -12,14 +12,14 @@ namespace osu.Game.Screens.Play.HUD
{
public partial class PlayerFlag : CompositeDrawable, ISerialisableDrawable
{
private readonly ClickableUpdateableFlag flag;
private readonly BaseUpdateableFlag flag;
private const float default_size = 40f;
public PlayerFlag()
{
Size = new Vector2(default_size, default_size / 1.4f);
InternalChild = flag = new ClickableUpdateableFlag
InternalChild = flag = new BaseUpdateableFlag
{
RelativeSizeAxes = Axes.Both,
};

View File

@ -0,0 +1,45 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Users.Drawables
{
public partial class BaseUpdateableFlag : ModelBackedDrawable<CountryCode>
{
public CountryCode CountryCode
{
get => Model;
set => Model = value;
}
/// <summary>
/// Whether to show a place holder on unknown country.
/// </summary>
public bool ShowPlaceholderOnUnknown = true;
public BaseUpdateableFlag(CountryCode countryCode = CountryCode.Unknown)
{
CountryCode = countryCode;
}
protected override Drawable? CreateDrawable(CountryCode countryCode)
{
if (countryCode == CountryCode.Unknown && !ShowPlaceholderOnUnknown)
return null;
return new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new DrawableFlag(countryCode)
{
RelativeSizeAxes = Axes.Both
},
}
};
}
}
}

View File

@ -11,19 +11,8 @@ using osu.Game.Overlays;
namespace osu.Game.Users.Drawables
{
public partial class ClickableUpdateableFlag : ModelBackedDrawable<CountryCode>
public partial class ClickableUpdateableFlag : BaseUpdateableFlag
{
public CountryCode CountryCode
{
get => Model;
set => Model = value;
}
/// <summary>
/// Whether to show a place holder on unknown country.
/// </summary>
public bool ShowPlaceholderOnUnknown = true;
/// <summary>
/// Perform an action in addition to showing the country ranking.
/// This should be used to perform auxiliary tasks and not as a primary action for clicking a flag (to maintain a consistent UX).