From 0e2dc9388af40be45090322c8f36a87a482a12b6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 10 Jul 2017 07:01:25 +0900 Subject: [PATCH] More changes in-line with framework changes. --- .../Tests/TestCaseHitObjects.cs | 6 +-- .../Objects/Drawable/DrawableFruit.cs | 7 +-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 13 ++--- .../Objects/Drawables/DrawableHitCircle.cs | 50 +++++++++++-------- .../Objects/Drawables/DrawableOsuHitObject.cs | 11 ++-- osu.Game/Graphics/IHasAccentColour.cs | 2 +- .../Graphics/Transforms/TransformAccent.cs | 12 ++--- .../UserInterface/PercentageCounter.cs | 9 ++-- .../Graphics/UserInterface/RollingCounter.cs | 1 - .../Graphics/UserInterface/ScoreCounter.cs | 9 ++-- .../UserInterface/SimpleComboCounter.cs | 9 ++-- osu.Game/Overlays/DragBar.cs | 9 ++-- osu.Game/Screens/Play/HUD/ComboCounter.cs | 10 ++-- .../Screens/Play/HUD/ComboResultCounter.cs | 9 ++-- .../Tournament/ScrollingTeamContainer.cs | 9 ++-- 15 files changed, 68 insertions(+), 98 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 33841cae90..62b5ba5a68 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -34,9 +34,9 @@ namespace osu.Desktop.VisualTests.Tests AddStep(@"circles", () => loadHitobjects(HitObjectType.Circle)); AddStep(@"slider", () => loadHitobjects(HitObjectType.Slider)); - AddStep(@"spinner", () => loadHitobjects(HitObjectType.Spinner)); + //AddStep(@"spinner", () => loadHitobjects(HitObjectType.Spinner)); - AddToggleStep(@"auto", state => { auto = state; loadHitobjects(mode); }); + //AddToggleStep(@"auto", state => { auto = state; loadHitobjects(mode); }); BasicSliderBar sliderBar; Add(new Container @@ -87,7 +87,7 @@ namespace osu.Desktop.VisualTests.Tests switch (mode) { case HitObjectType.Circle: - const int count = 10; + const int count = 1; for (int i = 0; i < count; i++) { diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs index ae6585bdb2..432d0e6256 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.Transforms; using OpenTK; namespace osu.Game.Rulesets.Catch.Objects.Drawable @@ -29,10 +28,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { Texture = textures.Get(@"Menu/logo"); - const double duration = 0; - - Transforms.Add(new TransformPosition { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) }); - Transforms.Add(new TransformAlpha { StartTime = h.StartTime + duration + 200, EndTime = h.StartTime + duration + 400, StartValue = 1, EndValue = 0 }); + //Transforms.Add(new TransformPosition { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) }); + //Transforms.Add(new TransformAlpha { StartTime = h.StartTime + duration + 200, EndTime = h.StartTime + duration + 400, StartValue = 1, EndValue = 0 }); Expire(true); } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index a0c683143c..af875a2e52 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Mania.UI private void transformVisibleTimeRangeTo(double newTimeRange, double duration = 0, EasingTypes easing = EasingTypes.None) { - TransformTo(() => visibleTimeRange.Value, newTimeRange, duration, easing, new TransformTimeSpan()); + TransformTo(newTimeRange, duration, easing, new TransformTimeSpan()); } protected override void Update() @@ -247,7 +247,7 @@ namespace osu.Game.Rulesets.Mania.UI private class TransformTimeSpan : Transform { - public override double CurrentValue + public virtual double CurrentValue { get { @@ -259,13 +259,8 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void Apply(Drawable d) - { - base.Apply(d); - - var p = (ManiaPlayfield)d; - p.visibleTimeRange.Value = (float)CurrentValue; - } + public override void Apply(Drawable d) => ((ManiaPlayfield)d).visibleTimeRange.Value = (float)CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((ManiaPlayfield)d).visibleTimeRange.Value; } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 09bfffeefe..75b2dc0a32 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -89,11 +89,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { base.UpdateInitialState(); - //sane defaults - ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1; - ApproachCircle.Alpha = 0; - ApproachCircle.Scale = new Vector2(4); - explode.Alpha = 0; + // sane defaults + ring.Show(); + circle.Show(); + number.Show(); + glow.Show(); + + ApproachCircle.Hide(); + ApproachCircle.ScaleTo(new Vector2(4)); + explode.Hide(); } protected override void UpdatePreemptState() @@ -106,43 +110,45 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void UpdateCurrentState(ArmedState state) { - ApproachCircle.FadeOut(); + double duration = ((HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime) - HitObject.StartTime; - double endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; - double duration = endTime - HitObject.StartTime; - - glow.Delay(duration); - glow.FadeOut(400); + using (glow.BeginDelayedSequence(duration)) + glow.FadeOut(400); switch (state) { case ArmedState.Idle: - Delay(duration + TIME_PREEMPT); - FadeOut(TIME_FADEOUT); + using (BeginDelayedSequence(duration + TIME_PREEMPT)) + FadeOut(TIME_FADEOUT); Expire(true); break; case ArmedState.Miss: + ApproachCircle.FadeOut(50); FadeOut(TIME_FADEOUT / 5); Expire(); break; case ArmedState.Hit: + ApproachCircle.FadeOut(50); + const double flash_in = 40; flash.FadeTo(0.8f, flash_in); - flash.Delay(flash_in); - flash.FadeOut(100); + using (flash.BeginDelayedSequence(flash_in)) + flash.FadeOut(100); explode.FadeIn(flash_in); - Delay(flash_in, true); + using (BeginDelayedSequence(flash_in, true)) + { + //after the flash, we can hide some elements that were behind it + ring.FadeOut(); + circle.FadeOut(); + number.FadeOut(); - //after the flash, we can hide some elements that were behind it - ring.FadeOut(); - circle.FadeOut(); - number.FadeOut(); + FadeOut(800); + ScaleTo(Scale * 1.5f, 400, EasingTypes.OutQuad); + } - FadeOut(800); - ScaleTo(Scale * 1.5f, 400, EasingTypes.OutQuad); Expire(); break; } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index 57a9804330..2711ec1a62 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -17,6 +17,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables : base(hitObject) { AccentColour = HitObject.ComboColour; + Alpha = 0; } protected override OsuJudgement CreateJudgement() => new OsuJudgement { MaxScore = OsuScoreResult.Hit300 }; @@ -25,10 +26,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { Flush(); - UpdateInitialState(); - using (BeginAbsoluteSequence(HitObject.StartTime - TIME_PREEMPT, true)) { + UpdateInitialState(); + UpdatePreemptState(); using (BeginDelayedSequence(TIME_PREEMPT + Judgement.TimeOffset, true)) @@ -36,8 +37,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } } - protected virtual void UpdateCurrentState(ArmedState state) + protected virtual void UpdateInitialState() { + Hide(); } protected virtual void UpdatePreemptState() @@ -45,9 +47,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables FadeIn(TIME_FADEIN); } - protected virtual void UpdateInitialState() + protected virtual void UpdateCurrentState(ArmedState state) { - Alpha = 0; } } diff --git a/osu.Game/Graphics/IHasAccentColour.cs b/osu.Game/Graphics/IHasAccentColour.cs index 672c59a935..9eb66d8fac 100644 --- a/osu.Game/Graphics/IHasAccentColour.cs +++ b/osu.Game/Graphics/IHasAccentColour.cs @@ -30,7 +30,7 @@ namespace osu.Game.Graphics public static void FadeAccent(this T accentedDrawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None) where T : Transformable, IHasAccentColour { - accentedDrawable.TransformTo(() => accentedDrawable.AccentColour, newColour, duration, easing, new TransformAccent()); + accentedDrawable.TransformTo(newColour, duration, easing, new TransformAccent()); } } } diff --git a/osu.Game/Graphics/Transforms/TransformAccent.cs b/osu.Game/Graphics/Transforms/TransformAccent.cs index d49f969c20..53a452ad8a 100644 --- a/osu.Game/Graphics/Transforms/TransformAccent.cs +++ b/osu.Game/Graphics/Transforms/TransformAccent.cs @@ -13,7 +13,7 @@ namespace osu.Game.Graphics.Transforms /// /// Current value of the transformed colour in linear colour space. /// - public override Color4 CurrentValue + public virtual Color4 CurrentValue { get { @@ -25,13 +25,7 @@ namespace osu.Game.Graphics.Transforms } } - public override void Apply(Drawable d) - { - base.Apply(d); - - var accented = d as IHasAccentColour; - if (accented != null) - accented.AccentColour = CurrentValue; - } + public override void Apply(Drawable d) => ((IHasAccentColour)d).AccentColour = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((IHasAccentColour)d).AccentColour; } } diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 79cdc9effe..b51dd2287b 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -47,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface protected class TransformAccuracy : Transform { - public override double CurrentValue + public virtual double CurrentValue { get { @@ -59,11 +59,8 @@ namespace osu.Game.Graphics.UserInterface } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((PercentageCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((PercentageCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((PercentageCounter)d).DisplayedCount; } } } diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 4338dd23eb..db6e6ff44f 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -210,7 +210,6 @@ namespace osu.Game.Graphics.UserInterface transform.StartTime = TransformStartTime; transform.EndTime = TransformStartTime + rollingTotalDuration; - transform.StartValue = currentValue; transform.EndValue = newValue; transform.Easing = RollingEasing; diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index f98e84852a..6fe43e1fcc 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -58,7 +58,7 @@ namespace osu.Game.Graphics.UserInterface protected class TransformScore : Transform { - public override double CurrentValue + public virtual double CurrentValue { get { @@ -70,11 +70,8 @@ namespace osu.Game.Graphics.UserInterface } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((ScoreCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((ScoreCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((ScoreCounter)d).DisplayedCount; } } } diff --git a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs index bee1a71894..a512728cea 100644 --- a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs @@ -39,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface private class TransformCounterCount : Transform { - public override int CurrentValue + public virtual int CurrentValue { get { @@ -51,11 +51,8 @@ namespace osu.Game.Graphics.UserInterface } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((SimpleComboCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((SimpleComboCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((SimpleComboCounter)d).DisplayedCount; } } } \ No newline at end of file diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 07e0c76396..89bb81c70b 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -75,7 +75,7 @@ namespace osu.Game.Overlays private void updatePosition(float position, bool easing = true) { position = MathHelper.Clamp(position, 0, 1); - Fill.TransformTo(() => Fill.Width, position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek()); + Fill.TransformTo(position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek()); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -100,11 +100,8 @@ namespace osu.Game.Overlays private class TransformSeek : TransformFloat { - public override void Apply(Drawable d) - { - base.Apply(d); - d.Width = CurrentValue; - } + public override void Apply(Drawable d) => d.Width = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = d.Width; } } } diff --git a/osu.Game/Screens/Play/HUD/ComboCounter.cs b/osu.Game/Screens/Play/HUD/ComboCounter.cs index 3793181ecd..f527eaacaf 100644 --- a/osu.Game/Screens/Play/HUD/ComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboCounter.cs @@ -198,7 +198,6 @@ namespace osu.Game.Screens.Play.HUD transform.StartTime = Time.Current; transform.EndTime = Time.Current + getProportionalDuration(currentValue, newValue); - transform.StartValue = currentValue; transform.EndValue = newValue; transform.Easing = RollingEasing; @@ -207,7 +206,7 @@ namespace osu.Game.Screens.Play.HUD protected class TransformComboRoll : Transform { - public override int CurrentValue + public virtual int CurrentValue { get { @@ -219,11 +218,8 @@ namespace osu.Game.Screens.Play.HUD } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((ComboCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((ComboCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((ComboCounter)d).DisplayedCount; } protected abstract void OnDisplayedCountRolling(int currentValue, int newValue); diff --git a/osu.Game/Screens/Play/HUD/ComboResultCounter.cs b/osu.Game/Screens/Play/HUD/ComboResultCounter.cs index a4a20c1fd0..c280702390 100644 --- a/osu.Game/Screens/Play/HUD/ComboResultCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboResultCounter.cs @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Play.HUD protected class TransformComboResult : Transform { - public override ulong CurrentValue + public virtual ulong CurrentValue { get { @@ -48,11 +48,8 @@ namespace osu.Game.Screens.Play.HUD } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((ComboResultCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((ComboResultCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((ComboResultCounter)d).DisplayedCount; } } } diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index a7019f1e35..30f109e598 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -297,7 +297,7 @@ namespace osu.Game.Screens.Tournament } } - private void speedTo(float value, double duration = 0, EasingTypes easing = EasingTypes.None) => TransformTo(() => speed, value, duration, easing, new TransformScrollSpeed()); + private void speedTo(float value, double duration = 0, EasingTypes easing = EasingTypes.None) => TransformTo(value, duration, easing, new TransformScrollSpeed()); private enum ScrollState { @@ -310,11 +310,8 @@ namespace osu.Game.Screens.Tournament public class TransformScrollSpeed : TransformFloat { - public override void Apply(Drawable d) - { - base.Apply(d); - ((ScrollingTeamContainer)d).speed = CurrentValue; - } + public override void Apply(Drawable d) => ((ScrollingTeamContainer)d).speed = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((ScrollingTeamContainer)d).speed; } public class ScrollingTeam : Container