Merge pull request #9970 from MiraiSubject/flag-fit

This commit is contained in:
Dean Herbert 2020-10-26 19:41:22 +09:00 committed by GitHub
commit 19e58dc4fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 17 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(75, 50);
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

@ -27,6 +27,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
AcronymText.Origin = Anchor.TopCentre; AcronymText.Origin = Anchor.TopCentre;
AcronymText.Text = team.Acronym.Value.ToUpperInvariant(); AcronymText.Text = team.Acronym.Value.ToUpperInvariant();
AcronymText.Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 10); AcronymText.Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 10);
Flag.Scale = new Vector2(0.48f);
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {

View File

@ -29,7 +29,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
var anchor = flip ? Anchor.TopLeft : Anchor.TopRight; var anchor = flip ? Anchor.TopLeft : Anchor.TopRight;
Flag.RelativeSizeAxes = Axes.None; Flag.RelativeSizeAxes = Axes.None;
Flag.Size = new Vector2(60, 40); Flag.Scale = new Vector2(0.8f);
Flag.Origin = anchor; Flag.Origin = anchor;
Flag.Anchor = anchor; Flag.Anchor = anchor;

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.54f);
Flag.Anchor = Flag.Origin = Anchor.CentreLeft; Flag.Anchor = Flag.Origin = Anchor.CentreLeft;
AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft; AcronymText.Anchor = AcronymText.Origin = Anchor.CentreLeft;

View File

@ -288,8 +288,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Flag.RelativeSizeAxes = Axes.None; Flag.RelativeSizeAxes = Axes.None;
Flag.Size = new Vector2(300, 200); Flag.Scale = new Vector2(1.2f);
Flag.Scale = new Vector2(0.3f);
InternalChild = new FillFlowContainer InternalChild = new FillFlowContainer
{ {

View File

@ -90,11 +90,10 @@ namespace osu.Game.Tournament.Screens.TeamWin
{ {
new DrawableTeamFlag(match.Winner) new DrawableTeamFlag(match.Winner)
{ {
Size = new Vector2(300, 200),
Scale = new Vector2(0.5f),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Position = new Vector2(-300, 10), Position = new Vector2(-300, 10),
Scale = new Vector2(2f)
}, },
new FillFlowContainer new FillFlowContainer
{ {