mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 01:23:24 +08:00
Move operation of setting GameplayClockContainer.StartTime
to Reset
call
This commit is contained in:
parent
17a1df281c
commit
af2e82d7d5
@ -107,12 +107,13 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
Add(gameplayContainer = new MasterGameplayClockContainer(working, start_time)
|
Add(gameplayContainer = new MasterGameplayClockContainer(working, start_time)
|
||||||
{
|
{
|
||||||
StartTime = start_time,
|
|
||||||
Child = new FrameStabilityContainer
|
Child = new FrameStabilityContainer
|
||||||
{
|
{
|
||||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gameplayContainer.Reset(start_time);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("start time", () => gameplayContainer.Start());
|
AddStep("start time", () => gameplayContainer.Start());
|
||||||
|
@ -27,7 +27,11 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
||||||
=> new MasterGameplayClockContainer(beatmap, gameplayStart) { StartTime = editorState.Time };
|
{
|
||||||
|
var masterGameplayClockContainer = new MasterGameplayClockContainer(beatmap, gameplayStart);
|
||||||
|
masterGameplayClockContainer.Reset(editorState.Time);
|
||||||
|
return masterGameplayClockContainer;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
|
@ -192,8 +192,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
.DefaultIfEmpty(0)
|
.DefaultIfEmpty(0)
|
||||||
.Min();
|
.Min();
|
||||||
|
|
||||||
masterClockContainer.StartTime = startTime;
|
masterClockContainer.Reset(startTime, true);
|
||||||
masterClockContainer.Reset(true);
|
|
||||||
|
|
||||||
// Although the clock has been started, this flag is set to allow for later synchronisation state changes to also be able to start it.
|
// Although the clock has been started, this flag is set to allow for later synchronisation state changes to also be able to start it.
|
||||||
canStartMasterClock = true;
|
canStartMasterClock = true;
|
||||||
|
@ -38,23 +38,13 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time from which the clock should start. Will be seeked to on calling <see cref="Reset"/>.
|
/// The time from which the clock should start. Will be seeked to on calling <see cref="Reset"/>.
|
||||||
/// Settting a start time will <see cref="Reset"/> to the new value.
|
/// Can be adjusted by calling <see cref="Reset"/> with a time value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// By default, a value of zero will be used.
|
/// By default, a value of zero will be used.
|
||||||
/// Importantly, the value will be inferred from the current beatmap in <see cref="MasterGameplayClockContainer"/> by default.
|
/// Importantly, the value will be inferred from the current beatmap in <see cref="MasterGameplayClockContainer"/> by default.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public double StartTime
|
public double StartTime { get; private set; }
|
||||||
{
|
|
||||||
get => startTime;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
startTime = value;
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double startTime;
|
|
||||||
|
|
||||||
public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
|
public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
|
||||||
|
|
||||||
@ -139,13 +129,18 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="time">The time to seek to on resetting. If <c>null</c>, the existing <see cref="StartTime"/> will be used.</param>
|
||||||
/// <param name="startClock">Whether to start the clock immediately, if not already started.</param>
|
/// <param name="startClock">Whether to start the clock immediately, if not already started.</param>
|
||||||
public void Reset(bool startClock = false)
|
public void Reset(double? time = null, bool startClock = false)
|
||||||
{
|
{
|
||||||
// Manually stop the source in order to not affect the IsPaused state.
|
// Manually stop the source in order to not affect the IsPaused state.
|
||||||
GameplayClock.Stop();
|
GameplayClock.Stop();
|
||||||
|
|
||||||
ensureSourceClockSet();
|
ensureSourceClockSet();
|
||||||
|
|
||||||
|
if (time != null)
|
||||||
|
StartTime = time.Value;
|
||||||
|
|
||||||
Seek(StartTime);
|
Seek(StartTime);
|
||||||
|
|
||||||
if (!IsPaused.Value || startClock)
|
if (!IsPaused.Value || startClock)
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Play
|
|||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
this.skipTargetTime = skipTargetTime;
|
this.skipTargetTime = skipTargetTime;
|
||||||
|
|
||||||
StartTime = findEarliestStartTime();
|
Reset(findEarliestStartTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private double findEarliestStartTime()
|
private double findEarliestStartTime()
|
||||||
|
@ -640,8 +640,7 @@ namespace osu.Game.Screens.Play
|
|||||||
bool wasFrameStable = DrawableRuleset.FrameStablePlayback;
|
bool wasFrameStable = DrawableRuleset.FrameStablePlayback;
|
||||||
DrawableRuleset.FrameStablePlayback = false;
|
DrawableRuleset.FrameStablePlayback = false;
|
||||||
|
|
||||||
GameplayClockContainer.StartTime = time;
|
GameplayClockContainer.Reset(time);
|
||||||
GameplayClockContainer.Reset();
|
|
||||||
|
|
||||||
// Delay resetting frame-stable playback for one frame to give the FrameStabilityContainer a chance to seek.
|
// Delay resetting frame-stable playback for one frame to give the FrameStabilityContainer a chance to seek.
|
||||||
frameStablePlaybackResetDelegate = ScheduleAfterChildren(() => DrawableRuleset.FrameStablePlayback = wasFrameStable);
|
frameStablePlaybackResetDelegate = ScheduleAfterChildren(() => DrawableRuleset.FrameStablePlayback = wasFrameStable);
|
||||||
@ -1012,7 +1011,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (GameplayClockContainer.IsRunning)
|
if (GameplayClockContainer.IsRunning)
|
||||||
throw new InvalidOperationException($"{nameof(StartGameplay)} should not be called when the gameplay clock is already running");
|
throw new InvalidOperationException($"{nameof(StartGameplay)} should not be called when the gameplay clock is already running");
|
||||||
|
|
||||||
GameplayClockContainer.Reset(true);
|
GameplayClockContainer.Reset(startClock: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSuspending(ScreenTransitionEvent e)
|
public override void OnSuspending(ScreenTransitionEvent e)
|
||||||
|
Loading…
Reference in New Issue
Block a user