Seperate drawable and updateable flag from Country + Use UpdateableFlag

This commit is contained in:
KingLuigi4932
2019-06-17 20:57:57 +03:00
parent 794ba17a2f
commit d665f1fe4b
8 changed files with 62 additions and 54 deletions

View File

@ -1,14 +1,7 @@
// 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 Newtonsoft.Json;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Users
{
@ -26,40 +19,4 @@ namespace osu.Game.Users
[JsonProperty(@"code")]
public string FlagName;
}
public class DrawableFlag : ModelBackedDrawable<Country>, IHasTooltip
{
private TextureStore textures;
private readonly Country country;
public Country Country
{
get => Model;
set => Model = value;
}
public string TooltipText => Country?.FullName;
public DrawableFlag(Country country = null)
{
this.country = country;
}
[BackgroundDependencyLoader]
private void load(TextureStore ts)
{
textures = ts ?? throw new ArgumentNullException(nameof(ts));
Country = country;
}
protected override Drawable CreateDrawable(Country country)
{
return new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get($@"Flags/{country?.FlagName ?? @"__"}"),
};
}
}
}