1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 11:03:22 +08:00

Merge pull request #2857 from peppy/make-loading-more-visible

Improve the visibility of the global loading animation
This commit is contained in:
Dan Balasescu 2018-06-27 13:06:43 +09:00 committed by GitHub
commit 6eb3e6c541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 8 deletions

View File

@ -0,0 +1,63 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using OpenTK.Graphics;
namespace osu.Game.Tests.Visual
{
public class TestCaseLoadingAnimation : GridTestCase
{
public TestCaseLoadingAnimation()
: base(2, 2)
{
LoadingAnimation loading;
Cell(0).AddRange(new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both
},
loading = new LoadingAnimation()
});
loading.Show();
Cell(1).AddRange(new Drawable[]
{
new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both
},
loading = new LoadingAnimation()
});
loading.Show();
Cell(2).AddRange(new Drawable[]
{
new Box
{
Colour = Color4.Gray,
RelativeSizeAxes = Axes.Both
},
loading = new LoadingAnimation()
});
loading.Show();
Cell(3).AddRange(new Drawable[]
{
loading = new LoadingAnimation()
});
Scheduler.AddDelayed(() => loading.ToggleVisibility(), 200, true);
}
}
}

View File

@ -4,12 +4,17 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using OpenTK; using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public class LoadingAnimation : VisibilityContainer public class LoadingAnimation : VisibilityContainer
{ {
private readonly SpriteIcon spinner; private readonly SpriteIcon spinner;
private readonly SpriteIcon spinnerShadow;
private const float spin_duration = 600;
private const float transition_duration = 200;
public LoadingAnimation() public LoadingAnimation()
{ {
@ -20,12 +25,22 @@ namespace osu.Game.Graphics.UserInterface
Children = new Drawable[] Children = new Drawable[]
{ {
spinner = new SpriteIcon spinnerShadow = new SpriteIcon
{ {
Size = new Vector2(20),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Icon = FontAwesome.fa_spinner RelativeSizeAxes = Axes.Both,
Position = new Vector2(1, 1),
Colour = Color4.Black,
Alpha = 0.4f,
Icon = FontAwesome.fa_circle_o_notch
},
spinner = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Icon = FontAwesome.fa_circle_o_notch
} }
}; };
} }
@ -34,12 +49,11 @@ namespace osu.Game.Graphics.UserInterface
{ {
base.LoadComplete(); base.LoadComplete();
spinner.Spin(2000, RotationDirection.Clockwise); spinner.Spin(spin_duration, RotationDirection.Clockwise);
spinnerShadow.Spin(spin_duration, RotationDirection.Clockwise);
} }
private const float transition_duration = 500; protected override void PopIn() => this.FadeIn(transition_duration * 2, Easing.OutQuint);
protected override void PopIn() => this.FadeIn(transition_duration * 5, Easing.OutQuint);
protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint); protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint);
} }

View File

@ -10,6 +10,7 @@ using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Overlays.Direct namespace osu.Game.Overlays.Direct
@ -48,9 +49,15 @@ namespace osu.Game.Overlays.Direct
set set
{ {
if (value) if (value)
{
icon.FadeTo(0.5f, transition_duration, Easing.OutQuint);
loadingAnimation.Show(); loadingAnimation.Show();
}
else else
{
icon.FadeTo(1, transition_duration, Easing.OutQuint);
loadingAnimation.Hide(); loadingAnimation.Hide();
}
} }
} }
@ -67,7 +74,10 @@ namespace osu.Game.Overlays.Direct
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Icon = FontAwesome.fa_play, Icon = FontAwesome.fa_play,
}, },
loadingAnimation = new LoadingAnimation(), loadingAnimation = new LoadingAnimation
{
Size = new Vector2(15),
},
}); });
Playing.ValueChanged += playingStateChanged; Playing.ValueChanged += playingStateChanged;