mirror of
https://github.com/ppy/osu
synced 2025-01-12 00:59:35 +00:00
Move skip logic to inside SkipButton
This commit is contained in:
parent
a43b122914
commit
a7d16ac213
@ -16,7 +16,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
base.Reset();
|
||||
|
||||
Add(new BackButton());
|
||||
Add(new SkipButton());
|
||||
Add(new SkipButton(Clock.CurrentTime + 5000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
#endregion
|
||||
|
||||
private SkipButton skipButton;
|
||||
|
||||
private HUDOverlay hudOverlay;
|
||||
private FailOverlay failOverlay;
|
||||
|
||||
@ -169,8 +167,9 @@ namespace osu.Game.Screens.Play
|
||||
Children = new Drawable[]
|
||||
{
|
||||
HitRenderer,
|
||||
skipButton = new SkipButton
|
||||
new SkipButton(firstObjectTime)
|
||||
{
|
||||
AudioClock = decoupledClock,
|
||||
Alpha = 0,
|
||||
Margin = new MarginPadding { Bottom = 140 } // this is temporary
|
||||
},
|
||||
@ -219,33 +218,6 @@ namespace osu.Game.Screens.Play
|
||||
scoreProcessor.Failed += onFail;
|
||||
}
|
||||
|
||||
private void initializeSkipButton()
|
||||
{
|
||||
const double skip_required_cutoff = 3000;
|
||||
const double fade_time = 300;
|
||||
|
||||
double firstHitObject = Beatmap.Beatmap.HitObjects.First().StartTime;
|
||||
|
||||
if (firstHitObject < skip_required_cutoff)
|
||||
{
|
||||
skipButton.Alpha = 0;
|
||||
skipButton.Expire();
|
||||
return;
|
||||
}
|
||||
|
||||
skipButton.FadeInFromZero(fade_time);
|
||||
|
||||
skipButton.Action = () =>
|
||||
{
|
||||
decoupledClock.Seek(firstHitObject - skip_required_cutoff - fade_time);
|
||||
skipButton.Action = null;
|
||||
};
|
||||
|
||||
skipButton.Delay(firstHitObject - skip_required_cutoff - fade_time);
|
||||
skipButton.FadeOut(fade_time);
|
||||
skipButton.Expire();
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
ValidForResume = false;
|
||||
@ -308,7 +280,6 @@ namespace osu.Game.Screens.Play
|
||||
Schedule(() =>
|
||||
{
|
||||
decoupledClock.Start();
|
||||
initializeSkipButton();
|
||||
});
|
||||
|
||||
pauseContainer.Alpha = 0;
|
||||
|
@ -5,6 +5,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK.Input;
|
||||
@ -13,8 +14,12 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class SkipButton : TwoLayerButton
|
||||
{
|
||||
public SkipButton()
|
||||
private readonly double startTime;
|
||||
public IAdjustableClock AudioClock;
|
||||
|
||||
public SkipButton(double startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
Text = @"Skip";
|
||||
Icon = FontAwesome.fa_osu_right_o;
|
||||
Anchor = Anchor.BottomRight;
|
||||
@ -27,6 +32,24 @@ namespace osu.Game.Screens.Play
|
||||
ActivationSound = audio.Sample.Get(@"Menu/menuhit");
|
||||
BackgroundColour = colours.Yellow;
|
||||
HoverColour = colours.YellowDark;
|
||||
|
||||
const double skip_required_cutoff = 3000;
|
||||
const double fade_time = 300;
|
||||
|
||||
if (startTime < skip_required_cutoff)
|
||||
{
|
||||
Alpha = 0;
|
||||
Expire();
|
||||
return;
|
||||
}
|
||||
|
||||
FadeInFromZero(fade_time);
|
||||
|
||||
Action = () => AudioClock.Seek(startTime - skip_required_cutoff - fade_time);
|
||||
|
||||
Delay(startTime - skip_required_cutoff - fade_time);
|
||||
FadeOut(fade_time);
|
||||
Expire();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
|
Loading…
Reference in New Issue
Block a user