mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 00:53:31 +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)
|
||||
{
|
||||
StartTime = start_time,
|
||||
Child = new FrameStabilityContainer
|
||||
{
|
||||
Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
|
||||
}
|
||||
});
|
||||
|
||||
gameplayContainer.Reset(start_time);
|
||||
});
|
||||
|
||||
AddStep("start time", () => gameplayContainer.Start());
|
||||
|
@ -27,7 +27,11 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
@ -192,8 +192,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
.DefaultIfEmpty(0)
|
||||
.Min();
|
||||
|
||||
masterClockContainer.StartTime = startTime;
|
||||
masterClockContainer.Reset(true);
|
||||
masterClockContainer.Reset(startTime, 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.
|
||||
canStartMasterClock = true;
|
||||
|
@ -38,23 +38,13 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
public double StartTime
|
||||
{
|
||||
get => startTime;
|
||||
set
|
||||
{
|
||||
startTime = value;
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
private double startTime;
|
||||
public double StartTime { get; private set; }
|
||||
|
||||
public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
|
||||
|
||||
@ -139,13 +129,18 @@ namespace osu.Game.Screens.Play
|
||||
/// <summary>
|
||||
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
|
||||
/// </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>
|
||||
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.
|
||||
GameplayClock.Stop();
|
||||
|
||||
ensureSourceClockSet();
|
||||
|
||||
if (time != null)
|
||||
StartTime = time.Value;
|
||||
|
||||
Seek(StartTime);
|
||||
|
||||
if (!IsPaused.Value || startClock)
|
||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Play
|
||||
this.beatmap = beatmap;
|
||||
this.skipTargetTime = skipTargetTime;
|
||||
|
||||
StartTime = findEarliestStartTime();
|
||||
Reset(findEarliestStartTime());
|
||||
}
|
||||
|
||||
private double findEarliestStartTime()
|
||||
|
@ -640,8 +640,7 @@ namespace osu.Game.Screens.Play
|
||||
bool wasFrameStable = DrawableRuleset.FrameStablePlayback;
|
||||
DrawableRuleset.FrameStablePlayback = false;
|
||||
|
||||
GameplayClockContainer.StartTime = time;
|
||||
GameplayClockContainer.Reset();
|
||||
GameplayClockContainer.Reset(time);
|
||||
|
||||
// Delay resetting frame-stable playback for one frame to give the FrameStabilityContainer a chance to seek.
|
||||
frameStablePlaybackResetDelegate = ScheduleAfterChildren(() => DrawableRuleset.FrameStablePlayback = wasFrameStable);
|
||||
@ -1012,7 +1011,7 @@ namespace osu.Game.Screens.Play
|
||||
if (GameplayClockContainer.IsRunning)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user