mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge remote-tracking branch 'upstream/master' into lead-in-fixes
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -15,26 +16,45 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class BreakOverlay : Container
|
||||
{
|
||||
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
|
||||
/// <summary>
|
||||
/// The duration of the break overlay fading.
|
||||
/// </summary>
|
||||
public const double BREAK_FADE_DURATION = BreakPeriod.MIN_BREAK_DURATION / 2;
|
||||
|
||||
private const float remaining_time_container_max_size = 0.3f;
|
||||
private const int vertical_margin = 25;
|
||||
|
||||
private List<BreakPeriod> breaks;
|
||||
|
||||
private readonly Container fadeContainer;
|
||||
|
||||
public List<BreakPeriod> Breaks
|
||||
private IReadOnlyList<BreakPeriod> breaks;
|
||||
|
||||
public IReadOnlyList<BreakPeriod> Breaks
|
||||
{
|
||||
get => breaks;
|
||||
set
|
||||
{
|
||||
breaks = value;
|
||||
initializeBreaks();
|
||||
|
||||
// reset index in case the new breaks list is smaller than last one
|
||||
isBreakTime.Value = false;
|
||||
CurrentBreakIndex = 0;
|
||||
|
||||
if (IsLoaded)
|
||||
initializeBreaks();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool RemoveCompletedTransforms => false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the gameplay is currently in a break.
|
||||
/// </summary>
|
||||
public IBindable<bool> IsBreakTime => isBreakTime;
|
||||
|
||||
protected int CurrentBreakIndex;
|
||||
|
||||
private readonly BindableBool isBreakTime = new BindableBool();
|
||||
|
||||
private readonly Container remainingTimeAdjustmentBox;
|
||||
private readonly Container remainingTimeBox;
|
||||
private readonly RemainingTimeCounter remainingTimeCounter;
|
||||
@ -109,10 +129,36 @@ namespace osu.Game.Screens.Play
|
||||
initializeBreaks();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
updateBreakTimeBindable();
|
||||
}
|
||||
|
||||
private void updateBreakTimeBindable()
|
||||
{
|
||||
if (breaks == null || breaks.Count == 0)
|
||||
return;
|
||||
|
||||
var time = Clock.CurrentTime;
|
||||
|
||||
if (time > breaks[CurrentBreakIndex].EndTime)
|
||||
{
|
||||
while (time > breaks[CurrentBreakIndex].EndTime && CurrentBreakIndex < breaks.Count - 1)
|
||||
CurrentBreakIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (time < breaks[CurrentBreakIndex].StartTime && CurrentBreakIndex > 0)
|
||||
CurrentBreakIndex--;
|
||||
}
|
||||
|
||||
var currentBreak = breaks[CurrentBreakIndex];
|
||||
isBreakTime.Value = currentBreak.HasEffect && currentBreak.Contains(time);
|
||||
}
|
||||
|
||||
private void initializeBreaks()
|
||||
{
|
||||
if (!IsLoaded) return; // we need a clock.
|
||||
|
||||
FinishTransforms(true);
|
||||
Scheduler.CancelDelayedTasks();
|
||||
|
||||
@ -125,25 +171,25 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
using (BeginAbsoluteSequence(b.StartTime, true))
|
||||
{
|
||||
fadeContainer.FadeIn(fade_duration);
|
||||
breakArrows.Show(fade_duration);
|
||||
fadeContainer.FadeIn(BREAK_FADE_DURATION);
|
||||
breakArrows.Show(BREAK_FADE_DURATION);
|
||||
|
||||
remainingTimeAdjustmentBox
|
||||
.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint)
|
||||
.Delay(b.Duration - fade_duration)
|
||||
.ResizeWidthTo(remaining_time_container_max_size, BREAK_FADE_DURATION, Easing.OutQuint)
|
||||
.Delay(b.Duration - BREAK_FADE_DURATION)
|
||||
.ResizeWidthTo(0);
|
||||
|
||||
remainingTimeBox
|
||||
.ResizeWidthTo(0, b.Duration - fade_duration)
|
||||
.ResizeWidthTo(0, b.Duration - BREAK_FADE_DURATION)
|
||||
.Then()
|
||||
.ResizeWidthTo(1);
|
||||
|
||||
remainingTimeCounter.CountTo(b.Duration).CountTo(0, b.Duration);
|
||||
|
||||
using (BeginDelayedSequence(b.Duration - fade_duration, true))
|
||||
using (BeginDelayedSequence(b.Duration - BREAK_FADE_DURATION, true))
|
||||
{
|
||||
fadeContainer.FadeOut(fade_duration);
|
||||
breakArrows.Hide(fade_duration);
|
||||
fadeContainer.FadeOut(BREAK_FADE_DURATION);
|
||||
breakArrows.Hide(BREAK_FADE_DURATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
42
osu.Game/Screens/Play/ComboEffects.cs
Normal file
42
osu.Game/Screens/Play/ComboEffects.cs
Normal file
@ -0,0 +1,42 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class ComboEffects : CompositeDrawable
|
||||
{
|
||||
private readonly ScoreProcessor processor;
|
||||
|
||||
private SkinnableSound comboBreakSample;
|
||||
|
||||
public ComboEffects(ScoreProcessor processor)
|
||||
{
|
||||
this.processor = processor;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("combobreak"));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
processor.Combo.BindValueChanged(onComboChange, true);
|
||||
}
|
||||
|
||||
private void onComboChange(ValueChangedEvent<int> combo)
|
||||
{
|
||||
if (combo.NewValue == 0 && combo.OldValue > 20)
|
||||
comboBreakSample?.Play();
|
||||
}
|
||||
}
|
||||
}
|
55
osu.Game/Screens/Play/DimmableStoryboard.cs
Normal file
55
osu.Game/Screens/Play/DimmableStoryboard.cs
Normal file
@ -0,0 +1,55 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
/// <summary>
|
||||
/// A container that handles <see cref="Storyboard"/> loading, as well as applies user-specified visual settings to it.
|
||||
/// </summary>
|
||||
public class DimmableStoryboard : UserDimContainer
|
||||
{
|
||||
private readonly Storyboard storyboard;
|
||||
private DrawableStoryboard drawableStoryboard;
|
||||
|
||||
public DimmableStoryboard(Storyboard storyboard)
|
||||
{
|
||||
this.storyboard = storyboard;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
initializeStoryboard(false);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
ShowStoryboard.BindValueChanged(_ => initializeStoryboard(true), true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
protected override bool ShowDimContent => ShowStoryboard.Value && DimLevel < 1;
|
||||
|
||||
private void initializeStoryboard(bool async)
|
||||
{
|
||||
if (drawableStoryboard != null)
|
||||
return;
|
||||
|
||||
if (!ShowStoryboard.Value)
|
||||
return;
|
||||
|
||||
drawableStoryboard = storyboard.CreateDrawable();
|
||||
drawableStoryboard.Masking = true;
|
||||
|
||||
if (async)
|
||||
LoadComponentAsync(drawableStoryboard, Add);
|
||||
else
|
||||
Add(drawableStoryboard);
|
||||
}
|
||||
}
|
||||
}
|
88
osu.Game/Screens/Play/DimmableVideo.cs
Normal file
88
osu.Game/Screens/Play/DimmableVideo.cs
Normal file
@ -0,0 +1,88 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Video;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class DimmableVideo : UserDimContainer
|
||||
{
|
||||
private readonly VideoSprite video;
|
||||
private DrawableVideo drawableVideo;
|
||||
|
||||
public DimmableVideo(VideoSprite video)
|
||||
{
|
||||
this.video = video;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
initializeVideo(false);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
ShowVideo.BindValueChanged(_ => initializeVideo(true), true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
protected override bool ShowDimContent => ShowVideo.Value && DimLevel < 1;
|
||||
|
||||
private void initializeVideo(bool async)
|
||||
{
|
||||
if (video == null)
|
||||
return;
|
||||
|
||||
if (drawableVideo != null)
|
||||
return;
|
||||
|
||||
if (!ShowVideo.Value)
|
||||
return;
|
||||
|
||||
drawableVideo = new DrawableVideo(video);
|
||||
|
||||
if (async)
|
||||
LoadComponentAsync(drawableVideo, Add);
|
||||
else
|
||||
Add(drawableVideo);
|
||||
}
|
||||
|
||||
private class DrawableVideo : Container
|
||||
{
|
||||
public DrawableVideo(VideoSprite video)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
|
||||
video.RelativeSizeAxes = Axes.Both;
|
||||
video.FillMode = FillMode.Fit;
|
||||
video.Anchor = Anchor.Centre;
|
||||
video.Origin = Anchor.Centre;
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
video,
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameplayClock clock)
|
||||
{
|
||||
if (clock != null)
|
||||
Clock = clock;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
113
osu.Game/Screens/Play/FailAnimation.cs
Normal file
113
osu.Game/Screens/Play/FailAnimation.cs
Normal file
@ -0,0 +1,113 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
/// <summary>
|
||||
/// Manage the animation to be applied when a player fails.
|
||||
/// Single file; automatically disposed after use.
|
||||
/// </summary>
|
||||
public class FailAnimation : Component
|
||||
{
|
||||
public Action OnComplete;
|
||||
|
||||
private readonly DrawableRuleset drawableRuleset;
|
||||
|
||||
private readonly BindableDouble trackFreq = new BindableDouble(1);
|
||||
|
||||
private Track track;
|
||||
|
||||
private const float duration = 2500;
|
||||
|
||||
private SampleChannel failSample;
|
||||
|
||||
public FailAnimation(DrawableRuleset drawableRuleset)
|
||||
{
|
||||
this.drawableRuleset = drawableRuleset;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, IBindable<WorkingBeatmap> beatmap)
|
||||
{
|
||||
track = beatmap.Value.Track;
|
||||
failSample = audio.Samples.Get(@"Gameplay/failsound");
|
||||
}
|
||||
|
||||
private bool started;
|
||||
|
||||
/// <summary>
|
||||
/// Start the fail animation playing.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if started more than once.</exception>
|
||||
public void Start()
|
||||
{
|
||||
if (started) throw new InvalidOperationException("Animation cannot be started more than once.");
|
||||
|
||||
started = true;
|
||||
|
||||
failSample.Play();
|
||||
|
||||
this.TransformBindableTo(trackFreq, 0, duration).OnComplete(_ =>
|
||||
{
|
||||
OnComplete?.Invoke();
|
||||
Expire();
|
||||
});
|
||||
|
||||
track.AddAdjustment(AdjustableProperty.Frequency, trackFreq);
|
||||
|
||||
applyToPlayfield(drawableRuleset.Playfield);
|
||||
drawableRuleset.Playfield.HitObjectContainer.FlashColour(Color4.Red, 500);
|
||||
drawableRuleset.Playfield.HitObjectContainer.FadeOut(duration / 2);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!started)
|
||||
return;
|
||||
|
||||
applyToPlayfield(drawableRuleset.Playfield);
|
||||
}
|
||||
|
||||
private readonly List<DrawableHitObject> appliedObjects = new List<DrawableHitObject>();
|
||||
|
||||
private void applyToPlayfield(Playfield playfield)
|
||||
{
|
||||
foreach (var nested in playfield.NestedPlayfields)
|
||||
applyToPlayfield(nested);
|
||||
|
||||
foreach (DrawableHitObject obj in playfield.HitObjectContainer.AliveObjects)
|
||||
{
|
||||
if (appliedObjects.Contains(obj))
|
||||
continue;
|
||||
|
||||
obj.RotateTo(RNG.NextSingle(-90, 90), duration);
|
||||
obj.ScaleTo(obj.Scale * 0.5f, duration);
|
||||
obj.MoveToOffset(new Vector2(0, 400), duration);
|
||||
appliedObjects.Add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
track?.RemoveAdjustment(AdjustableProperty.Frequency, trackFreq);
|
||||
}
|
||||
}
|
||||
}
|
@ -41,5 +41,7 @@ namespace osu.Game.Screens.Play
|
||||
public double FramesPerSecond => underlyingClock.FramesPerSecond;
|
||||
|
||||
public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo;
|
||||
|
||||
public IClock Source => underlyingClock;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -29,7 +30,7 @@ namespace osu.Game.Screens.Play
|
||||
/// <summary>
|
||||
/// The original source (usually a <see cref="WorkingBeatmap"/>'s track).
|
||||
/// </summary>
|
||||
private readonly IAdjustableClock sourceClock;
|
||||
private IAdjustableClock sourceClock;
|
||||
|
||||
public readonly BindableBool IsPaused = new BindableBool();
|
||||
|
||||
@ -60,8 +61,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private readonly FramedOffsetClock platformOffsetClock;
|
||||
|
||||
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
|
||||
|
||||
public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, double gameplayStartTime)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
@ -71,6 +70,7 @@ namespace osu.Game.Screens.Play
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
sourceClock = (IAdjustableClock)beatmap.Track ?? new StopwatchClock();
|
||||
(sourceClock as IAdjustableAudioComponent)?.AddAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
|
||||
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
@ -87,6 +87,10 @@ namespace osu.Game.Screens.Play
|
||||
GameplayClock.IsPaused.BindTo(IsPaused);
|
||||
}
|
||||
|
||||
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
|
||||
|
||||
private readonly BindableDouble pauseFreqAdjust = new BindableDouble(1);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
@ -131,6 +135,8 @@ namespace osu.Game.Screens.Play
|
||||
Seek(GameplayClock.CurrentTime);
|
||||
adjustableClock.Start();
|
||||
IsPaused.Value = false;
|
||||
|
||||
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -152,14 +158,23 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
adjustableClock.Stop();
|
||||
this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => adjustableClock.Stop());
|
||||
|
||||
IsPaused.Value = true;
|
||||
}
|
||||
|
||||
public void ResetLocalAdjustments()
|
||||
/// <summary>
|
||||
/// Changes the backing clock to avoid using the originally provided beatmap's track.
|
||||
/// </summary>
|
||||
public void StopUsingBeatmapClock()
|
||||
{
|
||||
// In the case of replays, we may have changed the playback rate.
|
||||
UserPlaybackRate.Value = 1;
|
||||
if (sourceClock != beatmap.Track)
|
||||
return;
|
||||
|
||||
removeSourceClockAdjustments();
|
||||
|
||||
sourceClock = new TrackVirtual(beatmap.Track.Length);
|
||||
adjustableClock.ChangeSource(sourceClock);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -184,5 +199,19 @@ namespace osu.Game.Screens.Play
|
||||
foreach (var mod in mods.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(sourceClock);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
removeSourceClockAdjustments();
|
||||
sourceClock = null;
|
||||
}
|
||||
|
||||
private void removeSourceClockAdjustments()
|
||||
{
|
||||
sourceClock.ResetSpeedAdjustments();
|
||||
(sourceClock as IAdjustableAudioComponent)?.RemoveAdjustment(AdjustableProperty.Frequency, pauseFreqAdjust);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
StateChanged += s => selectionIndex = -1;
|
||||
State.ValueChanged += s => selectionIndex = -1;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -304,6 +304,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private class Button : DialogButton
|
||||
{
|
||||
// required to ensure keyboard navigation always starts from an extremity (unless the cursor is moved)
|
||||
protected override bool OnHover(HoverEvent e) => true;
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
@ -312,5 +313,22 @@ namespace osu.Game.Screens.Play
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private GlobalActionContainer globalAction { get; set; }
|
||||
|
||||
protected override bool Handle(UIEvent e)
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case ScrollEvent _:
|
||||
if (ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
|
||||
return globalAction.TriggerEvent(e);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return base.Handle(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
102
osu.Game/Screens/Play/HUD/HitErrorDisplay.cs
Normal file
102
osu.Game/Screens/Play/HUD/HitErrorDisplay.cs
Normal file
@ -0,0 +1,102 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class HitErrorDisplay : Container<HitErrorMeter>
|
||||
{
|
||||
private const int fade_duration = 200;
|
||||
private const int margin = 10;
|
||||
|
||||
private readonly Bindable<ScoreMeterType> type = new Bindable<ScoreMeterType>();
|
||||
|
||||
private readonly HitWindows hitWindows;
|
||||
|
||||
private readonly ScoreProcessor processor;
|
||||
|
||||
public HitErrorDisplay(ScoreProcessor processor, HitWindows hitWindows)
|
||||
{
|
||||
this.processor = processor;
|
||||
this.hitWindows = hitWindows;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
processor.NewJudgement += onNewJudgement;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.ScoreMeter, type);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
type.BindValueChanged(typeChanged, true);
|
||||
}
|
||||
|
||||
private void onNewJudgement(JudgementResult result)
|
||||
{
|
||||
if (result.HitObject.HitWindows.WindowFor(HitResult.Miss) == 0)
|
||||
return;
|
||||
|
||||
foreach (var c in Children)
|
||||
c.OnNewJudgement(result);
|
||||
}
|
||||
|
||||
private void typeChanged(ValueChangedEvent<ScoreMeterType> type)
|
||||
{
|
||||
Children.ForEach(c => c.FadeOut(fade_duration, Easing.OutQuint));
|
||||
|
||||
if (hitWindows == null)
|
||||
return;
|
||||
|
||||
switch (type.NewValue)
|
||||
{
|
||||
case ScoreMeterType.HitErrorBoth:
|
||||
createBar(false);
|
||||
createBar(true);
|
||||
break;
|
||||
|
||||
case ScoreMeterType.HitErrorLeft:
|
||||
createBar(false);
|
||||
break;
|
||||
|
||||
case ScoreMeterType.HitErrorRight:
|
||||
createBar(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void createBar(bool rightAligned)
|
||||
{
|
||||
var display = new BarHitErrorMeter(hitWindows, rightAligned)
|
||||
{
|
||||
Margin = new MarginPadding(margin),
|
||||
Anchor = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
|
||||
Origin = rightAligned ? Anchor.CentreRight : Anchor.CentreLeft,
|
||||
Alpha = 0,
|
||||
};
|
||||
|
||||
Add(display);
|
||||
display.FadeInFromZero(fade_duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
processor.NewJudgement -= onNewJudgement;
|
||||
}
|
||||
}
|
||||
}
|
283
osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs
Normal file
283
osu.Game/Screens/Play/HUD/HitErrorMeters/BarHitErrorMeter.cs
Normal file
@ -0,0 +1,283 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
public class BarHitErrorMeter : HitErrorMeter
|
||||
{
|
||||
private readonly Anchor alignment;
|
||||
|
||||
private const int arrow_move_duration = 400;
|
||||
|
||||
private const int judgement_line_width = 6;
|
||||
|
||||
private const int bar_height = 200;
|
||||
|
||||
private const int bar_width = 2;
|
||||
|
||||
private const int spacing = 2;
|
||||
|
||||
private const float chevron_size = 8;
|
||||
|
||||
private SpriteIcon arrow;
|
||||
|
||||
private Container colourBarsEarly;
|
||||
private Container colourBarsLate;
|
||||
|
||||
private Container judgementsContainer;
|
||||
|
||||
private double maxHitWindow;
|
||||
|
||||
public BarHitErrorMeter(HitWindows hitWindows, bool rightAligned = false)
|
||||
: base(hitWindows)
|
||||
{
|
||||
alignment = rightAligned ? Anchor.x0 : Anchor.x2;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Height = bar_height,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(spacing, 0),
|
||||
Margin = new MarginPadding(2),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
judgementsContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.y1 | alignment,
|
||||
Origin = Anchor.y1 | alignment,
|
||||
Width = judgement_line_width,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
},
|
||||
colourBars = new Container
|
||||
{
|
||||
Width = bar_width,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.y1 | alignment,
|
||||
Origin = Anchor.y1 | alignment,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
colourBarsEarly = new Container
|
||||
{
|
||||
Anchor = Anchor.y1 | alignment,
|
||||
Origin = alignment,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 0.5f,
|
||||
Scale = new Vector2(1, -1),
|
||||
},
|
||||
colourBarsLate = new Container
|
||||
{
|
||||
Anchor = Anchor.y1 | alignment,
|
||||
Origin = alignment,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 0.5f,
|
||||
},
|
||||
new SpriteIcon
|
||||
{
|
||||
Y = -10,
|
||||
Size = new Vector2(10),
|
||||
Icon = FontAwesome.Solid.ShippingFast,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
},
|
||||
new SpriteIcon
|
||||
{
|
||||
Y = 10,
|
||||
Size = new Vector2(10),
|
||||
Icon = FontAwesome.Solid.Bicycle,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.y1 | alignment,
|
||||
Origin = Anchor.y1 | alignment,
|
||||
Width = chevron_size,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Child = arrow = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Y = 0.5f,
|
||||
Icon = alignment == Anchor.x2 ? FontAwesome.Solid.ChevronRight : FontAwesome.Solid.ChevronLeft,
|
||||
Size = new Vector2(chevron_size),
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
createColourBars(colours);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
colourBars.Height = 0;
|
||||
colourBars.ResizeHeightTo(1, 800, Easing.OutQuint);
|
||||
|
||||
arrow.Alpha = 0;
|
||||
arrow.Delay(200).FadeInFromZero(600);
|
||||
}
|
||||
|
||||
private void createColourBars(OsuColour colours)
|
||||
{
|
||||
var windows = HitWindows.GetAllAvailableWindows().ToArray();
|
||||
|
||||
maxHitWindow = windows.First().length;
|
||||
|
||||
for (var i = 0; i < windows.Length; i++)
|
||||
{
|
||||
var (result, length) = windows[i];
|
||||
|
||||
colourBarsEarly.Add(createColourBar(result, (float)(length / maxHitWindow), i == 0));
|
||||
colourBarsLate.Add(createColourBar(result, (float)(length / maxHitWindow), i == 0));
|
||||
}
|
||||
|
||||
// a little nub to mark the centre point.
|
||||
var centre = createColourBar(windows.Last().result, 0.01f);
|
||||
centre.Anchor = centre.Origin = Anchor.y1 | (alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2);
|
||||
centre.Width = 2.5f;
|
||||
colourBars.Add(centre);
|
||||
|
||||
Color4 getColour(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Meh:
|
||||
return colours.Yellow;
|
||||
|
||||
case HitResult.Ok:
|
||||
return colours.Green;
|
||||
|
||||
case HitResult.Good:
|
||||
return colours.GreenLight;
|
||||
|
||||
case HitResult.Great:
|
||||
return colours.Blue;
|
||||
|
||||
default:
|
||||
return colours.BlueLight;
|
||||
}
|
||||
}
|
||||
|
||||
Drawable createColourBar(HitResult result, float height, bool first = false)
|
||||
{
|
||||
var colour = getColour(result);
|
||||
|
||||
if (first)
|
||||
{
|
||||
// the first bar needs gradient rendering.
|
||||
const float gradient_start = 0.8f;
|
||||
|
||||
return new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = getColour(result),
|
||||
Height = height * gradient_start
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientVertical(colour, colour.Opacity(0)),
|
||||
Y = gradient_start,
|
||||
Height = height * (1 - gradient_start)
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colour,
|
||||
Height = height
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private double floatingAverage;
|
||||
private Container colourBars;
|
||||
|
||||
public override void OnNewJudgement(JudgementResult judgement)
|
||||
{
|
||||
if (!judgement.IsHit)
|
||||
return;
|
||||
|
||||
judgementsContainer.Add(new JudgementLine
|
||||
{
|
||||
Y = getRelativeJudgementPosition(judgement.TimeOffset),
|
||||
Anchor = alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2,
|
||||
Origin = Anchor.y1 | (alignment == Anchor.x2 ? Anchor.x0 : Anchor.x2),
|
||||
});
|
||||
|
||||
arrow.MoveToY(
|
||||
getRelativeJudgementPosition(floatingAverage = floatingAverage * 0.9 + judgement.TimeOffset * 0.1)
|
||||
, arrow_move_duration, Easing.Out);
|
||||
}
|
||||
|
||||
private float getRelativeJudgementPosition(double value) => (float)((value / maxHitWindow) + 1) / 2;
|
||||
|
||||
private class JudgementLine : CompositeDrawable
|
||||
{
|
||||
private const int judgement_fade_duration = 10000;
|
||||
|
||||
public JudgementLine()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
RelativePositionAxes = Axes.Y;
|
||||
Height = 3;
|
||||
|
||||
InternalChild = new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Width = 0;
|
||||
|
||||
this.ResizeWidthTo(1, 200, Easing.OutElasticHalf);
|
||||
this.FadeTo(0.8f, 150).Then().FadeOut(judgement_fade_duration, Easing.OutQuint).Expire();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs
Normal file
21
osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
public abstract class HitErrorMeter : CompositeDrawable
|
||||
{
|
||||
protected readonly HitWindows HitWindows;
|
||||
|
||||
protected HitErrorMeter(HitWindows hitWindows)
|
||||
{
|
||||
HitWindows = hitWindows;
|
||||
}
|
||||
|
||||
public abstract void OnNewJudgement(JudgementResult judgement);
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
@ -45,7 +46,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Text = "hold for menu",
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft
|
||||
@ -60,9 +60,23 @@ namespace osu.Game.Screens.Play.HUD
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
private Bindable<float> activationDelay;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
activationDelay = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay);
|
||||
activationDelay.BindValueChanged(v =>
|
||||
{
|
||||
text.Text = v.NewValue > 0
|
||||
? "hold for menu"
|
||||
: "press for menu";
|
||||
}, true);
|
||||
|
||||
text.FadeInFromZero(500, Easing.OutQuint).Delay(1500).FadeOut(500, Easing.OutQuint);
|
||||
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
@ -86,9 +100,11 @@ namespace osu.Game.Screens.Play.HUD
|
||||
if (text.Alpha > 0 || button.Progress.Value > 0 || button.IsHovered)
|
||||
Alpha = 1;
|
||||
else
|
||||
{
|
||||
Alpha = Interpolation.ValueAt(
|
||||
MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 200),
|
||||
Alpha, MathHelper.Clamp(1 - positionalAdjust, 0.04f, 1), 0, 200, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private class Button : HoldToConfirmContainer, IKeyBindingHandler<GlobalAction>
|
||||
|
@ -45,8 +45,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
VisualSettings = new VisualSettings { Expanded = false }
|
||||
}
|
||||
};
|
||||
|
||||
State = Visibility.Visible;
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(fade_duration);
|
||||
|
@ -23,7 +23,8 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class HUDOverlay : Container
|
||||
{
|
||||
private const int duration = 100;
|
||||
private const int duration = 250;
|
||||
private const Easing easing = Easing.OutQuint;
|
||||
|
||||
public readonly KeyCounterDisplay KeyCounter;
|
||||
public readonly RollingCounter<int> ComboCounter;
|
||||
@ -32,9 +33,12 @@ namespace osu.Game.Screens.Play
|
||||
public readonly HealthDisplay HealthDisplay;
|
||||
public readonly SongProgress Progress;
|
||||
public readonly ModDisplay ModDisplay;
|
||||
public readonly HitErrorDisplay HitErrorDisplay;
|
||||
public readonly HoldForMenuButton HoldToQuit;
|
||||
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
|
||||
|
||||
public Bindable<bool> ShowHealthbar = new Bindable<bool>(true);
|
||||
|
||||
private readonly ScoreProcessor scoreProcessor;
|
||||
private readonly DrawableRuleset drawableRuleset;
|
||||
private readonly IReadOnlyList<Mod> mods;
|
||||
@ -47,6 +51,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public Action<double> RequestSeek;
|
||||
|
||||
private readonly Container topScoreContainer;
|
||||
|
||||
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
||||
{
|
||||
this.scoreProcessor = scoreProcessor;
|
||||
@ -62,11 +68,10 @@ namespace osu.Game.Screens.Play
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
topScoreContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Y = 30,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
AutoSizeDuration = 200,
|
||||
AutoSizeEasing = Easing.Out,
|
||||
@ -80,6 +85,7 @@ namespace osu.Game.Screens.Play
|
||||
HealthDisplay = CreateHealthDisplay(),
|
||||
Progress = CreateProgress(),
|
||||
ModDisplay = CreateModsContainer(),
|
||||
HitErrorDisplay = CreateHitErrorDisplayOverlay(),
|
||||
}
|
||||
},
|
||||
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
|
||||
@ -113,8 +119,21 @@ namespace osu.Game.Screens.Play
|
||||
ModDisplay.Current.Value = mods;
|
||||
|
||||
showHud = config.GetBindable<bool>(OsuSetting.ShowInterface);
|
||||
showHud.ValueChanged += visible => visibilityContainer.FadeTo(visible.NewValue ? 1 : 0, duration);
|
||||
showHud.TriggerChange();
|
||||
showHud.BindValueChanged(visible => visibilityContainer.FadeTo(visible.NewValue ? 1 : 0, duration, easing), true);
|
||||
|
||||
ShowHealthbar.BindValueChanged(healthBar =>
|
||||
{
|
||||
if (healthBar.NewValue)
|
||||
{
|
||||
HealthDisplay.FadeIn(duration, easing);
|
||||
topScoreContainer.MoveToY(30, duration, easing);
|
||||
}
|
||||
else
|
||||
{
|
||||
HealthDisplay.FadeOut(duration, easing);
|
||||
topScoreContainer.MoveToY(0, duration, easing);
|
||||
}
|
||||
}, true);
|
||||
|
||||
if (!showHud.Value && !hasShownNotificationOnce)
|
||||
{
|
||||
@ -212,7 +231,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected virtual KeyCounterDisplay CreateKeyCounter() => new KeyCounterDisplay
|
||||
{
|
||||
FadeTime = 50,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Margin = new MarginPadding(10),
|
||||
@ -239,6 +257,8 @@ namespace osu.Game.Screens.Play
|
||||
Margin = new MarginPadding { Top = 20, Right = 10 },
|
||||
};
|
||||
|
||||
protected virtual HitErrorDisplay CreateHitErrorDisplayOverlay() => new HitErrorDisplay(scoreProcessor, drawableRuleset.FirstAvailableHitWindows);
|
||||
|
||||
protected virtual PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
||||
|
||||
protected virtual void BindProcessor(ScoreProcessor processor)
|
||||
|
28
osu.Game/Screens/Play/HotkeyExitOverlay.cs
Normal file
28
osu.Game/Screens/Play/HotkeyExitOverlay.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class HotkeyExitOverlay : HoldToConfirmOverlay, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (action != GlobalAction.QuickExit) return false;
|
||||
|
||||
BeginConfirm();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action)
|
||||
{
|
||||
if (action != GlobalAction.QuickExit) return false;
|
||||
|
||||
AbortConfirm();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -22,9 +20,6 @@ namespace osu.Game.Screens.Play
|
||||
private Container textLayer;
|
||||
private SpriteText countSpriteText;
|
||||
|
||||
private readonly List<KeyCounterState> states = new List<KeyCounterState>();
|
||||
private KeyCounterState currentState;
|
||||
|
||||
public bool IsCounting { get; set; } = true;
|
||||
private int countPresses;
|
||||
|
||||
@ -52,20 +47,30 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
isLit = value;
|
||||
updateGlowSprite(value);
|
||||
|
||||
if (value && IsCounting)
|
||||
{
|
||||
CountPresses++;
|
||||
saveState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Increment()
|
||||
{
|
||||
if (!IsCounting)
|
||||
return;
|
||||
|
||||
CountPresses++;
|
||||
}
|
||||
|
||||
public void Decrement()
|
||||
{
|
||||
if (!IsCounting)
|
||||
return;
|
||||
|
||||
CountPresses--;
|
||||
}
|
||||
|
||||
//further: change default values here and in KeyCounterCollection if needed, instead of passing them in every constructor
|
||||
public Color4 KeyDownTextColor { get; set; } = Color4.DarkGray;
|
||||
public Color4 KeyUpTextColor { get; set; } = Color4.White;
|
||||
public int FadeTime { get; set; }
|
||||
public double FadeTime { get; set; }
|
||||
|
||||
protected KeyCounter(string name)
|
||||
{
|
||||
@ -73,11 +78,8 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(TextureStore textures, GameplayClock clock)
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
if (clock != null)
|
||||
Clock = clock;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
buttonSprite = new Sprite
|
||||
@ -132,42 +134,16 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
glowSprite.FadeIn(FadeTime);
|
||||
textLayer.FadeColour(KeyDownTextColor, FadeTime);
|
||||
double remainingFadeTime = FadeTime * (1 - glowSprite.Alpha);
|
||||
glowSprite.FadeIn(remainingFadeTime, Easing.OutQuint);
|
||||
textLayer.FadeColour(KeyDownTextColor, remainingFadeTime, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
glowSprite.FadeOut(FadeTime);
|
||||
textLayer.FadeColour(KeyUpTextColor, FadeTime);
|
||||
double remainingFadeTime = 8 * FadeTime * glowSprite.Alpha;
|
||||
glowSprite.FadeOut(remainingFadeTime, Easing.OutQuint);
|
||||
textLayer.FadeColour(KeyUpTextColor, remainingFadeTime, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetCount()
|
||||
{
|
||||
CountPresses = 0;
|
||||
states.Clear();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (currentState?.Time > Clock.CurrentTime)
|
||||
restoreStateTo(Clock.CurrentTime);
|
||||
}
|
||||
|
||||
private void saveState()
|
||||
{
|
||||
if (currentState == null || currentState.Time < Clock.CurrentTime)
|
||||
states.Add(currentState = new KeyCounterState(Clock.CurrentTime, CountPresses));
|
||||
}
|
||||
|
||||
private void restoreStateTo(double time)
|
||||
{
|
||||
states.RemoveAll(state => state.Time > time);
|
||||
|
||||
currentState = states.LastOrDefault();
|
||||
CountPresses = currentState?.Count ?? 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Input.Bindings;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class KeyCounterAction<T> : KeyCounter, IKeyBindingHandler<T>
|
||||
public class KeyCounterAction<T> : KeyCounter
|
||||
where T : struct
|
||||
{
|
||||
public T Action { get; }
|
||||
@ -16,15 +16,25 @@ namespace osu.Game.Screens.Play
|
||||
Action = action;
|
||||
}
|
||||
|
||||
public bool OnPressed(T action)
|
||||
public bool OnPressed(T action, bool forwards)
|
||||
{
|
||||
if (action.Equals(Action)) IsLit = true;
|
||||
if (!EqualityComparer<T>.Default.Equals(action, Action))
|
||||
return false;
|
||||
|
||||
IsLit = true;
|
||||
if (forwards)
|
||||
Increment();
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(T action)
|
||||
public bool OnReleased(T action, bool forwards)
|
||||
{
|
||||
if (action.Equals(Action)) IsLit = false;
|
||||
if (!EqualityComparer<T>.Default.Equals(action, Action))
|
||||
return false;
|
||||
|
||||
IsLit = false;
|
||||
if (!forwards)
|
||||
Decrement();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ namespace osu.Game.Screens.Play
|
||||
public class KeyCounterDisplay : FillFlowContainer<KeyCounter>
|
||||
{
|
||||
private const int duration = 100;
|
||||
private const double key_fade_time = 80;
|
||||
|
||||
public readonly Bindable<bool> Visible = new Bindable<bool>(true);
|
||||
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
||||
@ -33,17 +34,11 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
base.Add(key);
|
||||
key.IsCounting = IsCounting;
|
||||
key.FadeTime = FadeTime;
|
||||
key.FadeTime = key_fade_time;
|
||||
key.KeyDownTextColor = KeyDownTextColor;
|
||||
key.KeyUpTextColor = KeyUpTextColor;
|
||||
}
|
||||
|
||||
public void ResetCount()
|
||||
{
|
||||
foreach (var counter in Children)
|
||||
counter.ResetCount();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
@ -68,22 +63,6 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
private int fadeTime;
|
||||
|
||||
public int FadeTime
|
||||
{
|
||||
get => fadeTime;
|
||||
set
|
||||
{
|
||||
if (value != fadeTime)
|
||||
{
|
||||
fadeTime = value;
|
||||
foreach (var child in Children)
|
||||
child.FadeTime = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 keyDownTextColor = Color4.DarkGray;
|
||||
|
||||
public Color4 KeyDownTextColor
|
||||
@ -123,11 +102,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private Receptor receptor;
|
||||
|
||||
public Receptor GetReceptor()
|
||||
{
|
||||
return receptor ?? (receptor = new Receptor(this));
|
||||
}
|
||||
|
||||
public void SetReceptor(Receptor receptor)
|
||||
{
|
||||
if (this.receptor != null)
|
||||
|
@ -18,7 +18,12 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Key == Key) IsLit = true;
|
||||
if (e.Key == Key)
|
||||
{
|
||||
IsLit = true;
|
||||
Increment();
|
||||
}
|
||||
|
||||
return base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,12 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
if (e.Button == Button) IsLit = true;
|
||||
if (e.Button == Button)
|
||||
{
|
||||
IsLit = true;
|
||||
Increment();
|
||||
}
|
||||
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
||||
using System;
|
||||
@ -26,13 +26,16 @@ using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
[Cached]
|
||||
public class Player : ScreenWithBeatmapBackground
|
||||
{
|
||||
protected override bool AllowBackButton => false; // handled by HoldForMenuButton
|
||||
public override bool AllowBackButton => false; // handled by HoldForMenuButton
|
||||
|
||||
protected override UserActivity InitialActivity => new UserActivity.SoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
|
||||
|
||||
public override float BackgroundParallaxAmount => 0.1f;
|
||||
|
||||
@ -58,12 +61,16 @@ namespace osu.Game.Screens.Play
|
||||
[Resolved]
|
||||
private ScoreManager scoreManager { get; set; }
|
||||
|
||||
private RulesetInfo ruleset;
|
||||
private RulesetInfo rulesetInfo;
|
||||
|
||||
private Ruleset ruleset;
|
||||
|
||||
private IAPIProvider api;
|
||||
|
||||
private SampleChannel sampleRestart;
|
||||
|
||||
private BreakOverlay breakOverlay;
|
||||
|
||||
protected ScoreProcessor ScoreProcessor { get; private set; }
|
||||
protected DrawableRuleset DrawableRuleset { get; private set; }
|
||||
|
||||
@ -73,10 +80,19 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
||||
|
||||
protected DimmableStoryboard DimmableStoryboard { get; private set; }
|
||||
protected DimmableVideo DimmableVideo { get; private set; }
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
protected new readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
/// <summary>
|
||||
/// Whether failing should be allowed.
|
||||
/// By default, this checks whether all selected mods allow failing.
|
||||
/// </summary>
|
||||
protected virtual bool AllowFail => Mods.Value.OfType<IApplicableFailOverride>().All(m => m.AllowFail);
|
||||
|
||||
private readonly bool allowPause;
|
||||
private readonly bool showResults;
|
||||
|
||||
@ -103,10 +119,9 @@ namespace osu.Game.Screens.Play
|
||||
if (working == null)
|
||||
return;
|
||||
|
||||
sampleRestart = audio.Sample.Get(@"Gameplay/restart");
|
||||
sampleRestart = audio.Samples.Get(@"Gameplay/restart");
|
||||
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
|
||||
ScoreProcessor = DrawableRuleset.CreateScoreProcessor();
|
||||
ScoreProcessor.Mods.BindTo(Mods);
|
||||
@ -116,18 +131,55 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||
|
||||
GameplayClockContainer.Children = new[]
|
||||
addUnderlayComponents(GameplayClockContainer);
|
||||
addGameplayComponents(GameplayClockContainer, working);
|
||||
addOverlayComponents(GameplayClockContainer, working);
|
||||
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true);
|
||||
|
||||
// bind clock into components that require it
|
||||
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
||||
|
||||
// Bind ScoreProcessor to ourselves
|
||||
ScoreProcessor.AllJudged += onCompletion;
|
||||
ScoreProcessor.Failed += onFail;
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
mod.ApplyToScoreProcessor(ScoreProcessor);
|
||||
}
|
||||
|
||||
private void addUnderlayComponents(Container target)
|
||||
{
|
||||
target.Add(DimmableVideo = new DimmableVideo(Beatmap.Value.Video) { RelativeSizeAxes = Axes.Both });
|
||||
target.Add(DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both });
|
||||
}
|
||||
|
||||
private void addGameplayComponents(Container target, WorkingBeatmap working)
|
||||
{
|
||||
var beatmapSkinProvider = new BeatmapSkinProvidingContainer(working.Skin);
|
||||
|
||||
// the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
|
||||
// full access to all skin sources.
|
||||
var rulesetSkinProvider = new SkinProvidingContainer(ruleset.CreateLegacySkinProvider(beatmapSkinProvider));
|
||||
|
||||
// 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)));
|
||||
|
||||
target.AddRange(new Drawable[]
|
||||
{
|
||||
StoryboardContainer = CreateStoryboardContainer(),
|
||||
new ScalingContainer(ScalingMode.Gameplay)
|
||||
{
|
||||
Child = new LocalSkinOverrideContainer(working.Skin)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = DrawableRuleset
|
||||
}
|
||||
},
|
||||
new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
||||
DrawableRuleset,
|
||||
new ComboEffects(ScoreProcessor)
|
||||
});
|
||||
}
|
||||
|
||||
private void addOverlayComponents(Container target, WorkingBeatmap working)
|
||||
{
|
||||
target.AddRange(new[]
|
||||
{
|
||||
breakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -135,6 +187,7 @@ namespace osu.Game.Screens.Play
|
||||
},
|
||||
// display the cursor above some HUD elements.
|
||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
||||
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value)
|
||||
{
|
||||
HoldToQuit =
|
||||
@ -173,23 +226,19 @@ namespace osu.Game.Screens.Play
|
||||
fadeOut(true);
|
||||
Restart();
|
||||
},
|
||||
}
|
||||
};
|
||||
},
|
||||
new HotkeyExitOverlay
|
||||
{
|
||||
Action = () =>
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(e => HUDOverlay.HoldToQuit.PauseOnFocusLost = !e.NewValue && PauseOnFocusLost, true);
|
||||
|
||||
// bind clock into components that require it
|
||||
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
|
||||
|
||||
// load storyboard as part of player's load if we can
|
||||
initializeStoryboard(false);
|
||||
|
||||
// Bind ScoreProcessor to ourselves
|
||||
ScoreProcessor.AllJudged += onCompletion;
|
||||
ScoreProcessor.Failed += onFail;
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
mod.ApplyToScoreProcessor(ScoreProcessor);
|
||||
fadeOut(true);
|
||||
performImmediateExit();
|
||||
},
|
||||
},
|
||||
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
|
||||
});
|
||||
}
|
||||
|
||||
private WorkingBeatmap loadBeatmap()
|
||||
@ -205,20 +254,20 @@ namespace osu.Game.Screens.Play
|
||||
if (beatmap == null)
|
||||
throw new InvalidOperationException("Beatmap was not loaded");
|
||||
|
||||
ruleset = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
||||
var rulesetInstance = ruleset.CreateInstance();
|
||||
rulesetInfo = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
||||
ruleset = rulesetInfo.CreateInstance();
|
||||
|
||||
try
|
||||
{
|
||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(working, Mods.Value);
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(working, Mods.Value);
|
||||
}
|
||||
catch (BeatmapInvalidForRulesetException)
|
||||
{
|
||||
// we may fail to create a DrawableRuleset 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();
|
||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(Beatmap.Value, Mods.Value);
|
||||
rulesetInfo = beatmap.BeatmapInfo.Ruleset;
|
||||
ruleset = rulesetInfo.CreateInstance();
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(Beatmap.Value, Mods.Value);
|
||||
}
|
||||
|
||||
if (!DrawableRuleset.Objects.Any())
|
||||
@ -237,33 +286,53 @@ namespace osu.Game.Screens.Play
|
||||
return working;
|
||||
}
|
||||
|
||||
private void performImmediateExit()
|
||||
{
|
||||
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
|
||||
completionProgressDelegate?.Cancel();
|
||||
|
||||
ValidForResume = false;
|
||||
|
||||
performUserRequestedExit();
|
||||
}
|
||||
|
||||
private void performUserRequestedExit()
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
this.Exit();
|
||||
if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
|
||||
{
|
||||
failAnimation.FinishTransforms(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (canPause)
|
||||
Pause();
|
||||
else
|
||||
this.Exit();
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public void Restart()
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
sampleRestart?.Play();
|
||||
|
||||
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
|
||||
onCompletionEvent = null;
|
||||
|
||||
ValidForResume = false;
|
||||
RestartRequested?.Invoke();
|
||||
this.Exit();
|
||||
|
||||
if (this.IsCurrentScreen())
|
||||
performImmediateExit();
|
||||
else
|
||||
this.MakeCurrent();
|
||||
}
|
||||
|
||||
private ScheduledDelegate onCompletionEvent;
|
||||
private ScheduledDelegate completionProgressDelegate;
|
||||
|
||||
private void onCompletion()
|
||||
{
|
||||
// Only show the completion screen if the player hasn't failed
|
||||
if (ScoreProcessor.HasFailed || onCompletionEvent != null)
|
||||
if (ScoreProcessor.HasFailed || completionProgressDelegate != null)
|
||||
return;
|
||||
|
||||
ValidForResume = false;
|
||||
@ -272,17 +341,15 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
using (BeginDelayedSequence(1000))
|
||||
{
|
||||
onCompletionEvent = Schedule(delegate
|
||||
completionProgressDelegate = Schedule(delegate
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
var score = CreateScore();
|
||||
if (DrawableRuleset.ReplayScore == null)
|
||||
scoreManager.Import(score);
|
||||
scoreManager.Import(score).Wait();
|
||||
|
||||
this.Push(CreateResults(score));
|
||||
|
||||
onCompletionEvent = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -292,7 +359,7 @@ namespace osu.Game.Screens.Play
|
||||
var score = DrawableRuleset.ReplayScore?.ScoreInfo ?? new ScoreInfo
|
||||
{
|
||||
Beatmap = Beatmap.Value.BeatmapInfo,
|
||||
Ruleset = ruleset,
|
||||
Ruleset = rulesetInfo,
|
||||
Mods = Mods.Value.ToArray(),
|
||||
User = api.LocalUser.Value,
|
||||
};
|
||||
@ -306,63 +373,40 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score);
|
||||
|
||||
#region Storyboard
|
||||
|
||||
private DrawableStoryboard storyboard;
|
||||
protected UserDimContainer StoryboardContainer { get; private set; }
|
||||
|
||||
protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 1,
|
||||
EnableUserDim = { Value = true }
|
||||
};
|
||||
|
||||
private Bindable<bool> showStoryboard;
|
||||
|
||||
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
|
||||
|
||||
#region Fail Logic
|
||||
|
||||
protected FailOverlay FailOverlay { get; private set; }
|
||||
|
||||
private FailAnimation failAnimation;
|
||||
|
||||
private bool onFail()
|
||||
{
|
||||
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
|
||||
if (!AllowFail)
|
||||
return false;
|
||||
|
||||
GameplayClockContainer.Stop();
|
||||
|
||||
HasFailed = true;
|
||||
|
||||
// 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.
|
||||
if (PauseOverlay.State == Visibility.Visible)
|
||||
if (PauseOverlay.State.Value == Visibility.Visible)
|
||||
PauseOverlay.Hide();
|
||||
|
||||
failAnimation.Start();
|
||||
|
||||
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
|
||||
Restart();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called back when the transform finishes
|
||||
private void onFailComplete()
|
||||
{
|
||||
GameplayClockContainer.Stop();
|
||||
|
||||
FailOverlay.Retries = RestartCount;
|
||||
FailOverlay.Show();
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -405,7 +449,12 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (!canPause) return;
|
||||
|
||||
IsResuming = false;
|
||||
if (IsResuming)
|
||||
{
|
||||
DrawableRuleset.CancelResume();
|
||||
IsResuming = false;
|
||||
}
|
||||
|
||||
GameplayClockContainer.Stop();
|
||||
PauseOverlay.Show();
|
||||
lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
||||
@ -419,8 +468,7 @@ namespace osu.Game.Screens.Play
|
||||
PauseOverlay.Hide();
|
||||
|
||||
// breaks and time-based conditions may allow instant resume.
|
||||
double time = GameplayClockContainer.GameplayClock.CurrentTime;
|
||||
if (Beatmap.Value.Beatmap.Breaks.Any(b => b.Contains(time)) || time < Beatmap.Value.Beatmap.HitObjects.First().StartTime)
|
||||
if (breakOverlay.IsBreakTime.Value || GameplayClockContainer.GameplayClock.CurrentTime < Beatmap.Value.Beatmap.HitObjects.First().StartTime)
|
||||
completeResume();
|
||||
else
|
||||
DrawableRuleset.RequestResume(completeResume);
|
||||
@ -450,18 +498,19 @@ namespace osu.Game.Screens.Play
|
||||
.Delay(250)
|
||||
.FadeIn(250);
|
||||
|
||||
showStoryboard.ValueChanged += _ => initializeStoryboard(true);
|
||||
|
||||
Background.EnableUserDim.Value = true;
|
||||
Background.BlurAmount.Value = 0;
|
||||
|
||||
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
StoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
|
||||
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
||||
|
||||
GameplayClockContainer.Restart();
|
||||
GameplayClockContainer.FadeInFromZero(750, Easing.OutQuint);
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToHUD>())
|
||||
mod.ApplyToHUD(HUDOverlay);
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
@ -472,24 +521,24 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
if (onCompletionEvent != null)
|
||||
if (completionProgressDelegate != null && !completionProgressDelegate.Cancelled && !completionProgressDelegate.Completed)
|
||||
{
|
||||
// Proceed to result screen if beatmap already finished playing
|
||||
onCompletionEvent.RunTask();
|
||||
// proceed to result screen if beatmap already finished playing
|
||||
completionProgressDelegate.RunTask();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (canPause)
|
||||
// ValidForResume is false when restarting
|
||||
if (ValidForResume)
|
||||
{
|
||||
Pause();
|
||||
return true;
|
||||
if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value)
|
||||
// still want to block if we are within the cooldown period and not already paused.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value)
|
||||
// still want to block if we are within the cooldown period and not already paused.
|
||||
return true;
|
||||
|
||||
GameplayClockContainer.ResetLocalAdjustments();
|
||||
// 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();
|
||||
|
||||
fadeOut();
|
||||
return base.OnExiting(next);
|
||||
|
@ -6,6 +6,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -14,14 +16,19 @@ using osu.Framework.Localisation;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -42,6 +49,8 @@ namespace osu.Game.Screens.Play
|
||||
private bool hideOverlays;
|
||||
public override bool HideOverlaysOnEnter => hideOverlays;
|
||||
|
||||
protected override UserActivity InitialActivity => null; //shows the previous screen status
|
||||
|
||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||
|
||||
protected override bool PlayResumeSound => false;
|
||||
@ -49,6 +58,18 @@ namespace osu.Game.Screens.Play
|
||||
private Task loadTask;
|
||||
|
||||
private InputManager inputManager;
|
||||
private IdleTracker idleTracker;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private NotificationOverlay notificationOverlay { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private VolumeOverlay volumeOverlay { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private AudioManager audioManager { get; set; }
|
||||
|
||||
private Bindable<bool> muteWarningShownOnce;
|
||||
|
||||
public PlayerLoader(Func<Player> createPlayer)
|
||||
{
|
||||
@ -62,8 +83,10 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(SessionStatics sessionStatics)
|
||||
{
|
||||
muteWarningShownOnce = sessionStatics.GetBindable<bool>(Static.MutedAudioNotificationShownOnce);
|
||||
|
||||
InternalChild = (content = new LogoTrackingContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
@ -90,13 +113,29 @@ namespace osu.Game.Screens.Play
|
||||
VisualSettings = new VisualSettings(),
|
||||
new InputSettings()
|
||||
}
|
||||
}
|
||||
},
|
||||
idleTracker = new IdleTracker(750)
|
||||
});
|
||||
|
||||
loadNewPlayer();
|
||||
}
|
||||
|
||||
private void playerLoaded(Player player) => info.Loading = false;
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager();
|
||||
|
||||
if (!muteWarningShownOnce.Value)
|
||||
{
|
||||
//Checks if the notification has not been shown yet and also if master volume is muted, track/music volume is muted or if the whole game is muted.
|
||||
if (volumeOverlay?.IsMuted.Value == true || audioManager.Volume.Value <= audioManager.Volume.MinValue || audioManager.VolumeTrack.Value <= audioManager.VolumeTrack.MinValue)
|
||||
{
|
||||
notificationOverlay?.Post(new MutedNotification());
|
||||
muteWarningShownOnce.Value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
@ -120,7 +159,7 @@ namespace osu.Game.Screens.Play
|
||||
player.RestartCount = restartCount;
|
||||
player.RestartRequested = restartRequested;
|
||||
|
||||
loadTask = LoadComponentAsync(player, playerLoaded);
|
||||
loadTask = LoadComponentAsync(player, _ => info.Loading = false);
|
||||
}
|
||||
|
||||
private void contentIn()
|
||||
@ -178,19 +217,13 @@ namespace osu.Game.Screens.Play
|
||||
content.StopTracking();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
inputManager = GetContainingInputManager();
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
private ScheduledDelegate pushDebounce;
|
||||
protected VisualSettings VisualSettings;
|
||||
|
||||
// Here because IsHovered will not update unless we do so.
|
||||
public override bool HandlePositionalInput => true;
|
||||
|
||||
private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null;
|
||||
private bool readyForPush => player.LoadState == LoadState.Ready && (IsHovered || idleTracker.IsIdle.Value) && inputManager?.DraggedDrawable == null;
|
||||
|
||||
private void pushWhenLoaded()
|
||||
{
|
||||
@ -244,6 +277,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
BackgroundBrightnessReduction = false;
|
||||
base.OnSuspending(next);
|
||||
cancelLoad();
|
||||
}
|
||||
@ -255,6 +289,7 @@ namespace osu.Game.Screens.Play
|
||||
cancelLoad();
|
||||
|
||||
Background.EnableUserDim.Value = false;
|
||||
BackgroundBrightnessReduction = false;
|
||||
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
@ -270,6 +305,22 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
private bool backgroundBrightnessReduction;
|
||||
|
||||
protected bool BackgroundBrightnessReduction
|
||||
{
|
||||
get => backgroundBrightnessReduction;
|
||||
set
|
||||
{
|
||||
if (value == backgroundBrightnessReduction)
|
||||
return;
|
||||
|
||||
backgroundBrightnessReduction = value;
|
||||
|
||||
Background.FadeColour(OsuColour.Gray(backgroundBrightnessReduction ? 0.8f : 1), 200);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -284,12 +335,16 @@ namespace osu.Game.Screens.Play
|
||||
// Preview user-defined background dim and blur when hovered on the visual settings panel.
|
||||
Background.EnableUserDim.Value = true;
|
||||
Background.BlurAmount.Value = 0;
|
||||
|
||||
BackgroundBrightnessReduction = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Returns background dim and blur to the values specified by PlayerLoader.
|
||||
Background.EnableUserDim.Value = false;
|
||||
Background.BlurAmount.Value = BACKGROUND_BLUR;
|
||||
|
||||
BackgroundBrightnessReduction = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,5 +499,33 @@ namespace osu.Game.Screens.Play
|
||||
Loading = true;
|
||||
}
|
||||
}
|
||||
|
||||
private class MutedNotification : SimpleNotification
|
||||
{
|
||||
public MutedNotification()
|
||||
{
|
||||
Text = "Your music volume is set to 0%! Click here to restore it.";
|
||||
}
|
||||
|
||||
public override bool IsImportant => true;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, AudioManager audioManager, NotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
|
||||
{
|
||||
Icon = FontAwesome.Solid.VolumeMute;
|
||||
IconBackgound.Colour = colours.RedDark;
|
||||
|
||||
Activated = delegate
|
||||
{
|
||||
notificationOverlay.Hide();
|
||||
|
||||
volumeOverlay.IsMuted.Value = false;
|
||||
audioManager.Volume.SetDefault();
|
||||
audioManager.VolumeTrack.SetDefault();
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
new PlayerCheckbox
|
||||
{
|
||||
LabelText = "Show floating comments",
|
||||
Bindable = config.GetBindable<bool>(OsuSetting.FloatingComments)
|
||||
Current = config.GetBindable<bool>(OsuSetting.FloatingComments)
|
||||
},
|
||||
new FocusedTextBox
|
||||
{
|
||||
|
@ -25,6 +25,6 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config) => mouseButtonsCheckbox.Bindable = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
|
||||
private void load(OsuConfigManager config) => mouseButtonsCheckbox.Current = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Overlays.Settings;
|
||||
namespace osu.Game.Screens.Play.PlayerSettings
|
||||
{
|
||||
public class PlayerSliderBar<T> : SettingsSlider<T>
|
||||
where T : struct, IEquatable<T>, IComparable, IConvertible
|
||||
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
|
||||
{
|
||||
public OsuSliderBar<T> Bar => (OsuSliderBar<T>)Control;
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
private readonly PlayerSliderBar<double> dimSliderBar;
|
||||
private readonly PlayerSliderBar<double> blurSliderBar;
|
||||
private readonly PlayerCheckbox showStoryboardToggle;
|
||||
private readonly PlayerCheckbox showVideoToggle;
|
||||
private readonly PlayerCheckbox beatmapSkinsToggle;
|
||||
private readonly PlayerCheckbox beatmapHitsoundsToggle;
|
||||
|
||||
@ -37,6 +38,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
Text = "Toggles:"
|
||||
},
|
||||
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" },
|
||||
showVideoToggle = new PlayerCheckbox { LabelText = "Video" },
|
||||
beatmapSkinsToggle = new PlayerCheckbox { LabelText = "Beatmap skins" },
|
||||
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" }
|
||||
};
|
||||
@ -47,9 +49,10 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
{
|
||||
dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||
blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel);
|
||||
showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
beatmapSkinsToggle.Bindable = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
|
||||
beatmapHitsoundsToggle.Bindable = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
|
||||
showStoryboardToggle.Current = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
showVideoToggle.Current = config.GetBindable<bool>(OsuSetting.ShowVideoBackground);
|
||||
beatmapSkinsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
|
||||
beatmapHitsoundsToggle.Current = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
private readonly Score score;
|
||||
|
||||
// Disallow replays from failing. (see https://github.com/ppy/osu/issues/6108)
|
||||
protected override bool AllowFail => false;
|
||||
|
||||
public ReplayPlayer(Score score, bool allowPause = true, bool showResults = true)
|
||||
: base(allowPause, showResults)
|
||||
{
|
||||
|
34
osu.Game/Screens/Play/ReplayPlayerLoader.cs
Normal file
34
osu.Game/Screens/Play/ReplayPlayerLoader.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class ReplayPlayerLoader : PlayerLoader
|
||||
{
|
||||
private readonly ScoreInfo scoreInfo;
|
||||
|
||||
public ReplayPlayerLoader(Score score)
|
||||
: base(() => new ReplayPlayer(score))
|
||||
{
|
||||
if (score.Replay == null)
|
||||
throw new ArgumentNullException(nameof(score.Replay), $"{nameof(score)} must have a non-null {nameof(score.Replay)}.");
|
||||
|
||||
scoreInfo = score.ScoreInfo;
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = base.CreateChildDependencies(parent);
|
||||
|
||||
// these will be reverted thanks to PlayerLoader's lease.
|
||||
Mods.Value = scoreInfo.Mods;
|
||||
Ruleset.Value = scoreInfo.Ruleset;
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace osu.Game.Screens.Play
|
||||
/// <summary>
|
||||
/// An overlay which can be used to require further user actions before gameplay is resumed.
|
||||
/// </summary>
|
||||
public abstract class ResumeOverlay : OverlayContainer
|
||||
public abstract class ResumeOverlay : VisibilityContainer
|
||||
{
|
||||
public CursorContainer GameplayCursor { get; set; }
|
||||
|
||||
@ -29,8 +29,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected const float TRANSITION_TIME = 500;
|
||||
|
||||
protected override bool BlockPositionalInput => false;
|
||||
|
||||
protected abstract string Message { get; }
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
@ -23,7 +23,7 @@ using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class SkipOverlay : OverlayContainer, IKeyBindingHandler<GlobalAction>
|
||||
public class SkipOverlay : VisibilityContainer, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private readonly double startTime;
|
||||
|
||||
@ -36,7 +36,6 @@ namespace osu.Game.Screens.Play
|
||||
private double displayTime;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
protected override bool BlockPositionalInput => false;
|
||||
|
||||
/// <summary>
|
||||
/// Displays a skip overlay, giving the user the ability to skip forward.
|
||||
@ -46,7 +45,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
this.startTime = startTime;
|
||||
|
||||
State = Visibility.Visible;
|
||||
Show();
|
||||
|
||||
RelativePositionAxes = Axes.Both;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -136,7 +135,7 @@ namespace osu.Game.Screens.Play
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
if (!e.HasAnyButtonPressed)
|
||||
fadeContainer.State = Visibility.Visible;
|
||||
fadeContainer.Show();
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
@ -161,6 +160,8 @@ namespace osu.Game.Screens.Play
|
||||
private Visibility state;
|
||||
private ScheduledDelegate scheduledHide;
|
||||
|
||||
public override bool IsPresent => true;
|
||||
|
||||
public Visibility State
|
||||
{
|
||||
get => state;
|
||||
@ -180,8 +181,11 @@ namespace osu.Game.Screens.Play
|
||||
this.FadeIn(500, Easing.OutExpo);
|
||||
|
||||
if (!IsHovered && !IsDragged)
|
||||
{
|
||||
using (BeginDelayedSequence(1000))
|
||||
scheduledHide = Schedule(() => State = Visibility.Hidden);
|
||||
scheduledHide = Schedule(Hide);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Visibility.Hidden:
|
||||
@ -196,20 +200,25 @@ namespace osu.Game.Screens.Play
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
State = Visibility.Visible;
|
||||
Show();
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
Show();
|
||||
scheduledHide?.Cancel();
|
||||
return base.OnMouseDown(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
State = Visibility.Visible;
|
||||
return base.OnMouseUp(e);
|
||||
Show();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Hide() => State = Visibility.Hidden;
|
||||
|
||||
public override void Show() => State = Visibility.Visible;
|
||||
}
|
||||
|
||||
private class Button : OsuClickableContainer
|
||||
@ -234,7 +243,7 @@ namespace osu.Game.Screens.Play
|
||||
colourNormal = colours.Yellow;
|
||||
colourHover = colours.YellowDark;
|
||||
|
||||
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
|
||||
sampleConfirm = audio.Samples.Get(@"SongSelect/confirm-selection");
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
|
@ -106,7 +106,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
State = Visibility.Visible;
|
||||
base.LoadComplete();
|
||||
|
||||
Show();
|
||||
|
||||
replayLoaded.ValueChanged += loaded => AllowSeeking = loaded.NewValue;
|
||||
replayLoaded.TriggerChange();
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Threading;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
@ -121,6 +122,12 @@ namespace osu.Game.Screens.Play
|
||||
handleBase.X = newX;
|
||||
}
|
||||
|
||||
protected override void OnUserChange(double value) => OnSeek?.Invoke(value);
|
||||
private ScheduledDelegate scheduledSeek;
|
||||
|
||||
protected override void OnUserChange(double value)
|
||||
{
|
||||
scheduledSeek?.Cancel();
|
||||
scheduledSeek = Schedule(() => OnSeek?.Invoke(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace osu.Game.Screens.Play
|
||||
return base.Invalidate(invalidation, source, shallPropagate);
|
||||
}
|
||||
|
||||
private Cached layout = new Cached();
|
||||
private readonly Cached layout = new Cached();
|
||||
private ScheduledDelegate scheduledCreate;
|
||||
|
||||
protected override void Update()
|
||||
@ -103,6 +103,7 @@ namespace osu.Game.Screens.Play
|
||||
var newColumns = new BufferedContainer<Column>
|
||||
{
|
||||
CacheDrawnFrameBuffer = true,
|
||||
RedrawOnScale = false,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user