2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2018-05-28 02:00:21 +08:00
|
|
|
|
using osu.Framework;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Logging;
|
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Framework.Threading;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Configuration;
|
2019-01-04 12:29:37 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.Cursor;
|
|
|
|
|
using osu.Game.Online.API;
|
2018-06-06 14:10:09 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
2018-11-28 15:12:57 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2018-12-22 15:26:27 +08:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osu.Game.Storyboards.Drawables;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
|
{
|
|
|
|
|
public class Player : ScreenWithBeatmapBackground, IProvideCursor
|
|
|
|
|
{
|
2018-11-07 00:47:02 +08:00
|
|
|
|
protected override bool AllowBackButton => false; // handled by HoldForMenuButton
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override float BackgroundParallaxAmount => 0.1f;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-01-28 14:41:54 +08:00
|
|
|
|
public override bool HideOverlaysOnEnter => true;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-01-28 14:41:54 +08:00
|
|
|
|
public override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered;
|
2018-06-06 14:10:09 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public Action RestartRequested;
|
|
|
|
|
|
|
|
|
|
public bool HasFailed { get; private set; }
|
|
|
|
|
|
|
|
|
|
public bool AllowPause { get; set; } = true;
|
|
|
|
|
public bool AllowLeadIn { get; set; } = true;
|
|
|
|
|
public bool AllowResults { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
private Bindable<bool> mouseWheelDisabled;
|
|
|
|
|
private Bindable<double> userAudioOffset;
|
2019-02-25 12:27:44 +08:00
|
|
|
|
|
|
|
|
|
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public int RestartCount;
|
|
|
|
|
|
|
|
|
|
public CursorContainer Cursor => RulesetContainer.Cursor;
|
|
|
|
|
public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded.Value;
|
|
|
|
|
|
|
|
|
|
private IAdjustableClock sourceClock;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The decoupled clock used for gameplay. Should be used for seeks and clock control.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private DecoupleableInterpolatingFramedClock adjustableClock;
|
|
|
|
|
|
2018-11-29 13:56:29 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private ScoreManager scoreManager { get; set; }
|
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
protected PauseContainer PauseContainer { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private RulesetInfo ruleset;
|
|
|
|
|
|
|
|
|
|
private APIAccess api;
|
|
|
|
|
|
|
|
|
|
private SampleChannel sampleRestart;
|
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
protected ScoreProcessor ScoreProcessor { get; private set; }
|
|
|
|
|
protected RulesetContainer RulesetContainer { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
protected HUDOverlay HUDOverlay { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private FailOverlay failOverlay;
|
|
|
|
|
|
|
|
|
|
private DrawableStoryboard storyboard;
|
2019-02-28 17:25:58 +08:00
|
|
|
|
protected UserDimContainer StoryboardContainer { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-27 16:56:44 +08:00
|
|
|
|
protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 1,
|
|
|
|
|
EnableUserDim = { Value = true }
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-20 16:30:27 +08:00
|
|
|
|
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-08-31 06:04:40 +08:00
|
|
|
|
private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
this.api = api;
|
|
|
|
|
|
|
|
|
|
WorkingBeatmap working = Beatmap.Value;
|
|
|
|
|
if (working is DummyWorkingBeatmap)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-08-31 06:04:40 +08:00
|
|
|
|
sampleRestart = audio.Sample.Get(@"Gameplay/restart");
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
|
|
|
|
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
|
|
|
|
|
2018-04-19 19:44:38 +08:00
|
|
|
|
IBeatmap beatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
beatmap = working.Beatmap;
|
|
|
|
|
|
|
|
|
|
if (beatmap == null)
|
|
|
|
|
throw new InvalidOperationException("Beatmap was not loaded");
|
|
|
|
|
|
|
|
|
|
ruleset = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
|
|
|
|
var rulesetInstance = ruleset.CreateInstance();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2018-05-07 09:17:54 +08:00
|
|
|
|
RulesetContainer = rulesetInstance.CreateRulesetContainerWith(working);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
catch (BeatmapInvalidForRulesetException)
|
|
|
|
|
{
|
|
|
|
|
// we may fail to create a RulesetContainer if the beatmap cannot be loaded with the user's preferred ruleset
|
|
|
|
|
// let's try again forcing the beatmap's ruleset.
|
|
|
|
|
ruleset = beatmap.BeatmapInfo.Ruleset;
|
|
|
|
|
rulesetInstance = ruleset.CreateInstance();
|
2018-05-23 16:37:39 +08:00
|
|
|
|
RulesetContainer = rulesetInstance.CreateRulesetContainerWith(Beatmap.Value);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!RulesetContainer.Objects.Any())
|
2018-04-20 16:30:27 +08:00
|
|
|
|
{
|
2018-08-22 15:01:58 +08:00
|
|
|
|
Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Error);
|
2018-04-20 16:30:27 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error(e, "Could not load beatmap sucessfully!");
|
|
|
|
|
//couldn't load, hard abort!
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sourceClock = (IAdjustableClock)working.Track ?? new StopwatchClock();
|
|
|
|
|
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
|
|
|
|
|
|
|
|
|
adjustableClock.Seek(AllowLeadIn
|
2018-07-23 14:33:47 +08:00
|
|
|
|
? Math.Min(0, RulesetContainer.GameplayStartTime - beatmap.BeatmapInfo.AudioLeadIn)
|
2018-07-17 13:29:22 +08:00
|
|
|
|
: RulesetContainer.GameplayStartTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
adjustableClock.ProcessFrame();
|
|
|
|
|
|
2018-05-28 02:00:21 +08:00
|
|
|
|
// Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited.
|
|
|
|
|
// This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
|
2018-06-07 12:42:31 +08:00
|
|
|
|
var platformOffsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0 };
|
2018-05-28 02:00:21 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
// the final usable gameplay clock with user-set offsets applied.
|
2018-06-07 12:42:31 +08:00
|
|
|
|
var offsetClock = new FramedOffsetClock(platformOffsetClock);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-22 16:51:39 +08:00
|
|
|
|
userAudioOffset.ValueChanged += offset => offsetClock.Offset = offset.NewValue;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
userAudioOffset.TriggerChange();
|
|
|
|
|
|
2018-05-26 13:46:05 +08:00
|
|
|
|
ScoreProcessor = RulesetContainer.CreateScoreProcessor();
|
2018-06-29 15:49:11 +08:00
|
|
|
|
if (!ScoreProcessor.Mode.Disabled)
|
|
|
|
|
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-28 19:01:15 +08:00
|
|
|
|
PauseContainer = new PauseContainer(offsetClock, adjustableClock)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-18 21:05:24 +08:00
|
|
|
|
Retries = RestartCount,
|
2019-03-05 12:27:39 +08:00
|
|
|
|
OnRetry = restart,
|
2018-12-13 15:17:24 +08:00
|
|
|
|
OnQuit = performUserRequestedExit,
|
2019-02-21 17:56:34 +08:00
|
|
|
|
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded.Value,
|
2019-02-20 15:53:57 +08:00
|
|
|
|
Children = new Container[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-27 16:56:44 +08:00
|
|
|
|
StoryboardContainer = CreateStoryboardContainer(),
|
2019-01-04 12:29:37 +08:00
|
|
|
|
new ScalingContainer(ScalingMode.Gameplay)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-01-04 14:34:32 +08:00
|
|
|
|
Child = new LocalSkinOverrideContainer(working.Skin)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = RulesetContainer
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2018-05-26 13:46:05 +08:00
|
|
|
|
new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-05-14 14:36:42 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Breaks = beatmap.Breaks
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2019-01-04 12:29:37 +08:00
|
|
|
|
new ScalingContainer(ScalingMode.Gameplay)
|
|
|
|
|
{
|
|
|
|
|
Child = RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
|
|
|
|
|
},
|
2019-03-05 12:26:54 +08:00
|
|
|
|
HUDOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working, adjustableClock)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
},
|
2018-07-17 13:29:22 +08:00
|
|
|
|
new SkipOverlay(RulesetContainer.GameplayStartTime)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-03-05 12:26:54 +08:00
|
|
|
|
RequestSeek = time => adjustableClock.Seek(time)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
failOverlay = new FailOverlay
|
|
|
|
|
{
|
2019-03-05 12:27:39 +08:00
|
|
|
|
OnRetry = restart,
|
2018-12-13 15:17:24 +08:00
|
|
|
|
OnQuit = performUserRequestedExit,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
new HotkeyRetryOverlay
|
|
|
|
|
{
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2019-01-23 19:52:00 +08:00
|
|
|
|
if (!this.IsCurrentScreen()) return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-08-02 18:08:23 +08:00
|
|
|
|
fadeOut(true);
|
2019-03-05 12:27:39 +08:00
|
|
|
|
restart();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-23 13:43:23 +08:00
|
|
|
|
HUDOverlay.HoldToQuit.Action = performUserRequestedExit;
|
|
|
|
|
HUDOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);
|
2018-04-22 01:21:09 +08:00
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
RulesetContainer.IsPaused.BindTo(PauseContainer.IsPaused);
|
2018-07-19 00:18:07 +08:00
|
|
|
|
|
2019-02-21 17:56:34 +08:00
|
|
|
|
if (ShowStoryboard.Value)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
initializeStoryboard(false);
|
|
|
|
|
|
|
|
|
|
// Bind ScoreProcessor to ourselves
|
2018-05-26 13:46:05 +08:00
|
|
|
|
ScoreProcessor.AllJudged += onCompletion;
|
|
|
|
|
ScoreProcessor.Failed += onFail;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
foreach (var mod in Beatmap.Value.Mods.Value.OfType<IApplicableToScoreProcessor>())
|
2018-05-26 13:46:05 +08:00
|
|
|
|
mod.ApplyToScoreProcessor(ScoreProcessor);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void applyRateFromMods()
|
|
|
|
|
{
|
|
|
|
|
if (sourceClock == null) return;
|
|
|
|
|
|
|
|
|
|
sourceClock.Rate = 1;
|
|
|
|
|
foreach (var mod in Beatmap.Value.Mods.Value.OfType<IApplicableToClock>())
|
|
|
|
|
mod.ApplyToClock(sourceClock);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-13 15:17:24 +08:00
|
|
|
|
private void performUserRequestedExit()
|
|
|
|
|
{
|
2019-01-23 19:52:00 +08:00
|
|
|
|
if (!this.IsCurrentScreen()) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
this.Exit();
|
2018-12-13 15:17:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-05 12:27:39 +08:00
|
|
|
|
private void restart()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-01-23 19:52:00 +08:00
|
|
|
|
if (!this.IsCurrentScreen()) return;
|
2018-12-13 15:17:24 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
sampleRestart?.Play();
|
|
|
|
|
ValidForResume = false;
|
|
|
|
|
RestartRequested?.Invoke();
|
2019-01-23 19:52:00 +08:00
|
|
|
|
this.Exit();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ScheduledDelegate onCompletionEvent;
|
|
|
|
|
|
|
|
|
|
private void onCompletion()
|
|
|
|
|
{
|
|
|
|
|
// Only show the completion screen if the player hasn't failed
|
2018-05-26 13:46:05 +08:00
|
|
|
|
if (ScoreProcessor.HasFailed || onCompletionEvent != null)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ValidForResume = false;
|
|
|
|
|
|
|
|
|
|
if (!AllowResults) return;
|
|
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(1000))
|
|
|
|
|
{
|
|
|
|
|
onCompletionEvent = Schedule(delegate
|
|
|
|
|
{
|
2019-01-23 19:52:00 +08:00
|
|
|
|
if (!this.IsCurrentScreen()) return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-11-30 17:32:08 +08:00
|
|
|
|
var score = CreateScore();
|
2018-12-04 03:37:26 +08:00
|
|
|
|
if (RulesetContainer.ReplayScore == null)
|
2018-11-29 17:07:51 +08:00
|
|
|
|
scoreManager.Import(score, true);
|
2018-11-29 13:56:29 +08:00
|
|
|
|
|
2019-02-18 11:55:42 +08:00
|
|
|
|
this.Push(CreateResults(score));
|
2018-07-28 06:34:51 +08:00
|
|
|
|
|
|
|
|
|
onCompletionEvent = null;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 17:32:08 +08:00
|
|
|
|
protected virtual ScoreInfo CreateScore()
|
2018-11-29 12:22:45 +08:00
|
|
|
|
{
|
2019-01-04 14:49:23 +08:00
|
|
|
|
var score = RulesetContainer.ReplayScore?.ScoreInfo ?? new ScoreInfo
|
2018-11-29 12:22:45 +08:00
|
|
|
|
{
|
2018-11-30 17:31:54 +08:00
|
|
|
|
Beatmap = Beatmap.Value.BeatmapInfo,
|
2018-11-29 12:22:45 +08:00
|
|
|
|
Ruleset = ruleset,
|
2018-12-27 21:16:58 +08:00
|
|
|
|
Mods = Beatmap.Value.Mods.Value.ToArray(),
|
|
|
|
|
User = api.LocalUser.Value,
|
2018-11-29 12:22:45 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ScoreProcessor.PopulateScore(score);
|
|
|
|
|
|
|
|
|
|
return score;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private bool onFail()
|
|
|
|
|
{
|
|
|
|
|
if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
adjustableClock.Stop();
|
|
|
|
|
|
|
|
|
|
HasFailed = true;
|
|
|
|
|
failOverlay.Retries = RestartCount;
|
|
|
|
|
failOverlay.Show();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override void OnEntering(IScreen last)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
|
2018-04-20 16:30:27 +08:00
|
|
|
|
if (!LoadedBeatmapSuccessfully)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
Alpha = 0;
|
|
|
|
|
this
|
2018-04-13 17:19:50 +08:00
|
|
|
|
.ScaleTo(0.7f)
|
|
|
|
|
.ScaleTo(1, 750, Easing.OutQuint)
|
|
|
|
|
.Delay(250)
|
|
|
|
|
.FadeIn(250);
|
|
|
|
|
|
2019-02-28 19:36:00 +08:00
|
|
|
|
ShowStoryboard.ValueChanged += enabled =>
|
2019-02-24 19:03:24 +08:00
|
|
|
|
{
|
2019-02-28 19:36:00 +08:00
|
|
|
|
if (enabled.NewValue) initializeStoryboard(true);
|
2019-02-24 19:03:24 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-02-20 15:53:57 +08:00
|
|
|
|
Background.EnableUserDim.Value = true;
|
2019-02-25 12:15:37 +08:00
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
2019-02-28 17:25:58 +08:00
|
|
|
|
StoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
2019-02-28 19:30:23 +08:00
|
|
|
|
|
2019-02-25 12:15:37 +08:00
|
|
|
|
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
2019-02-18 15:34:11 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
sourceClock.Reset();
|
|
|
|
|
|
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
adjustableClock.ChangeSource(sourceClock);
|
|
|
|
|
applyRateFromMods();
|
|
|
|
|
|
|
|
|
|
this.Delay(750).Schedule(() =>
|
|
|
|
|
{
|
2019-02-28 19:01:15 +08:00
|
|
|
|
if (!PauseContainer.IsPaused.Value)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
adjustableClock.Start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
PauseContainer.Alpha = 0;
|
|
|
|
|
PauseContainer.FadeIn(750, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override void OnSuspending(IScreen next)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
fadeOut();
|
|
|
|
|
base.OnSuspending(next);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
public override bool OnExiting(IScreen next)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-28 06:34:51 +08:00
|
|
|
|
if (onCompletionEvent != null)
|
|
|
|
|
{
|
|
|
|
|
// Proceed to result screen if beatmap already finished playing
|
|
|
|
|
onCompletionEvent.RunTask();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
if ((!AllowPause || HasFailed || !ValidForResume || PauseContainer?.IsPaused.Value != false || RulesetContainer?.HasReplayLoaded.Value != false) && (!PauseContainer?.IsResuming ?? true))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
// In the case of replays, we may have changed the playback rate.
|
|
|
|
|
applyRateFromMods();
|
|
|
|
|
fadeOut();
|
|
|
|
|
return base.OnExiting(next);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 16:30:27 +08:00
|
|
|
|
if (LoadedBeatmapSuccessfully)
|
2019-02-28 19:01:15 +08:00
|
|
|
|
PauseContainer?.Pause();
|
2019-02-15 15:17:01 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-02 18:08:23 +08:00
|
|
|
|
private void fadeOut(bool instant = false)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-08-02 18:08:23 +08:00
|
|
|
|
float fadeOutDuration = instant ? 0 : 250;
|
2019-01-23 19:52:00 +08:00
|
|
|
|
this.FadeOut(fadeOutDuration);
|
2019-02-28 19:30:23 +08:00
|
|
|
|
|
2019-02-20 15:53:57 +08:00
|
|
|
|
Background.EnableUserDim.Value = false;
|
2019-02-25 12:15:37 +08:00
|
|
|
|
storyboardReplacesBackground.Value = false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 19:01:15 +08:00
|
|
|
|
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !PauseContainer.IsPaused.Value;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private void initializeStoryboard(bool asyncLoad)
|
|
|
|
|
{
|
2019-02-28 19:36:00 +08:00
|
|
|
|
if (StoryboardContainer == null || storyboard != null)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var beatmap = Beatmap.Value;
|
|
|
|
|
|
|
|
|
|
storyboard = beatmap.Storyboard.CreateDrawable();
|
|
|
|
|
storyboard.Masking = true;
|
|
|
|
|
|
|
|
|
|
if (asyncLoad)
|
2019-02-27 16:02:04 +08:00
|
|
|
|
LoadComponentAsync(storyboard, StoryboardContainer.Add);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
else
|
2019-02-27 16:02:04 +08:00
|
|
|
|
StoryboardContainer.Add(storyboard);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-22 15:26:27 +08:00
|
|
|
|
protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|