mirror of
https://github.com/ppy/osu
synced 2025-03-11 05:49:12 +00:00
Add animated osu! logo.
This commit is contained in:
parent
918a3bc74f
commit
1f370fe29c
@ -1 +1 @@
|
||||
Subproject commit 14813bc7b6a570b2d727ee1f4bf4265d150a20fc
|
||||
Subproject commit 6edd5eacdd25cc8c4f4dbca3414678c0b7dc5deb
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -22,13 +23,26 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
Alpha = 0.3f;
|
||||
}
|
||||
|
||||
private float triangleScale = 1;
|
||||
|
||||
public float TriangleScale
|
||||
{
|
||||
get { return triangleScale; }
|
||||
set
|
||||
{
|
||||
triangleScale = value;
|
||||
|
||||
Children.ForEach(t => t.ScaleTo(triangleScale));
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
triangle = textures.Get(@"Play/osu/triangle@2x");
|
||||
}
|
||||
|
||||
private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800);
|
||||
private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800 / triangleScale);
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
@ -36,7 +50,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
|
||||
foreach (Drawable d in Children)
|
||||
{
|
||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 880)));
|
||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 880)) / triangleScale);
|
||||
if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0)
|
||||
d.Expire();
|
||||
}
|
||||
@ -47,17 +61,26 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
|
||||
}
|
||||
|
||||
private void addTriangle(bool randomX)
|
||||
protected virtual Sprite CreateTriangle()
|
||||
{
|
||||
Add(new Sprite
|
||||
var scale = triangleScale * RNG.NextSingle() * 0.4f + 0.2f;
|
||||
|
||||
return new Sprite
|
||||
{
|
||||
Texture = triangle,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Position = new Vector2(RNG.NextSingle(), randomX ? RNG.NextSingle() : 1),
|
||||
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
||||
Alpha = RNG.NextSingle()
|
||||
});
|
||||
Scale = new Vector2(scale),
|
||||
Alpha = RNG.NextSingle(),
|
||||
Depth = scale,
|
||||
};
|
||||
}
|
||||
|
||||
private void addTriangle(bool randomX)
|
||||
{
|
||||
var sprite = CreateTriangle();
|
||||
sprite.Position = new Vector2(RNG.NextSingle(), randomX ? RNG.NextSingle() : 1);
|
||||
Add(sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,10 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
logo = new OsuLogo()
|
||||
logo = new OsuLogo
|
||||
{
|
||||
Alpha = 0,
|
||||
Triangles = false,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
Interactive = false,
|
||||
Colour = Color4.DarkGray,
|
||||
|
@ -2,35 +2,50 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// osu! logo and its attachments (pulsing, visualiser etc.)
|
||||
/// </summary>
|
||||
public partial class OsuLogo : Container
|
||||
public partial class OsuLogo : BufferedContainer
|
||||
{
|
||||
private Sprite logo;
|
||||
private CircularContainer logoContainer;
|
||||
private Container logoBounceContainer;
|
||||
private MenuVisualisation vis;
|
||||
|
||||
private CircularContainer colourAndTriangles;
|
||||
|
||||
public Action Action;
|
||||
|
||||
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * 0.8f;
|
||||
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * 0.78f;
|
||||
|
||||
private Sprite ripple;
|
||||
|
||||
private Container rippleContainer;
|
||||
|
||||
public bool Triangles
|
||||
{
|
||||
set
|
||||
{
|
||||
colourAndTriangles.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos)
|
||||
{
|
||||
return logoContainer.Contains(screenSpacePos);
|
||||
@ -65,12 +80,32 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
colourAndTriangles = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.78f),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(233, 103, 161, 255),
|
||||
},
|
||||
new OsuLogoTriangles
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
}
|
||||
},
|
||||
logo = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(0.5f),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -85,6 +120,7 @@ namespace osu.Game.Screens.Menu
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
Scale = new Vector2(0.5f),
|
||||
Alpha = 0.05f
|
||||
}
|
||||
}
|
||||
@ -105,15 +141,15 @@ namespace osu.Game.Screens.Menu
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
logo.Texture = textures.Get(@"Menu/logo");
|
||||
ripple.Texture = textures.Get(@"Menu/logo");
|
||||
logo.Texture = textures.Get(@"Menu/logo@2x");
|
||||
ripple.Texture = textures.Get(@"Menu/logo@2x");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ripple.ScaleTo(1.1f, 500);
|
||||
ripple.ScaleTo(ripple.Scale * 1.1f, 500);
|
||||
ripple.FadeOut(500);
|
||||
ripple.Loop(300);
|
||||
}
|
||||
@ -152,5 +188,44 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
logoBounceContainer.ScaleTo(1, 500, EasingTypes.OutElastic);
|
||||
}
|
||||
|
||||
class OsuLogoTriangles : Triangles
|
||||
{
|
||||
public OsuLogoTriangles()
|
||||
{
|
||||
TriangleScale = 4;
|
||||
Alpha = 1;
|
||||
}
|
||||
|
||||
public override float CornerRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
return DrawSize.X / 2f;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
Debug.Assert(false, "Cannot manually set CornerRadius of CircularContainer.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override Sprite CreateTriangle()
|
||||
{
|
||||
var triangle = base.CreateTriangle();
|
||||
triangle.Alpha = 1;
|
||||
triangle.Colour = getTriangleShade();
|
||||
return triangle;
|
||||
}
|
||||
|
||||
private Color4 getTriangleShade()
|
||||
{
|
||||
float val = RNG.NextSingle();
|
||||
return Interpolation.ValueAt(val,
|
||||
new Color4(222, 91, 149, 255),
|
||||
new Color4(255, 125, 183, 255),
|
||||
0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user