mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:33:22 +08:00
Merge pull request #8455 from Game4all/handle-novideo-beatmaps
Fix NullReferenceException when starting the no-video version of a beatmap with video
This commit is contained in:
commit
6ecfeb8cc3
31
osu.Game.Tests/Resources/storyboard_no_video.osu
Normal file
31
osu.Game.Tests/Resources/storyboard_no_video.osu
Normal file
@ -0,0 +1,31 @@
|
||||
osu file format v14
|
||||
|
||||
[Events]
|
||||
//Background and Video events
|
||||
0,0,"BG.jpg",0,0
|
||||
Video,0,"video.avi"
|
||||
//Break Periods
|
||||
//Storyboard Layer 0 (Background)
|
||||
//Storyboard Layer 1 (Fail)
|
||||
//Storyboard Layer 2 (Pass)
|
||||
//Storyboard Layer 3 (Foreground)
|
||||
//Storyboard Layer 4 (Overlay)
|
||||
//Storyboard Sound Samples
|
||||
|
||||
[TimingPoints]
|
||||
1674,333.333333333333,4,2,1,70,1,0
|
||||
1674,-100,4,2,1,70,0,0
|
||||
3340,-100,4,2,1,70,0,0
|
||||
3507,-100,4,2,1,70,0,0
|
||||
3673,-100,4,2,1,70,0,0
|
||||
|
||||
[Colours]
|
||||
Combo1 : 240,80,80
|
||||
Combo2 : 171,252,203
|
||||
Combo3 : 128,128,255
|
||||
Combo4 : 249,254,186
|
||||
|
||||
[HitObjects]
|
||||
148,303,1674,5,6,3:2:0:0:
|
||||
378,252,1840,1,0,0:0:0:0:
|
||||
389,270,2340,5,2,0:1:0:0:
|
@ -9,8 +9,12 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
@ -54,7 +58,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
State = { Value = Visibility.Visible },
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStoryboard()
|
||||
{
|
||||
AddStep("Restart", restart);
|
||||
AddToggleStep("Passing", passing =>
|
||||
{
|
||||
@ -62,6 +70,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStoryboardMissingVideo()
|
||||
{
|
||||
AddStep("Load storyboard with missing video", loadStoryboardNoVideo);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -94,5 +108,28 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
storyboardContainer.Add(storyboard);
|
||||
decoupledClock.ChangeSource(working.Track);
|
||||
}
|
||||
|
||||
private void loadStoryboardNoVideo()
|
||||
{
|
||||
if (storyboard != null)
|
||||
storyboardContainer.Remove(storyboard);
|
||||
|
||||
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
|
||||
storyboardContainer.Clock = decoupledClock;
|
||||
|
||||
Storyboard sb;
|
||||
|
||||
using (var str = TestResources.OpenResource("storyboard_no_video.osu"))
|
||||
using (var bfr = new LineBufferedReader(str))
|
||||
{
|
||||
var decoder = new LegacyStoryboardDecoder();
|
||||
sb = decoder.Decode(bfr);
|
||||
}
|
||||
|
||||
storyboard = sb.CreateDrawable(Beatmap.Value);
|
||||
|
||||
storyboardContainer.Add(storyboard);
|
||||
decoupledClock.ChangeSource(Beatmap.Value.Track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ namespace osu.Game.Storyboards.Drawables
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (videoSprite == null) return;
|
||||
|
||||
using (videoSprite.BeginAbsoluteSequence(0))
|
||||
videoSprite.FadeIn(500);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user