2019-03-04 12:24:19 +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.
|
2018-11-11 09:13:17 +08:00
|
|
|
|
2018-11-18 20:15:29 +08:00
|
|
|
using System;
|
2018-11-11 09:13:17 +08:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-02 12:40:43 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-11-11 09:13:17 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Video;
|
|
|
|
using osu.Framework.Platform;
|
2018-11-17 13:55:27 +08:00
|
|
|
using osu.Game.Graphics;
|
2018-11-11 09:13:17 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
2018-11-22 09:25:30 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-11-11 09:13:17 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.Schedule
|
|
|
|
{
|
|
|
|
public class ScheduleScreen : TournamentScreen, IProvideVideo
|
|
|
|
{
|
|
|
|
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
|
|
|
|
private Container mainContainer;
|
|
|
|
private LadderInfo ladder;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(LadderInfo ladder, Storage storage)
|
|
|
|
{
|
|
|
|
this.ladder = ladder;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new VideoSprite(storage.GetStream(@"BG Side Logo - OWC.m4v"))
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Loop = true,
|
|
|
|
},
|
|
|
|
mainContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
currentMatch.BindValueChanged(matchChanged);
|
|
|
|
currentMatch.BindTo(ladder.CurrentMatch);
|
|
|
|
}
|
|
|
|
|
2019-06-14 15:23:53 +08:00
|
|
|
private void matchChanged(ValueChangedEvent<MatchPairing> match)
|
2018-11-11 09:13:17 +08:00
|
|
|
{
|
2019-06-14 15:23:53 +08:00
|
|
|
if (match.NewValue == null)
|
2018-11-11 09:13:17 +08:00
|
|
|
{
|
|
|
|
mainContainer.Clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-01 14:32:11 +08:00
|
|
|
var upcoming = ladder.Pairings.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 12:52:56 +08:00
|
|
|
var conditionals = ladder
|
|
|
|
.Pairings.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.ConditionalPairings.Where(cp => m.Acronyms.TrueForAll(a => cp.Acronyms.Contains(a))));
|
2018-12-01 14:32:11 +08:00
|
|
|
|
|
|
|
upcoming = upcoming.Concat(conditionals);
|
|
|
|
upcoming = upcoming.OrderBy(p => p.Date.Value).Take(12);
|
|
|
|
|
2018-11-11 09:13:17 +08:00
|
|
|
mainContainer.Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Height = 0.65f,
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new ScheduleContainer("recent matches")
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.4f,
|
|
|
|
ChildrenEnumerable = ladder.Pairings
|
2018-12-01 14:32:11 +08: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 09:13:17 +08:00
|
|
|
.OrderByDescending(p => p.Date.Value)
|
|
|
|
.Take(8)
|
|
|
|
.Select(p => new SchedulePairing(p))
|
|
|
|
},
|
|
|
|
new ScheduleContainer("match overview")
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.6f,
|
2018-12-01 14:32:11 +08:00
|
|
|
ChildrenEnumerable = upcoming.Select(p => new SchedulePairing(p))
|
2018-11-11 09:13:17 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new ScheduleContainer("current match")
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Height = 0.25f,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Margin = new MarginPadding { Left = -10, Bottom = 10, Top = -5 },
|
|
|
|
Spacing = new Vector2(10, 0),
|
2019-06-14 15:23:53 +08:00
|
|
|
Text = match.NewValue.Grouping.Value?.Name.Value,
|
2018-11-11 09:13:17 +08:00
|
|
|
Colour = Color4.Black,
|
2019-03-04 11:06:41 +08:00
|
|
|
Font = OsuFont.GetFont(size: 20)
|
2018-11-11 09:13:17 +08:00
|
|
|
},
|
2019-06-14 15:23:53 +08:00
|
|
|
new SchedulePairing(match.NewValue, false),
|
2018-11-11 09:13:17 +08:00
|
|
|
new OsuSpriteText
|
|
|
|
{
|
2019-06-14 15:23:53 +08:00
|
|
|
Text = "Start Time " + match.NewValue.Date.Value.ToUniversalTime().ToString("HH:mm UTC"),
|
2018-11-11 09:13:17 +08:00
|
|
|
Colour = Color4.Black,
|
2019-03-04 11:06:41 +08:00
|
|
|
Font = OsuFont.GetFont(size: 20)
|
2018-11-11 09:13:17 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public class SchedulePairing : DrawableMatchPairing
|
|
|
|
{
|
2018-11-17 13:55:27 +08:00
|
|
|
public SchedulePairing(MatchPairing pairing, bool showTimestamp = true)
|
2018-11-11 09:13:17 +08:00
|
|
|
: base(pairing)
|
|
|
|
{
|
|
|
|
Flow.Direction = FillDirection.Horizontal;
|
2018-11-17 13:55:27 +08:00
|
|
|
|
2018-12-01 14:32:11 +08:00
|
|
|
bool conditional = pairing is ConditionalMatchPairing;
|
|
|
|
|
|
|
|
if (conditional)
|
|
|
|
Colour = OsuColour.Gray(0.5f);
|
|
|
|
|
2018-11-17 13:55:27 +08:00
|
|
|
if (showTimestamp)
|
|
|
|
{
|
|
|
|
AddInternal(new DrawableDate(Pairing.Date.Value)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Colour = Color4.Black,
|
2019-03-02 12:52:56 +08:00
|
|
|
Alpha = conditional ? 0.6f : 1,
|
2018-11-17 13:55:27 +08:00
|
|
|
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
|
|
|
});
|
|
|
|
AddInternal(new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Colour = Color4.Black,
|
2019-03-02 12:52:56 +08:00
|
|
|
Alpha = conditional ? 0.6f : 1,
|
2018-11-17 13:55:27 +08:00
|
|
|
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
2018-12-01 14:32:11 +08:00
|
|
|
Text = pairing.Date.Value.ToUniversalTime().ToString("HH:mm UTC") + (conditional ? " (conditional)" : "")
|
2018-11-17 13:55:27 +08:00
|
|
|
});
|
|
|
|
}
|
2018-11-11 09:13:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class ScheduleContainer : Container
|
|
|
|
{
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
private readonly FillFlowContainer content;
|
|
|
|
|
|
|
|
public ScheduleContainer(string title)
|
|
|
|
{
|
|
|
|
Padding = new MarginPadding { Left = 30, Top = 30 };
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
X = 30,
|
|
|
|
Text = title,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
Spacing = new Vector2(10, 0),
|
2019-03-04 11:06:41 +08:00
|
|
|
Font = OsuFont.GetFont(size: 30)
|
2018-11-11 09:13:17 +08:00
|
|
|
},
|
|
|
|
content = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Margin = new MarginPadding(40)
|
|
|
|
},
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
Colour = new Color4(233, 187, 79, 255),
|
|
|
|
Width = 5,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|