2017-09-21 03:33:07 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.BreaksOverlay
|
|
|
|
|
{
|
|
|
|
|
public class BreakOverlay : Container
|
|
|
|
|
{
|
|
|
|
|
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
|
2017-09-21 06:44:30 +08:00
|
|
|
|
private const float remaining_time_container_max_size = 0.35f;
|
|
|
|
|
private const int vertical_margin = 25;
|
|
|
|
|
private const float glowing_x_offset = 0.13f;
|
|
|
|
|
private const float glowing_x_final = 0.22f;
|
|
|
|
|
private const float blurred_x_offset = 0.2f;
|
2017-09-21 03:33:07 +08:00
|
|
|
|
|
|
|
|
|
public List<BreakPeriod> Breaks;
|
|
|
|
|
|
|
|
|
|
public override IFrameBasedClock Clock
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
base.Clock = remainingTimeCounter.Clock = value;
|
|
|
|
|
}
|
|
|
|
|
get { return base.Clock; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly bool letterboxing;
|
|
|
|
|
private readonly LetterboxOverlay letterboxOverlay;
|
|
|
|
|
private readonly Container remainingTimeBox;
|
|
|
|
|
private readonly RemainingTimeCounter remainingTimeCounter;
|
|
|
|
|
private readonly InfoContainer info;
|
|
|
|
|
|
2017-09-21 06:44:30 +08:00
|
|
|
|
private readonly GlowingIcon leftGlowingIcon;
|
|
|
|
|
private readonly GlowingIcon rightGlowingIcon;
|
|
|
|
|
|
|
|
|
|
private readonly BlurredIcon leftBlurredIcon;
|
|
|
|
|
private readonly BlurredIcon rightBlurredIcon;
|
|
|
|
|
|
2017-09-21 03:33:07 +08:00
|
|
|
|
public BreakOverlay(bool letterboxing)
|
|
|
|
|
{
|
|
|
|
|
this.letterboxing = letterboxing;
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-09-21 06:44:30 +08:00
|
|
|
|
letterboxOverlay = new LetterboxOverlay
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
2017-09-21 03:33:07 +08:00
|
|
|
|
remainingTimeBox = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-09-21 06:44:30 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-09-21 03:33:07 +08:00
|
|
|
|
Size = new Vector2(0, 8),
|
|
|
|
|
CornerRadius = 4,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both }
|
|
|
|
|
},
|
|
|
|
|
remainingTimeCounter = new RemainingTimeCounter
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
2017-09-21 06:44:30 +08:00
|
|
|
|
Margin = new MarginPadding { Bottom = vertical_margin },
|
2017-09-21 03:33:07 +08:00
|
|
|
|
},
|
|
|
|
|
info = new InfoContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2017-09-21 06:44:30 +08:00
|
|
|
|
Margin = new MarginPadding { Top = vertical_margin },
|
|
|
|
|
},
|
|
|
|
|
leftGlowingIcon = new GlowingIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Icon = Graphics.FontAwesome.fa_chevron_left,
|
|
|
|
|
Size = new Vector2(60),
|
|
|
|
|
},
|
|
|
|
|
rightGlowingIcon = new GlowingIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Icon = Graphics.FontAwesome.fa_chevron_right,
|
|
|
|
|
Size = new Vector2(60),
|
|
|
|
|
},
|
|
|
|
|
leftBlurredIcon = new BlurredIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Icon = Graphics.FontAwesome.fa_chevron_left,
|
|
|
|
|
},
|
|
|
|
|
rightBlurredIcon = new BlurredIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Icon = Graphics.FontAwesome.fa_chevron_right,
|
2017-09-21 03:33:07 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
InitializeBreaks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitializeBreaks()
|
|
|
|
|
{
|
|
|
|
|
if (Breaks != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var b in Breaks)
|
|
|
|
|
{
|
|
|
|
|
if (b.HasEffect)
|
|
|
|
|
{
|
|
|
|
|
using (BeginAbsoluteSequence(b.StartTime, true))
|
|
|
|
|
{
|
|
|
|
|
onBreakIn(b);
|
|
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(b.Duration, true))
|
|
|
|
|
onBreakOut();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onBreakIn(BreakPeriod b)
|
|
|
|
|
{
|
|
|
|
|
if (letterboxing)
|
|
|
|
|
letterboxOverlay.FadeIn(fade_duration);
|
|
|
|
|
|
|
|
|
|
remainingTimeBox
|
|
|
|
|
.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint)
|
|
|
|
|
.Then()
|
|
|
|
|
.ResizeWidthTo(0, b.Duration);
|
|
|
|
|
|
2017-09-21 06:44:30 +08:00
|
|
|
|
Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime);
|
2017-09-21 03:33:07 +08:00
|
|
|
|
remainingTimeCounter.FadeIn(fade_duration);
|
|
|
|
|
|
|
|
|
|
info.FadeIn(fade_duration);
|
2017-09-21 06:44:30 +08:00
|
|
|
|
|
|
|
|
|
leftGlowingIcon.MoveToX(1 - glowing_x_final, fade_duration, Easing.OutQuint);
|
|
|
|
|
rightGlowingIcon.MoveToX(glowing_x_final, fade_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
leftBlurredIcon.MoveToX(1, fade_duration, Easing.OutQuint);
|
|
|
|
|
rightBlurredIcon.MoveToX(0, fade_duration, Easing.OutQuint);
|
2017-09-21 03:33:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onBreakOut()
|
|
|
|
|
{
|
|
|
|
|
if (letterboxing)
|
|
|
|
|
letterboxOverlay.FadeOut(fade_duration);
|
|
|
|
|
|
|
|
|
|
remainingTimeCounter.FadeOut(fade_duration);
|
|
|
|
|
info.FadeOut(fade_duration);
|
2017-09-21 06:44:30 +08:00
|
|
|
|
|
|
|
|
|
leftGlowingIcon.MoveToX(1 + glowing_x_offset, fade_duration, Easing.OutQuint);
|
|
|
|
|
rightGlowingIcon.MoveToX(-glowing_x_offset, fade_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
leftBlurredIcon.MoveToX(1 + blurred_x_offset, fade_duration, Easing.OutQuint);
|
|
|
|
|
rightBlurredIcon.MoveToX(-blurred_x_offset, fade_duration, Easing.OutQuint);
|
2017-09-21 03:33:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|