2019-06-19 00:50:16 +00: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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-06-24 16:24:31 +00:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2019-06-19 00:50:16 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Users.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class UpdateableFlag : ModelBackedDrawable<Country>
|
|
|
|
|
{
|
|
|
|
|
public Country Country
|
|
|
|
|
{
|
|
|
|
|
get => Model;
|
|
|
|
|
set => Model = value;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-24 08:51:45 +00:00
|
|
|
|
protected override bool TransformImmediately { get; }
|
|
|
|
|
|
2019-06-19 17:17:02 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether to show a place holder on null country.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool ShowPlaceholderOnNull = true;
|
|
|
|
|
|
2019-06-24 16:24:31 +00:00
|
|
|
|
public UpdateableFlag(Country country = null, bool hideImmediately = false)
|
2019-06-19 00:50:16 +00:00
|
|
|
|
{
|
2019-06-24 16:24:31 +00:00
|
|
|
|
TransformImmediately = hideImmediately;
|
2019-06-19 00:50:16 +00:00
|
|
|
|
Country = country;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-24 16:24:31 +00:00
|
|
|
|
protected override TransformSequence<Drawable> ApplyHideTransforms(Drawable drawable) => TransformImmediately ? drawable?.FadeOut() : base.ApplyHideTransforms(drawable);
|
|
|
|
|
|
2019-06-19 17:17:02 +00:00
|
|
|
|
protected override Drawable CreateDrawable(Country country)
|
2019-06-19 00:50:16 +00:00
|
|
|
|
{
|
2019-06-19 17:17:02 +00:00
|
|
|
|
if (country == null && !ShowPlaceholderOnNull)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return new DrawableFlag(country)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
};
|
|
|
|
|
}
|
2019-06-19 00:50:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|