mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:07:44 +08:00
Add remaining time container
This commit is contained in:
parent
1d978d3617
commit
0f04d8c6a7
@ -5,24 +5,45 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class BreakOverlay : VisibilityContainer
|
||||
public class BreakOverlay : Container
|
||||
{
|
||||
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
|
||||
private const int remaining_time_container_max_size = 500;
|
||||
|
||||
public List<BreakPeriod> Breaks;
|
||||
|
||||
private readonly bool letterboxing;
|
||||
private readonly LetterboxOverlay letterboxOverlay;
|
||||
private readonly Container remainingTimeContainer;
|
||||
|
||||
public BreakOverlay(bool letterboxing)
|
||||
{
|
||||
this.letterboxing = letterboxing;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Child = letterboxOverlay = new LetterboxOverlay();
|
||||
Children = new Drawable[]
|
||||
{
|
||||
letterboxOverlay = new LetterboxOverlay(),
|
||||
remainingTimeContainer = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0, 8),
|
||||
CornerRadius = 4,
|
||||
Masking = true,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -41,22 +62,25 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
using (BeginAbsoluteSequence(b.StartTime, true))
|
||||
{
|
||||
Show();
|
||||
onBreakIn(b);
|
||||
|
||||
using (BeginDelayedSequence(b.Duration, true))
|
||||
Hide();
|
||||
onBreakOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
private void onBreakIn(BreakPeriod b)
|
||||
{
|
||||
if (letterboxing) letterboxOverlay.FadeIn(fade_duration);
|
||||
if (letterboxing)
|
||||
letterboxOverlay.FadeIn(fade_duration);
|
||||
|
||||
remainingTimeContainer.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint).Then().ResizeWidthTo(0, b.Duration);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
private void onBreakOut()
|
||||
{
|
||||
if (letterboxing) letterboxOverlay.FadeOut(fade_duration);
|
||||
}
|
||||
|
@ -21,15 +21,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
Clock = new FramedClock();
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
},
|
||||
breakOverlay = new BreakOverlay(true)
|
||||
};
|
||||
Child = breakOverlay = new BreakOverlay(true);
|
||||
|
||||
AddStep("Add 2s break", () => startBreak(2000));
|
||||
AddStep("Add 5s break", () => startBreak(5000));
|
||||
|
Loading…
Reference in New Issue
Block a user