2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-02-07 20:45:59 +08:00
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
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;
|
2017-02-25 20:12:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
using osu.Framework.Input;
|
2017-01-27 12:50:22 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2016-12-01 19:21:14 +08:00
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2016-10-15 21:31:16 +08:00
|
|
|
|
using OpenTK;
|
2016-12-01 19:21:14 +08:00
|
|
|
|
using OpenTK.Graphics;
|
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>
|
2017-02-09 21:18:08 +08:00
|
|
|
|
public class OsuLogo : Container
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2017-01-27 16:57:52 +08:00
|
|
|
|
public Color4 OsuPink = OsuColour.FromHex(@"e967a1");
|
|
|
|
|
|
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-12-01 19:52:26 +08:00
|
|
|
|
private Container logoHoverContainer;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
2017-02-18 16:35:04 +08:00
|
|
|
|
private SampleChannel sampleClick;
|
2017-02-07 20:45:59 +08:00
|
|
|
|
|
2016-12-01 20:12:37 +08:00
|
|
|
|
private Container colourAndTriangles;
|
2016-12-01 19:21:14 +08:00
|
|
|
|
|
2016-10-07 16:07:23 +08:00
|
|
|
|
public Action Action;
|
|
|
|
|
|
2016-12-01 19:52:26 +08:00
|
|
|
|
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.78f;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
|
|
|
|
private Sprite ripple;
|
|
|
|
|
|
|
|
|
|
private Container rippleContainer;
|
|
|
|
|
|
2016-12-01 19:21:14 +08:00
|
|
|
|
public bool Triangles
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
colourAndTriangles.Alpha = value ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2017-01-27 12:50:22 +08:00
|
|
|
|
private Box flashLayer;
|
2016-10-07 16:07:23 +08:00
|
|
|
|
|
|
|
|
|
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-12-01 19:52:26 +08:00
|
|
|
|
logoHoverContainer = new Container
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2016-10-22 17:40:04 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-12-01 19:21:14 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-10-17 01:25:08 +08:00
|
|
|
|
{
|
2016-12-01 20:29:14 +08:00
|
|
|
|
new BufferedContainer
|
2016-12-01 19:21:14 +08:00
|
|
|
|
{
|
2016-12-01 20:29:14 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-12-01 19:21:14 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-12-01 20:29:14 +08:00
|
|
|
|
logoContainer = new CircularContainer
|
2016-12-01 19:21:14 +08:00
|
|
|
|
{
|
2016-12-01 19:52:26 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
2016-12-01 20:29:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Scale = new Vector2(0.8f),
|
2016-12-01 19:52:26 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2016-12-01 20:29:14 +08:00
|
|
|
|
colourAndTriangles = new Container
|
2016-12-01 19:52:26 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2016-12-01 20:29:14 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-01-30 15:08:31 +08:00
|
|
|
|
new Box
|
2016-12-01 20:29:14 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-27 16:57:52 +08:00
|
|
|
|
Colour = OsuPink,
|
2016-12-01 20:29:14 +08:00
|
|
|
|
},
|
2017-01-30 15:53:12 +08:00
|
|
|
|
new Triangles
|
2016-12-01 20:29:14 +08:00
|
|
|
|
{
|
2017-01-30 15:53:12 +08:00
|
|
|
|
TriangleScale = 4,
|
|
|
|
|
ColourLight = OsuColour.FromHex(@"ff7db7"),
|
|
|
|
|
ColourDark = OsuColour.FromHex(@"de5b95"),
|
2016-12-01 20:29:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
}
|
2016-12-01 19:52:26 +08:00
|
|
|
|
},
|
2017-01-27 12:50:22 +08:00
|
|
|
|
flashLayer = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
2016-12-01 20:29:14 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
logo = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
}
|
2016-12-01 20:12:37 +08:00
|
|
|
|
},
|
2016-12-01 19:52:26 +08:00
|
|
|
|
rippleContainer = new Container
|
2016-10-17 01:25:08 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2016-12-01 19:52:26 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
ripple = new Sprite()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
2016-12-01 20:29:14 +08:00
|
|
|
|
Alpha = 0.15f
|
2016-12-01 19:52:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-17 01:25:08 +08:00
|
|
|
|
},
|
2017-02-09 21:18:08 +08:00
|
|
|
|
new MenuVisualisation
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2016-12-01 19:52:26 +08:00
|
|
|
|
Size = logo.Size,
|
2016-11-05 17:15:37 +08:00
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
2016-12-01 19:52:26 +08:00
|
|
|
|
Alpha = 0.2f,
|
2016-10-07 16:07:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-02-07 20:45:59 +08:00
|
|
|
|
private void load(TextureStore textures, AudioManager audio)
|
2016-10-07 16:07:23 +08:00
|
|
|
|
{
|
2017-02-07 20:45:59 +08:00
|
|
|
|
sampleClick = audio.Sample.Get(@"Menu/menuhit");
|
2017-02-06 21:17:29 +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
|
|
|
|
|
2016-12-01 19:21:14 +08:00
|
|
|
|
ripple.ScaleTo(ripple.Scale * 1.1f, 500);
|
2016-10-07 16:07:23 +08:00
|
|
|
|
ripple.FadeOut(500);
|
|
|
|
|
ripple.Loop(300);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (!Interactive) return false;
|
|
|
|
|
|
2016-12-01 19:52:26 +08:00
|
|
|
|
logoBounceContainer.ScaleTo(0.9f, 1000, EasingTypes.Out);
|
2016-10-07 16:07:23 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
|
|
|
|
{
|
2016-12-01 19:52:26 +08:00
|
|
|
|
logoBounceContainer.ScaleTo(1f, 500, EasingTypes.OutElastic);
|
2016-10-07 16:07:23 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-16 21:23:03 +08:00
|
|
|
|
protected override bool OnDragStart(InputState state) => true;
|
|
|
|
|
|
2016-10-07 16:07:23 +08:00
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
|
{
|
|
|
|
|
if (!Interactive) return false;
|
|
|
|
|
|
2017-02-07 20:45:59 +08:00
|
|
|
|
sampleClick.Play();
|
|
|
|
|
|
2017-02-25 20:12:39 +08:00
|
|
|
|
flashLayer.ClearTransforms();
|
2017-01-27 12:50:22 +08:00
|
|
|
|
flashLayer.Alpha = 0.4f;
|
|
|
|
|
flashLayer.FadeOut(1500, EasingTypes.OutExpo);
|
|
|
|
|
|
2016-10-07 16:07:23 +08:00
|
|
|
|
Action?.Invoke();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
if (!Interactive) return false;
|
2016-12-01 19:52:26 +08:00
|
|
|
|
logoHoverContainer.ScaleTo(1.2f, 500, EasingTypes.OutElastic);
|
2016-10-07 16:07:23 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
2016-12-01 19:52:26 +08:00
|
|
|
|
logoHoverContainer.ScaleTo(1, 500, EasingTypes.OutElastic);
|
2016-10-07 16:07:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|