From 1e2f9d1ba18f6f5cad952bae93e9be5b9cbac264 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jun 2019 21:07:30 +0900 Subject: [PATCH] Fix start failure if videos are missing --- .../Components/TourneyVideo.cs | 45 +++++++++++++++++++ .../Screens/Ladder/LadderScreen.cs | 4 +- .../Screens/Schedule/ScheduleScreen.cs | 4 +- .../Screens/TeamIntro/TeamIntroScreen.cs | 3 +- .../Screens/TeamWin/TeamWinScreen.cs | 9 ++-- .../Screens/Teams/TeamsEditorScreen.cs | 1 - .../Screens/TournamentSceneManager.cs | 6 +-- 7 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 osu.Game.Tournament/Components/TourneyVideo.cs diff --git a/osu.Game.Tournament/Components/TourneyVideo.cs b/osu.Game.Tournament/Components/TourneyVideo.cs new file mode 100644 index 0000000000..4f4660f645 --- /dev/null +++ b/osu.Game.Tournament/Components/TourneyVideo.cs @@ -0,0 +1,45 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.IO; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Video; +using osu.Game.Graphics; + +namespace osu.Game.Tournament.Components +{ + public class TourneyVideo : CompositeDrawable + { + private readonly VideoSprite video; + + public TourneyVideo(Stream stream) + { + if (stream == null) + { + InternalChild = new Box + { + Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.3f), OsuColour.Gray(0.6f)), + RelativeSizeAxes = Axes.Both, + }; + } + else + InternalChild = video = new VideoSprite(stream) + { + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fit, + }; + } + + public bool Loop + { + set + { + if (video != null) + video.Loop = value; + } + } + } +} diff --git a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs index 1457992003..4a50db9997 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderScreen.cs @@ -8,9 +8,9 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Lines; -using osu.Framework.Graphics.Video; using osu.Framework.Platform; using osu.Game.Graphics; +using osu.Game.Tournament.Components; using osu.Game.Tournament.Screens.Ladder.Components; using osuTK.Graphics; @@ -39,7 +39,7 @@ namespace osu.Game.Tournament.Screens.Ladder RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new VideoSprite(storage.GetStream(@"BG Side Logo - OWC.m4v")) + new TourneyVideo(storage.GetStream(@"BG Side Logo - OWC.m4v")) { RelativeSizeAxes = Axes.Both, Loop = true, diff --git a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs index 0e17936079..be934afe8e 100644 --- a/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs +++ b/osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs @@ -8,10 +8,10 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Video; using osu.Framework.Platform; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Tournament.Components; using osu.Game.Tournament.Screens.Ladder.Components; using osuTK; using osuTK.Graphics; @@ -33,7 +33,7 @@ namespace osu.Game.Tournament.Screens.Schedule InternalChildren = new Drawable[] { - new VideoSprite(storage.GetStream(@"BG Side Logo - OWC.m4v")) + new TourneyVideo(storage.GetStream(@"BG Side Logo - OWC.m4v")) { RelativeSizeAxes = Axes.Both, Loop = true, diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs index 1e08b4add5..078d823d81 100644 --- a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs +++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Video; using osu.Framework.Platform; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -30,7 +29,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro InternalChildren = new Drawable[] { - new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v")) + new TourneyVideo(storage.GetStream(@"BG Team - Both OWC.m4v")) { RelativeSizeAxes = Axes.Both, Loop = true, diff --git a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs index d73ec8fca6..c80f3b2dfb 100644 --- a/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs +++ b/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Video; using osu.Framework.Platform; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -24,8 +23,8 @@ namespace osu.Game.Tournament.Screens.TeamWin private readonly Bindable currentMatch = new Bindable(); private readonly Bindable currentCompleted = new Bindable(); - private VideoSprite blueWinVideo; - private VideoSprite redWinVideo; + private TourneyVideo blueWinVideo; + private TourneyVideo redWinVideo; [BackgroundDependencyLoader] private void load(LadderInfo ladder, Storage storage) @@ -34,13 +33,13 @@ namespace osu.Game.Tournament.Screens.TeamWin InternalChildren = new Drawable[] { - blueWinVideo = new VideoSprite(storage.GetStream(@"BG Team - Win Blue.m4v")) + blueWinVideo = new TourneyVideo(storage.GetStream(@"BG Team - Win Blue.m4v")) { Alpha = 1, RelativeSizeAxes = Axes.Both, Loop = true, }, - redWinVideo = new VideoSprite(storage.GetStream(@"BG Team - Win Red.m4v")) + redWinVideo = new TourneyVideo(storage.GetStream(@"BG Team - Win Red.m4v")) { Alpha = 0, RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs b/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs index c20073907d..503e7468b0 100644 --- a/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Teams/TeamsEditorScreen.cs @@ -16,7 +16,6 @@ using osu.Game.Overlays.Settings; using osu.Game.Tournament.Components; using osu.Game.Users; using osuTK; -using osuTK.Graphics; namespace osu.Game.Tournament.Screens.Teams { diff --git a/osu.Game.Tournament/Screens/TournamentSceneManager.cs b/osu.Game.Tournament/Screens/TournamentSceneManager.cs index 8393cd52a2..f1a2f2219b 100644 --- a/osu.Game.Tournament/Screens/TournamentSceneManager.cs +++ b/osu.Game.Tournament/Screens/TournamentSceneManager.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Video; using osu.Framework.Platform; using osu.Game.Graphics.UserInterface; using osu.Game.Tournament.Components; @@ -30,7 +29,7 @@ namespace osu.Game.Tournament.Screens public class TournamentSceneManager : CompositeDrawable { private Container screens; - private VideoSprite video; + private TourneyVideo video; [Cached] private MatchChatDisplay chat = new MatchChatDisplay(); @@ -59,11 +58,10 @@ namespace osu.Game.Tournament.Screens //Masking = true, Children = new Drawable[] { - video = new VideoSprite(storage.GetStream("BG Logoless - OWC.m4v")) + video = new TourneyVideo(storage.GetStream("BG Logoless - OWC.m4v")) { Loop = true, RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fit, }, screens = new Container {