1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Add arrows overlay

This commit is contained in:
EVAST9919 2017-09-22 01:16:05 +03:00
parent 5383e33f3d
commit 56bde64839
5 changed files with 129 additions and 79 deletions

View File

@ -0,0 +1,84 @@
// 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 OpenTK;
namespace osu.Game.Screens.Play.BreaksOverlay
{
public class ArrowsOverlay : Container
{
private const int glowing_size = 60;
private const float glowing_final_offset = 0.25f;
private const float glowing_offscreen_offset = 0.6f;
private const int blurred_size = 130;
private const float blurred_final_offset = 0.35f;
private const float blurred_offscreen_offset = 0.7f;
private readonly GlowIcon leftGlowIcon;
private readonly GlowIcon rightGlowIcon;
private readonly BlurredIcon leftBlurredIcon;
private readonly BlurredIcon rightBlurredIcon;
public ArrowsOverlay()
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
leftGlowIcon = new GlowIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
X = - glowing_offscreen_offset,
Icon = Graphics.FontAwesome.fa_chevron_right,
Size = new Vector2(glowing_size),
},
rightGlowIcon = new GlowIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
X = glowing_offscreen_offset,
Icon = Graphics.FontAwesome.fa_chevron_left,
Size = new Vector2(glowing_size),
},
leftBlurredIcon = new BlurredIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
X = - blurred_offscreen_offset,
Icon = Graphics.FontAwesome.fa_chevron_right,
Size = new Vector2(blurred_size),
},
rightBlurredIcon = new BlurredIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
X = blurred_offscreen_offset,
Icon = Graphics.FontAwesome.fa_chevron_left,
Size = new Vector2(blurred_size),
},
};
}
public void Show(double fadeDuration)
{
leftGlowIcon.MoveToX(-glowing_final_offset, fadeDuration, Easing.OutQuint);
rightGlowIcon.MoveToX(glowing_final_offset, fadeDuration, Easing.OutQuint);
leftBlurredIcon.MoveToX(-blurred_final_offset, fadeDuration, Easing.OutQuint);
rightBlurredIcon.MoveToX(blurred_final_offset, fadeDuration, Easing.OutQuint);
}
public void Hide(double fadeDuration)
{
leftGlowIcon.MoveToX(-glowing_offscreen_offset, fadeDuration, Easing.OutQuint);
rightGlowIcon.MoveToX(glowing_offscreen_offset, fadeDuration, Easing.OutQuint);
leftBlurredIcon.MoveToX(-blurred_offscreen_offset, fadeDuration, Easing.OutQuint);
rightBlurredIcon.MoveToX(blurred_offscreen_offset, fadeDuration, Easing.OutQuint);
}
}
}

View File

@ -10,9 +10,9 @@ namespace osu.Game.Screens.Play.BreaksOverlay
{ {
public class BlurredIcon : BufferedContainer public class BlurredIcon : BufferedContainer
{ {
private const int icon_size = 130; private const int blur_sigma = 20;
private readonly GlowingIcon icon; private readonly GlowIcon icon;
public FontAwesome Icon public FontAwesome Icon
{ {
@ -20,20 +20,26 @@ namespace osu.Game.Screens.Play.BreaksOverlay
get { return icon.Icon; } get { return icon.Icon; }
} }
public override Vector2 Size
{
set
{
icon.Size = value;
base.Size = value + new Vector2(blur_sigma * 2);
}
get { return icon.Size; }
}
public BlurredIcon() public BlurredIcon()
{ {
Anchor = Anchor.CentreLeft;
RelativePositionAxes = Axes.X; RelativePositionAxes = Axes.X;
Size = new Vector2(icon_size * 1.7f); BlurSigma = new Vector2(blur_sigma);
Masking = true;
BlurSigma = new Vector2(20);
Alpha = 0.6f; Alpha = 0.6f;
CacheDrawnFrameBuffer = true; CacheDrawnFrameBuffer = true;
Child = icon = new GlowingIcon Child = icon = new GlowIcon
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Size = new Vector2(icon_size),
}; };
} }
} }

View File

@ -15,9 +15,6 @@ namespace osu.Game.Screens.Play.BreaksOverlay
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
private const float remaining_time_container_max_size = 0.35f; private const float remaining_time_container_max_size = 0.35f;
private const int vertical_margin = 25; 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;
public List<BreakPeriod> Breaks; public List<BreakPeriod> Breaks;
@ -26,12 +23,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
private readonly Container remainingTimeBox; private readonly Container remainingTimeBox;
private readonly RemainingTimeCounter remainingTimeCounter; private readonly RemainingTimeCounter remainingTimeCounter;
private readonly InfoContainer info; private readonly InfoContainer info;
private readonly ArrowsOverlay arrowsOverlay;
private readonly GlowingIcon leftGlowingIcon;
private readonly GlowingIcon rightGlowingIcon;
private readonly BlurredIcon leftBlurredIcon;
private readonly BlurredIcon rightBlurredIcon;
public BreakOverlay(bool letterboxing) public BreakOverlay(bool letterboxing)
{ {
@ -67,31 +59,10 @@ namespace osu.Game.Screens.Play.BreaksOverlay
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = vertical_margin }, Margin = new MarginPadding { Top = vertical_margin },
}, },
leftGlowingIcon = new GlowingIcon arrowsOverlay = new ArrowsOverlay
{ {
Origin = Anchor.CentreRight, Anchor = Anchor.Centre,
Icon = Graphics.FontAwesome.fa_chevron_left, Origin = Anchor.Centre,
Size = new Vector2(60),
X = 1 + glowing_x_offset,
},
rightGlowingIcon = new GlowingIcon
{
Origin = Anchor.CentreLeft,
Icon = Graphics.FontAwesome.fa_chevron_right,
Size = new Vector2(60),
X = -glowing_x_offset,
},
leftBlurredIcon = new BlurredIcon
{
Origin = Anchor.CentreRight,
Icon = Graphics.FontAwesome.fa_chevron_left,
X = 1 + blurred_x_offset,
},
rightBlurredIcon = new BlurredIcon
{
Origin = Anchor.CentreLeft,
Icon = Graphics.FontAwesome.fa_chevron_right,
X = -blurred_x_offset,
} }
}; };
} }
@ -136,12 +107,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
remainingTimeCounter.FadeIn(fade_duration); remainingTimeCounter.FadeIn(fade_duration);
info.FadeIn(fade_duration); info.FadeIn(fade_duration);
arrowsOverlay.Show(fade_duration);
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);
} }
private void onBreakOut() private void onBreakOut()
@ -151,12 +117,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
remainingTimeCounter.FadeOut(fade_duration); remainingTimeCounter.FadeOut(fade_duration);
info.FadeOut(fade_duration); info.FadeOut(fade_duration);
arrowsOverlay.Hide(fade_duration);
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);
} }
} }
} }

View File

@ -1,42 +1,40 @@
// 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 osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using OpenTK; using OpenTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
namespace osu.Game.Screens.Play.BreaksOverlay namespace osu.Game.Screens.Play.BreaksOverlay
{ {
public class GlowingIcon : Container public class GlowIcon : Container
{ {
private readonly SpriteIcon icon; private const int blur_sigma = 5;
private readonly SpriteIcon glow;
private readonly BufferedContainer glowContainer;
public FontAwesome Icon private readonly SpriteIcon spriteIcon;
{ private readonly SpriteIcon glowIcon;
set { icon.Icon = glow.Icon = value; } private readonly BufferedContainer glowContainer;
get { return icon.Icon; }
}
public override Vector2 Size public override Vector2 Size
{ {
set set
{ {
glow.Size = icon.Size = value; spriteIcon.Size = glowIcon.Size = value;
glowContainer.Size = value * 1.5f; glowContainer.Size = value + new Vector2(blur_sigma * 2);
}
get
{
return glow.Size;
} }
get { return spriteIcon.Size; }
} }
public GlowingIcon() public FontAwesome Icon
{
set { spriteIcon.Icon = glowIcon.Icon = value; }
get { return spriteIcon.Icon; }
}
public GlowIcon()
{ {
Anchor = Anchor.CentreLeft;
RelativePositionAxes = Axes.X; RelativePositionAxes = Axes.X;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
@ -45,17 +43,17 @@ namespace osu.Game.Screens.Play.BreaksOverlay
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Masking = true, BlurSigma = new Vector2(blur_sigma),
BlurSigma = new Vector2(10),
CacheDrawnFrameBuffer = true, CacheDrawnFrameBuffer = true,
Child = glow = new SpriteIcon Child = glowIcon = new SpriteIcon
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Shadow = false, Shadow = false,
}, },
}, },
icon = new SpriteIcon spriteIcon = new SpriteIcon
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -67,7 +65,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
glow.Colour = colours.Blue; glowIcon.Colour = colours.BlueLight;
} }
} }
} }

View File

@ -275,9 +275,10 @@
<Compile Include="Beatmaps\Formats\OsuLegacyDecoder.cs" /> <Compile Include="Beatmaps\Formats\OsuLegacyDecoder.cs" />
<Compile Include="Beatmaps\IO\ArchiveReader.cs" /> <Compile Include="Beatmaps\IO\ArchiveReader.cs" />
<Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" /> <Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" />
<Compile Include="Screens\Play\BreaksOverlay\ArrowsOverlay.cs" />
<Compile Include="Screens\Play\BreaksOverlay\BlurredIcon.cs" /> <Compile Include="Screens\Play\BreaksOverlay\BlurredIcon.cs" />
<Compile Include="Screens\Play\BreaksOverlay\BreakOverlay.cs" /> <Compile Include="Screens\Play\BreaksOverlay\BreakOverlay.cs" />
<Compile Include="Screens\Play\BreaksOverlay\GlowingIcon.cs" /> <Compile Include="Screens\Play\BreaksOverlay\GlowIcon.cs" />
<Compile Include="Screens\Play\BreaksOverlay\InfoContainer.cs" /> <Compile Include="Screens\Play\BreaksOverlay\InfoContainer.cs" />
<Compile Include="Screens\Play\BreaksOverlay\LetterboxOverlay.cs" /> <Compile Include="Screens\Play\BreaksOverlay\LetterboxOverlay.cs" />
<Compile Include="Screens\Play\BreaksOverlay\RemainingTimeCounter.cs" /> <Compile Include="Screens\Play\BreaksOverlay\RemainingTimeCounter.cs" />