1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Allow the schedule screen to show even when a current match is not selected

This commit is contained in:
Dean Herbert 2021-07-17 00:21:58 +09:00
parent da7e880e46
commit 83ebbb7f8e
2 changed files with 60 additions and 52 deletions

View File

@ -28,6 +28,12 @@ namespace osu.Game.Tournament.Tests.Screens
setMatchDate(TimeSpan.FromHours(3));
}
[Test]
public void TestNoCurrentMatch()
{
AddStep("Set null current match", () => Ladder.CurrentMatch.Value = null);
}
private void setMatchDate(TimeSpan relativeTime)
// Humanizer cannot handle negative timespans.
=> AddStep($"start time is {relativeTime}", () =>

View File

@ -96,19 +96,18 @@ namespace osu.Game.Tournament.Screens.Schedule
}
},
};
}
protected override void LoadComplete()
{
base.LoadComplete();
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
currentMatch.BindValueChanged(matchChanged, true);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
{
if (match.NewValue == null)
{
mainContainer.Clear();
return;
}
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);
var conditionals = 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)
@ -117,6 +116,8 @@ namespace osu.Game.Tournament.Screens.Schedule
upcoming = upcoming.Concat(conditionals);
upcoming = upcoming.OrderBy(p => p.Date.Value).Take(8);
ScheduleContainer comingUpNext;
mainContainer.Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
@ -153,57 +154,58 @@ namespace osu.Game.Tournament.Screens.Schedule
}
}
},
new ScheduleContainer("coming up next")
comingUpNext = new ScheduleContainer("coming up next")
{
RelativeSizeAxes = Axes.Both,
Height = 0.25f,
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
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 FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new ScheduleMatchDate(match.NewValue.Date.Value)
{
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
}
}
},
}
},
}
}
}
};
if (match.NewValue != null)
{
comingUpNext.Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
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 FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new ScheduleMatchDate(match.NewValue.Date.Value)
{
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
}
}
},
}
};
}
}
public class ScheduleMatch : DrawableTournamentMatch