2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-21 03:33:07 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-03-03 23:50:41 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-09-21 03:33:07 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-03-03 23:50:41 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2017-09-21 03:33:07 +08:00
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
2017-09-23 21:42:18 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-03-03 23:50:41 +08:00
|
|
|
|
using osu.Game.Screens.Play.Break;
|
2017-09-21 03:33:07 +08:00
|
|
|
|
|
2018-03-03 23:50:41 +08:00
|
|
|
|
namespace osu.Game.Screens.Play
|
2017-09-21 03:33:07 +08:00
|
|
|
|
{
|
|
|
|
|
public class BreakOverlay : Container
|
|
|
|
|
{
|
|
|
|
|
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
|
2017-09-23 01:43:51 +08:00
|
|
|
|
private const float remaining_time_container_max_size = 0.3f;
|
2017-09-21 06:44:30 +08:00
|
|
|
|
private const int vertical_margin = 25;
|
2017-09-21 03:33:07 +08:00
|
|
|
|
|
2017-10-02 05:44:57 +08:00
|
|
|
|
private List<BreakPeriod> breaks;
|
2018-03-03 23:50:41 +08:00
|
|
|
|
|
|
|
|
|
private readonly Container fadeContainer;
|
|
|
|
|
|
2017-10-02 05:44:57 +08:00
|
|
|
|
public List<BreakPeriod> Breaks
|
|
|
|
|
{
|
2018-03-03 23:50:41 +08:00
|
|
|
|
get => breaks;
|
2017-10-02 05:44:57 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
breaks = value;
|
|
|
|
|
initializeBreaks();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-03 20:20:36 +08:00
|
|
|
|
public override bool RemoveCompletedTransforms => false;
|
|
|
|
|
|
2017-10-06 09:49:16 +08:00
|
|
|
|
private readonly Container remainingTimeAdjustmentBox;
|
2017-09-21 03:33:07 +08:00
|
|
|
|
private readonly Container remainingTimeBox;
|
|
|
|
|
private readonly RemainingTimeCounter remainingTimeCounter;
|
2018-03-03 23:50:41 +08:00
|
|
|
|
private readonly BreakInfo info;
|
|
|
|
|
private readonly BreakArrows breakArrows;
|
2017-09-21 06:44:30 +08:00
|
|
|
|
|
2018-01-24 16:48:42 +08:00
|
|
|
|
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor)
|
|
|
|
|
: this(letterboxing)
|
2018-01-13 04:33:24 +08:00
|
|
|
|
{
|
|
|
|
|
bindProcessor(scoreProcessor);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 03:33:07 +08:00
|
|
|
|
public BreakOverlay(bool letterboxing)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2018-03-03 23:50:41 +08:00
|
|
|
|
Child = fadeContainer = new Container
|
2017-09-21 03:33:07 +08:00
|
|
|
|
{
|
2018-03-03 23:50:41 +08:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
2017-09-21 03:33:07 +08:00
|
|
|
|
{
|
2018-03-03 23:50:41 +08:00
|
|
|
|
new LetterboxOverlay
|
2017-10-06 09:49:16 +08:00
|
|
|
|
{
|
2018-03-03 23:50:41 +08:00
|
|
|
|
Alpha = letterboxing ? 1 : 0,
|
2017-10-06 09:49:16 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-03-03 23:50:41 +08:00
|
|
|
|
},
|
|
|
|
|
remainingTimeAdjustmentBox = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-10-06 09:49:16 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2018-03-03 23:50:41 +08: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 09:49:16 +08:00
|
|
|
|
}
|
2017-09-21 03:33:07 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-03 23:50:41 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
initializeBreaks();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 05:44:57 +08:00
|
|
|
|
private void initializeBreaks()
|
2017-09-21 03:33:07 +08:00
|
|
|
|
{
|
2018-03-03 23:50:41 +08:00
|
|
|
|
if (!IsLoaded) return; // we need a clock.
|
|
|
|
|
|
2017-10-02 05:44:57 +08:00
|
|
|
|
FinishTransforms(true);
|
2017-10-02 13:51:00 +08:00
|
|
|
|
Scheduler.CancelDelayedTasks();
|
2017-10-02 05:44:57 +08:00
|
|
|
|
|
2018-03-03 23:50:41 +08:00
|
|
|
|
if (breaks == null) return; //we need breaks.
|
2017-09-22 03:54:46 +08:00
|
|
|
|
|
2017-10-02 05:44:57 +08:00
|
|
|
|
foreach (var b in breaks)
|
2017-09-21 03:33:07 +08:00
|
|
|
|
{
|
2017-09-22 03:54:46 +08:00
|
|
|
|
if (!b.HasEffect)
|
|
|
|
|
continue;
|
|
|
|
|
|
2017-11-03 20:20:36 +08:00
|
|
|
|
using (BeginAbsoluteSequence(b.StartTime, true))
|
|
|
|
|
{
|
2018-03-03 23:50:41 +08:00
|
|
|
|
fadeContainer.FadeIn(fade_duration);
|
|
|
|
|
breakArrows.Show(fade_duration);
|
|
|
|
|
|
2017-11-03 20:20:36 +08:00
|
|
|
|
remainingTimeAdjustmentBox
|
|
|
|
|
.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint)
|
|
|
|
|
.Delay(b.Duration - fade_duration)
|
|
|
|
|
.ResizeWidthTo(0);
|
|
|
|
|
|
|
|
|
|
remainingTimeBox
|
|
|
|
|
.ResizeWidthTo(0, b.Duration - fade_duration)
|
|
|
|
|
.Then()
|
|
|
|
|
.ResizeWidthTo(1);
|
|
|
|
|
|
2017-11-06 13:58:05 +08:00
|
|
|
|
remainingTimeCounter.CountTo(b.Duration).CountTo(0, b.Duration);
|
2017-11-03 20:20:36 +08:00
|
|
|
|
|
2018-03-03 23:50:41 +08:00
|
|
|
|
using (BeginDelayedSequence(b.Duration - fade_duration, true))
|
|
|
|
|
{
|
|
|
|
|
fadeContainer.FadeOut(fade_duration);
|
|
|
|
|
breakArrows.Hide(fade_duration);
|
|
|
|
|
}
|
2017-09-21 03:33:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-13 04:33:24 +08:00
|
|
|
|
private void bindProcessor(ScoreProcessor processor)
|
2017-09-23 21:42:18 +08:00
|
|
|
|
{
|
|
|
|
|
info.AccuracyDisplay.Current.BindTo(processor.Accuracy);
|
2017-10-02 10:56:38 +08:00
|
|
|
|
info.GradeDisplay.Current.BindTo(processor.Rank);
|
2017-09-23 21:42:18 +08:00
|
|
|
|
}
|
2017-09-21 03:33:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|