mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:42:54 +08:00
Merge pull request #6374 from peppy/fix-negative-key-counter
Fix key counters appearing negative on intense beatmaps
This commit is contained in:
commit
c2f5f14839
@ -47,6 +47,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
private IFrameBasedClock parentGameplayClock;
|
private IFrameBasedClock parentGameplayClock;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current direction of playback to be exposed to frame stable children.
|
||||||
|
/// </summary>
|
||||||
|
private int direction;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(GameplayClock clock)
|
private void load(GameplayClock clock)
|
||||||
{
|
{
|
||||||
@ -110,27 +115,22 @@ namespace osu.Game.Rulesets.UI
|
|||||||
setClock(); // LoadComplete may not be run yet, but we still want the clock.
|
setClock(); // LoadComplete may not be run yet, but we still want the clock.
|
||||||
|
|
||||||
validState = true;
|
validState = true;
|
||||||
|
requireMoreUpdateLoops = false;
|
||||||
manualClock.Rate = parentGameplayClock.Rate;
|
|
||||||
manualClock.IsRunning = parentGameplayClock.IsRunning;
|
|
||||||
|
|
||||||
var newProposedTime = parentGameplayClock.CurrentTime;
|
var newProposedTime = parentGameplayClock.CurrentTime;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!FrameStablePlayback)
|
if (!FrameStablePlayback)
|
||||||
{
|
|
||||||
manualClock.CurrentTime = newProposedTime;
|
|
||||||
requireMoreUpdateLoops = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else if (firstConsumption)
|
if (firstConsumption)
|
||||||
{
|
{
|
||||||
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
|
// On the first update, frame-stability seeking would result in unexpected/unwanted behaviour.
|
||||||
// Instead we perform an initial seek to the proposed time.
|
// Instead we perform an initial seek to the proposed time.
|
||||||
manualClock.CurrentTime = newProposedTime;
|
|
||||||
|
|
||||||
// do a second process to clear out ElapsedTime
|
// process frame (in addition to finally clause) to clear out ElapsedTime
|
||||||
|
manualClock.CurrentTime = newProposedTime;
|
||||||
framedClock.ProcessFrame();
|
framedClock.ProcessFrame();
|
||||||
|
|
||||||
firstConsumption = false;
|
firstConsumption = false;
|
||||||
@ -144,11 +144,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
: Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time);
|
: Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAttached)
|
if (isAttached)
|
||||||
{
|
|
||||||
manualClock.CurrentTime = newProposedTime;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
double? newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime);
|
double? newTime = ReplayInputHandler.SetFrameFromTime(newProposedTime);
|
||||||
|
|
||||||
@ -156,19 +152,24 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
// we shouldn't execute for this time value. probably waiting on more replay data.
|
// we shouldn't execute for this time value. probably waiting on more replay data.
|
||||||
validState = false;
|
validState = false;
|
||||||
|
|
||||||
requireMoreUpdateLoops = true;
|
requireMoreUpdateLoops = true;
|
||||||
manualClock.CurrentTime = newProposedTime;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
manualClock.CurrentTime = newTime.Value;
|
newProposedTime = newTime.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
requireMoreUpdateLoops = manualClock.CurrentTime != parentGameplayClock.CurrentTime;
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
if (newProposedTime != manualClock.CurrentTime)
|
||||||
|
direction = newProposedTime > manualClock.CurrentTime ? 1 : -1;
|
||||||
|
|
||||||
|
manualClock.CurrentTime = newProposedTime;
|
||||||
|
manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction;
|
||||||
|
manualClock.IsRunning = parentGameplayClock.IsRunning;
|
||||||
|
|
||||||
|
requireMoreUpdateLoops |= manualClock.CurrentTime != parentGameplayClock.CurrentTime;
|
||||||
|
|
||||||
// The manual clock time has changed in the above code. The framed clock now needs to be updated
|
// The manual clock time has changed in the above code. The framed clock now needs to be updated
|
||||||
// to ensure that the its time is valid for our children before input is processed
|
// to ensure that the its time is valid for our children before input is processed
|
||||||
framedClock.ProcessFrame();
|
framedClock.ProcessFrame();
|
||||||
|
@ -137,9 +137,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnPressed(T action) => Target.Children.OfType<KeyCounterAction<T>>().Any(c => c.OnPressed(action, Clock.ElapsedFrameTime > 0));
|
public bool OnPressed(T action) => Target.Children.OfType<KeyCounterAction<T>>().Any(c => c.OnPressed(action, Clock.Rate >= 0));
|
||||||
|
|
||||||
public bool OnReleased(T action) => Target.Children.OfType<KeyCounterAction<T>>().Any(c => c.OnReleased(action, Clock.ElapsedFrameTime > 0));
|
public bool OnReleased(T action) => Target.Children.OfType<KeyCounterAction<T>>().Any(c => c.OnReleased(action, Clock.Rate >= 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user