1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 06:27:27 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/PlayerFlag.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.6 KiB
C#
Raw Normal View History

2023-03-06 07:17:30 +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.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
2023-03-06 07:17:30 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
2023-03-06 07:17:30 +08:00
using osu.Game.Skinning;
using osu.Game.Users.Drawables;
using osuTK;
namespace osu.Game.Screens.Play.HUD
{
public partial class PlayerFlag : CompositeDrawable, ISerialisableDrawable
{
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos) => false;
private readonly UpdateableFlag flag;
2023-03-06 07:17:30 +08:00
private const float default_size = 40f;
[Resolved]
private GameplayState? gameplayState { get; set; }
[Resolved]
private IAPIProvider api { get; set; } = null!;
private IBindable<APIUser>? apiUser;
2023-03-06 07:17:30 +08:00
public PlayerFlag()
{
Size = new Vector2(default_size, default_size / 1.4f);
InternalChild = flag = new UpdateableFlag
2023-03-06 07:17:30 +08:00
{
RelativeSizeAxes = Axes.Both,
};
}
2023-03-07 16:01:29 +08:00
[BackgroundDependencyLoader]
private void load()
2023-03-06 07:17:30 +08:00
{
if (gameplayState != null)
flag.CountryCode = gameplayState.Score.ScoreInfo.User.CountryCode;
else
{
apiUser = api.LocalUser.GetBoundCopy();
apiUser.BindValueChanged(u => flag.CountryCode = u.NewValue.CountryCode, true);
}
2023-03-06 07:17:30 +08:00
}
public bool UsesFixedAnchor { get; set; }
}
}