2019-06-19 08:50:16 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2019-11-30 08:01:07 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-06-19 08:50:16 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-11-30 08:01:07 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2021-07-30 20:32:08 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-11-30 08:01:07 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2019-06-19 08:50:16 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Users.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class UpdateableFlag : ModelBackedDrawable<Country>
|
|
|
|
|
{
|
|
|
|
|
public Country Country
|
|
|
|
|
{
|
|
|
|
|
get => Model;
|
|
|
|
|
set => Model = value;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-20 01:17:02 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether to show a place holder on null country.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool ShowPlaceholderOnNull = true;
|
|
|
|
|
|
2019-07-16 05:15:03 +08:00
|
|
|
|
public UpdateableFlag(Country country = null)
|
2019-06-19 08:50:16 +08:00
|
|
|
|
{
|
|
|
|
|
Country = country;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-20 01:17:02 +08:00
|
|
|
|
protected override Drawable CreateDrawable(Country country)
|
2019-06-19 08:50:16 +08:00
|
|
|
|
{
|
2019-06-20 01:17:02 +08:00
|
|
|
|
if (country == null && !ShowPlaceholderOnNull)
|
|
|
|
|
return null;
|
|
|
|
|
|
2021-07-30 20:32:08 +08:00
|
|
|
|
return new Container
|
2019-06-20 01:17:02 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-07-30 20:32:08 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new DrawableFlag(country)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
new HoverClickSounds(HoverSampleSet.Submit)
|
|
|
|
|
}
|
2019-06-20 01:17:02 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2019-11-30 08:01:07 +08:00
|
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private RankingsOverlay rankingsOverlay { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
|
{
|
2019-12-01 08:56:03 +08:00
|
|
|
|
rankingsOverlay?.ShowCountry(Country);
|
2019-11-30 08:01:07 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-06-19 08:50:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|