2019-11-25 09:48:58 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-03-03 15:50:41 +00:00
|
|
|
using System.Collections.Generic;
|
2017-09-20 19:33:07 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-03-03 15:50:41 +00:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2017-09-20 19:33:07 +00:00
|
|
|
using osu.Game.Beatmaps.Timing;
|
2017-09-23 13:42:18 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-03-03 15:50:41 +00:00
|
|
|
using osu.Game.Screens.Play.Break;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-03-03 15:50:41 +00:00
|
|
|
namespace osu.Game.Screens.Play
|
2017-09-20 19:33:07 +00:00
|
|
|
{
|
|
|
|
public class BreakOverlay : Container
|
|
|
|
{
|
2019-08-07 13:59:35 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The duration of the break overlay fading.
|
|
|
|
/// </summary>
|
|
|
|
public const double BREAK_FADE_DURATION = BreakPeriod.MIN_BREAK_DURATION / 2;
|
|
|
|
|
2017-09-22 17:43:51 +00:00
|
|
|
private const float remaining_time_container_max_size = 0.3f;
|
2017-09-20 22:44:30 +00:00
|
|
|
private const int vertical_margin = 25;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-03-03 15:50:41 +00:00
|
|
|
private readonly Container fadeContainer;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-07-26 02:41:10 +00:00
|
|
|
private IReadOnlyList<BreakPeriod> breaks;
|
|
|
|
|
|
|
|
public IReadOnlyList<BreakPeriod> Breaks
|
2017-10-01 21:44:57 +00:00
|
|
|
{
|
2018-03-03 15:50:41 +00:00
|
|
|
get => breaks;
|
2017-10-01 21:44:57 +00:00
|
|
|
set
|
|
|
|
{
|
|
|
|
breaks = value;
|
2019-07-26 02:11:01 +00:00
|
|
|
|
2019-08-08 01:41:23 +00:00
|
|
|
if (IsLoaded)
|
|
|
|
initializeBreaks();
|
2017-10-01 21:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-11-03 12:20:36 +00:00
|
|
|
public override bool RemoveCompletedTransforms => false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-10-06 01:49:16 +00:00
|
|
|
private readonly Container remainingTimeAdjustmentBox;
|
2017-09-20 19:33:07 +00:00
|
|
|
private readonly Container remainingTimeBox;
|
|
|
|
private readonly RemainingTimeCounter remainingTimeCounter;
|
2018-03-03 15:50:41 +00:00
|
|
|
private readonly BreakArrows breakArrows;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-03-28 03:18:28 +00:00
|
|
|
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor)
|
2017-09-20 19:33:07 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2020-03-26 06:28:56 +00:00
|
|
|
|
|
|
|
BreakInfo info;
|
|
|
|
|
2018-03-03 15:50:41 +00:00
|
|
|
Child = fadeContainer = new Container
|
2017-09-20 19:33:07 +00:00
|
|
|
{
|
2018-03-03 15:50:41 +00:00
|
|
|
Alpha = 0,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
2017-09-20 19:33:07 +00:00
|
|
|
{
|
2018-03-03 15:50:41 +00:00
|
|
|
new LetterboxOverlay
|
2017-10-06 01:49:16 +00:00
|
|
|
{
|
2018-03-03 15:50:41 +00:00
|
|
|
Alpha = letterboxing ? 1 : 0,
|
2017-10-06 01:49:16 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2018-03-03 15:50:41 +00:00
|
|
|
},
|
|
|
|
remainingTimeAdjustmentBox = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-10-06 01:49:16 +00:00
|
|
|
RelativeSizeAxes = Axes.X,
|
2018-03-03 15:50:41 +00:00
|
|
|
Width = 0,
|
|
|
|
Child = remainingTimeBox = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = 8,
|
|
|
|
CornerRadius = 4,
|
|
|
|
Masking = true,
|
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
remainingTimeCounter = new RemainingTimeCounter
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
Margin = new MarginPadding { Bottom = vertical_margin },
|
|
|
|
},
|
|
|
|
info = new BreakInfo
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Margin = new MarginPadding { Top = vertical_margin },
|
|
|
|
},
|
|
|
|
breakArrows = new BreakArrows
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2017-10-06 01:49:16 +00:00
|
|
|
}
|
2017-09-20 19:33:07 +00:00
|
|
|
}
|
|
|
|
};
|
2019-03-05 04:26:54 +00:00
|
|
|
|
2020-03-26 06:28:56 +00:00
|
|
|
if (scoreProcessor != null)
|
|
|
|
{
|
|
|
|
info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy);
|
|
|
|
info.GradeDisplay.Current.BindTo(scoreProcessor.Rank);
|
|
|
|
}
|
2017-09-20 19:33:07 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-03-03 15:50:41 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
initializeBreaks();
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-10-01 21:44:57 +00:00
|
|
|
private void initializeBreaks()
|
2017-09-20 19:33:07 +00:00
|
|
|
{
|
2017-10-01 21:44:57 +00:00
|
|
|
FinishTransforms(true);
|
2017-10-02 05:51:00 +00:00
|
|
|
Scheduler.CancelDelayedTasks();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-05-05 01:31:11 +00:00
|
|
|
if (breaks == null) return; // we need breaks.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-10-01 21:44:57 +00:00
|
|
|
foreach (var b in breaks)
|
2017-09-20 19:33:07 +00:00
|
|
|
{
|
2017-09-21 19:54:46 +00:00
|
|
|
if (!b.HasEffect)
|
|
|
|
continue;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2021-07-05 15:52:39 +00:00
|
|
|
using (BeginAbsoluteSequence(b.StartTime))
|
2017-11-03 12:20:36 +00:00
|
|
|
{
|
2019-08-07 13:59:35 +00:00
|
|
|
fadeContainer.FadeIn(BREAK_FADE_DURATION);
|
|
|
|
breakArrows.Show(BREAK_FADE_DURATION);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-11-03 12:20:36 +00:00
|
|
|
remainingTimeAdjustmentBox
|
2019-08-07 13:59:35 +00:00
|
|
|
.ResizeWidthTo(remaining_time_container_max_size, BREAK_FADE_DURATION, Easing.OutQuint)
|
|
|
|
.Delay(b.Duration - BREAK_FADE_DURATION)
|
2017-11-03 12:20:36 +00:00
|
|
|
.ResizeWidthTo(0);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-11-03 12:20:36 +00:00
|
|
|
remainingTimeBox
|
2019-08-07 13:59:35 +00:00
|
|
|
.ResizeWidthTo(0, b.Duration - BREAK_FADE_DURATION)
|
2017-11-03 12:20:36 +00:00
|
|
|
.Then()
|
|
|
|
.ResizeWidthTo(1);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-11-06 05:58:05 +00:00
|
|
|
remainingTimeCounter.CountTo(b.Duration).CountTo(0, b.Duration);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2021-07-05 15:52:39 +00:00
|
|
|
using (BeginDelayedSequence(b.Duration - BREAK_FADE_DURATION))
|
2018-03-03 15:50:41 +00:00
|
|
|
{
|
2019-08-07 13:59:35 +00:00
|
|
|
fadeContainer.FadeOut(BREAK_FADE_DURATION);
|
|
|
|
breakArrows.Hide(BREAK_FADE_DURATION);
|
2018-03-03 15:50:41 +00:00
|
|
|
}
|
2017-09-20 19:33:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|