From 30292f44da289b8112ea757e87acfbd0bfee460a Mon Sep 17 00:00:00 2001 From: HoLLy Date: Thu, 31 Jan 2019 17:57:59 +0100 Subject: [PATCH 01/14] Fix Catch diffcalc being off --- .../Difficulty/CatchDifficultyCalculator.cs | 2 ++ osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index a0b813478d..a54e8a06db 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -41,6 +41,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty); float halfCatchWidth = catcher.CatchWidth * 0.5f; + halfCatchWidth *= 0.8f; + var difficultyHitObjects = new List(); foreach (var hitObject in beatmap.HitObjects) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index d79f106310..7de06223d3 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Catch.UI { public class CatcherArea : Container { - public const float CATCHER_SIZE = 100; + public const float CATCHER_SIZE = 106.75f; protected internal readonly Catcher MovableCatcher; @@ -447,6 +447,7 @@ namespace osu.Game.Rulesets.Catch.UI Size = new Vector2(CATCHER_SIZE); // Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling. + // OriginPosition = new Vector2(-0.02f, 0.06f) * CATCHER_SIZE; OriginPosition = new Vector2(-0.02f, 0.06f) * CATCHER_SIZE; } From be6b5419c4aec827ea5aa9023ae8e1a8acab6eeb Mon Sep 17 00:00:00 2001 From: HoLLy Date: Thu, 31 Jan 2019 18:10:44 +0100 Subject: [PATCH 02/14] Remove uncommented line Didn't mean to push this --- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 7de06223d3..438bfaef55 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -447,7 +447,6 @@ namespace osu.Game.Rulesets.Catch.UI Size = new Vector2(CATCHER_SIZE); // Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling. - // OriginPosition = new Vector2(-0.02f, 0.06f) * CATCHER_SIZE; OriginPosition = new Vector2(-0.02f, 0.06f) * CATCHER_SIZE; } From f6318d36706e0ea69a7d97b106bdc7246ba7c3d3 Mon Sep 17 00:00:00 2001 From: HoLLy Date: Fri, 1 Feb 2019 13:06:36 +0100 Subject: [PATCH 03/14] Add comment explaining *= 0.8f --- osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index a54e8a06db..265fbbd55c 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -41,6 +41,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty); float halfCatchWidth = catcher.CatchWidth * 0.5f; + // We're only using 80% of the catcher's width to simulate imperfect gameplay. halfCatchWidth *= 0.8f; var difficultyHitObjects = new List(); From f8033a3b359dda92342e7d58405dc50293935cc3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 19 Feb 2019 12:16:44 +0900 Subject: [PATCH 04/14] Give TestWorkingBeatmap a reference clock --- .../TestCaseTaikoPlayfield.cs | 2 +- .../Visual/TestCaseEditorCompose.cs | 2 +- .../Visual/TestCaseEditorSeekSnapping.cs | 2 +- .../Visual/TestCaseEditorSummaryTimeline.cs | 2 +- .../Visual/TestCasePlaybackControl.cs | 2 +- osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs | 87 +++++++++++++++++-- osu.Game/Tests/Visual/EditorTestCase.cs | 2 +- osu.Game/Tests/Visual/TestCasePlayer.cs | 2 +- 8 files changed, 89 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs index 2c02649102..00e1b649d9 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TestCaseTaikoPlayfield.cs @@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Taiko.Tests Ruleset = new TaikoRuleset().RulesetInfo }, ControlPointInfo = controlPointInfo - }); + }, Clock); Add(playfieldContainer = new Container { diff --git a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs index 66e13545d9..a52454d684 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorCompose.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorCompose.cs @@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, Clock); Child = new ComposeScreen(); } } diff --git a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs index 6cb9a1abfd..244f3b9d3d 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs @@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual } }; - Beatmap.Value = new TestWorkingBeatmap(testBeatmap); + Beatmap.Value = new TestWorkingBeatmap(testBeatmap, Clock); Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock }; } diff --git a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs index b952582ef2..219b0d7b47 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, Clock); Add(new SummaryTimeline { diff --git a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs index 15b96d394a..60fd2fa79b 100644 --- a/osu.Game.Tests/Visual/TestCasePlaybackControl.cs +++ b/osu.Game.Tests/Visual/TestCasePlaybackControl.cs @@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual Size = new Vector2(200,100) }; - Beatmap.Value = new TestWorkingBeatmap(new Beatmap()); + Beatmap.Value = new TestWorkingBeatmap(new Beatmap(), Clock); Child = playback; } diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index bfbfed082a..9a6d50ab11 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -1,29 +1,106 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Audio.Track; using osu.Framework.Graphics.Textures; +using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Rulesets; +using osuTK; namespace osu.Game.Tests.Beatmaps { public class TestWorkingBeatmap : WorkingBeatmap { - public TestWorkingBeatmap(RulesetInfo ruleset) - : this(new TestBeatmap(ruleset)) + private readonly TrackVirtualManual track; + private readonly IBeatmap beatmap; + + /// + /// Create an instance which creates a for the provided ruleset when requested. + /// + /// The target ruleset. + /// An optional clock which should be used instead of a stopwatch for virtual time progression. + public TestWorkingBeatmap(RulesetInfo ruleset, IFrameBasedClock referenceClock) + : this(new TestBeatmap(ruleset), referenceClock) { } - public TestWorkingBeatmap(IBeatmap beatmap) + /// + /// Create an instance which provides the when requested. + /// + /// The beatmap + /// An optional clock which should be used instead of a stopwatch for virtual time progression. + public TestWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock referenceClock = null) : base(beatmap.BeatmapInfo) { this.beatmap = beatmap; + + if (referenceClock != null) + track = new TrackVirtualManual(referenceClock); } - private readonly IBeatmap beatmap; protected override IBeatmap GetBeatmap() => beatmap; protected override Texture GetBackground() => null; - protected override Track GetTrack() => null; + protected override Track GetTrack() => track; + } + + /// + /// A virtual track which tracks a reference clock. + /// + public class TrackVirtualManual : Track + { + private readonly IFrameBasedClock referenceClock; + private readonly ManualClock clock; + + private bool running; + private double offset; + + public TrackVirtualManual(IFrameBasedClock referenceClock) + { + this.referenceClock = referenceClock; + Length = double.PositiveInfinity; + clock = new ManualClock(); + } + + public override bool Seek(double seek) + { + offset = MathHelper.Clamp(seek, 0, Length) - referenceClock.CurrentTime; + return true; + } + + public override void Start() + { + running = true; + Seek(0); + } + + public override void Reset() + { + Seek(0); + base.Reset(); + } + + public override void Stop() + { + running = false; + } + + public override bool IsRunning => running; + + public override double CurrentTime => running ? clock.CurrentTime : 0; + + protected override void UpdateState() + { + base.UpdateState(); + + clock.CurrentTime = Math.Min(referenceClock.CurrentTime + offset, Length); + + if (CurrentTime >= Length) + { + Stop(); + RaiseCompleted(); + } + } } } diff --git a/osu.Game/Tests/Visual/EditorTestCase.cs b/osu.Game/Tests/Visual/EditorTestCase.cs index bc5f937480..b455ed2f05 100644 --- a/osu.Game/Tests/Visual/EditorTestCase.cs +++ b/osu.Game/Tests/Visual/EditorTestCase.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo); + Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo, Clock); LoadComponentAsync(new Editor(), LoadScreen); } diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index a926a06295..60b630513a 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual private Player loadPlayerFor(Ruleset r) { var beatmap = CreateBeatmap(r); - var working = new TestWorkingBeatmap(beatmap); + var working = new TestWorkingBeatmap(beatmap, Clock); workingWeakReferences.Add(working); From 62fe5ad48117a278c658d55c28ee2997eb55271c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 19 Feb 2019 12:35:52 +0900 Subject: [PATCH 05/14] Nest class --- osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index 9a6d50ab11..aa4b3f3c03 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -43,63 +43,63 @@ namespace osu.Game.Tests.Beatmaps protected override IBeatmap GetBeatmap() => beatmap; protected override Texture GetBackground() => null; protected override Track GetTrack() => track; - } - /// - /// A virtual track which tracks a reference clock. - /// - public class TrackVirtualManual : Track - { - private readonly IFrameBasedClock referenceClock; - private readonly ManualClock clock; - - private bool running; - private double offset; - - public TrackVirtualManual(IFrameBasedClock referenceClock) + /// + /// A virtual track which tracks a reference clock. + /// + public class TrackVirtualManual : Track { - this.referenceClock = referenceClock; - Length = double.PositiveInfinity; - clock = new ManualClock(); - } + private readonly IFrameBasedClock referenceClock; + private readonly ManualClock clock; - public override bool Seek(double seek) - { - offset = MathHelper.Clamp(seek, 0, Length) - referenceClock.CurrentTime; - return true; - } + private bool running; + private double offset; - public override void Start() - { - running = true; - Seek(0); - } - - public override void Reset() - { - Seek(0); - base.Reset(); - } - - public override void Stop() - { - running = false; - } - - public override bool IsRunning => running; - - public override double CurrentTime => running ? clock.CurrentTime : 0; - - protected override void UpdateState() - { - base.UpdateState(); - - clock.CurrentTime = Math.Min(referenceClock.CurrentTime + offset, Length); - - if (CurrentTime >= Length) + public TrackVirtualManual(IFrameBasedClock referenceClock) { - Stop(); - RaiseCompleted(); + this.referenceClock = referenceClock; + Length = double.PositiveInfinity; + clock = new ManualClock(); + } + + public override bool Seek(double seek) + { + offset = MathHelper.Clamp(seek, 0, Length) - referenceClock.CurrentTime; + return true; + } + + public override void Start() + { + running = true; + Seek(0); + } + + public override void Reset() + { + Seek(0); + base.Reset(); + } + + public override void Stop() + { + running = false; + } + + public override bool IsRunning => running; + + public override double CurrentTime => running ? clock.CurrentTime : 0; + + protected override void UpdateState() + { + base.UpdateState(); + + clock.CurrentTime = Math.Min(referenceClock.CurrentTime + offset, Length); + + if (CurrentTime >= Length) + { + Stop(); + RaiseCompleted(); + } } } } From 0fce23a36bcb358f463971ea70a1dd735d2282ea Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 19 Feb 2019 12:38:45 +0900 Subject: [PATCH 06/14] Fix test regression --- osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs | 2 +- osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs index 219b0d7b47..305924958b 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSummaryTimeline.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, Clock); + Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, null); Add(new SummaryTimeline { diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index aa4b3f3c03..e6de9d37b2 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -20,7 +20,7 @@ namespace osu.Game.Tests.Beatmaps /// Create an instance which creates a for the provided ruleset when requested. /// /// The target ruleset. - /// An optional clock which should be used instead of a stopwatch for virtual time progression. + /// A clock which should be used instead of a stopwatch for virtual time progression. public TestWorkingBeatmap(RulesetInfo ruleset, IFrameBasedClock referenceClock) : this(new TestBeatmap(ruleset), referenceClock) { From 87dd7bcf6b2d31d7338c153c96b998f0bc70b37d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 19 Feb 2019 13:02:33 +0900 Subject: [PATCH 07/14] Fix one more test regression --- osu.Game/Tests/Visual/EditorTestCase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Tests/Visual/EditorTestCase.cs b/osu.Game/Tests/Visual/EditorTestCase.cs index b455ed2f05..67a1cb6de3 100644 --- a/osu.Game/Tests/Visual/EditorTestCase.cs +++ b/osu.Game/Tests/Visual/EditorTestCase.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual [BackgroundDependencyLoader] private void load() { - Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo, Clock); + Beatmap.Value = new TestWorkingBeatmap(ruleset.RulesetInfo, null); LoadComponentAsync(new Editor(), LoadScreen); } From 703df770002511ab2bb58f20263117b7184144c6 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 19 Feb 2019 19:16:03 +0900 Subject: [PATCH 08/14] Update in-line with framework IsActive changes --- osu.Game/OsuGame.cs | 16 +++++++--------- osu.Game/Screens/Play/PauseContainer.cs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7b4ff3d295..e3b3a9ed79 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -120,6 +120,8 @@ namespace osu.Game forwardLoggedErrorsToNotifications(); RavenLogger = new RavenLogger(this); + + IsActive.BindValueChanged(updateActiveState); } public void ToggleSettings() => settings.ToggleVisibility(); @@ -674,16 +676,12 @@ namespace osu.Game private readonly BindableDouble inactiveVolumeAdjust = new BindableDouble(); - protected override void OnDeactivated() + private void updateActiveState(bool isActive) { - base.OnDeactivated(); - Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); - } - - protected override void OnActivated() - { - base.OnActivated(); - Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); + if (isActive) + Audio.RemoveAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); + else + Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeAdjust); } public bool OnReleased(GlobalAction action) => false; diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index 8dae0ab964..7889be493e 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -116,7 +116,7 @@ namespace osu.Game.Screens.Play protected override void Update() { // eagerly pause when we lose window focus (if we are locally playing). - if (!game.IsActive && CanPause) + if (!game.IsActive.Value && CanPause) Pause(); if (!IsPaused) From 49eadcb575fd9a37c322f407fd0aa77a846864c9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 19 Feb 2019 19:44:09 +0900 Subject: [PATCH 09/14] Update active state immediately + fix potential nullref --- osu.Game/OsuGame.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index e3b3a9ed79..914ecba30d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -120,8 +120,6 @@ namespace osu.Game forwardLoggedErrorsToNotifications(); RavenLogger = new RavenLogger(this); - - IsActive.BindValueChanged(updateActiveState); } public void ToggleSettings() => settings.ToggleVisibility(); @@ -185,6 +183,8 @@ namespace osu.Game configSkin.TriggerChange(); LocalConfig.BindWith(OsuSetting.VolumeInactive, inactiveVolumeAdjust); + + IsActive.BindValueChanged(updateActiveState, true); } private ExternalLinkOpener externalLinkOpener; From b4bb87fee39516895d80bd431a6c98c18e233229 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Feb 2019 12:08:30 +0900 Subject: [PATCH 10/14] Make TrackVirtualTracking more accurate on seeks/stops --- osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index e6de9d37b2..90f2449f53 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -50,28 +50,32 @@ namespace osu.Game.Tests.Beatmaps public class TrackVirtualManual : Track { private readonly IFrameBasedClock referenceClock; - private readonly ManualClock clock; + + private readonly ManualClock clock = new ManualClock(); private bool running; + + /// + /// Local offset added to the reference clock to resolve correct time. + /// private double offset; public TrackVirtualManual(IFrameBasedClock referenceClock) { this.referenceClock = referenceClock; Length = double.PositiveInfinity; - clock = new ManualClock(); } public override bool Seek(double seek) { - offset = MathHelper.Clamp(seek, 0, Length) - referenceClock.CurrentTime; + offset = MathHelper.Clamp(seek, 0, Length); + lastReferenceTime = null; return true; } public override void Start() { running = true; - Seek(0); } public override void Reset() @@ -82,18 +86,41 @@ namespace osu.Game.Tests.Beatmaps public override void Stop() { - running = false; + if (running) + { + running = false; + // on stopping, the current value should be transferred out of the clock, as we can no longer rely on + // the referenceClock (which will still be counting time). + offset = clock.CurrentTime; + lastReferenceTime = null; + } } public override bool IsRunning => running; - public override double CurrentTime => running ? clock.CurrentTime : 0; + private double? lastReferenceTime; + + public override double CurrentTime => clock.CurrentTime; protected override void UpdateState() { base.UpdateState(); - clock.CurrentTime = Math.Min(referenceClock.CurrentTime + offset, Length); + if (running) + { + double refTime = referenceClock.CurrentTime; + + if (!lastReferenceTime.HasValue) + { + // if the clock just started running, the current value should be transferred to the offset + // (to zero the progression of time). + offset -= refTime; + } + + lastReferenceTime = referenceClock.CurrentTime; + } + + clock.CurrentTime = Math.Min((lastReferenceTime ?? 0) + offset, Length); if (CurrentTime >= Length) { From f6d70e687b471dc9686a99ebbb97695df9e6f2c1 Mon Sep 17 00:00:00 2001 From: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com> Date: Wed, 20 Feb 2019 12:27:25 +0900 Subject: [PATCH 11/14] Use correct local variable Co-Authored-By: peppy --- osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs index 90f2449f53..90b5178169 100644 --- a/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestWorkingBeatmap.cs @@ -117,7 +117,7 @@ namespace osu.Game.Tests.Beatmaps offset -= refTime; } - lastReferenceTime = referenceClock.CurrentTime; + lastReferenceTime = refTime; } clock.CurrentTime = Math.Min((lastReferenceTime ?? 0) + offset, Length); From d25d10d8fcc511059a4486b36dd209ab5318b3a4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 20 Feb 2019 14:13:54 +0900 Subject: [PATCH 12/14] Fix position not being set for the first hitobject --- .../CatchDifficultyCalculatorTest.cs | 2 +- .../Difficulty/Preprocessing/CatchDifficultyHitObject.cs | 2 ++ osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs | 9 ++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs index c9831aad6d..fc2a153f49 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Catch.Tests { protected override string ResourceAssembly => "osu.Game.Rulesets.Catch"; - [TestCase(3.8701854263563118d, "diffcalc-test")] + [TestCase(3.8701758020428221d, "diffcalc-test")] public void Test(double expected, string name) => base.Test(expected, name); diff --git a/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs index 6d00bb27b5..24e526ed19 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/Preprocessing/CatchDifficultyHitObject.cs @@ -18,6 +18,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Preprocessing public new CatchHitObject LastObject => (CatchHitObject)base.LastObject; public readonly float NormalizedPosition; + public readonly float LastNormalizedPosition; /// /// Milliseconds elapsed since the start time of the previous , with a minimum of 25ms. @@ -31,6 +32,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Preprocessing var scalingFactor = normalized_hitobject_radius / halfCatcherWidth; NormalizedPosition = BaseObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; + LastNormalizedPosition = LastObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; // Every strain interval is hard capped at the equivalent of 600 BPM streaming speed as a safety measure StrainTime = Math.Max(25, DeltaTime); diff --git a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs index e06ca08fbe..d146153294 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/Skills/Movement.cs @@ -21,20 +21,23 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills protected override double DecayWeight => 0.94; - private float lastPlayerPosition; + private float? lastPlayerPosition; private float lastDistanceMoved; protected override double StrainValueOf(DifficultyHitObject current) { var catchCurrent = (CatchDifficultyHitObject)current; + if (lastPlayerPosition == null) + lastPlayerPosition = catchCurrent.LastNormalizedPosition; + float playerPosition = MathHelper.Clamp( - lastPlayerPosition, + lastPlayerPosition.Value, catchCurrent.NormalizedPosition - (normalized_hitobject_radius - absolute_player_positioning_error), catchCurrent.NormalizedPosition + (normalized_hitobject_radius - absolute_player_positioning_error) ); - float distanceMoved = playerPosition - lastPlayerPosition; + float distanceMoved = playerPosition - lastPlayerPosition.Value; double distanceAddition = Math.Pow(Math.Abs(distanceMoved), 1.3) / 500; double sqrtStrain = Math.Sqrt(catchCurrent.StrainTime); From c01b18f02fb617f3e31004775500080d9243d9c1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 20 Feb 2019 15:18:51 +0900 Subject: [PATCH 13/14] Adjust expected testcase value --- osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs index fc2a153f49..b99dd08ef0 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchDifficultyCalculatorTest.cs @@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Catch.Tests { protected override string ResourceAssembly => "osu.Game.Rulesets.Catch"; - [TestCase(3.8701758020428221d, "diffcalc-test")] + [TestCase(4.2038001515546597d, "diffcalc-test")] public void Test(double expected, string name) => base.Test(expected, name); From b1337ed07fc2317ee8c1266e9fe394eb882a0f1e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Feb 2019 16:09:29 +0900 Subject: [PATCH 14/14] Update framework --- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 6b94fa4f98..6d55071070 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -16,7 +16,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index d677ef4e21..19c16541a2 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -105,8 +105,8 @@ - - + +