From a6c0fd29f2fe7b111eeee7747fcdb17c94142448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 6 Nov 2016 08:25:21 +0100 Subject: [PATCH 1/5] Make use of new timing system in Drawables and Transforms. --- osu-framework | 2 +- osu.Game.Tests/osu.Game.Tests.csproj | 6 ++++-- osu.Game/Beatmaps/Objects/DrawableHitObject.cs | 2 +- osu.Game/GameModes/Menu/Button.cs | 2 +- osu.Game/GameModes/Play/ComboCounter.cs | 6 +++--- osu.Game/GameModes/Play/ComboResultCounter.cs | 2 +- osu.Game/Graphics/UserInterface/RollingCounter.cs | 4 ++-- osu.Game/Graphics/UserInterface/ScoreCounter.cs | 2 +- osu.Game/Graphics/UserInterface/StarCounter.cs | 6 +++--- .../Graphics/UserInterface/Volume/VolumeControl.cs | 13 ++----------- .../UserInterface/Volume/VolumeControlReceptor.cs | 8 +------- .../Graphics/UserInterface/Volume/VolumeMeter.cs | 10 ++-------- 12 files changed, 22 insertions(+), 41 deletions(-) diff --git a/osu-framework b/osu-framework index ed33cc4899..beddb830a2 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit ed33cc48996e9b57093c4d057aa0560319495dee +Subproject commit beddb830a23b40fe970892e4c84339871e202034 diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index af6fa91661..d4a1976f17 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -75,7 +75,9 @@ osu.Game.Resources - + + + @@ -86,4 +88,4 @@ - + \ No newline at end of file diff --git a/osu.Game/Beatmaps/Objects/DrawableHitObject.cs b/osu.Game/Beatmaps/Objects/DrawableHitObject.cs index d6b459b0d1..eb5e5bc094 100644 --- a/osu.Game/Beatmaps/Objects/DrawableHitObject.cs +++ b/osu.Game/Beatmaps/Objects/DrawableHitObject.cs @@ -49,7 +49,7 @@ namespace osu.Game.Beatmaps.Objects { base.Update(); - if (Time >= HitObject.EndTime && !counted) + if (Time.Current >= HitObject.EndTime && !counted) { counted = true; if (state == ArmedState.Armed) diff --git a/osu.Game/GameModes/Menu/Button.cs b/osu.Game/GameModes/Menu/Button.cs index 779501a448..012c000f9c 100644 --- a/osu.Game/GameModes/Menu/Button.cs +++ b/osu.Game/GameModes/Menu/Button.cs @@ -112,7 +112,7 @@ namespace osu.Game.GameModes.Menu icon.ScaleTo(1, 500, EasingTypes.OutElasticHalf); double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time + offset; + double startTime = Time.Current + offset; icon.RotateTo(10, offset, EasingTypes.InOutSine); icon.ScaleTo(new Vector2(1, 0.9f), offset, EasingTypes.Out); diff --git a/osu.Game/GameModes/Play/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index 8d5f55f775..06c45d7386 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -238,8 +238,8 @@ namespace osu.Game.GameModes.Play return; } - transform.StartTime = Time; - transform.EndTime = Time + getProportionalDuration(currentValue, newValue); + transform.StartTime = Time.Current; + transform.EndTime = Time.Current + getProportionalDuration(currentValue, newValue); transform.StartValue = currentValue; transform.EndValue = newValue; transform.Easing = RollingEasing; @@ -253,7 +253,7 @@ namespace osu.Game.GameModes.Play { get { - double time = CurrentTime ?? 0; + double time = Time?.Current ?? 0; if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; diff --git a/osu.Game/GameModes/Play/ComboResultCounter.cs b/osu.Game/GameModes/Play/ComboResultCounter.cs index fd96906d18..9607c6df14 100644 --- a/osu.Game/GameModes/Play/ComboResultCounter.cs +++ b/osu.Game/GameModes/Play/ComboResultCounter.cs @@ -45,7 +45,7 @@ namespace osu.Game.GameModes.Play { get { - double time = CurrentTime ?? 0; + double time = Time?.Current ?? 0; if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 80f1b345b6..13737ded34 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -225,8 +225,8 @@ namespace osu.Game.Graphics.UserInterface ? GetProportionalDuration(currentValue, newValue) : RollingDuration; - transform.StartTime = Time; - transform.EndTime = Time + rollingTotalDuration; + transform.StartTime = Time.Current; + transform.EndTime = Time.Current + 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 48f4da1fcf..56be64b92e 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -60,7 +60,7 @@ namespace osu.Game.Graphics.UserInterface { get { - double time = CurrentTime ?? 0; + double time = Time?.Current ?? 0; if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index cff8fc65fe..e56e699be9 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -50,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface { get { - double elapsedTime = Time - transformStartTime; + double elapsedTime = Time.Current - transformStartTime; double expectedElapsedTime = Math.Abs(prevCount - count) * animationDelay; if (elapsedTime >= expectedElapsedTime) return count; @@ -149,7 +149,7 @@ namespace osu.Game.Graphics.UserInterface public void StopAnimation() { prevCount = count; - transformStartTime = Time; + transformStartTime = Time.Current; for (int i = 0; i < MaxStars; i++) transformStarQuick(i, count); @@ -188,7 +188,7 @@ namespace osu.Game.Graphics.UserInterface transformStar(i, newValue); stars[i].DelayReset(); } - transformStartTime = Time; + transformStartTime = Time.Current; } } } diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 4d86483262..0acd330b0e 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -67,21 +67,12 @@ namespace osu.Game.Graphics.UserInterface.Volume base.Dispose(isDisposing); } - protected override bool OnWheelDown(InputState state) + protected override bool OnWheel(InputState state) { if (!IsVisible) return false; - volumeMeterMaster.TriggerWheelDown(state); - return true; - } - - protected override bool OnWheelUp(InputState state) - { - if (!IsVisible) - return false; - - volumeMeterMaster.TriggerWheelUp(state); + volumeMeterMaster.TriggerWheel(state); return true; } diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs index 1601c2a883..1c98aaa61d 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControlReceptor.cs @@ -14,13 +14,7 @@ namespace osu.Game.Graphics.UserInterface.Volume { public Action ActivateRequested; - protected override bool OnWheelDown(InputState state) - { - ActivateRequested?.Invoke(); - return true; - } - - protected override bool OnWheelUp(InputState state) + protected override bool OnWheel(InputState state) { ActivateRequested?.Invoke(); return true; diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs index 64cb59175c..c72ddeede3 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs @@ -73,15 +73,9 @@ namespace osu.Game.Graphics.UserInterface.Volume } } - protected override bool OnWheelUp(InputState state) + protected override bool OnWheel(InputState state) { - Volume += 0.05f; - return true; - } - - protected override bool OnWheelDown(InputState state) - { - Volume -= 0.05f; + Volume += 0.05f * state.Mouse.WheelDiff; return true; } From 8894e5f73a407ef990434c7a95fc78abeda7d717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 6 Nov 2016 08:54:36 +0100 Subject: [PATCH 2/5] Fade the options overlay to prevent unnecessary updates to its content. --- osu-framework | 2 +- osu.Game/Overlays/OptionsOverlay.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index beddb830a2..4c8683bcfc 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit beddb830a23b40fe970892e4c84339871e202034 +Subproject commit 4c8683bcfc024d7c341f3e7bb20661d241f50d0c diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index cdf7628953..3774b71254 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -101,11 +101,13 @@ namespace osu.Game.Overlays protected override void PopIn() { MoveToX(0, 300, EasingTypes.Out); + FadeTo(1, 300); } protected override void PopOut() { MoveToX(-width, 300, EasingTypes.Out); + FadeTo(0, 300); } } } From 5f2bf165a2be0d29dbe58951337af03930a16b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 6 Nov 2016 10:06:09 +0100 Subject: [PATCH 3/5] Remove now obsolete clock usages. --- osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs | 4 ++-- osu.Game/GameModes/Play/ComboCounter.cs | 3 --- osu.Game/Graphics/UserInterface/RollingCounter.cs | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs index 2b52657f1e..d00803e42b 100644 --- a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs +++ b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs @@ -265,7 +265,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable base.Update(); foreach (Framework.Graphics.Drawable d in Children) - d.Position -= new Vector2(0, (float)(d.Scale.X * (Clock.ElapsedFrameTime / 20))); + d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 20))); } } } @@ -342,7 +342,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable base.Update(); foreach (Framework.Graphics.Drawable d in Children) - d.Position -= new Vector2(0, (float)(d.Scale.X * (Clock.ElapsedFrameTime / 20))); + d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 20))); } } } diff --git a/osu.Game/GameModes/Play/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index 06c45d7386..a9db04347d 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -229,9 +229,6 @@ namespace osu.Game.GameModes.Play { Flush(false, typeof(TransformComboRoll)); - if (Clock == null) - return; - if (RollingDuration < 1) { DisplayedCount = Count; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 13737ded34..af77093b34 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -211,9 +211,6 @@ namespace osu.Game.Graphics.UserInterface Flush(false, type); - if (Clock == null) - return; - if (RollingDuration < 1) { DisplayedCount = Count; From 103176826f6ae80284e78b88e07826d1d565d92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 6 Nov 2016 11:13:52 +0100 Subject: [PATCH 4/5] Ensure transformations are never used prior to being added to the Drawable tree. --- osu-framework | 2 +- osu.Game/Beatmaps/Objects/DrawableHitObject.cs | 2 +- osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs | 2 +- osu.Game/GameModes/Play/ComboCounter.cs | 7 ++++++- osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs | 4 ++-- osu.Game/Graphics/UserInterface/RollingCounter.cs | 9 +++++++-- osu.Game/Graphics/UserInterface/StarCounter.cs | 8 +++++--- osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs | 4 ++-- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/osu-framework b/osu-framework index 4c8683bcfc..cbcf8a77af 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4c8683bcfc024d7c341f3e7bb20661d241f50d0c +Subproject commit cbcf8a77afb8fb0fa759c5ee2a798bface6b80b4 diff --git a/osu.Game/Beatmaps/Objects/DrawableHitObject.cs b/osu.Game/Beatmaps/Objects/DrawableHitObject.cs index 037cd92fb6..380e527de4 100644 --- a/osu.Game/Beatmaps/Objects/DrawableHitObject.cs +++ b/osu.Game/Beatmaps/Objects/DrawableHitObject.cs @@ -52,7 +52,7 @@ namespace osu.Game.Beatmaps.Objects if (AllowHit?.Invoke(this) == false) return false; - HitTime = Time; + HitTime = Time.Current; State = ArmedState.Armed; return true; diff --git a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs index 890b576d83..cf150e7e04 100644 --- a/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs +++ b/osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs @@ -96,7 +96,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable approachCircle.Transforms.Add(new TransformScale { StartTime = t - 1000, EndTime = t, StartValue = new Vector2(2f), EndValue = new Vector2(0.6f) }); //set transform delay to t==hitTime - Delay(t - Time, true); + Delay(t - Time.Current, true); approachCircle.FadeOut(); glow.FadeOut(400); diff --git a/osu.Game/GameModes/Play/ComboCounter.cs b/osu.Game/GameModes/Play/ComboCounter.cs index a9db04347d..ec0d1b45d5 100644 --- a/osu.Game/GameModes/Play/ComboCounter.cs +++ b/osu.Game/GameModes/Play/ComboCounter.cs @@ -205,8 +205,13 @@ namespace osu.Game.GameModes.Play private void updateCount(ulong value, bool rolling = false) { - ulong prevCount = count; count = value; + + if (!IsLoaded) + return; + + ulong prevCount = count; + if (!rolling) { Flush(false, typeof(TransformComboRoll)); diff --git a/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs b/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs index 8d1c6d5b57..0a087225fc 100644 --- a/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs +++ b/osu.Game/GameModes/Play/Mania/ManiaComboCounter.cs @@ -31,9 +31,9 @@ namespace osu.Game.GameModes.Play.Mania protected override float PopOutInitialAlpha => 1.0f; protected override double PopOutDuration => 300; - protected override void Load(BaseGame game) + protected override void LoadComplete() { - base.Load(game); + base.LoadComplete(); PopOutSpriteText.Anchor = Anchor.BottomCentre; PopOutSpriteText.Origin = Anchor.Centre; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index af77093b34..87403c232a 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -123,8 +123,6 @@ namespace osu.Game.Graphics.UserInterface { base.Load(game); - Flush(false, TransformType); - DisplayedCount = Count; DisplayedCountSpriteText.Text = FormatCount(count); @@ -132,6 +130,13 @@ namespace osu.Game.Graphics.UserInterface DisplayedCountSpriteText.Origin = this.Origin; } + protected override void LoadComplete() + { + base.LoadComplete(); + + Flush(false, TransformType); + } + /// /// Sets count value, bypassing rollover animation. /// diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index e56e699be9..47385861ab 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -70,14 +70,16 @@ namespace osu.Game.Graphics.UserInterface { return count; } + set { - prevCount = VisibleValue; - count = value; if (IsLoaded) { - transformCount(prevCount, count); + prevCount = VisibleValue; + transformCount(prevCount, value); } + + count = value; } } diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs index c72ddeede3..bcd1d9f8db 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeMeter.cs @@ -57,9 +57,9 @@ namespace osu.Game.Graphics.UserInterface.Volume }; } - protected override void Load(BaseGame game) + protected override void LoadComplete() { - base.Load(game); + base.LoadComplete(); updateFill(); } From 108d32b6d86e509e8fa147076eb63eb30cbb368f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sun, 6 Nov 2016 18:50:21 +0100 Subject: [PATCH 5/5] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index cbcf8a77af..4631a91f00 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cbcf8a77afb8fb0fa759c5ee2a798bface6b80b4 +Subproject commit 4631a91f00e8be3eddf13736b5ecd8d25d6d3918