1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Change TeamFlag from sprite to a container with a sprite

This commit is contained in:
Shivam 2020-08-24 15:08:50 +02:00
parent a4ba2181ec
commit d9ba677773
3 changed files with 21 additions and 12 deletions

View File

@ -4,19 +4,24 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osuTK;
namespace osu.Game.Tournament.Components namespace osu.Game.Tournament.Components
{ {
public class DrawableTeamFlag : Sprite public class DrawableTeamFlag : Container
{ {
private readonly TournamentTeam team; private readonly TournamentTeam team;
[UsedImplicitly] [UsedImplicitly]
private Bindable<string> flag; private Bindable<string> flag;
private Sprite flagSprite;
public DrawableTeamFlag(TournamentTeam team) public DrawableTeamFlag(TournamentTeam team)
{ {
this.team = team; this.team = team;
@ -27,7 +32,18 @@ namespace osu.Game.Tournament.Components
{ {
if (team == null) return; if (team == null) return;
(flag = team.FlagName.GetBoundCopy()).BindValueChanged(acronym => Texture = textures.Get($@"Flags/{team.FlagName}"), true); Size = new Vector2(70, 47);
Masking = true;
CornerRadius = 5;
Child = flagSprite = new Sprite
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill
};
(flag = team.FlagName.GetBoundCopy()).BindValueChanged(acronym => flagSprite.Texture = textures.Get($@"Flags/{team.FlagName}"), true);
} }
} }
} }

View File

@ -4,9 +4,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -17,7 +15,7 @@ namespace osu.Game.Tournament.Components
{ {
public readonly TournamentTeam Team; public readonly TournamentTeam Team;
protected readonly Sprite Flag; protected readonly Container Flag;
protected readonly TournamentSpriteText AcronymText; protected readonly TournamentSpriteText AcronymText;
[UsedImplicitly] [UsedImplicitly]
@ -27,12 +25,7 @@ namespace osu.Game.Tournament.Components
{ {
Team = team; Team = team;
Flag = new DrawableTeamFlag(team) Flag = new DrawableTeamFlag(team);
{
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit
};
AcronymText = new TournamentSpriteText AcronymText = new TournamentSpriteText
{ {
Font = OsuFont.Torus.With(weight: FontWeight.Regular), Font = OsuFont.Torus.With(weight: FontWeight.Regular),

View File

@ -63,7 +63,7 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
this.losers = losers; this.losers = losers;
Size = new Vector2(150, 40); Size = new Vector2(150, 40);
Flag.Scale = new Vector2(0.9f); Flag.Scale = new Vector2(0.6f);
Flag.Anchor = Flag.Origin = Anchor.CentreLeft; Flag.Anchor = Flag.Origin = Anchor.CentreLeft;
AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft; AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft;