2019-06-04 07:13:16 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
using System;
|
2019-04-09 04:33:16 +00:00
|
|
|
using System.Collections.Generic;
|
2020-03-24 05:13:46 +00:00
|
|
|
using System.IO;
|
2018-04-13 09:19:50 +00:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-02-21 10:04:31 +00:00
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-10-02 03:02:47 +00:00
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Logging;
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
using osu.Framework.Threading;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Configuration;
|
2019-01-04 04:29:37 +00:00
|
|
|
using osu.Game.Graphics.Containers;
|
2020-03-24 05:13:46 +00:00
|
|
|
using osu.Game.IO.Archives;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Online.API;
|
2018-06-06 06:10:09 +00:00
|
|
|
using osu.Game.Overlays;
|
2020-03-23 10:31:43 +00:00
|
|
|
using osu.Game.Replays;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Rulesets.UI;
|
2018-11-28 07:12:57 +00:00
|
|
|
using osu.Game.Scoring;
|
2020-03-24 05:13:46 +00:00
|
|
|
using osu.Game.Scoring.Legacy;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Screens.Ranking;
|
|
|
|
using osu.Game.Skinning;
|
2019-04-12 20:54:35 +00:00
|
|
|
using osu.Game.Users;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
2019-11-01 06:32:06 +00:00
|
|
|
[Cached]
|
2019-03-05 09:06:24 +00:00
|
|
|
public class Player : ScreenWithBeatmapBackground
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2020-04-20 03:42:33 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The delay upon completion of the beatmap before displaying the results screen.
|
|
|
|
/// </summary>
|
|
|
|
public const double RESULTS_DISPLAY_DELAY = 1000.0;
|
|
|
|
|
2019-06-25 07:55:49 +00:00
|
|
|
public override bool AllowBackButton => false; // handled by HoldForMenuButton
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-06-12 07:33:15 +00:00
|
|
|
protected override UserActivity InitialActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
public override float BackgroundParallaxAmount => 0.1f;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-01-28 06:41:54 +00:00
|
|
|
public override bool HideOverlaysOnEnter => true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-08-08 19:21:30 +00:00
|
|
|
private const OverlayActivation initial_overlay_activation_mode = OverlayActivation.UserTriggered;
|
|
|
|
public override OverlayActivation InitialOverlayActivationMode => initial_overlay_activation_mode;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The current activation mode for overlays.
|
|
|
|
/// </summary>
|
|
|
|
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(initial_overlay_activation_mode);
|
2018-06-06 06:10:09 +00:00
|
|
|
|
2019-05-10 06:39:25 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether gameplay should pause when the game window focus is lost.
|
|
|
|
/// </summary>
|
|
|
|
protected virtual bool PauseOnFocusLost => true;
|
2018-06-06 06:10:09 +00:00
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
public Action RestartRequested;
|
|
|
|
|
|
|
|
public bool HasFailed { get; private set; }
|
|
|
|
|
|
|
|
private Bindable<bool> mouseWheelDisabled;
|
2019-02-25 04:27:44 +00:00
|
|
|
|
|
|
|
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
public int RestartCount;
|
|
|
|
|
2018-11-29 05:56:29 +00:00
|
|
|
[Resolved]
|
|
|
|
private ScoreManager scoreManager { get; set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-26 03:21:49 +00:00
|
|
|
private RulesetInfo rulesetInfo;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-26 03:21:49 +00:00
|
|
|
private Ruleset ruleset;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-02-14 13:14:00 +00:00
|
|
|
[Resolved]
|
|
|
|
private IAPIProvider api { get; set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-08-03 14:00:10 +00:00
|
|
|
[Resolved(CanBeNull = true)]
|
2020-08-02 19:34:35 +00:00
|
|
|
private OsuGame game { get; set; }
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
private SampleChannel sampleRestart;
|
|
|
|
|
2019-12-12 06:14:59 +00:00
|
|
|
public BreakOverlay BreakOverlay;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-03-26 06:28:56 +00:00
|
|
|
private BreakTracker breakTracker;
|
|
|
|
|
2020-05-12 19:12:48 +00:00
|
|
|
private SkipOverlay skipOverlay;
|
|
|
|
|
2019-02-28 11:01:15 +00:00
|
|
|
protected ScoreProcessor ScoreProcessor { get; private set; }
|
2019-12-19 11:03:14 +00:00
|
|
|
|
|
|
|
protected HealthProcessor HealthProcessor { get; private set; }
|
|
|
|
|
2019-03-19 14:44:15 +00:00
|
|
|
protected DrawableRuleset DrawableRuleset { get; private set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-02-28 11:01:15 +00:00
|
|
|
protected HUDOverlay HUDOverlay { get; private set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-03-19 14:44:15 +00:00
|
|
|
public bool LoadedBeatmapSuccessfully => DrawableRuleset?.Objects.Any() == true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-03-17 15:46:15 +00:00
|
|
|
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-11-25 07:24:29 +00:00
|
|
|
public DimmableStoryboard DimmableStoryboard { get; private set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-04-09 04:33:16 +00:00
|
|
|
[Cached]
|
2019-04-17 07:11:59 +00:00
|
|
|
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
2019-04-25 08:36:17 +00:00
|
|
|
protected new readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
2019-04-09 04:33:16 +00:00
|
|
|
|
2019-09-18 19:49:28 +00:00
|
|
|
/// <summary>
|
2019-09-19 04:58:54 +00:00
|
|
|
/// Whether failing should be allowed.
|
2019-09-19 05:31:11 +00:00
|
|
|
/// By default, this checks whether all selected mods allow failing.
|
2019-09-18 19:49:28 +00:00
|
|
|
/// </summary>
|
2020-05-12 11:08:35 +00:00
|
|
|
protected virtual bool CheckModsAllowFailure() => Mods.Value.OfType<IApplicableFailOverride>().All(m => m.PerformFail());
|
2019-09-18 19:49:28 +00:00
|
|
|
|
2019-03-26 07:53:44 +00:00
|
|
|
private readonly bool allowPause;
|
|
|
|
private readonly bool showResults;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Create a new player instance.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="allowPause">Whether pausing should be allowed. If not allowed, attempting to pause will quit.</param>
|
|
|
|
/// <param name="showResults">Whether results screen should be pushed on completion.</param>
|
|
|
|
public Player(bool allowPause = true, bool showResults = true)
|
|
|
|
{
|
|
|
|
this.allowPause = allowPause;
|
|
|
|
this.showResults = showResults;
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-02-14 03:30:11 +00:00
|
|
|
private GameplayBeatmap gameplayBeatmap;
|
|
|
|
|
2020-06-18 14:35:03 +00:00
|
|
|
private ScreenSuspensionHandler screenSuspension;
|
|
|
|
|
2020-02-14 03:30:11 +00:00
|
|
|
private DependencyContainer dependencies;
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
|
|
|
2020-03-23 10:31:43 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
PrepareReplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
private Replay recordingReplay;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Run any recording / playback setup for replays.
|
|
|
|
/// </summary>
|
|
|
|
protected virtual void PrepareReplay()
|
|
|
|
{
|
|
|
|
DrawableRuleset.SetRecordTarget(recordingReplay = new Replay());
|
|
|
|
}
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2020-02-14 13:14:00 +00:00
|
|
|
private void load(AudioManager audio, OsuConfigManager config)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-04-17 07:11:59 +00:00
|
|
|
Mods.Value = base.Mods.Value.Select(m => m.CreateCopy()).ToArray();
|
2019-04-09 04:33:16 +00:00
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
if (Beatmap.Value is DummyWorkingBeatmap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IBeatmap playableBeatmap = loadPlayableBeatmap();
|
2019-03-06 11:30:14 +00:00
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
if (playableBeatmap == null)
|
2018-04-13 09:19:50 +00:00
|
|
|
return;
|
|
|
|
|
2019-05-28 08:06:01 +00:00
|
|
|
sampleRestart = audio.Samples.Get(@"Gameplay/restart");
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
|
|
|
|
2019-12-24 08:01:17 +00:00
|
|
|
ScoreProcessor = ruleset.CreateScoreProcessor();
|
|
|
|
ScoreProcessor.ApplyBeatmap(playableBeatmap);
|
2019-04-25 10:56:57 +00:00
|
|
|
ScoreProcessor.Mods.BindTo(Mods);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-12-27 07:14:49 +00:00
|
|
|
HealthProcessor = ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
|
2019-12-24 08:01:17 +00:00
|
|
|
HealthProcessor.ApplyBeatmap(playableBeatmap);
|
2019-12-19 11:03:14 +00:00
|
|
|
|
2018-06-29 07:49:11 +00:00
|
|
|
if (!ScoreProcessor.Mode.Disabled)
|
|
|
|
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
InternalChild = GameplayClockContainer = new GameplayClockContainer(Beatmap.Value, Mods.Value, DrawableRuleset.GameplayStartTime);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-02-14 03:30:11 +00:00
|
|
|
AddInternal(gameplayBeatmap = new GameplayBeatmap(playableBeatmap));
|
2020-06-18 14:35:03 +00:00
|
|
|
AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));
|
2020-02-14 03:30:11 +00:00
|
|
|
|
|
|
|
dependencies.CacheAs(gameplayBeatmap);
|
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
addUnderlayComponents(GameplayClockContainer);
|
2020-04-02 09:39:49 +00:00
|
|
|
addGameplayComponents(GameplayClockContainer, Beatmap.Value, playableBeatmap);
|
2019-12-12 06:58:11 +00:00
|
|
|
addOverlayComponents(GameplayClockContainer, Beatmap.Value);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-05-08 07:37:50 +00:00
|
|
|
if (!DrawableRuleset.AllowGameplayOverlays)
|
2020-05-07 06:52:36 +00:00
|
|
|
{
|
|
|
|
HUDOverlay.ShowHud.Value = false;
|
|
|
|
HUDOverlay.ShowHud.Disabled = true;
|
|
|
|
BreakOverlay.Hide();
|
2020-05-12 19:12:48 +00:00
|
|
|
skipOverlay.Hide();
|
2020-05-07 06:52:36 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 14:00:10 +00:00
|
|
|
if (game != null)
|
|
|
|
OverlayActivationMode.BindTo(game.OverlayActivationMode);
|
|
|
|
|
2020-08-16 15:18:40 +00:00
|
|
|
DrawableRuleset.IsPaused.BindValueChanged(_ => updateOverlayActivationMode());
|
|
|
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateOverlayActivationMode());
|
|
|
|
breakTracker.IsBreakTime.BindValueChanged(_ => updateOverlayActivationMode());
|
|
|
|
|
2020-03-06 09:00:17 +00:00
|
|
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
// bind clock into components that require it
|
|
|
|
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-12-19 11:03:14 +00:00
|
|
|
DrawableRuleset.OnNewResult += r =>
|
|
|
|
{
|
|
|
|
HealthProcessor.ApplyResult(r);
|
|
|
|
ScoreProcessor.ApplyResult(r);
|
2020-05-03 14:55:44 +00:00
|
|
|
gameplayBeatmap.ApplyResult(r);
|
2019-12-19 11:03:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DrawableRuleset.OnRevertResult += r =>
|
|
|
|
{
|
|
|
|
HealthProcessor.RevertResult(r);
|
|
|
|
ScoreProcessor.RevertResult(r);
|
|
|
|
};
|
2019-12-11 08:25:06 +00:00
|
|
|
|
2019-12-19 11:03:14 +00:00
|
|
|
// Bind the judgement processors to ourselves
|
2020-04-19 02:58:22 +00:00
|
|
|
ScoreProcessor.HasCompleted.ValueChanged += updateCompletionState;
|
2019-12-19 11:03:14 +00:00
|
|
|
HealthProcessor.Failed += onFail;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
|
|
|
mod.ApplyToScoreProcessor(ScoreProcessor);
|
2019-12-19 11:03:14 +00:00
|
|
|
|
|
|
|
foreach (var mod in Mods.Value.OfType<IApplicableToHealthProcessor>())
|
|
|
|
mod.ApplyToHealthProcessor(HealthProcessor);
|
|
|
|
|
2020-03-26 06:28:56 +00:00
|
|
|
breakTracker.IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
|
2019-08-27 09:27:21 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
private void addUnderlayComponents(Container target)
|
|
|
|
{
|
2019-09-15 15:20:56 +00:00
|
|
|
target.Add(DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both });
|
2019-08-27 09:27:21 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-04-02 09:39:49 +00:00
|
|
|
private void addGameplayComponents(Container target, WorkingBeatmap working, IBeatmap playableBeatmap)
|
2019-08-27 09:27:21 +00:00
|
|
|
{
|
|
|
|
var beatmapSkinProvider = new BeatmapSkinProvidingContainer(working.Skin);
|
2018-05-27 18:00:21 +00:00
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
// the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
|
|
|
|
// full access to all skin sources.
|
2020-04-02 09:39:49 +00:00
|
|
|
var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider, playableBeatmap));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
// load the skinning hierarchy first.
|
|
|
|
// this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
|
|
|
|
target.Add(new ScalingContainer(ScalingMode.Gameplay)
|
|
|
|
.WithChild(beatmapSkinProvider
|
|
|
|
.WithChild(target = rulesetSkinProvider)));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
target.AddRange(new Drawable[]
|
2019-08-26 03:21:49 +00:00
|
|
|
{
|
2019-08-27 09:27:21 +00:00
|
|
|
DrawableRuleset,
|
|
|
|
new ComboEffects(ScoreProcessor)
|
|
|
|
});
|
2020-03-26 06:28:56 +00:00
|
|
|
|
|
|
|
DrawableRuleset.FrameStableComponents.AddRange(new Drawable[]
|
|
|
|
{
|
|
|
|
ScoreProcessor,
|
|
|
|
HealthProcessor,
|
|
|
|
breakTracker = new BreakTracker(DrawableRuleset.GameplayStartTime, ScoreProcessor)
|
|
|
|
{
|
|
|
|
Breaks = working.Beatmap.Breaks
|
|
|
|
}
|
|
|
|
});
|
2019-08-27 09:27:21 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-08-27 09:27:21 +00:00
|
|
|
private void addOverlayComponents(Container target, WorkingBeatmap working)
|
|
|
|
{
|
|
|
|
target.AddRange(new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2020-05-19 17:47:01 +00:00
|
|
|
DimmableStoryboard.OverlayLayerContainer.CreateProxy(),
|
2020-03-27 20:19:49 +00:00
|
|
|
BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
|
|
|
{
|
|
|
|
Clock = DrawableRuleset.FrameStableClock,
|
|
|
|
ProcessCustomClock = false,
|
|
|
|
Breaks = working.Beatmap.Breaks
|
|
|
|
},
|
2019-03-18 02:48:11 +00:00
|
|
|
// display the cursor above some HUD elements.
|
2019-03-20 06:27:06 +00:00
|
|
|
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
2019-09-02 02:20:50 +00:00
|
|
|
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
2019-12-19 11:03:14 +00:00
|
|
|
HUDOverlay = new HUDOverlay(ScoreProcessor, HealthProcessor, DrawableRuleset, Mods.Value)
|
2019-03-18 02:48:11 +00:00
|
|
|
{
|
2019-05-10 06:51:12 +00:00
|
|
|
HoldToQuit =
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-05-10 06:51:12 +00:00
|
|
|
Action = performUserRequestedExit,
|
|
|
|
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
|
|
|
},
|
2019-03-18 02:48:11 +00:00
|
|
|
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
|
2020-03-06 09:00:17 +00:00
|
|
|
KeyCounter =
|
|
|
|
{
|
|
|
|
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
|
|
|
IsCounting = false
|
|
|
|
},
|
2019-03-18 02:48:11 +00:00
|
|
|
RequestSeek = GameplayClockContainer.Seek,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
},
|
2020-05-12 19:12:48 +00:00
|
|
|
skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime)
|
2019-03-18 02:48:11 +00:00
|
|
|
{
|
2019-11-21 09:57:19 +00:00
|
|
|
RequestSkip = GameplayClockContainer.Skip
|
2019-03-18 02:48:11 +00:00
|
|
|
},
|
|
|
|
FailOverlay = new FailOverlay
|
|
|
|
{
|
2019-03-18 05:57:06 +00:00
|
|
|
OnRetry = Restart,
|
2019-03-18 02:48:11 +00:00
|
|
|
OnQuit = performUserRequestedExit,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-03-18 02:48:11 +00:00
|
|
|
PauseOverlay = new PauseOverlay
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-03-18 02:48:11 +00:00
|
|
|
OnResume = Resume,
|
|
|
|
Retries = RestartCount,
|
2018-04-13 09:19:50 +00:00
|
|
|
OnRetry = Restart,
|
2018-12-13 07:17:24 +00:00
|
|
|
OnQuit = performUserRequestedExit,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
|
|
|
new HotkeyRetryOverlay
|
|
|
|
{
|
|
|
|
Action = () =>
|
|
|
|
{
|
2019-01-23 11:52:00 +00:00
|
|
|
if (!this.IsCurrentScreen()) return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-08-02 10:08:23 +00:00
|
|
|
fadeOut(true);
|
2018-04-13 09:19:50 +00:00
|
|
|
Restart();
|
|
|
|
},
|
2019-06-04 07:13:16 +00:00
|
|
|
},
|
2019-06-24 09:15:27 +00:00
|
|
|
new HotkeyExitOverlay
|
|
|
|
{
|
|
|
|
Action = () =>
|
|
|
|
{
|
|
|
|
if (!this.IsCurrentScreen()) return;
|
|
|
|
|
|
|
|
fadeOut(true);
|
2019-06-25 14:15:58 +00:00
|
|
|
performImmediateExit();
|
2019-06-24 09:15:27 +00:00
|
|
|
},
|
|
|
|
},
|
2020-03-26 03:50:18 +00:00
|
|
|
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, },
|
2019-12-25 05:35:32 +00:00
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 09:00:17 +00:00
|
|
|
private void onBreakTimeChanged(ValueChangedEvent<bool> isBreakTime)
|
2020-02-29 15:37:42 +00:00
|
|
|
{
|
2020-03-06 09:00:17 +00:00
|
|
|
updatePauseOnFocusLostState();
|
|
|
|
HUDOverlay.KeyCounter.IsCounting = !isBreakTime.NewValue;
|
2020-02-29 15:37:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-03 19:25:45 +00:00
|
|
|
private void updateOverlayActivationMode()
|
|
|
|
{
|
2020-08-16 15:18:40 +00:00
|
|
|
bool canTriggerOverlays = DrawableRuleset.IsPaused.Value || breakTracker.IsBreakTime.Value;
|
2020-08-05 09:21:09 +00:00
|
|
|
|
|
|
|
if (DrawableRuleset.HasReplayLoaded.Value || canTriggerOverlays)
|
2020-08-03 19:25:45 +00:00
|
|
|
OverlayActivationMode.Value = OverlayActivation.UserTriggered;
|
|
|
|
else
|
2020-08-05 09:21:09 +00:00
|
|
|
OverlayActivationMode.Value = OverlayActivation.Disabled;
|
2020-08-03 19:25:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 09:00:17 +00:00
|
|
|
private void updatePauseOnFocusLostState() =>
|
2019-12-11 06:45:50 +00:00
|
|
|
HUDOverlay.HoldToQuit.PauseOnFocusLost = PauseOnFocusLost
|
2020-03-06 09:00:17 +00:00
|
|
|
&& !DrawableRuleset.HasReplayLoaded.Value
|
2020-03-26 06:28:56 +00:00
|
|
|
&& !breakTracker.IsBreakTime.Value;
|
2019-12-11 06:45:50 +00:00
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
private IBeatmap loadPlayableBeatmap()
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-12-12 06:58:11 +00:00
|
|
|
IBeatmap playable;
|
2019-03-06 11:30:14 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2019-12-12 06:58:11 +00:00
|
|
|
if (Beatmap.Value.Beatmap == null)
|
2019-03-06 11:30:14 +00:00
|
|
|
throw new InvalidOperationException("Beatmap was not loaded");
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
rulesetInfo = Ruleset.Value ?? Beatmap.Value.BeatmapInfo.Ruleset;
|
2019-08-26 03:21:49 +00:00
|
|
|
ruleset = rulesetInfo.CreateInstance();
|
2019-03-06 11:30:14 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2019-12-12 06:58:11 +00:00
|
|
|
playable = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Mods.Value);
|
2019-03-06 11:30:14 +00:00
|
|
|
}
|
|
|
|
catch (BeatmapInvalidForRulesetException)
|
|
|
|
{
|
2019-12-12 06:58:11 +00:00
|
|
|
// A playable beatmap may not be creatable with the user's preferred ruleset, so try using the beatmap's default ruleset
|
|
|
|
rulesetInfo = Beatmap.Value.BeatmapInfo.Ruleset;
|
2019-08-26 03:21:49 +00:00
|
|
|
ruleset = rulesetInfo.CreateInstance();
|
2019-12-12 06:58:11 +00:00
|
|
|
|
|
|
|
playable = Beatmap.Value.GetPlayableBeatmap(rulesetInfo, Mods.Value);
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
if (playable.HitObjects.Count == 0)
|
2019-03-06 11:30:14 +00:00
|
|
|
{
|
|
|
|
Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Error);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Logger.Error(e, "Could not load beatmap sucessfully!");
|
|
|
|
//couldn't load, hard abort!
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-21 17:21:09 +00:00
|
|
|
|
2019-12-12 06:58:11 +00:00
|
|
|
return playable;
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
2018-07-18 16:18:07 +00:00
|
|
|
|
2019-06-25 14:15:58 +00:00
|
|
|
private void performImmediateExit()
|
2018-12-13 07:17:24 +00:00
|
|
|
{
|
2019-06-24 09:15:27 +00:00
|
|
|
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
|
2019-08-06 14:05:12 +00:00
|
|
|
completionProgressDelegate?.Cancel();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-06-24 09:15:27 +00:00
|
|
|
ValidForResume = false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-06-25 14:15:58 +00:00
|
|
|
performUserRequestedExit();
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 14:15:58 +00:00
|
|
|
private void performUserRequestedExit()
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-06-25 14:15:58 +00:00
|
|
|
if (!this.IsCurrentScreen()) return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-10-04 03:41:53 +00:00
|
|
|
if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
|
2019-10-04 03:23:42 +00:00
|
|
|
{
|
|
|
|
failAnimation.FinishTransforms(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-02 18:16:31 +00:00
|
|
|
if (canPause)
|
|
|
|
Pause();
|
|
|
|
else
|
|
|
|
this.Exit();
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-11-01 06:51:45 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
|
|
|
|
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
|
|
|
|
/// </summary>
|
2018-04-13 09:19:50 +00:00
|
|
|
public void Restart()
|
|
|
|
{
|
|
|
|
sampleRestart?.Play();
|
|
|
|
RestartRequested?.Invoke();
|
2019-11-01 06:32:06 +00:00
|
|
|
|
|
|
|
if (this.IsCurrentScreen())
|
|
|
|
performImmediateExit();
|
2019-11-01 06:51:10 +00:00
|
|
|
else
|
|
|
|
this.MakeCurrent();
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 14:05:12 +00:00
|
|
|
private ScheduledDelegate completionProgressDelegate;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-04-19 02:58:22 +00:00
|
|
|
private void updateCompletionState(ValueChangedEvent<bool> completionState)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2020-03-19 05:10:54 +00:00
|
|
|
// screen may be in the exiting transition phase.
|
|
|
|
if (!this.IsCurrentScreen())
|
|
|
|
return;
|
|
|
|
|
2020-04-19 02:59:56 +00:00
|
|
|
if (!completionState.NewValue)
|
|
|
|
{
|
|
|
|
completionProgressDelegate?.Cancel();
|
|
|
|
completionProgressDelegate = null;
|
|
|
|
ValidForResume = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-21 02:51:20 +00:00
|
|
|
if (completionProgressDelegate != null)
|
|
|
|
throw new InvalidOperationException($"{nameof(updateCompletionState)} was fired more than once");
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
// Only show the completion screen if the player hasn't failed
|
2020-04-21 02:51:20 +00:00
|
|
|
if (HealthProcessor.HasFailed)
|
2018-04-13 09:19:50 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
ValidForResume = false;
|
|
|
|
|
2019-03-26 07:53:44 +00:00
|
|
|
if (!showResults) return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-04-20 03:42:33 +00:00
|
|
|
using (BeginDelayedSequence(RESULTS_DISPLAY_DELAY))
|
2020-04-21 02:51:20 +00:00
|
|
|
completionProgressDelegate = Schedule(GotoRanking);
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2018-11-30 09:32:08 +00:00
|
|
|
protected virtual ScoreInfo CreateScore()
|
2018-11-29 04:22:45 +00:00
|
|
|
{
|
2020-03-17 07:42:55 +00:00
|
|
|
var score = new ScoreInfo
|
2018-11-29 04:22:45 +00:00
|
|
|
{
|
2018-11-30 09:31:54 +00:00
|
|
|
Beatmap = Beatmap.Value.BeatmapInfo,
|
2019-08-26 03:21:49 +00:00
|
|
|
Ruleset = rulesetInfo,
|
2019-04-10 03:03:57 +00:00
|
|
|
Mods = Mods.Value.ToArray(),
|
2018-11-29 04:22:45 +00:00
|
|
|
};
|
|
|
|
|
2020-03-17 07:42:55 +00:00
|
|
|
if (DrawableRuleset.ReplayScore != null)
|
|
|
|
score.User = DrawableRuleset.ReplayScore.ScoreInfo?.User ?? new GuestUser();
|
|
|
|
else
|
|
|
|
score.User = api.LocalUser.Value;
|
|
|
|
|
2018-11-29 04:22:45 +00:00
|
|
|
ScoreProcessor.PopulateScore(score);
|
|
|
|
|
|
|
|
return score;
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:48:11 +00:00
|
|
|
protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !GameplayClockContainer.IsPaused.Value;
|
|
|
|
|
2020-05-26 08:00:41 +00:00
|
|
|
protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score);
|
2019-03-18 02:48:11 +00:00
|
|
|
|
|
|
|
#region Fail Logic
|
|
|
|
|
|
|
|
protected FailOverlay FailOverlay { get; private set; }
|
|
|
|
|
2019-06-04 07:13:16 +00:00
|
|
|
private FailAnimation failAnimation;
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
private bool onFail()
|
|
|
|
{
|
2020-05-12 11:08:35 +00:00
|
|
|
if (!CheckModsAllowFailure())
|
2018-04-13 09:19:50 +00:00
|
|
|
return false;
|
|
|
|
|
2018-10-31 11:03:37 +00:00
|
|
|
HasFailed = true;
|
|
|
|
|
2019-03-18 02:48:11 +00:00
|
|
|
// There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer)
|
|
|
|
// could process an extra frame after the GameplayClock is stopped.
|
|
|
|
// In such cases we want the fail state to precede a user triggered pause.
|
2019-06-11 05:28:52 +00:00
|
|
|
if (PauseOverlay.State.Value == Visibility.Visible)
|
2019-03-18 02:48:11 +00:00
|
|
|
PauseOverlay.Hide();
|
|
|
|
|
2019-09-18 16:45:59 +00:00
|
|
|
failAnimation.Start();
|
2019-09-19 08:53:10 +00:00
|
|
|
|
|
|
|
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
|
2018-10-14 15:18:52 +00:00
|
|
|
Restart();
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-04 07:13:16 +00:00
|
|
|
// Called back when the transform finishes
|
|
|
|
private void onFailComplete()
|
|
|
|
{
|
|
|
|
GameplayClockContainer.Stop();
|
|
|
|
|
2019-03-18 02:48:11 +00:00
|
|
|
FailOverlay.Retries = RestartCount;
|
|
|
|
FailOverlay.Show();
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 02:48:11 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Pause Logic
|
|
|
|
|
|
|
|
public bool IsResuming { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The amount of gameplay time after which a second pause is allowed.
|
|
|
|
/// </summary>
|
|
|
|
private const double pause_cooldown = 1000;
|
|
|
|
|
|
|
|
protected PauseOverlay PauseOverlay { get; private set; }
|
|
|
|
|
|
|
|
private double? lastPauseActionTime;
|
|
|
|
|
|
|
|
private bool canPause =>
|
|
|
|
// must pass basic screen conditions (beatmap loaded, instance allows pause)
|
2019-03-26 07:53:44 +00:00
|
|
|
LoadedBeatmapSuccessfully && allowPause && ValidForResume
|
2019-03-18 02:48:11 +00:00
|
|
|
// replays cannot be paused and exit immediately
|
2019-03-20 06:27:06 +00:00
|
|
|
&& !DrawableRuleset.HasReplayLoaded.Value
|
2019-03-18 02:48:11 +00:00
|
|
|
// cannot pause if we are already in a fail state
|
|
|
|
&& !HasFailed
|
2019-03-22 05:42:51 +00:00
|
|
|
// cannot pause if already paused (or in a cooldown state) unless we are in a resuming state.
|
2019-11-24 07:44:35 +00:00
|
|
|
&& (IsResuming || (GameplayClockContainer.IsPaused.Value == false && !pauseCooldownActive));
|
2019-03-18 05:40:53 +00:00
|
|
|
|
|
|
|
private bool pauseCooldownActive =>
|
|
|
|
lastPauseActionTime.HasValue && GameplayClockContainer.GameplayClock.CurrentTime < lastPauseActionTime + pause_cooldown;
|
2019-03-18 02:48:11 +00:00
|
|
|
|
|
|
|
private bool canResume =>
|
|
|
|
// cannot resume from a non-paused state
|
|
|
|
GameplayClockContainer.IsPaused.Value
|
|
|
|
// cannot resume if we are already in a fail state
|
|
|
|
&& !HasFailed
|
|
|
|
// already resuming
|
|
|
|
&& !IsResuming;
|
|
|
|
|
|
|
|
public void Pause()
|
|
|
|
{
|
|
|
|
if (!canPause) return;
|
|
|
|
|
2019-10-25 19:57:49 +00:00
|
|
|
if (IsResuming)
|
|
|
|
{
|
|
|
|
DrawableRuleset.CancelResume();
|
2019-11-01 05:43:52 +00:00
|
|
|
IsResuming = false;
|
2019-10-25 19:57:49 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 02:48:11 +00:00
|
|
|
GameplayClockContainer.Stop();
|
|
|
|
PauseOverlay.Show();
|
|
|
|
lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Resume()
|
|
|
|
{
|
|
|
|
if (!canResume) return;
|
|
|
|
|
|
|
|
IsResuming = true;
|
|
|
|
PauseOverlay.Hide();
|
2019-03-18 05:40:53 +00:00
|
|
|
|
2019-04-07 19:32:55 +00:00
|
|
|
// breaks and time-based conditions may allow instant resume.
|
2020-03-26 06:28:56 +00:00
|
|
|
if (breakTracker.IsBreakTime.Value)
|
2019-03-18 05:40:53 +00:00
|
|
|
completeResume();
|
|
|
|
else
|
2019-03-20 06:27:06 +00:00
|
|
|
DrawableRuleset.RequestResume(completeResume);
|
2019-03-18 05:40:53 +00:00
|
|
|
|
|
|
|
void completeResume()
|
|
|
|
{
|
|
|
|
GameplayClockContainer.Start();
|
|
|
|
IsResuming = false;
|
|
|
|
}
|
2019-03-18 02:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Screen Logic
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
public override void OnEntering(IScreen last)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
2018-04-20 08:30:27 +00:00
|
|
|
if (!LoadedBeatmapSuccessfully)
|
2018-04-13 09:19:50 +00:00
|
|
|
return;
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
Alpha = 0;
|
|
|
|
this
|
2018-04-13 09:19:50 +00:00
|
|
|
.ScaleTo(0.7f)
|
|
|
|
.ScaleTo(1, 750, Easing.OutQuint)
|
|
|
|
.Delay(250)
|
|
|
|
.FadeIn(250);
|
|
|
|
|
2019-11-25 07:24:29 +00:00
|
|
|
Background.EnableUserDim.Value = true;
|
|
|
|
Background.BlurAmount.Value = 0;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-12-10 20:06:13 +00:00
|
|
|
// bind component bindables.
|
2020-03-26 06:28:56 +00:00
|
|
|
Background.IsBreakTime.BindTo(breakTracker.IsBreakTime);
|
|
|
|
DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime);
|
2019-12-10 20:06:13 +00:00
|
|
|
|
2019-02-28 11:01:15 +00:00
|
|
|
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
2019-07-12 02:50:06 +00:00
|
|
|
DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-02-25 04:15:37 +00:00
|
|
|
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
2019-02-18 07:34:11 +00:00
|
|
|
|
2019-03-17 15:46:15 +00:00
|
|
|
GameplayClockContainer.Restart();
|
2019-03-18 02:48:11 +00:00
|
|
|
GameplayClockContainer.FadeInFromZero(750, Easing.OutQuint);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-11-25 07:24:29 +00:00
|
|
|
foreach (var mod in Mods.Value.OfType<IApplicableToPlayer>())
|
|
|
|
mod.ApplyToPlayer(this);
|
|
|
|
|
2019-06-29 01:23:59 +00:00
|
|
|
foreach (var mod in Mods.Value.OfType<IApplicableToHUD>())
|
|
|
|
mod.ApplyToHUD(HUDOverlay);
|
2020-08-02 19:34:35 +00:00
|
|
|
|
2020-08-16 15:18:40 +00:00
|
|
|
updateOverlayActivationMode();
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
public override void OnSuspending(IScreen next)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2020-06-18 14:35:03 +00:00
|
|
|
screenSuspension?.Expire();
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
fadeOut();
|
|
|
|
base.OnSuspending(next);
|
|
|
|
}
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
public override bool OnExiting(IScreen next)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2020-06-18 14:35:03 +00:00
|
|
|
screenSuspension?.Expire();
|
|
|
|
|
2019-08-06 14:05:12 +00:00
|
|
|
if (completionProgressDelegate != null && !completionProgressDelegate.Cancelled && !completionProgressDelegate.Completed)
|
2018-07-27 22:34:51 +00:00
|
|
|
{
|
2019-08-06 14:05:12 +00:00
|
|
|
// proceed to result screen if beatmap already finished playing
|
2020-03-19 05:10:54 +00:00
|
|
|
completionProgressDelegate.RunTask();
|
2018-07-27 22:34:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-09-13 06:41:53 +00:00
|
|
|
// ValidForResume is false when restarting
|
|
|
|
if (ValidForResume)
|
2019-06-04 07:13:16 +00:00
|
|
|
{
|
2019-09-13 06:41:53 +00:00
|
|
|
if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value)
|
|
|
|
// still want to block if we are within the cooldown period and not already paused.
|
|
|
|
return true;
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-11-01 05:11:18 +00:00
|
|
|
// GameplayClockContainer performs seeks / start / stop operations on the beatmap's track.
|
|
|
|
// as we are no longer the current screen, we cannot guarantee the track is still usable.
|
2019-12-23 10:13:36 +00:00
|
|
|
GameplayClockContainer?.StopUsingBeatmapClock();
|
2019-11-01 05:11:18 +00:00
|
|
|
|
2019-03-16 05:20:10 +00:00
|
|
|
fadeOut();
|
|
|
|
return base.OnExiting(next);
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 13:51:28 +00:00
|
|
|
protected virtual void GotoRanking()
|
|
|
|
{
|
|
|
|
if (DrawableRuleset.ReplayScore != null)
|
|
|
|
{
|
|
|
|
// if a replay is present, we likely don't want to import into the local database.
|
|
|
|
this.Push(CreateResults(CreateScore()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LegacyByteArrayReader replayReader = null;
|
|
|
|
|
|
|
|
var score = new Score { ScoreInfo = CreateScore() };
|
|
|
|
|
|
|
|
if (recordingReplay?.Frames.Count > 0)
|
|
|
|
{
|
|
|
|
score.Replay = recordingReplay;
|
|
|
|
|
|
|
|
using (var stream = new MemoryStream())
|
|
|
|
{
|
|
|
|
new LegacyScoreEncoder(score, gameplayBeatmap.PlayableBeatmap).Encode(stream);
|
|
|
|
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scoreManager.Import(score.ScoreInfo, replayReader)
|
|
|
|
.ContinueWith(imported => Schedule(() =>
|
|
|
|
{
|
|
|
|
// screen may be in the exiting transition phase.
|
|
|
|
if (this.IsCurrentScreen())
|
|
|
|
this.Push(CreateResults(imported.Result));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2018-08-02 10:08:23 +00:00
|
|
|
private void fadeOut(bool instant = false)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2018-08-02 10:08:23 +00:00
|
|
|
float fadeOutDuration = instant ? 0 : 250;
|
2019-01-23 11:52:00 +00:00
|
|
|
this.FadeOut(fadeOutDuration);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-02-20 07:53:57 +00:00
|
|
|
Background.EnableUserDim.Value = false;
|
2019-02-25 04:15:37 +00:00
|
|
|
storyboardReplacesBackground.Value = false;
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 02:48:11 +00:00
|
|
|
#endregion
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|