2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2020-03-06 15:07:54 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2020-03-07 11:51:11 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2020-03-06 15:07:54 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Tournament.Components;
|
|
|
|
|
using osu.Game.Tournament.Models;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.Gameplay.Components
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class TeamDisplay : DrawableTournamentTeam
|
2020-03-06 15:07:54 +08:00
|
|
|
|
{
|
2020-03-07 13:46:40 +08:00
|
|
|
|
private readonly TeamScore score;
|
|
|
|
|
|
2023-10-28 13:29:46 +08:00
|
|
|
|
private readonly TournamentSpriteTextWithBackground teamNameText;
|
2022-07-13 17:10:27 +08:00
|
|
|
|
|
|
|
|
|
private readonly Bindable<string> teamName = new Bindable<string>("???");
|
|
|
|
|
|
2021-04-04 04:24:55 +08:00
|
|
|
|
private bool showScore;
|
|
|
|
|
|
2020-06-09 23:09:29 +08:00
|
|
|
|
public bool ShowScore
|
|
|
|
|
{
|
2021-04-04 04:24:55 +08:00
|
|
|
|
get => showScore;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (showScore == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
showScore = value;
|
|
|
|
|
|
|
|
|
|
if (IsLoaded)
|
2021-04-04 17:41:40 +08:00
|
|
|
|
updateDisplay();
|
2021-04-04 04:24:55 +08:00
|
|
|
|
}
|
2020-06-09 23:09:29 +08:00
|
|
|
|
}
|
2020-03-07 13:46:40 +08:00
|
|
|
|
|
2023-10-28 14:25:55 +08:00
|
|
|
|
public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin)
|
2020-03-06 15:07:54 +08:00
|
|
|
|
: base(team)
|
|
|
|
|
{
|
2020-03-07 11:51:11 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2020-03-06 15:07:54 +08:00
|
|
|
|
|
2020-03-07 11:51:11 +08:00
|
|
|
|
bool flip = colour == TeamColour.Red;
|
2020-03-06 15:07:54 +08:00
|
|
|
|
|
2020-03-07 11:51:11 +08:00
|
|
|
|
var anchor = flip ? Anchor.TopLeft : Anchor.TopRight;
|
2020-03-06 15:07:54 +08:00
|
|
|
|
|
|
|
|
|
Flag.RelativeSizeAxes = Axes.None;
|
2020-10-23 20:11:29 +08:00
|
|
|
|
Flag.Scale = new Vector2(0.8f);
|
2020-03-07 11:51:11 +08:00
|
|
|
|
Flag.Origin = anchor;
|
|
|
|
|
Flag.Anchor = anchor;
|
|
|
|
|
|
|
|
|
|
Margin = new MarginPadding(20);
|
2020-03-06 15:07:54 +08:00
|
|
|
|
|
|
|
|
|
InternalChild = new Container
|
|
|
|
|
{
|
2020-03-07 11:51:11 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2020-03-06 15:07:54 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-03-07 11:51:11 +08:00
|
|
|
|
new FillFlowContainer
|
2020-03-06 15:07:54 +08:00
|
|
|
|
{
|
2020-03-07 11:51:11 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
Flag,
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Origin = anchor,
|
|
|
|
|
Anchor = anchor,
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5),
|
2020-09-14 03:03:46 +08:00
|
|
|
|
Origin = anchor,
|
|
|
|
|
Anchor = anchor,
|
2020-03-07 11:51:11 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new DrawableTeamHeader(colour)
|
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(0.75f),
|
|
|
|
|
Origin = anchor,
|
|
|
|
|
Anchor = anchor,
|
|
|
|
|
},
|
2020-03-07 13:46:40 +08:00
|
|
|
|
score = new TeamScore(currentTeamScore, colour, pointsToWin)
|
2020-03-07 11:51:11 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = anchor,
|
|
|
|
|
Anchor = anchor,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-10-28 13:29:46 +08:00
|
|
|
|
new FillFlowContainer
|
2020-03-07 11:51:11 +08:00
|
|
|
|
{
|
2023-10-28 13:29:46 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5),
|
2020-03-07 11:51:11 +08:00
|
|
|
|
Origin = anchor,
|
|
|
|
|
Anchor = anchor,
|
2023-10-28 13:29:46 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
teamNameText = new TournamentSpriteTextWithBackground
|
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(0.5f),
|
|
|
|
|
Origin = anchor,
|
|
|
|
|
Anchor = anchor,
|
|
|
|
|
},
|
2023-10-28 14:25:55 +08:00
|
|
|
|
new DrawableTeamSeed(Team)
|
2023-10-28 13:29:46 +08:00
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(0.5f),
|
|
|
|
|
Origin = anchor,
|
|
|
|
|
Anchor = anchor,
|
2023-10-28 14:25:55 +08:00
|
|
|
|
},
|
2023-10-28 13:29:46 +08:00
|
|
|
|
}
|
2020-03-07 11:51:11 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
2020-03-06 15:07:54 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-04-04 04:24:55 +08:00
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2021-04-04 17:41:40 +08:00
|
|
|
|
|
|
|
|
|
updateDisplay();
|
|
|
|
|
FinishTransforms(true);
|
2022-07-13 17:10:27 +08:00
|
|
|
|
|
|
|
|
|
if (Team != null)
|
|
|
|
|
teamName.BindTo(Team.FullName);
|
|
|
|
|
|
2023-10-28 13:29:46 +08:00
|
|
|
|
teamName.BindValueChanged(name => teamNameText.Text.Text = name.NewValue, true);
|
2021-04-04 17:41:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDisplay()
|
|
|
|
|
{
|
|
|
|
|
score.FadeTo(ShowScore ? 1 : 0, 200);
|
2021-04-04 04:24:55 +08:00
|
|
|
|
}
|
2020-03-06 15:07:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|