mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 18:52:55 +08:00
Merge pull request #17162 from peppy/realm-offset-feedback-fix-2
Fix feedback from realm writes causing offset slider to jump around
This commit is contained in:
commit
dfe98c6536
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -23,8 +25,6 @@ using osu.Game.Scoring;
|
|||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.PlayerSettings
|
namespace osu.Game.Screens.Play.PlayerSettings
|
||||||
{
|
{
|
||||||
public class BeatmapOffsetControl : CompositeDrawable
|
public class BeatmapOffsetControl : CompositeDrawable
|
||||||
@ -122,7 +122,19 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
beatmapOffsetSubscription = realm.SubscribeToPropertyChanged(
|
beatmapOffsetSubscription = realm.SubscribeToPropertyChanged(
|
||||||
r => r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID)?.UserSettings,
|
r => r.Find<BeatmapInfo>(beatmap.Value.BeatmapInfo.ID)?.UserSettings,
|
||||||
settings => settings.Offset,
|
settings => settings.Offset,
|
||||||
val => Current.Value = val);
|
val =>
|
||||||
|
{
|
||||||
|
// At the point we reach here, it's not guaranteed that all realm writes have taken place (there may be some in-flight).
|
||||||
|
// We are only aware of writes that originated from our own flow, so if we do see one that's active we can avoid handling the feedback value arriving.
|
||||||
|
if (realmWriteTask == null)
|
||||||
|
Current.Value = val;
|
||||||
|
|
||||||
|
if (realmWriteTask?.IsCompleted == true)
|
||||||
|
{
|
||||||
|
// we can also mark any in-flight write that is managed locally as "seen" and start handling any incoming changes again.
|
||||||
|
realmWriteTask = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Current.BindValueChanged(currentChanged);
|
Current.BindValueChanged(currentChanged);
|
||||||
}
|
}
|
||||||
@ -158,10 +170,12 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
if (settings == null) // only the case for tests.
|
if (settings == null) // only the case for tests.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (settings.Offset == Current.Value)
|
double val = Current.Value;
|
||||||
|
|
||||||
|
if (settings.Offset == val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
settings.Offset = Current.Value;
|
settings.Offset = val;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user