1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 05:42:55 +08:00
osu-lazer/osu.Game/Users/Drawables/UpdateableFlag.cs

60 lines
1.6 KiB
C#

// 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.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
namespace osu.Game.Users.Drawables
{
public class UpdateableFlag : ModelBackedDrawable<Country>
{
public Country Country
{
get => Model;
set => Model = value;
}
/// <summary>
/// Whether to show a place holder on null country.
/// </summary>
public bool ShowPlaceholderOnNull = true;
public UpdateableFlag(Country country = null)
{
Country = country;
}
protected override Drawable CreateDrawable(Country country)
{
if (country == null && !ShowPlaceholderOnNull)
return null;
return new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new DrawableFlag(country)
{
RelativeSizeAxes = Axes.Both
},
new HoverClickSounds(HoverSampleSet.Submit)
}
};
}
[Resolved(canBeNull: true)]
private RankingsOverlay rankingsOverlay { get; set; }
protected override bool OnClick(ClickEvent e)
{
rankingsOverlay?.ShowCountry(Country);
return true;
}
}
}