Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Break skipping (Spacebar) #3264

Closed
wants to merge 9 commits into from
33 changes: 32 additions & 1 deletion osu.Game/Screens/Play/BreakOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Bindings;
using osu.Framework.Timing;
using osu.Game.Beatmaps.Timing;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.Break;

namespace osu.Game.Screens.Play
{
public class BreakOverlay : Container
public class BreakOverlay : Container, IKeyBindingHandler<GlobalAction>
{
public IAdjustableClock AdjustableClock;

private const double skip_required_cutoff = 3000;
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
private const float remaining_time_container_max_size = 0.3f;
private const int vertical_margin = 25;
Expand Down Expand Up @@ -151,5 +157,30 @@ private void bindProcessor(ScoreProcessor processor)
info.AccuracyDisplay.Current.BindTo(processor.Accuracy);
info.GradeDisplay.Current.BindTo(processor.Rank);
}

public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.SkipCutscene:
double startTime = -1;
foreach (var b in breaks)
{
if(Time.Current > b.StartTime && Time.Current + skip_required_cutoff + fade_duration < b.EndTime)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

{
startTime = b.EndTime;
break;
}
}
if (startTime == -1)
return false;
AdjustableClock?.Seek(startTime - skip_required_cutoff - fade_duration);
return true;
}

return false;
}

public bool OnReleased(GlobalAction action) => false;
}
}
3 changes: 2 additions & 1 deletion osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
ProcessCustomClock = false,
Breaks = beatmap.Breaks
Breaks = beatmap.Breaks,
AdjustableClock = adjustableClock
},
RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
hudOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working, offsetClock, adjustableClock)
Expand Down