Make all the overlays IStateful

This commit is contained in:
EVAST9919 2017-10-05 04:38:13 +03:00
parent 80fb14e3dc
commit 22a59d753b
5 changed files with 69 additions and 47 deletions

View File

@ -5,11 +5,15 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using OpenTK; using OpenTK;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using System;
using osu.Game.Beatmaps.Timing;
namespace osu.Game.Screens.Play.BreaksOverlay namespace osu.Game.Screens.Play.BreaksOverlay
{ {
public class ArrowsOverlay : Container public class ArrowsOverlay : VisibilityContainer
{ {
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
private const int glow_icon_size = 60; private const int glow_icon_size = 60;
private const int glow_icon_blur_sigma = 10; private const int glow_icon_blur_sigma = 10;
private const float glow_icon_final_offset = 0.22f; private const float glow_icon_final_offset = 0.22f;
@ -79,22 +83,22 @@ namespace osu.Game.Screens.Play.BreaksOverlay
}; };
} }
public void Show(double fadeDuration) protected override void PopIn()
{ {
leftGlowIcon.MoveToX(-glow_icon_final_offset, fadeDuration, Easing.OutQuint); leftGlowIcon.MoveToX(-glow_icon_final_offset, fade_duration, Easing.OutQuint);
rightGlowIcon.MoveToX(glow_icon_final_offset, fadeDuration, Easing.OutQuint); rightGlowIcon.MoveToX(glow_icon_final_offset, fade_duration, Easing.OutQuint);
leftBlurredIcon.MoveToX(-blurred_icon_final_offset, fadeDuration, Easing.OutQuint); leftBlurredIcon.MoveToX(-blurred_icon_final_offset, fade_duration, Easing.OutQuint);
rightBlurredIcon.MoveToX(blurred_icon_final_offset, fadeDuration, Easing.OutQuint); rightBlurredIcon.MoveToX(blurred_icon_final_offset, fade_duration, Easing.OutQuint);
} }
public void Hide(double fadeDuration) protected override void PopOut()
{ {
leftGlowIcon.MoveToX(-glow_icon_offscreen_offset, fadeDuration, Easing.OutQuint); leftGlowIcon.MoveToX(-glow_icon_offscreen_offset, fade_duration, Easing.OutQuint);
rightGlowIcon.MoveToX(glow_icon_offscreen_offset, fadeDuration, Easing.OutQuint); rightGlowIcon.MoveToX(glow_icon_offscreen_offset, fade_duration, Easing.OutQuint);
leftBlurredIcon.MoveToX(-blurred_icon_offscreen_offset, fadeDuration, Easing.OutQuint); leftBlurredIcon.MoveToX(-blurred_icon_offscreen_offset, fade_duration, Easing.OutQuint);
rightBlurredIcon.MoveToX(blurred_icon_offscreen_offset, fadeDuration, Easing.OutQuint); rightBlurredIcon.MoveToX(blurred_icon_offscreen_offset, fade_duration, Easing.OutQuint);
} }
} }
} }

View File

@ -106,7 +106,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
private void onBreakIn(BreakPeriod b) private void onBreakIn(BreakPeriod b)
{ {
if (letterboxing) if (letterboxing)
letterboxOverlay.FadeIn(fade_duration); letterboxOverlay.Show();
remainingTimeBox remainingTimeBox
.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint) .ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint)
@ -115,20 +115,19 @@ namespace osu.Game.Screens.Play.BreaksOverlay
Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime); Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime);
remainingTimeCounter.FadeIn(fade_duration); remainingTimeCounter.Show();
info.Show();
info.FadeIn(fade_duration); arrowsOverlay.Show();
arrowsOverlay.Show(fade_duration);
} }
private void onBreakOut() private void onBreakOut()
{ {
if (letterboxing) if (letterboxing)
letterboxOverlay.FadeOut(fade_duration); letterboxOverlay.Hide();
remainingTimeCounter.FadeOut(fade_duration); remainingTimeCounter.Hide();
info.FadeOut(fade_duration); info.Hide();
arrowsOverlay.Hide(fade_duration); arrowsOverlay.Hide();
} }
public void BindProcessor(ScoreProcessor processor) public void BindProcessor(ScoreProcessor processor)

View File

@ -1,16 +1,20 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK; using OpenTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Beatmaps.Timing;
namespace osu.Game.Screens.Play.BreaksOverlay namespace osu.Game.Screens.Play.BreaksOverlay
{ {
public class InfoContainer : FillFlowContainer public class InfoContainer : VisibilityContainer
{ {
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
public PercentageInfoLine AccuracyDisplay; public PercentageInfoLine AccuracyDisplay;
public InfoLine<int> RankDisplay; public InfoLine<int> RankDisplay;
public InfoLine<ScoreRank> GradeDisplay; public InfoLine<ScoreRank> GradeDisplay;
@ -18,9 +22,10 @@ namespace osu.Game.Screens.Play.BreaksOverlay
public InfoContainer() public InfoContainer()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Alpha = 0; Child = new FillFlowContainer
Direction = FillDirection.Vertical; {
Spacing = new Vector2(5); Direction = FillDirection.Vertical,
Spacing = new Vector2(5),
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new OsuSpriteText
@ -44,7 +49,11 @@ namespace osu.Game.Screens.Play.BreaksOverlay
GradeDisplay = new InfoLine<ScoreRank>("Grade"), GradeDisplay = new InfoLine<ScoreRank>("Grade"),
}, },
} }
},
}; };
} }
protected override void PopIn() => this.FadeIn(fade_duration);
protected override void PopOut() => this.FadeOut(fade_duration);
} }
} }

View File

@ -1,16 +1,19 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.Timing;
namespace osu.Game.Screens.Play.BreaksOverlay namespace osu.Game.Screens.Play.BreaksOverlay
{ {
public class LetterboxOverlay : Container public class LetterboxOverlay : VisibilityContainer
{ {
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
private const int height = 350; private const int height = 350;
private static readonly Color4 transparent_black = new Color4(0, 0, 0, 0); private static readonly Color4 transparent_black = new Color4(0, 0, 0, 0);
@ -18,7 +21,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay
public LetterboxOverlay() public LetterboxOverlay()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
Alpha = 0;
Children = new Drawable[] Children = new Drawable[]
{ {
new Container new Container
@ -59,5 +61,8 @@ namespace osu.Game.Screens.Play.BreaksOverlay
} }
}; };
} }
protected override void PopIn() => this.FadeIn(fade_duration);
protected override void PopOut() => this.FadeOut(fade_duration);
} }
} }

View File

@ -5,11 +5,14 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using System; using System;
using osu.Game.Beatmaps.Timing;
namespace osu.Game.Screens.Play.BreaksOverlay namespace osu.Game.Screens.Play.BreaksOverlay
{ {
public class RemainingTimeCounter : Container public class RemainingTimeCounter : VisibilityContainer
{ {
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
private readonly OsuSpriteText counter; private readonly OsuSpriteText counter;
private int? previousSecond; private int? previousSecond;
@ -21,7 +24,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay
public RemainingTimeCounter() public RemainingTimeCounter()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Alpha = 0;
Child = counter = new OsuSpriteText Child = counter = new OsuSpriteText
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -56,5 +58,8 @@ namespace osu.Game.Screens.Play.BreaksOverlay
else isCounting = false; else isCounting = false;
} }
} }
protected override void PopIn() => this.FadeIn(fade_duration);
protected override void PopOut() => this.FadeOut(fade_duration);
} }
} }