mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Seperate drawable and updateable flag from Country + Use UpdateableFlag
This commit is contained in:
@ -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 ?? @"__"}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
47
osu.Game/Users/Drawables/DrawableFlag.cs
Normal file
47
osu.Game/Users/Drawables/DrawableFlag.cs
Normal file
@ -0,0 +1,47 @@
|
||||
// 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 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.Drawables
|
||||
{
|
||||
public class UpdateableFlag : ModelBackedDrawable<Country>
|
||||
{
|
||||
public Country Country
|
||||
{
|
||||
get => Model;
|
||||
set => Model = value;
|
||||
}
|
||||
|
||||
public UpdateableFlag(Country country = null) => Country = country;
|
||||
|
||||
protected override Drawable CreateDrawable(Country country) => new DrawableFlag(country)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
|
||||
public class DrawableFlag : Sprite, IHasTooltip
|
||||
{
|
||||
private readonly Country country;
|
||||
|
||||
public string TooltipText => country?.FullName;
|
||||
|
||||
public DrawableFlag(Country country) => this.country = country;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore ts)
|
||||
{
|
||||
if (ts == null)
|
||||
throw new ArgumentNullException(nameof(ts));
|
||||
|
||||
Texture = ts.Get($@"Flags/{country?.FlagName ?? @"__"}");
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays.Profile.Header.Components;
|
||||
using osu.Game.Users.Drawables;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
@ -137,7 +138,7 @@ namespace osu.Game.Users
|
||||
Spacing = new Vector2(5f, 0f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DrawableFlag(user.Country)
|
||||
new UpdateableFlag(user.Country)
|
||||
{
|
||||
Width = 30f,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
|
Reference in New Issue
Block a user