Skip to content

Commit

Permalink
Fix gameplay limitations for adjusting offset not actually being applied
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 16, 2025
1 parent a4174a3 commit 1d240eb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ private void load(OsuConfigManager config, OsuGameBase game, CancellationToken c
}

dependencies.CacheAs(DrawableRuleset.FrameStableClock);
dependencies.CacheAs<IGameplayClock>(DrawableRuleset.FrameStableClock);

// add the overlay components as a separate step as they proxy some elements from the above underlay/gameplay components.
// also give the overlays the ruleset skin provider to allow rulesets to potentially override HUD elements (used to disable combo counters etc.)
Expand Down
40 changes: 29 additions & 11 deletions osu.Game/Screens/Play/PlayerSettings/BeatmapOffsetControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,36 @@ protected override void Dispose(bool isDisposing)
beatmapOffsetSubscription?.Dispose();
}

public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
protected override void Update()
{
base.Update();
Current.Disabled = !allowOffsetAdjust;
}

private bool allowOffsetAdjust
{
// General limitations to ensure players don't do anything too weird.
// These match stable for now.
if (player is SubmittingPlayer)
get
{
// TODO: the blocking conditions should probably display a message.
if (player?.IsBreakTime.Value == false && gameplayClock?.CurrentTime - gameplayClock?.StartTime > 10000)
return false;
// General limitations to ensure players don't do anything too weird.
// These match stable for now.
if (player is SubmittingPlayer)
{
Debug.Assert(gameplayClock != null);

// TODO: the blocking conditions should probably display a message.
if (!player.IsBreakTime.Value && gameplayClock.CurrentTime - gameplayClock.StartTime > 10000)
return false;

if (gameplayClock?.IsPaused.Value == true)
return false;
if (gameplayClock.IsPaused.Value)
return false;
}

return true;
}
}

public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
// To match stable, this should adjust by 5 ms, or 1 ms when holding alt.
// But that is hard to make work with global actions due to the operating mode.
// Let's use the more precise as a default for now.
Expand All @@ -296,11 +312,13 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
switch (e.Action)
{
case GlobalAction.IncreaseOffset:
Current.Value += amount;
if (!Current.Disabled)
Current.Value += amount;
return true;

case GlobalAction.DecreaseOffset:
Current.Value -= amount;
if (!Current.Disabled)
Current.Value -= amount;
return true;
}

Expand Down

0 comments on commit 1d240eb

Please sign in to comment.