2020-03-03 17:12:42 +08:00
|
|
|
// 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.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Tournament.Components;
|
|
|
|
using osu.Game.Tournament.Models;
|
|
|
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.TeamIntro
|
|
|
|
{
|
2021-07-16 23:14:48 +08:00
|
|
|
public class SeedingScreen : TournamentMatchScreen, IProvideVideo
|
2020-03-03 17:12:42 +08:00
|
|
|
{
|
|
|
|
private Container mainContainer;
|
|
|
|
|
|
|
|
private readonly Bindable<TournamentTeam> currentTeam = new Bindable<TournamentTeam>();
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(Storage storage)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2020-03-06 17:38:29 +08:00
|
|
|
new TourneyVideo("seeding")
|
2020-03-03 17:12:42 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Loop = true,
|
|
|
|
},
|
|
|
|
mainContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new ControlPanel
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new TourneyButton
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Show first team",
|
2021-07-16 23:14:48 +08:00
|
|
|
Action = () => currentTeam.Value = CurrentMatch.Value.Team1.Value,
|
2020-03-03 17:12:42 +08:00
|
|
|
},
|
|
|
|
new TourneyButton
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = "Show second team",
|
2021-07-16 23:14:48 +08:00
|
|
|
Action = () => currentTeam.Value = CurrentMatch.Value.Team2.Value,
|
2020-03-03 17:12:42 +08:00
|
|
|
},
|
|
|
|
new SettingsTeamDropdown(LadderInfo.Teams)
|
|
|
|
{
|
|
|
|
LabelText = "Show specific team",
|
2020-10-06 16:18:41 +08:00
|
|
|
Current = currentTeam,
|
2020-03-03 17:12:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
currentTeam.BindValueChanged(teamChanged, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void teamChanged(ValueChangedEvent<TournamentTeam> team)
|
|
|
|
{
|
|
|
|
if (team.NewValue == null)
|
|
|
|
{
|
|
|
|
mainContainer.Clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
showTeam(team.NewValue);
|
|
|
|
}
|
|
|
|
|
2021-07-16 23:14:48 +08:00
|
|
|
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
|
|
|
|
{
|
|
|
|
base.CurrentMatchChanged(match);
|
|
|
|
|
|
|
|
if (match.NewValue == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
currentTeam.Value = match.NewValue.Team1.Value;
|
|
|
|
}
|
2020-03-03 17:12:42 +08:00
|
|
|
|
|
|
|
private void showTeam(TournamentTeam team)
|
|
|
|
{
|
|
|
|
mainContainer.Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new LeftInfo(team) { Position = new Vector2(55, 150), },
|
|
|
|
new RightInfo(team) { Position = new Vector2(500, 150), },
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private class RightInfo : CompositeDrawable
|
|
|
|
{
|
|
|
|
public RightInfo(TournamentTeam team)
|
|
|
|
{
|
|
|
|
FillFlowContainer fill;
|
|
|
|
|
|
|
|
Width = 400;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
fill = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var seeding in team.SeedingResults)
|
|
|
|
{
|
|
|
|
fill.Add(new ModRow(seeding.Mod.Value, seeding.Seed.Value));
|
|
|
|
foreach (var beatmap in seeding.Beatmaps)
|
|
|
|
fill.Add(new BeatmapScoreRow(beatmap));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class BeatmapScoreRow : CompositeDrawable
|
|
|
|
{
|
|
|
|
public BeatmapScoreRow(SeedingBeatmap beatmap)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-06 15:08:24 +08:00
|
|
|
new TournamentSpriteText { Text = beatmap.BeatmapInfo.Metadata.Title, Colour = TournamentGame.TEXT_COLOUR, },
|
|
|
|
new TournamentSpriteText { Text = "by", Colour = TournamentGame.TEXT_COLOUR, Font = OsuFont.Torus.With(weight: FontWeight.Regular) },
|
|
|
|
new TournamentSpriteText { Text = beatmap.BeatmapInfo.Metadata.Artist, Colour = TournamentGame.TEXT_COLOUR, Font = OsuFont.Torus.With(weight: FontWeight.Regular) },
|
2020-03-03 17:12:42 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(40),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-06 15:08:24 +08:00
|
|
|
new TournamentSpriteText { Text = beatmap.Score.ToString("#,0"), Colour = TournamentGame.TEXT_COLOUR, Width = 80 },
|
|
|
|
new TournamentSpriteText { Text = "#" + beatmap.Seed.Value.ToString("#,0"), Colour = TournamentGame.TEXT_COLOUR, Font = OsuFont.Torus.With(weight: FontWeight.Regular) },
|
2020-03-03 17:12:42 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class ModRow : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly string mods;
|
|
|
|
private readonly int seeding;
|
|
|
|
|
|
|
|
public ModRow(string mods, int seeding)
|
|
|
|
{
|
|
|
|
this.mods = mods;
|
|
|
|
this.seeding = seeding;
|
|
|
|
|
|
|
|
Padding = new MarginPadding { Vertical = 10 };
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
{
|
2021-07-17 23:53:58 +08:00
|
|
|
FillFlowContainer row;
|
|
|
|
|
2020-03-03 17:12:42 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2021-07-17 23:53:58 +08:00
|
|
|
row = new FillFlowContainer
|
2020-03-03 17:12:42 +08:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
},
|
|
|
|
};
|
2021-07-17 23:53:58 +08:00
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(mods))
|
|
|
|
{
|
|
|
|
row.Add(new Sprite
|
|
|
|
{
|
|
|
|
Texture = textures.Get($"mods/{mods.ToLower()}"),
|
|
|
|
Scale = new Vector2(0.5f)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
row.Add(new Container
|
|
|
|
{
|
|
|
|
Size = new Vector2(50, 16),
|
|
|
|
CornerRadius = 10,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = TournamentGame.ELEMENT_BACKGROUND_COLOUR,
|
|
|
|
},
|
|
|
|
new TournamentSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Text = seeding.ToString("#,0"),
|
|
|
|
Colour = TournamentGame.ELEMENT_FOREGROUND_COLOUR
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
2020-03-03 17:12:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class LeftInfo : CompositeDrawable
|
|
|
|
{
|
|
|
|
public LeftInfo(TournamentTeam team)
|
|
|
|
{
|
|
|
|
FillFlowContainer fill;
|
|
|
|
|
|
|
|
Width = 200;
|
|
|
|
|
|
|
|
if (team == null) return;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
fill = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new TeamDisplay(team) { Margin = new MarginPadding { Bottom = 30 } },
|
|
|
|
new RowDisplay("Average Rank:", $"#{team.AverageRank:#,0}"),
|
|
|
|
new RowDisplay("Seed:", team.Seed.Value),
|
|
|
|
new RowDisplay("Last year's placing:", team.LastYearPlacing.Value > 0 ? $"#{team.LastYearPlacing:#,0}" : "0"),
|
|
|
|
new Container { Margin = new MarginPadding { Bottom = 30 } },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var p in team.Players)
|
2021-02-17 13:50:48 +08:00
|
|
|
fill.Add(new RowDisplay(p.Username, p.Statistics?.GlobalRank?.ToString("\\##,0") ?? "-"));
|
2020-03-03 17:12:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
internal class RowDisplay : CompositeDrawable
|
|
|
|
{
|
|
|
|
public RowDisplay(string left, string right)
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new TournamentSpriteText
|
|
|
|
{
|
|
|
|
Text = left,
|
2020-03-06 15:08:24 +08:00
|
|
|
Colour = TournamentGame.TEXT_COLOUR,
|
|
|
|
Font = OsuFont.Torus.With(size: 22, weight: FontWeight.SemiBold),
|
2020-03-03 17:12:42 +08:00
|
|
|
},
|
|
|
|
new TournamentSpriteText
|
|
|
|
{
|
|
|
|
Text = right,
|
2020-03-06 15:08:24 +08:00
|
|
|
Colour = TournamentGame.TEXT_COLOUR,
|
2020-03-03 17:12:42 +08:00
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Font = OsuFont.Torus.With(size: 22, weight: FontWeight.Regular),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class TeamDisplay : DrawableTournamentTeam
|
|
|
|
{
|
|
|
|
public TeamDisplay(TournamentTeam team)
|
|
|
|
: base(team)
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
Flag.RelativeSizeAxes = Axes.None;
|
2020-10-23 20:11:29 +08:00
|
|
|
Flag.Scale = new Vector2(1.2f);
|
2020-03-03 17:12:42 +08:00
|
|
|
|
|
|
|
InternalChild = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 5),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
Flag,
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = team?.FullName.Value ?? "???",
|
|
|
|
Font = OsuFont.Torus.With(size: 32, weight: FontWeight.SemiBold),
|
2020-03-06 15:08:24 +08:00
|
|
|
Colour = TournamentGame.TEXT_COLOUR,
|
2020-03-03 17:12:42 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|