2016-10-07 16:07:23 +08:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
|
|
|
|
using osu.Framework.Input;
|
2016-10-15 21:31:16 +08:00
|
|
|
|
using OpenTK;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
2016-11-14 16:23:33 +08:00
|
|
|
|
namespace osu.Game.Screens.Menu
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// osu! logo and its attachments (pulsing, visualiser etc.)
|
|
|
|
|
/// </summary>
|
2016-10-22 16:50:42 +08:00
|
|
|
|
public partial class OsuLogo : Container
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2016-10-17 01:25:08 +08:00
|
|
|
|
private Sprite logo;
|
|
|
|
|
private CircularContainer logoContainer;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
private Container logoBounceContainer;
|
2016-10-08 11:53:46 +08:00
|
|
|
|
private MenuVisualisation vis;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
|
|
|
|
public Action Action;
|
|
|
|
|
|
2016-10-19 00:53:31 +08:00
|
|
|
|
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * 0.8f;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
|
|
|
|
private Sprite ripple;
|
|
|
|
|
|
|
|
|
|
private Container rippleContainer;
|
|
|
|
|
|
2016-10-17 01:25:08 +08:00
|
|
|
|
public override bool Contains(Vector2 screenSpacePos)
|
|
|
|
|
{
|
|
|
|
|
return logoContainer.Contains(screenSpacePos);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-07 16:07:23 +08:00
|
|
|
|
public bool Ripple
|
|
|
|
|
{
|
|
|
|
|
get { return rippleContainer.Alpha > 0; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
rippleContainer.Alpha = value ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Interactive = true;
|
|
|
|
|
|
|
|
|
|
public OsuLogo()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2016-10-22 16:50:42 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
2016-10-07 16:07:23 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-10-22 16:50:42 +08:00
|
|
|
|
logoBounceContainer = new Container
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2016-10-22 16:50:42 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-10-07 16:07:23 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-10-17 01:25:08 +08:00
|
|
|
|
logoContainer = new CircularContainer
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2016-10-22 17:40:04 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-10-07 16:07:23 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
2016-10-17 01:25:08 +08:00
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
logo = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
},
|
2016-10-07 16:07:23 +08:00
|
|
|
|
},
|
|
|
|
|
rippleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
ripple = new Sprite()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2016-11-05 17:15:37 +08:00
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
2016-10-07 16:07:23 +08:00
|
|
|
|
Alpha = 0.05f
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-10-08 11:53:46 +08:00
|
|
|
|
vis = new MenuVisualisation
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = logo.Size,
|
2016-11-05 17:15:37 +08:00
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
2016-10-07 16:07:23 +08:00
|
|
|
|
Alpha = 0.2f,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2016-11-09 07:13:20 +08:00
|
|
|
|
logo.Texture = textures.Get(@"Menu/logo");
|
|
|
|
|
ripple.Texture = textures.Get(@"Menu/logo");
|
2016-11-01 22:24:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
|
|
|
|
ripple.ScaleTo(1.1f, 500);
|
|
|
|
|
ripple.FadeOut(500);
|
|
|
|
|
ripple.Loop(300);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (!Interactive) return false;
|
|
|
|
|
|
|
|
|
|
logoBounceContainer.ScaleTo(1.1f, 1000, EasingTypes.Out);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
|
{
|
|
|
|
|
if (!Interactive) return false;
|
|
|
|
|
|
|
|
|
|
Action?.Invoke();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
if (!Interactive) return false;
|
|
|
|
|
logoBounceContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
logoBounceContainer.ScaleTo(1, 500, EasingTypes.OutElastic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|