mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 01:47:33 +08:00
Merge pull request #12546 from smoogipoo/gcc-change-source-on-reset
Ensure source is set on GameplayClockContainer.Reset()
This commit is contained in:
commit
2764a42824
@ -63,8 +63,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Start()
|
public virtual void Start()
|
||||||
{
|
{
|
||||||
// Ensure that the source clock is set.
|
ensureSourceClockSet();
|
||||||
ChangeSource(SourceClock);
|
|
||||||
|
|
||||||
if (!AdjustableSource.IsRunning)
|
if (!AdjustableSource.IsRunning)
|
||||||
{
|
{
|
||||||
@ -100,6 +99,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Reset()
|
public virtual void Reset()
|
||||||
{
|
{
|
||||||
|
ensureSourceClockSet();
|
||||||
Seek(0);
|
Seek(0);
|
||||||
|
|
||||||
// Manually stop the source in order to not affect the IsPaused state.
|
// Manually stop the source in order to not affect the IsPaused state.
|
||||||
@ -115,6 +115,19 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <param name="sourceClock">The new source.</param>
|
/// <param name="sourceClock">The new source.</param>
|
||||||
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
|
protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ensures that the <see cref="AdjustableSource"/> is set to <see cref="SourceClock"/>, if it hasn't been given a source yet.
|
||||||
|
/// This is usually done before a seek to avoid accidentally seeking only the adjustable source in decoupled mode,
|
||||||
|
/// but not the actual source clock.
|
||||||
|
/// That will pretty much only happen on the very first call of this method, as the source clock is passed in the constructor,
|
||||||
|
/// but it is not yet set on the adjustable source there.
|
||||||
|
/// </summary>
|
||||||
|
private void ensureSourceClockSet()
|
||||||
|
{
|
||||||
|
if (AdjustableSource.Source == null)
|
||||||
|
ChangeSource(SourceClock);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
if (!IsPaused.Value)
|
if (!IsPaused.Value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user