mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
BreakOverlay and LetterboxOverlay implementation
This commit is contained in:
64
osu.Game/Screens/Play/BreakOverlay.cs
Normal file
64
osu.Game/Screens/Play/BreakOverlay.cs
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class BreakOverlay : VisibilityContainer
|
||||
{
|
||||
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
|
||||
|
||||
public List<BreakPeriod> Breaks;
|
||||
|
||||
private readonly bool letterboxing;
|
||||
private readonly LetterboxOverlay letterboxOverlay;
|
||||
|
||||
public BreakOverlay(bool letterboxing)
|
||||
{
|
||||
this.letterboxing = letterboxing;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Child = letterboxOverlay = new LetterboxOverlay();
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
Show();
|
||||
|
||||
using (BeginDelayedSequence(b.Duration, true))
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
if (letterboxing) letterboxOverlay.FadeIn(fade_duration);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
if (letterboxing) letterboxOverlay.FadeOut(fade_duration);
|
||||
}
|
||||
}
|
||||
}
|
63
osu.Game/Screens/Play/LetterboxOverlay.cs
Normal file
63
osu.Game/Screens/Play/LetterboxOverlay.cs
Normal file
@ -0,0 +1,63 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class LetterboxOverlay : Container
|
||||
{
|
||||
private const int letterbox_height = 350;
|
||||
|
||||
private Color4 transparentBlack => new Color4(0, 0, 0, 0);
|
||||
|
||||
public LetterboxOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Alpha = 0;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = letterbox_height,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new ColourInfo
|
||||
{
|
||||
TopLeft = Color4.Black,
|
||||
TopRight = Color4.Black,
|
||||
BottomLeft = transparentBlack,
|
||||
BottomRight = transparentBlack,
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = letterbox_height,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new ColourInfo
|
||||
{
|
||||
TopLeft = transparentBlack,
|
||||
TopRight = transparentBlack,
|
||||
BottomLeft = Color4.Black,
|
||||
BottomRight = Color4.Black,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -161,21 +161,25 @@ namespace osu.Game.Screens.Play
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SkipButton(firstObjectTime) { AudioClock = decoupledClock },
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Clock = offsetClock,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RulesetContainer,
|
||||
}
|
||||
Child = RulesetContainer,
|
||||
},
|
||||
hudOverlay = new HUDOverlay
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new BreakOverlay(beatmap.BeatmapInfo.LetterboxInBreaks)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Breaks = beatmap.Breaks,
|
||||
Clock = decoupledClock
|
||||
},
|
||||
new SkipButton(firstObjectTime) { AudioClock = decoupledClock },
|
||||
}
|
||||
},
|
||||
failOverlay = new FailOverlay
|
||||
|
Reference in New Issue
Block a user