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,13 +154,17 @@ 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[]
}
}
};
if (match.NewValue != null)
{
new FillFlowContainer
comingUpNext.Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
@ -199,12 +204,9 @@ namespace osu.Game.Tournament.Screens.Schedule
}
},
}
},
}
}
}
};
}
}
public class ScheduleMatch : DrawableTournamentMatch
{