Merge branch 'master' into fix-disabled-set-crash

This commit is contained in:
Dan Balasescu
2019-03-05 17:25:13 +09:00
committed by GitHub
372 changed files with 3325 additions and 1072 deletions

View File

@ -19,7 +19,6 @@ using osu.Framework.Threading;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Online.API;
@ -32,7 +31,6 @@ using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
using osu.Game.Skinning;
using osu.Game.Storyboards.Drawables;
using osuTK.Graphics;
namespace osu.Game.Screens.Play
{
@ -57,6 +55,8 @@ namespace osu.Game.Screens.Play
private Bindable<bool> mouseWheelDisabled;
private Bindable<double> userAudioOffset;
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
public int RestartCount;
public CursorContainer Cursor => RulesetContainer.Cursor;
@ -72,7 +72,7 @@ namespace osu.Game.Screens.Play
[Resolved]
private ScoreManager scoreManager { get; set; }
private PauseContainer pauseContainer;
protected PauseContainer PauseContainer { get; private set; }
private RulesetInfo ruleset;
@ -80,14 +80,21 @@ namespace osu.Game.Screens.Play
private SampleChannel sampleRestart;
protected ScoreProcessor ScoreProcessor;
protected RulesetContainer RulesetContainer;
protected ScoreProcessor ScoreProcessor { get; private set; }
protected RulesetContainer RulesetContainer { get; private set; }
protected HUDOverlay HUDOverlay;
protected HUDOverlay HUDOverlay { get; private set; }
private FailOverlay failOverlay;
private DrawableStoryboard storyboard;
private Container storyboardContainer;
protected UserDimContainer StoryboardContainer { get; private set; }
protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true)
{
RelativeSizeAxes = Axes.Both,
Alpha = 1,
EnableUserDim = { Value = true }
};
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
@ -168,19 +175,15 @@ namespace osu.Game.Screens.Play
InternalChildren = new Drawable[]
{
pauseContainer = new PauseContainer(offsetClock, adjustableClock)
PauseContainer = new PauseContainer(offsetClock, adjustableClock)
{
Retries = RestartCount,
OnRetry = Restart,
OnQuit = performUserRequestedExit,
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
Children = new[]
Children = new Container[]
{
storyboardContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
},
StoryboardContainer = CreateStoryboardContainer(),
new ScalingContainer(ScalingMode.Gameplay)
{
Child = new LocalSkinOverrideContainer(working.Skin)
@ -236,7 +239,7 @@ namespace osu.Game.Screens.Play
HUDOverlay.HoldToQuit.Action = performUserRequestedExit;
HUDOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);
RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused);
RulesetContainer.IsPaused.BindTo(PauseContainer.IsPaused);
if (ShowStoryboard.Value)
initializeStoryboard(false);
@ -261,6 +264,7 @@ namespace osu.Game.Screens.Play
private void performUserRequestedExit()
{
if (!this.IsCurrentScreen()) return;
this.Exit();
}
@ -296,7 +300,7 @@ namespace osu.Game.Screens.Play
if (RulesetContainer.ReplayScore == null)
scoreManager.Import(score);
this.Push(CreateResults(score));
this.Push(CreateResults(score));
onCompletionEvent = null;
});
@ -345,6 +349,18 @@ namespace osu.Game.Screens.Play
.Delay(250)
.FadeIn(250);
ShowStoryboard.ValueChanged += enabled =>
{
if (enabled.NewValue) initializeStoryboard(true);
};
Background.EnableUserDim.Value = true;
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
StoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
Task.Run(() =>
{
sourceClock.Reset();
@ -356,7 +372,7 @@ namespace osu.Game.Screens.Play
this.Delay(750).Schedule(() =>
{
if (!pauseContainer.IsPaused.Value)
if (!PauseContainer.IsPaused.Value)
{
adjustableClock.Start();
}
@ -364,8 +380,8 @@ namespace osu.Game.Screens.Play
});
});
pauseContainer.Alpha = 0;
pauseContainer.FadeIn(750, Easing.OutQuint);
PauseContainer.Alpha = 0;
PauseContainer.FadeIn(750, Easing.OutQuint);
}
public override void OnSuspending(IScreen next)
@ -383,17 +399,16 @@ namespace osu.Game.Screens.Play
return true;
}
if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded.Value != false) && (!pauseContainer?.IsResuming ?? true))
if ((!AllowPause || HasFailed || !ValidForResume || PauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded.Value != false) && (!PauseContainer?.IsResuming ?? true))
{
// In the case of replays, we may have changed the playback rate.
applyRateFromMods();
fadeOut();
return base.OnExiting(next);
}
if (LoadedBeatmapSuccessfully)
pauseContainer?.Pause();
PauseContainer?.Pause();
return true;
}
@ -402,14 +417,16 @@ namespace osu.Game.Screens.Play
{
float fadeOutDuration = instant ? 0 : 250;
this.FadeOut(fadeOutDuration);
Background?.FadeColour(Color4.White, fadeOutDuration, Easing.OutQuint);
Background.EnableUserDim.Value = false;
storyboardReplacesBackground.Value = false;
}
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused.Value;
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !PauseContainer.IsPaused.Value;
private void initializeStoryboard(bool asyncLoad)
{
if (storyboardContainer == null)
if (StoryboardContainer == null || storyboard != null)
return;
var beatmap = Beatmap.Value;
@ -418,29 +435,9 @@ namespace osu.Game.Screens.Play
storyboard.Masking = true;
if (asyncLoad)
LoadComponentAsync(storyboard, storyboardContainer.Add);
LoadComponentAsync(storyboard, StoryboardContainer.Add);
else
storyboardContainer.Add(storyboard);
}
protected override void UpdateBackgroundElements()
{
if (!this.IsCurrentScreen()) return;
base.UpdateBackgroundElements();
if (ShowStoryboard.Value && storyboard == null)
initializeStoryboard(true);
var beatmap = Beatmap.Value;
var storyboardVisible = ShowStoryboard.Value && beatmap.Storyboard.HasDrawable;
storyboardContainer?
.FadeColour(OsuColour.Gray(BackgroundOpacity), BACKGROUND_FADE_DURATION, Easing.OutQuint)
.FadeTo(storyboardVisible && BackgroundOpacity > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
if (storyboardVisible && beatmap.Storyboard.ReplacesBackground)
Background?.FadeColour(Color4.Black, BACKGROUND_FADE_DURATION, Easing.OutQuint);
StoryboardContainer.Add(storyboard);
}
protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score);