2019-03-04 04:24:19 +00: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.
|
2018-11-11 01:13:17 +00:00
|
|
|
|
2018-11-18 12:15:29 +00:00
|
|
|
using System;
|
2018-11-11 01:13:17 +00:00
|
|
|
using System.Linq;
|
2020-03-06 07:09:07 +00:00
|
|
|
using Humanizer;
|
2018-11-11 01:13:17 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-03-02 04:40:43 +00:00
|
|
|
using osu.Framework.Bindables;
|
2018-11-11 01:13:17 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Platform;
|
2018-11-17 05:55:27 +00:00
|
|
|
using osu.Game.Graphics;
|
2019-06-17 12:07:30 +00:00
|
|
|
using osu.Game.Tournament.Components;
|
2019-06-18 05:51:48 +00:00
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-11 01:13:17 +00:00
|
|
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
2018-11-22 01:25:30 +00:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-11-11 01:13:17 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.Schedule
|
|
|
|
{
|
2020-03-06 07:09:07 +00:00
|
|
|
public class ScheduleScreen : TournamentScreen // IProvidesVideo
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
2019-06-18 05:57:05 +00:00
|
|
|
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
2018-11-11 01:13:17 +00:00
|
|
|
private Container mainContainer;
|
|
|
|
private LadderInfo ladder;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(LadderInfo ladder, Storage storage)
|
|
|
|
{
|
|
|
|
this.ladder = ladder;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2020-03-06 09:38:29 +00:00
|
|
|
new TourneyVideo("schedule")
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Loop = true,
|
|
|
|
},
|
2020-03-06 07:09:07 +00:00
|
|
|
new Container
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-03-06 07:09:07 +00:00
|
|
|
Padding = new MarginPadding(100) { Bottom = 50 },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new DrawableTournamentTitleText(),
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Margin = new MarginPadding { Top = 40 },
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.White,
|
|
|
|
Size = new Vector2(50, 10),
|
|
|
|
},
|
|
|
|
new TournamentSpriteTextWithBackground("Schedule")
|
|
|
|
{
|
|
|
|
X = 60,
|
|
|
|
Scale = new Vector2(0.8f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
mainContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-11-11 01:13:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
currentMatch.BindValueChanged(matchChanged);
|
|
|
|
currentMatch.BindTo(ladder.CurrentMatch);
|
|
|
|
}
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
2019-06-14 07:23:53 +00:00
|
|
|
if (match.NewValue == null)
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
|
|
|
mainContainer.Clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
var upcoming = ladder.Matches.Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4);
|
2019-03-02 04:52:56 +00:00
|
|
|
var conditionals = ladder
|
2019-06-18 05:57:05 +00:00
|
|
|
.Matches.Where(p => !p.Completed.Value && (p.Team1.Value == null || p.Team2.Value == null) && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
|
|
|
.SelectMany(m => m.ConditionalMatches.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a))));
|
2018-12-01 06:32:11 +00:00
|
|
|
|
|
|
|
upcoming = upcoming.Concat(conditionals);
|
2020-03-07 07:31:28 +00:00
|
|
|
upcoming = upcoming.OrderBy(p => p.Date.Value).Take(8);
|
2018-12-01 06:32:11 +00:00
|
|
|
|
2018-11-11 01:13:17 +00:00
|
|
|
mainContainer.Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-03-07 04:26:54 +00:00
|
|
|
Height = 0.74f,
|
2018-11-11 01:13:17 +00:00
|
|
|
Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new ScheduleContainer("recent matches")
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.4f,
|
2019-06-18 05:57:05 +00:00
|
|
|
ChildrenEnumerable = ladder.Matches
|
2018-12-01 06:32:11 +00:00
|
|
|
.Where(p => p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null
|
|
|
|
&& Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
|
2018-11-11 01:13:17 +00:00
|
|
|
.OrderByDescending(p => p.Date.Value)
|
|
|
|
.Take(8)
|
2019-06-18 05:57:05 +00:00
|
|
|
.Select(p => new ScheduleMatch(p))
|
2018-11-11 01:13:17 +00:00
|
|
|
},
|
2020-03-06 07:09:07 +00:00
|
|
|
new ScheduleContainer("upcoming matches")
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.6f,
|
2019-06-18 05:57:05 +00:00
|
|
|
ChildrenEnumerable = upcoming.Select(p => new ScheduleMatch(p))
|
2018-11-11 01:13:17 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-03-06 07:09:07 +00:00
|
|
|
new ScheduleContainer("coming up next")
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Height = 0.25f,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-06 07:09:07 +00:00
|
|
|
new FillFlowContainer
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
2020-03-07 04:26:54 +00:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2020-03-06 07:09:07 +00:00
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(30),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new ScheduleMatch(match.NewValue, false)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
},
|
|
|
|
new TournamentSpriteTextWithBackground(match.NewValue.Round.Value?.Name.Value)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Scale = new Vector2(0.5f)
|
|
|
|
},
|
|
|
|
new TournamentSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Text = match.NewValue.Team1.Value?.FullName + " vs " + match.NewValue.Team2.Value?.FullName,
|
|
|
|
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold)
|
|
|
|
},
|
|
|
|
new TournamentSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Text = $"Starting {match.NewValue.Date.Value.Humanize()}",
|
|
|
|
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
|
|
|
|
},
|
|
|
|
}
|
2018-11-11 01:13:17 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
public class ScheduleMatch : DrawableTournamentMatch
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
2019-06-18 05:57:05 +00:00
|
|
|
public ScheduleMatch(TournamentMatch match, bool showTimestamp = true)
|
|
|
|
: base(match)
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
|
|
|
Flow.Direction = FillDirection.Horizontal;
|
2018-11-17 05:55:27 +00:00
|
|
|
|
2020-03-07 04:26:54 +00:00
|
|
|
Scale = new Vector2(0.8f);
|
|
|
|
|
2019-06-18 05:57:05 +00:00
|
|
|
bool conditional = match is ConditionalTournamentMatch;
|
2018-12-01 06:32:11 +00:00
|
|
|
|
|
|
|
if (conditional)
|
|
|
|
Colour = OsuColour.Gray(0.5f);
|
|
|
|
|
2018-11-17 05:55:27 +00:00
|
|
|
if (showTimestamp)
|
|
|
|
{
|
2019-06-18 05:57:05 +00:00
|
|
|
AddInternal(new DrawableDate(Match.Date.Value)
|
2018-11-17 05:55:27 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopLeft,
|
2020-03-07 04:26:54 +00:00
|
|
|
Colour = OsuColour.Gray(0.7f),
|
2019-03-02 04:52:56 +00:00
|
|
|
Alpha = conditional ? 0.6f : 1,
|
2020-03-07 04:26:54 +00:00
|
|
|
Font = OsuFont.Torus,
|
2018-11-17 05:55:27 +00:00
|
|
|
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
|
|
|
});
|
2020-03-03 10:14:44 +00:00
|
|
|
AddInternal(new TournamentSpriteText
|
2018-11-17 05:55:27 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2020-03-07 04:26:54 +00:00
|
|
|
Colour = OsuColour.Gray(0.7f),
|
2019-03-02 04:52:56 +00:00
|
|
|
Alpha = conditional ? 0.6f : 1,
|
2018-11-17 05:55:27 +00:00
|
|
|
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
2019-06-18 05:57:05 +00:00
|
|
|
Text = match.Date.Value.ToUniversalTime().ToString("HH:mm UTC") + (conditional ? " (conditional)" : "")
|
2018-11-17 05:55:27 +00:00
|
|
|
});
|
|
|
|
}
|
2018-11-11 01:13:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class ScheduleContainer : Container
|
|
|
|
{
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
private readonly FillFlowContainer content;
|
|
|
|
|
|
|
|
public ScheduleContainer(string title)
|
|
|
|
{
|
2020-03-07 04:26:54 +00:00
|
|
|
Padding = new MarginPadding { Left = 60, Top = 10 };
|
2018-11-11 01:13:17 +00:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2020-03-07 04:26:54 +00:00
|
|
|
new FillFlowContainer
|
2018-11-11 01:13:17 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-03-07 04:26:54 +00:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new TournamentSpriteTextWithBackground(title.ToUpperInvariant())
|
|
|
|
{
|
|
|
|
Scale = new Vector2(0.5f)
|
|
|
|
},
|
|
|
|
content = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Margin = new MarginPadding(10)
|
|
|
|
},
|
|
|
|
}
|
2018-11-11 01:13:17 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|