Merge remote-tracking branch 'upstream/master' into colour-score-meter

This commit is contained in:
Dean Herbert
2020-01-24 11:45:33 +09:00
419 changed files with 5911 additions and 2668 deletions

View File

@ -10,7 +10,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;

View File

@ -163,8 +163,6 @@ namespace osu.Game.Screens.Play
// Don't let mouse down events through the overlay or people can click circles while paused.
protected override bool OnMouseDown(MouseDownEvent e) => true;
protected override bool OnMouseUp(MouseUpEvent e) => true;
protected override bool OnMouseMove(MouseMoveEvent e) => true;
protected void AddButton(string text, Color4 colour, Action action)
@ -247,16 +245,8 @@ namespace osu.Game.Screens.Play
return false;
}
public bool OnReleased(GlobalAction action)
public void OnReleased(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
case GlobalAction.Select:
return true;
}
return false;
}
private void buttonSelectionChanged(DialogButton button, bool isSelected)

View File

@ -12,7 +12,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -259,16 +259,14 @@ namespace osu.Game.Screens.Play.HUD
return false;
}
public bool OnReleased(GlobalAction action)
public void OnReleased(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
AbortConfirm();
return true;
break;
}
return false;
}
protected override bool OnMouseDown(MouseDownEvent e)
@ -278,11 +276,10 @@ namespace osu.Game.Screens.Play.HUD
return true;
}
protected override bool OnMouseUp(MouseUpEvent e)
protected override void OnMouseUp(MouseUpEvent e)
{
if (!e.HasAnyButtonPressed)
AbortConfirm();
return true;
}
}
}

View File

@ -41,6 +41,7 @@ namespace osu.Game.Screens.Play
public Bindable<bool> ShowHealthbar = new Bindable<bool>(true);
private readonly ScoreProcessor scoreProcessor;
private readonly HealthProcessor healthProcessor;
private readonly DrawableRuleset drawableRuleset;
private readonly IReadOnlyList<Mod> mods;
@ -63,9 +64,10 @@ namespace osu.Game.Screens.Play
private IEnumerable<Drawable> hideTargets => new Drawable[] { visibilityContainer, KeyCounter };
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
public HUDOverlay(ScoreProcessor scoreProcessor, HealthProcessor healthProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
{
this.scoreProcessor = scoreProcessor;
this.healthProcessor = healthProcessor;
this.drawableRuleset = drawableRuleset;
this.mods = mods;
@ -119,7 +121,10 @@ namespace osu.Game.Screens.Play
private void load(OsuConfigManager config, NotificationOverlay notificationOverlay)
{
if (scoreProcessor != null)
BindProcessor(scoreProcessor);
BindScoreProcessor(scoreProcessor);
if (healthProcessor != null)
BindHealthProcessor(healthProcessor);
if (drawableRuleset != null)
{
@ -288,15 +293,19 @@ namespace osu.Game.Screens.Play
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
protected virtual void BindProcessor(ScoreProcessor processor)
protected virtual void BindScoreProcessor(ScoreProcessor processor)
{
ScoreCounter?.Current.BindTo(processor.TotalScore);
AccuracyCounter?.Current.BindTo(processor.Accuracy);
ComboCounter?.Current.BindTo(processor.Combo);
HealthDisplay?.Current.BindTo(processor.Health);
if (HealthDisplay is StandardHealthDisplay shd)
processor.NewJudgement += shd.Flash;
}
protected virtual void BindHealthProcessor(HealthProcessor processor)
{
HealthDisplay?.Current.BindTo(processor.Health);
}
}
}

View File

@ -17,12 +17,11 @@ namespace osu.Game.Screens.Play
return true;
}
public bool OnReleased(GlobalAction action)
public void OnReleased(GlobalAction action)
{
if (action != GlobalAction.QuickExit) return false;
if (action != GlobalAction.QuickExit) return;
AbortConfirm();
return true;
}
}
}

View File

@ -17,12 +17,11 @@ namespace osu.Game.Screens.Play
return true;
}
public bool OnReleased(GlobalAction action)
public void OnReleased(GlobalAction action)
{
if (action != GlobalAction.QuickRetry) return false;
if (action != GlobalAction.QuickRetry) return;
AbortConfirm();
return true;
}
}
}

View File

@ -27,15 +27,14 @@ namespace osu.Game.Screens.Play
return false;
}
public bool OnReleased(T action, bool forwards)
public void OnReleased(T action, bool forwards)
{
if (!EqualityComparer<T>.Default.Equals(action, Action))
return false;
return;
IsLit = false;
if (!forwards)
Decrement();
return false;
}
}
}

View File

@ -27,10 +27,10 @@ namespace osu.Game.Screens.Play
return base.OnKeyDown(e);
}
protected override bool OnKeyUp(KeyUpEvent e)
protected override void OnKeyUp(KeyUpEvent e)
{
if (e.Key == Key) IsLit = false;
return base.OnKeyUp(e);
base.OnKeyUp(e);
}
}
}

View File

@ -45,10 +45,10 @@ namespace osu.Game.Screens.Play
return base.OnMouseDown(e);
}
protected override bool OnMouseUp(MouseUpEvent e)
protected override void OnMouseUp(MouseUpEvent e)
{
if (e.Button == Button) IsLit = false;
return base.OnMouseUp(e);
base.OnMouseUp(e);
}
}
}

View File

@ -72,6 +72,9 @@ namespace osu.Game.Screens.Play
public BreakOverlay BreakOverlay;
protected ScoreProcessor ScoreProcessor { get; private set; }
protected HealthProcessor HealthProcessor { get; private set; }
protected DrawableRuleset DrawableRuleset { get; private set; }
protected HUDOverlay HUDOverlay { get; private set; }
@ -128,9 +131,13 @@ namespace osu.Game.Screens.Play
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
ScoreProcessor = ruleset.CreateScoreProcessor(playableBeatmap);
ScoreProcessor = ruleset.CreateScoreProcessor();
ScoreProcessor.ApplyBeatmap(playableBeatmap);
ScoreProcessor.Mods.BindTo(Mods);
HealthProcessor = ruleset.CreateHealthProcessor(playableBeatmap.HitObjects[0].StartTime);
HealthProcessor.ApplyBeatmap(playableBeatmap);
if (!ScoreProcessor.Mode.Disabled)
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
@ -145,15 +152,28 @@ namespace osu.Game.Screens.Play
// bind clock into components that require it
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
DrawableRuleset.OnNewResult += ScoreProcessor.ApplyResult;
DrawableRuleset.OnRevertResult += ScoreProcessor.RevertResult;
DrawableRuleset.OnNewResult += r =>
{
HealthProcessor.ApplyResult(r);
ScoreProcessor.ApplyResult(r);
};
// Bind ScoreProcessor to ourselves
DrawableRuleset.OnRevertResult += r =>
{
HealthProcessor.RevertResult(r);
ScoreProcessor.RevertResult(r);
};
// Bind the judgement processors to ourselves
ScoreProcessor.AllJudged += onCompletion;
ScoreProcessor.Failed += onFail;
HealthProcessor.Failed += onFail;
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
mod.ApplyToScoreProcessor(ScoreProcessor);
foreach (var mod in Mods.Value.OfType<IApplicableToHealthProcessor>())
mod.ApplyToHealthProcessor(HealthProcessor);
BreakOverlay.IsBreakTime.ValueChanged += _ => updatePauseOnFocusLostState();
}
@ -188,16 +208,10 @@ namespace osu.Game.Screens.Play
{
target.AddRange(new[]
{
BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, DrawableRuleset.GameplayStartTime, ScoreProcessor)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Breaks = working.Beatmap.Breaks
},
// display the cursor above some HUD elements.
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value)
HUDOverlay = new HUDOverlay(ScoreProcessor, HealthProcessor, DrawableRuleset, Mods.Value)
{
HoldToQuit =
{
@ -248,6 +262,18 @@ namespace osu.Game.Screens.Play
},
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
});
DrawableRuleset.Overlays.Add(BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, DrawableRuleset.GameplayStartTime, ScoreProcessor)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Breaks = working.Beatmap.Breaks
});
DrawableRuleset.Overlays.Add(ScoreProcessor);
DrawableRuleset.Overlays.Add(HealthProcessor);
HealthProcessor.IsBreakTime.BindTo(BreakOverlay.IsBreakTime);
}
private void updatePauseOnFocusLostState() =>
@ -342,7 +368,7 @@ namespace osu.Game.Screens.Play
private void onCompletion()
{
// Only show the completion screen if the player hasn't failed
if (ScoreProcessor.HasFailed || completionProgressDelegate != null)
if (HealthProcessor.HasFailed || completionProgressDelegate != null)
return;
ValidForResume = false;
@ -350,18 +376,7 @@ namespace osu.Game.Screens.Play
if (!showResults) return;
using (BeginDelayedSequence(1000))
{
completionProgressDelegate = Schedule(delegate
{
if (!this.IsCurrentScreen()) return;
var score = CreateScore();
if (DrawableRuleset.ReplayScore == null)
scoreManager.Import(score).Wait();
this.Push(CreateResults(score));
});
}
scheduleGotoRanking();
}
protected virtual ScoreInfo CreateScore()
@ -542,7 +557,7 @@ namespace osu.Game.Screens.Play
if (completionProgressDelegate != null && !completionProgressDelegate.Cancelled && !completionProgressDelegate.Completed)
{
// proceed to result screen if beatmap already finished playing
completionProgressDelegate.RunTask();
scheduleGotoRanking();
return true;
}
@ -562,7 +577,7 @@ namespace osu.Game.Screens.Play
// 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.
GameplayClockContainer.StopUsingBeatmapClock();
GameplayClockContainer?.StopUsingBeatmapClock();
fadeOut();
return base.OnExiting(next);
@ -577,6 +592,19 @@ namespace osu.Game.Screens.Play
storyboardReplacesBackground.Value = false;
}
private void scheduleGotoRanking()
{
completionProgressDelegate?.Cancel();
completionProgressDelegate = Schedule(delegate
{
var score = CreateScore();
if (DrawableRuleset.ReplayScore == null)
scoreManager.Import(score).Wait();
this.Push(CreateResults(score));
});
}
#endregion
}
}

View File

@ -44,7 +44,7 @@ namespace osu.Game.Screens.Play
private LogoTrackingContainer content;
private BeatmapMetadataDisplay info;
protected BeatmapMetadataDisplay MetadataInfo;
private bool hideOverlays;
public override bool HideOverlaysOnEnter => hideOverlays;
@ -96,7 +96,7 @@ namespace osu.Game.Screens.Play
RelativeSizeAxes = Axes.Both,
}).WithChildren(new Drawable[]
{
info = new BeatmapMetadataDisplay(Beatmap.Value, Mods.Value, content.LogoFacade)
MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods, content.LogoFacade)
{
Alpha = 0,
Anchor = Anchor.Centre,
@ -118,8 +118,6 @@ namespace osu.Game.Screens.Play
},
idleTracker = new IdleTracker(750)
});
loadNewPlayer();
}
protected override void LoadComplete()
@ -127,6 +125,21 @@ namespace osu.Game.Screens.Play
base.LoadComplete();
inputManager = GetContainingInputManager();
}
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
loadNewPlayer();
content.ScaleTo(0.7f);
Background?.FadeColour(Color4.White, 800, Easing.OutQuint);
contentIn();
MetadataInfo.Delay(750).FadeIn(500);
this.Delay(1800).Schedule(pushWhenLoaded);
if (!muteWarningShownOnce.Value)
{
@ -145,7 +158,7 @@ namespace osu.Game.Screens.Play
contentIn();
info.Loading = true;
MetadataInfo.Loading = true;
//we will only be resumed if the player has requested a re-run (see ValidForResume setting above)
loadNewPlayer();
@ -161,7 +174,7 @@ namespace osu.Game.Screens.Play
player.RestartCount = restartCount;
player.RestartRequested = restartRequested;
LoadTask = LoadComponentAsync(player, _ => info.Loading = false);
LoadTask = LoadComponentAsync(player, _ => MetadataInfo.Loading = false);
}
private void contentIn()
@ -179,19 +192,6 @@ namespace osu.Game.Screens.Play
content.FadeOut(250);
}
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
content.ScaleTo(0.7f);
Background?.FadeColour(Color4.White, 800, Easing.OutQuint);
contentIn();
info.Delay(750).FadeIn(500);
this.Delay(1800).Schedule(pushWhenLoaded);
}
protected override void LogoArriving(OsuLogo logo, bool resuming)
{
base.LogoArriving(logo, resuming);
@ -350,7 +350,7 @@ namespace osu.Game.Screens.Play
}
}
private class BeatmapMetadataDisplay : Container
protected class BeatmapMetadataDisplay : Container
{
private class MetadataLine : Container
{
@ -379,11 +379,13 @@ namespace osu.Game.Screens.Play
}
private readonly WorkingBeatmap beatmap;
private readonly IReadOnlyList<Mod> mods;
private readonly Bindable<IReadOnlyList<Mod>> mods;
private readonly Drawable facade;
private LoadingAnimation loading;
private Sprite backgroundSprite;
public IBindable<IReadOnlyList<Mod>> Mods => mods;
public bool Loading
{
set
@ -401,11 +403,13 @@ namespace osu.Game.Screens.Play
}
}
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, Drawable facade)
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable facade)
{
this.beatmap = beatmap;
this.mods = mods;
this.facade = facade;
this.mods = new Bindable<IReadOnlyList<Mod>>();
this.mods.BindTo(mods);
}
[BackgroundDependencyLoader]
@ -492,7 +496,7 @@ namespace osu.Game.Screens.Play
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 20 },
Current = { Value = mods }
Current = mods
}
},
}

View File

@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Game.Scoring;
namespace osu.Game.Screens.Play
@ -20,15 +20,13 @@ namespace osu.Game.Screens.Play
scoreInfo = score.ScoreInfo;
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
public override void OnEntering(IScreen last)
{
var dependencies = base.CreateChildDependencies(parent);
// these will be reverted thanks to PlayerLoader's lease.
Mods.Value = scoreInfo.Mods;
Ruleset.Value = scoreInfo.Ruleset;
return dependencies;
base.OnEntering(last);
}
}
}

View File

@ -19,7 +19,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Game.Input.Bindings;
namespace osu.Game.Screens.Play
@ -143,7 +143,9 @@ namespace osu.Game.Screens.Play
return false;
}
public bool OnReleased(GlobalAction action) => false;
public void OnReleased(GlobalAction action)
{
}
private class FadeContainer : Container, IStateful<Visibility>
{
@ -202,10 +204,9 @@ namespace osu.Game.Screens.Play
return true;
}
protected override bool OnMouseUp(MouseUpEvent e)
protected override void OnMouseUp(MouseUpEvent e)
{
Show();
return true;
}
public override void Hide() => State = Visibility.Hidden;
@ -311,10 +312,10 @@ namespace osu.Game.Screens.Play
return base.OnMouseDown(e);
}
protected override bool OnMouseUp(MouseUpEvent e)
protected override void OnMouseUp(MouseUpEvent e)
{
aspect.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(e);
base.OnMouseUp(e);
}
protected override bool OnClick(ClickEvent e)

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.MathUtils;
using osu.Framework.Utils;
using osu.Framework.Threading;
namespace osu.Game.Screens.Play