Support displaying team seed in TeamDisplay

This commit is contained in:
Salman Ahmed 2023-10-28 08:29:46 +03:00
parent c5ff708c6f
commit 28e331deed
4 changed files with 38 additions and 9 deletions

View File

@ -21,6 +21,7 @@ namespace osu.Game.Tournament.Tests.Components
{ {
FlagName = { Value = "AU" }, FlagName = { Value = "AU" },
FullName = { Value = "Australia" }, FullName = { Value = "Australia" },
Seed = { Value = "#5" },
Players = Players =
{ {
new TournamentUser { Username = "ASecretBox" }, new TournamentUser { Username = "ASecretBox" },
@ -30,7 +31,7 @@ namespace osu.Game.Tournament.Tests.Components
new TournamentUser { Username = "Parkes" }, new TournamentUser { Username = "Parkes" },
new TournamentUser { Username = "Shiroha" }, new TournamentUser { Username = "Shiroha" },
new TournamentUser { Username = "Jordan The Bear" }, new TournamentUser { Username = "Jordan The Bear" },
} },
}; };
var match = new TournamentMatch { Team1 = { Value = team } }; var match = new TournamentMatch { Team1 = { Value = team } };
@ -100,7 +101,7 @@ namespace osu.Game.Tournament.Tests.Components
Cell(i).AddRange(new Drawable[] Cell(i).AddRange(new Drawable[]
{ {
new TournamentSpriteText { Text = "TeamDisplay" }, new TournamentSpriteText { Text = "TeamDisplay" },
new TeamDisplay(team, TeamColour.Red, new Bindable<int?>(2), 6) new TeamDisplay(team, TeamColour.Red, new Bindable<int?>(2), 6, true)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -67,7 +67,7 @@ namespace osu.Game.Tournament.Tests
FlagName = { Value = "JP" }, FlagName = { Value = "JP" },
FullName = { Value = "Japan" }, FullName = { Value = "Japan" },
LastYearPlacing = { Value = 10 }, LastYearPlacing = { Value = 10 },
Seed = { Value = "Low" }, Seed = { Value = "#12" },
SeedingResults = SeedingResults =
{ {
new SeedingResult new SeedingResult
@ -140,6 +140,7 @@ namespace osu.Game.Tournament.Tests
Acronym = { Value = "USA" }, Acronym = { Value = "USA" },
FlagName = { Value = "US" }, FlagName = { Value = "US" },
FullName = { Value = "United States" }, FullName = { Value = "United States" },
Seed = { Value = "#3" },
Players = Players =
{ {
new TournamentUser { Username = "Hello" }, new TournamentUser { Username = "Hello" },

View File

@ -14,9 +14,11 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
{ {
private readonly TeamScore score; private readonly TeamScore score;
private readonly TournamentSpriteTextWithBackground teamText; private readonly TournamentSpriteTextWithBackground teamNameText;
private readonly TournamentSpriteTextWithBackground teamSeedText;
private readonly Bindable<string> teamName = new Bindable<string>("???"); private readonly Bindable<string> teamName = new Bindable<string>("???");
private readonly Bindable<string> teamSeed = new Bindable<string>();
private bool showScore; private bool showScore;
@ -35,7 +37,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
} }
} }
public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin) public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin, bool displaySeed)
: base(team) : base(team)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
@ -95,11 +97,29 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
} }
} }
}, },
teamText = new TournamentSpriteTextWithBackground new FillFlowContainer
{ {
Scale = new Vector2(0.5f), AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Origin = anchor, Origin = anchor,
Anchor = anchor, Anchor = anchor,
Children = new Drawable[]
{
teamNameText = new TournamentSpriteTextWithBackground
{
Scale = new Vector2(0.5f),
Origin = anchor,
Anchor = anchor,
},
teamSeedText = new TournamentSpriteTextWithBackground
{
Scale = new Vector2(0.5f),
Origin = anchor,
Anchor = anchor,
Alpha = displaySeed ? 1 : 0,
}
}
}, },
} }
}, },
@ -117,9 +137,13 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
FinishTransforms(true); FinishTransforms(true);
if (Team != null) if (Team != null)
{
teamName.BindTo(Team.FullName); teamName.BindTo(Team.FullName);
teamSeed.BindTo(Team.Seed);
}
teamName.BindValueChanged(name => teamText.Text.Text = name.NewValue, true); teamName.BindValueChanged(name => teamNameText.Text.Text = name.NewValue, true);
teamSeed.BindValueChanged(seed => teamSeedText.Text.Text = seed.NewValue, true);
} }
private void updateDisplay() private void updateDisplay()

View File

@ -21,6 +21,8 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
private TeamDisplay? teamDisplay; private TeamDisplay? teamDisplay;
public readonly BindableBool DisplaySeed = new BindableBool();
public bool ShowScore public bool ShowScore
{ {
get => teamDisplay?.ShowScore ?? false; get => teamDisplay?.ShowScore ?? false;
@ -48,6 +50,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
currentMatch.BindValueChanged(matchChanged); currentMatch.BindValueChanged(matchChanged);
currentTeam.BindValueChanged(teamChanged); currentTeam.BindValueChanged(teamChanged);
DisplaySeed.BindValueChanged(_ => currentTeam.TriggerChange());
updateMatch(); updateMatch();
} }
@ -101,7 +104,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
teamDisplay = new TeamDisplay(team.NewValue, teamColour, currentTeamScore, currentMatch.Value?.PointsToWin ?? 0), teamDisplay = new TeamDisplay(team.NewValue, teamColour, currentTeamScore, currentMatch.Value?.PointsToWin ?? 0, DisplaySeed.Value),
}; };
teamDisplay.ShowScore = wasShowingScores; teamDisplay.ShowScore = wasShowingScores;