Make the osu! logo shared game-wide

There should only ever be one osu! logo. It is now passed around between screens in a superfluous manner.
This commit is contained in:
Dean Herbert
2017-11-01 20:54:58 +09:00
parent 7fa3ac8cf2
commit b8b05fe8d2
9 changed files with 289 additions and 109 deletions

View File

@ -29,6 +29,8 @@ namespace osu.Game.Screens.Menu
{
public readonly Color4 OsuPink = OsuColour.FromHex(@"e967a1");
private const double transition_length = 300;
private readonly Sprite logo;
private readonly CircularContainer logoContainer;
private readonly Container logoBounceContainer;
@ -54,7 +56,7 @@ namespace osu.Game.Screens.Menu
public bool Triangles
{
set { colourAndTriangles.Alpha = value ? 1 : 0; }
set { colourAndTriangles.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); }
}
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => logoContainer.ReceiveMouseInputAt(screenSpacePos);
@ -62,10 +64,9 @@ namespace osu.Game.Screens.Menu
public bool Ripple
{
get { return rippleContainer.Alpha > 0; }
set { rippleContainer.Alpha = value ? 1 : 0; }
set { rippleContainer.FadeTo(value ? 1 : 0, transition_length, Easing.OutQuint); }
}
public bool Interactive = true;
private readonly Box flashLayer;
private readonly Container impactContainer;
@ -76,11 +77,12 @@ namespace osu.Game.Screens.Menu
public OsuLogo()
{
AlwaysPresent = true;
EarlyActivationMilliseconds = early_activation;
Size = new Vector2(default_size);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
@ -222,6 +224,27 @@ namespace osu.Game.Screens.Menu
ripple.Texture = textures.Get(@"Menu/logo");
}
private double? reservationEndTime;
private Action<OsuLogo> reservationCallback;
private bool canFulfillReservation => !reservationEndTime.HasValue || reservationEndTime <= Time.Current;
public void RequestUsage(Action<OsuLogo> callback)
{
reservationCallback = callback;
}
private void fulfillReservation()
{
reservationCallback(this);
reservationCallback = null;
}
public void ReserveFor(float duration)
{
reservationEndTime = Time.Current + duration;
}
private int lastBeatIndex;
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
@ -288,11 +311,16 @@ namespace osu.Game.Screens.Menu
{
triangles.Velocity = paused_velocity;
}
if (reservationCallback != null && canFulfillReservation)
fulfillReservation();
}
private bool interactive => Action != null && Alpha > 0.2f;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
if (!Interactive) return false;
if (!interactive) return false;
logoBounceContainer.ScaleTo(0.9f, 1000, Easing.Out);
return true;
@ -306,7 +334,7 @@ namespace osu.Game.Screens.Menu
protected override bool OnClick(InputState state)
{
if (!Interactive) return false;
if (!interactive) return false;
sampleClick.Play();
@ -320,7 +348,7 @@ namespace osu.Game.Screens.Menu
protected override bool OnHover(InputState state)
{
if (!Interactive) return false;
if (!interactive) return false;
logoHoverContainer.ScaleTo(1.1f, 500, Easing.OutElastic);
return true;