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:
commit
6eb3e6c541
63
osu.Game.Tests/Visual/TestCaseLoadingAnimation.cs
Normal file
63
osu.Game.Tests/Visual/TestCaseLoadingAnimation.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user