Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerSkipOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public MultiplayerSkipOverlay(double startTime)
{
}

protected override OsuClickableContainer CreateButton() => skipButton = new Button
protected override OsuClickableContainer CreateButton(IBindable<bool> inSkipPeriod) => skipButton = new Button
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
InSkipPeriod = { BindTarget = inSkipPeriod },
};

protected override void LoadComplete()
Expand Down Expand Up @@ -119,6 +120,9 @@ public partial class Button : OsuClickableContainer

public readonly BindableInt SkippedCount = new BindableInt();
public readonly BindableInt RequiredCount = new BindableInt();
public readonly BindableBool InSkipPeriod = new BindableBool();

private readonly BindableBool clicked = new BindableBool();

[Resolved]
private OsuColour colours { get; set; } = null!;
Expand Down Expand Up @@ -201,11 +205,17 @@ protected override void LoadComplete()

SkippedCount.BindValueChanged(_ => updateCount());
RequiredCount.BindValueChanged(_ => updateCount(), true);

InSkipPeriod.BindValueChanged(_ => updateEnabledState());
clicked.BindValueChanged(_ => updateEnabledState(), true);

Enabled.BindValueChanged(_ => updateColours(), true);

FinishTransforms(true);
}

private void updateEnabledState() => Enabled.Value = InSkipPeriod.Value && !clicked.Value;

private void updateChevronsSpacing()
{
if (SkippedCount.Value > 0 && RequiredCount.Value > 1)
Expand Down Expand Up @@ -300,7 +310,7 @@ protected override bool OnClick(ClickEvent e)

base.OnClick(e);

Enabled.Value = false;
clicked.Value = true;
return true;
}

Expand Down
24 changes: 13 additions & 11 deletions osu.Game/Screens/Play/SkipOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
Expand Down Expand Up @@ -52,9 +53,9 @@ public partial class SkipOverlay : BeatSyncedContainer, IKeyBindingHandler<Globa
private double displayTime;

/// <summary>
/// Becomes <see langword="false"/> when the overlay starts fading out.
/// Whether the gameplay clock is currently at the skippable period.
/// </summary>
private bool isClickable;
private readonly BindableBool inSkipPeriod = new BindableBool();

private bool skipQueued;

Expand Down Expand Up @@ -92,7 +93,7 @@ private void load(OsuColour colours)
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
button = CreateButton(),
button = CreateButton(inSkipPeriod),
RemainingTimeBox = new Circle
{
Height = 5,
Expand All @@ -106,10 +107,15 @@ private void load(OsuColour colours)
};
}

protected virtual OsuClickableContainer CreateButton() => new Button
/// <summary>
/// Creates a skip button.
/// </summary>
/// <param name="inSkipPeriod">Whether the gameplay clock is currently at the skippable period.</param>
protected virtual OsuClickableContainer CreateButton(IBindable<bool> inSkipPeriod) => new Button
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Enabled = { BindTarget = inSkipPeriod },
};

private const double fade_time = 300;
Expand Down Expand Up @@ -187,17 +193,13 @@ protected override void Update()

RemainingTimeBox.Width = (float)Interpolation.Lerp(RemainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));

isClickable = progress > 0;

if (!isClickable)
button.Enabled.Value = false;

buttonContainer.State.Value = isClickable ? Visibility.Visible : Visibility.Hidden;
inSkipPeriod.Value = progress > 0;
buttonContainer.State.Value = inSkipPeriod.Value ? Visibility.Visible : Visibility.Hidden;
}

protected override bool OnMouseMove(MouseMoveEvent e)
{
if (isClickable && !e.HasAnyButtonPressed)
if (inSkipPeriod.Value && !e.HasAnyButtonPressed)
FadingContent.TriggerShow();

return base.OnMouseMove(e);
Expand Down
Loading