mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 12:23:21 +08:00
Nest delays and implement IStateful, allowing for flushing on early dismiss
Note that this will break rotation loops until https://github.com/ppy/osu-framework/issues/900 is addressed.
This commit is contained in:
parent
ab5341eadc
commit
20052b060c
@ -16,7 +16,6 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Graphics.Transforms;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -188,10 +187,9 @@ namespace osu.Game.Overlays
|
|||||||
if (state.Keyboard.Keys.Contains(Key.Escape)) dismiss();
|
if (state.Keyboard.Keys.Contains(Key.Escape)) dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
private const double duration1 = 400;
|
private const double initial_duration = 400;
|
||||||
private const double duration2 = 900;
|
private const double step_duration = 900;
|
||||||
private const double duration3 = 900;
|
|
||||||
private const double duration4 = 1000;
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
base.PopIn();
|
base.PopIn();
|
||||||
@ -200,56 +198,63 @@ namespace osu.Game.Overlays
|
|||||||
background.FlashColour(Color4.White.Opacity(0.25f), 400);
|
background.FlashColour(Color4.White.Opacity(0.25f), 400);
|
||||||
|
|
||||||
getSample.Play();
|
getSample.Play();
|
||||||
Delay(200, true);
|
|
||||||
|
|
||||||
var innerRotate = new TransformRotation
|
using (innerSpin.BeginLoopedSequence())
|
||||||
|
innerSpin.RotateTo(360, 20000);
|
||||||
|
|
||||||
|
using (outerSpin.BeginLoopedSequence())
|
||||||
|
outerSpin.RotateTo(360, 40000);
|
||||||
|
|
||||||
|
using (BeginDelayedSequence(200, true))
|
||||||
{
|
{
|
||||||
EndValue = 359,
|
disc.FadeIn(initial_duration);
|
||||||
StartTime = Clock.TimeInfo.Current,
|
particleContainer.FadeIn(initial_duration);
|
||||||
EndTime = Clock.TimeInfo.Current + 20000,
|
outerSpin.FadeTo(0.1f, initial_duration * 2);
|
||||||
};
|
disc.ScaleTo(1f, initial_duration * 2, EasingTypes.OutElastic);
|
||||||
|
|
||||||
innerRotate.Loop(0);
|
using (BeginDelayedSequence(initial_duration + 200, true))
|
||||||
innerSpin.Transforms.Add(innerRotate);
|
{
|
||||||
|
backgroundStrip.FadeIn(step_duration);
|
||||||
|
leftStrip.ResizeWidthTo(1f, step_duration, EasingTypes.OutQuint);
|
||||||
|
rightStrip.ResizeWidthTo(1f, step_duration, EasingTypes.OutQuint);
|
||||||
|
Schedule(() =>
|
||||||
|
{
|
||||||
|
if (drawableMedal.State != DisplayState.Full) drawableMedal.State = DisplayState.Icon;
|
||||||
|
});
|
||||||
|
|
||||||
var outerRotate = new TransformRotation
|
using (BeginDelayedSequence(step_duration, true))
|
||||||
{
|
{
|
||||||
EndValue = 359,
|
Schedule(() =>
|
||||||
StartTime = Clock.TimeInfo.Current,
|
{
|
||||||
EndTime = Clock.TimeInfo.Current + 40000,
|
if (drawableMedal.State != DisplayState.Full) drawableMedal.State = DisplayState.MedalUnlocked;
|
||||||
};
|
});
|
||||||
|
|
||||||
outerRotate.Loop(0);
|
using (BeginDelayedSequence(step_duration, true))
|
||||||
outerSpin.Transforms.Add(outerRotate);
|
Schedule(() =>
|
||||||
|
{
|
||||||
disc.FadeIn(duration1);
|
if (drawableMedal.State != DisplayState.Full) drawableMedal.State = DisplayState.Full;
|
||||||
particleContainer.FadeIn(duration1);
|
});
|
||||||
outerSpin.FadeTo(0.1f, duration1 * 2);
|
}
|
||||||
disc.ScaleTo(1f, duration1 * 2, EasingTypes.OutElastic);
|
}
|
||||||
|
}
|
||||||
Delay(duration1 + 200, true);
|
|
||||||
backgroundStrip.FadeIn(duration2);
|
|
||||||
leftStrip.ResizeWidthTo(1f, duration2, EasingTypes.OutQuint);
|
|
||||||
rightStrip.ResizeWidthTo(1f, duration2, EasingTypes.OutQuint);
|
|
||||||
drawableMedal.ChangeState(DrawableMedal.DisplayState.Icon, duration2);
|
|
||||||
|
|
||||||
Delay(duration2, true);
|
|
||||||
drawableMedal.ChangeState(DrawableMedal.DisplayState.MedalUnlocked, duration3);
|
|
||||||
|
|
||||||
Delay(duration3, true);
|
|
||||||
drawableMedal.ChangeState(DrawableMedal.DisplayState.Full, duration4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
{
|
{
|
||||||
base.PopOut();
|
base.PopOut();
|
||||||
|
|
||||||
FadeOut(200);
|
FadeOut(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dismiss()
|
private void dismiss()
|
||||||
{
|
{
|
||||||
if (drawableMedal.Transforms.Count != 0) return;
|
if (drawableMedal.State != DisplayState.Full)
|
||||||
|
{
|
||||||
|
// if we haven't yet, play out the animation fully
|
||||||
|
drawableMedal.State = DisplayState.Full;
|
||||||
|
Flush(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Hide();
|
Hide();
|
||||||
Expire();
|
Expire();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -13,7 +14,7 @@ using osu.Game.Users;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.MedalSplash
|
namespace osu.Game.Overlays.MedalSplash
|
||||||
{
|
{
|
||||||
public class DrawableMedal : Container
|
public class DrawableMedal : Container, IStateful<DisplayState>
|
||||||
{
|
{
|
||||||
private const float scale_when_unlocked = 0.76f;
|
private const float scale_when_unlocked = 0.76f;
|
||||||
private const float scale_when_full = 0.6f;
|
private const float scale_when_full = 0.6f;
|
||||||
@ -24,7 +25,7 @@ namespace osu.Game.Overlays.MedalSplash
|
|||||||
private readonly OsuSpriteText unlocked, name;
|
private readonly OsuSpriteText unlocked, name;
|
||||||
private readonly TextFlowContainer description;
|
private readonly TextFlowContainer description;
|
||||||
private readonly FillFlowContainer infoFlow;
|
private readonly FillFlowContainer infoFlow;
|
||||||
|
private DisplayState state;
|
||||||
public DrawableMedal(Medal medal)
|
public DrawableMedal(Medal medal)
|
||||||
{
|
{
|
||||||
this.medal = medal;
|
this.medal = medal;
|
||||||
@ -116,34 +117,67 @@ namespace osu.Game.Overlays.MedalSplash
|
|||||||
infoFlow.Position = new Vector2(0f, unlocked.Position.Y + 90);
|
infoFlow.Position = new Vector2(0f, unlocked.Position.Y + 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeState(DisplayState newState, double duration)
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
switch (newState)
|
base.LoadComplete();
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayState State
|
||||||
|
{
|
||||||
|
get { return state; }
|
||||||
|
set
|
||||||
{
|
{
|
||||||
|
if (state == value) return;
|
||||||
|
|
||||||
|
state = value;
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState()
|
||||||
|
{
|
||||||
|
if (!IsLoaded) return;
|
||||||
|
|
||||||
|
const double duration = 900;
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case DisplayState.None:
|
||||||
|
medalContainer.ScaleTo(0);
|
||||||
|
break;
|
||||||
case DisplayState.Icon:
|
case DisplayState.Icon:
|
||||||
medalContainer.Scale = Vector2.Zero;
|
|
||||||
medalContainer.ScaleTo(1, duration, EasingTypes.OutElastic);
|
medalContainer.ScaleTo(1, duration, EasingTypes.OutElastic);
|
||||||
medalContainer.FadeInFromZero(duration);
|
medalContainer.FadeIn(duration);
|
||||||
break;
|
break;
|
||||||
case DisplayState.MedalUnlocked:
|
case DisplayState.MedalUnlocked:
|
||||||
|
medalContainer.ScaleTo(1);
|
||||||
|
medalContainer.Show();
|
||||||
|
|
||||||
ScaleTo(scale_when_unlocked, duration, EasingTypes.OutExpo);
|
ScaleTo(scale_when_unlocked, duration, EasingTypes.OutExpo);
|
||||||
MoveToY(MedalOverlay.DISC_SIZE / 2 - 30, duration, EasingTypes.OutExpo);
|
MoveToY(MedalOverlay.DISC_SIZE / 2 - 30, duration, EasingTypes.OutExpo);
|
||||||
unlocked.FadeInFromZero(duration);
|
unlocked.FadeInFromZero(duration);
|
||||||
break;
|
break;
|
||||||
case DisplayState.Full:
|
case DisplayState.Full:
|
||||||
|
medalContainer.ScaleTo(1);
|
||||||
|
medalContainer.Show();
|
||||||
|
|
||||||
ScaleTo(scale_when_full, duration, EasingTypes.OutExpo);
|
ScaleTo(scale_when_full, duration, EasingTypes.OutExpo);
|
||||||
MoveToY(MedalOverlay.DISC_SIZE / 2 - 60, duration, EasingTypes.OutExpo);
|
MoveToY(MedalOverlay.DISC_SIZE / 2 - 60, duration, EasingTypes.OutExpo);
|
||||||
name.FadeInFromZero(duration);
|
name.FadeInFromZero(duration + 100);
|
||||||
description.FadeInFromZero(duration * 2);
|
description.FadeInFromZero(duration * 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public enum DisplayState
|
|
||||||
{
|
|
||||||
Icon,
|
|
||||||
MedalUnlocked,
|
|
||||||
Full,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum DisplayState
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Icon,
|
||||||
|
MedalUnlocked,
|
||||||
|
Full,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user