1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 15:12:57 +08:00

Simplify and localise storyboard logic in Player.cs

This commit is contained in:
Dean Herbert 2019-03-18 11:12:47 +09:00
parent bcaff9f7b4
commit f13003c53b

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System; using System;
@ -70,9 +70,32 @@ namespace osu.Game.Screens.Play
protected HUDOverlay HUDOverlay { get; private set; } protected HUDOverlay HUDOverlay { get; private set; }
private FailOverlay failOverlay; private FailOverlay failOverlay;
#region Storyboard
private DrawableStoryboard storyboard; private DrawableStoryboard storyboard;
protected UserDimContainer StoryboardContainer { get; private set; } protected UserDimContainer StoryboardContainer { get; private set; }
private void initializeStoryboard(bool asyncLoad)
{
if (StoryboardContainer == null || storyboard != null)
return;
if (!ShowStoryboard.Value)
return;
var beatmap = Beatmap.Value;
storyboard = beatmap.Storyboard.CreateDrawable();
storyboard.Masking = true;
if (asyncLoad)
LoadComponentAsync(storyboard, StoryboardContainer.Add);
else
StoryboardContainer.Add(storyboard);
}
#endregion
protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true) protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -173,7 +196,7 @@ namespace osu.Game.Screens.Play
// bind clock into components that require it // bind clock into components that require it
RulesetContainer.IsPaused.BindTo(GameplayClockContainer.IsPaused); RulesetContainer.IsPaused.BindTo(GameplayClockContainer.IsPaused);
if (ShowStoryboard.Value) // load storyboard as part of player's load if we can
initializeStoryboard(false); initializeStoryboard(false);
// Bind ScoreProcessor to ourselves // Bind ScoreProcessor to ourselves
@ -317,10 +340,7 @@ namespace osu.Game.Screens.Play
.Delay(250) .Delay(250)
.FadeIn(250); .FadeIn(250);
ShowStoryboard.ValueChanged += enabled => ShowStoryboard.ValueChanged += _ => initializeStoryboard(true);
{
if (enabled.NewValue) initializeStoryboard(true);
};
Background.EnableUserDim.Value = true; Background.EnableUserDim.Value = true;
@ -376,22 +396,6 @@ namespace osu.Game.Screens.Play
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !PausableGameplayContainer.IsPaused.Value; protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !PausableGameplayContainer.IsPaused.Value;
private void initializeStoryboard(bool asyncLoad)
{
if (StoryboardContainer == null || storyboard != null)
return;
var beatmap = Beatmap.Value;
storyboard = beatmap.Storyboard.CreateDrawable();
storyboard.Masking = true;
if (asyncLoad)
LoadComponentAsync(storyboard, StoryboardContainer.Add);
else
StoryboardContainer.Add(storyboard);
}
protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score); protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score);
} }
} }