Merge pull request #25274 from frenzibyte/tournament-display-team-seed

Support displaying team seeds in tournament client
This commit is contained in:
Dean Herbert 2023-10-31 13:34:13 +09:00 committed by GitHub
commit 0ffd5104ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 79 additions and 11 deletions

View File

@ -1,6 +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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Tests.Visual;
@ -14,13 +15,19 @@ namespace osu.Game.Tournament.Tests.Components
{
public partial class TestSceneDrawableTournamentTeam : OsuGridTestScene
{
[Cached]
protected LadderInfo Ladder { get; private set; } = new LadderInfo();
public TestSceneDrawableTournamentTeam()
: base(4, 3)
{
AddToggleStep("toggle seed view", v => Ladder.DisplayTeamSeeds.Value = v);
var team = new TournamentTeam
{
FlagName = { Value = "AU" },
FullName = { Value = "Australia" },
Seed = { Value = "#5" },
Players =
{
new TournamentUser { Username = "ASecretBox" },
@ -30,7 +37,7 @@ namespace osu.Game.Tournament.Tests.Components
new TournamentUser { Username = "Parkes" },
new TournamentUser { Username = "Shiroha" },
new TournamentUser { Username = "Jordan The Bear" },
}
},
};
var match = new TournamentMatch { Team1 = { Value = team } };

View File

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

View File

@ -0,0 +1,45 @@
// 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;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Components
{
public partial class DrawableTeamSeed : TournamentSpriteTextWithBackground
{
private readonly TournamentTeam? team;
private IBindable<string> seed = null!;
private Bindable<bool> displaySeed = null!;
public DrawableTeamSeed(TournamentTeam? team)
{
this.team = team;
}
[Resolved]
private LadderInfo ladder { get; set; } = null!;
[BackgroundDependencyLoader]
private void load()
{
Text.Font = Text.Font.With(size: 36);
}
protected override void LoadComplete()
{
base.LoadComplete();
if (team == null)
return;
seed = team.Seed.GetBoundCopy();
seed.BindValueChanged(s => Text.Text = s.NewValue, true);
displaySeed = ladder.DisplayTeamSeeds.GetBoundCopy();
displaySeed.BindValueChanged(v => Alpha = v.NewValue ? 1 : 0, true);
}
}
}

View File

@ -18,11 +18,12 @@ namespace osu.Game.Tournament.Components
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new DrawableTeamHeader(colour),
new DrawableTeamTitle(team),
new DrawableTeamSeed(team),
}
};
}

View File

@ -30,7 +30,7 @@ namespace osu.Game.Tournament.Components
Colour = TournamentGame.ELEMENT_FOREGROUND_COLOUR,
Font = OsuFont.Torus.With(weight: FontWeight.SemiBold, size: 50),
Padding = new MarginPadding { Left = 10, Right = 20 },
Text = text
Text = text,
}
};
}

View File

@ -42,5 +42,7 @@ namespace osu.Game.Tournament.Models
public Bindable<bool> AutoProgressScreens = new BindableBool(true);
public Bindable<bool> SplitMapPoolByMods = new BindableBool(true);
public Bindable<bool> DisplayTeamSeeds = new BindableBool();
}
}

View File

@ -14,7 +14,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
{
private readonly TeamScore score;
private readonly TournamentSpriteTextWithBackground teamText;
private readonly TournamentSpriteTextWithBackground teamNameText;
private readonly Bindable<string> teamName = new Bindable<string>("???");
@ -95,7 +95,13 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
}
}
},
teamText = new TournamentSpriteTextWithBackground
teamNameText = new TournamentSpriteTextWithBackground
{
Scale = new Vector2(0.5f),
Origin = anchor,
Anchor = anchor,
},
new DrawableTeamSeed(Team)
{
Scale = new Vector2(0.5f),
Origin = anchor,
@ -119,7 +125,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components
if (Team != null)
teamName.BindTo(Team.FullName);
teamName.BindValueChanged(name => teamText.Text.Text = name.NewValue, true);
teamName.BindValueChanged(name => teamNameText.Text.Text = name.NewValue, true);
}
private void updateDisplay()

View File

@ -36,7 +36,7 @@ namespace osu.Game.Tournament.Screens.Gameplay
private Drawable chroma = null!;
[BackgroundDependencyLoader]
private void load(LadderInfo ladder, MatchIPCInfo ipc)
private void load(MatchIPCInfo ipc)
{
this.ipc = ipc;
@ -49,7 +49,7 @@ namespace osu.Game.Tournament.Screens.Gameplay
},
header = new MatchHeader
{
ShowLogo = false
ShowLogo = false,
},
new Container
{
@ -118,12 +118,12 @@ namespace osu.Game.Tournament.Screens.Gameplay
LabelText = "Players per team",
Current = LadderInfo.PlayersPerTeam,
KeyboardStep = 1,
}
},
}
}
});
ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);
LadderInfo.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);
warmup.BindValueChanged(w =>
{

View File

@ -140,6 +140,12 @@ namespace osu.Game.Tournament.Screens.Setup
Description = "Screens will progress automatically from gameplay -> results -> map pool",
Current = LadderInfo.AutoProgressScreens,
},
new LabelledSwitchButton
{
Label = "Display team seeds",
Description = "Team seeds will display alongside each team at the top in gameplay/map pool screens.",
Current = LadderInfo.DisplayTeamSeeds,
},
};
}