Skip to content
Merged

aa #107

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
3 changes: 3 additions & 0 deletions osu.Game/Screens/Backgrounds/EditorBackgroundScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public void RefreshBackgroundAsync()
private void updateState(bool withAnimation = true)
{
background?.Storyboard.FadeTo(showStoryboard.Value ? 1 : 0, withAnimation ? 500 : 0, Easing.OutQuint);
// if the storyboard is disabled, in some cases (e.g. involving `StoryboardReplacesBackground`)
// we still need to show the background sprite, because if we don't, then there will be no background shown at all
background?.Sprite.FadeTo(showStoryboard.Value ? 0 : 1, withAnimation ? 500 : 0, Easing.OutQuint);

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateState() now fades the background sprite to 0 whenever showStoryboard is enabled. This hides the beatmap background even for storyboards that don’t replace the background, which can result in a blank/incorrect background. Consider only hiding background.Sprite when the loaded storyboard actually replaces the background (eg background.Beatmap.Storyboard.ReplacesBackground), and otherwise keep the sprite visible while the storyboard is shown.

Suggested change
background?.Sprite.FadeTo(showStoryboard.Value ? 0 : 1, withAnimation ? 500 : 0, Easing.OutQuint);
bool storyboardReplacesBackground = background?.Beatmap?.Storyboard?.ReplacesBackground ?? false;
float targetBackgroundAlpha = showStoryboard.Value && storyboardReplacesBackground ? 0 : 1;
background?.Sprite.FadeTo(targetBackgroundAlpha, withAnimation ? 500 : 0, Easing.OutQuint);

Copilot uses AI. Check for mistakes.
}

public override bool Equals(BackgroundScreen? other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public partial class GameplayWarmupScreen : RankedPlaySubScreen
[Resolved]
private RulesetStore rulesets { get; set; } = null!;

[Resolved]
private MusicController musicController { get; set; } = null!;

[Resolved]
private Bindable<WorkingBeatmap> globalBeatmap { get; set; } = null!;

Expand Down Expand Up @@ -164,6 +167,10 @@ protected override void LoadComplete()
globalRuleset.Value = ruleset;
globalMods.Value = item.RequiredMods.Select(m => m.ToMod(rulesetInstance)).ToArray();

// Play the new track from its preview point.
globalBeatmap.Value.PrepareTrackForPreview(false);
Comment on lines +170 to +171

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PrepareTrackForPreview(false) sets Track.Looping = false. If the warmup lasts long enough for the beatmap track to complete, MusicController will advance to the next track (see onTrackCompleted()), which would desync music from the selected beatmap. This should likely prepare the track with looping enabled (or otherwise ensure the track can’t complete while waiting).

Suggested change
// Play the new track from its preview point.
globalBeatmap.Value.PrepareTrackForPreview(false);
// Play the new track from its preview point, looping during warmup to avoid completion.
globalBeatmap.Value.PrepareTrackForPreview(true);

Copilot uses AI. Check for mistakes.
musicController.Play(true);

Client.ChangeState(MultiplayerUserState.Ready).FireAndForget();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ public partial class RankedPlayScreen : OsuScreen, IPreviewTrackOwner, IHandlePr
[Resolved]
private PreviewTrackManager previewTrackManager { get; set; } = null!;

[Resolved]
private MusicController music { get; set; } = null!;

[Resolved]
private QueueController? controller { get; set; }

Expand Down Expand Up @@ -285,16 +282,9 @@ private void onStageChanged(RankedPlayStage stage)
}
}

public override void OnEntering(ScreenTransitionEvent e)
{
base.OnEntering(e);

beginHandlingTrack();
}

public override void OnSuspending(ScreenTransitionEvent e)
{
endHandlingTrack();
previewTrackManager.StopAnyPlaying(this);

base.OnSuspending(e);
}
Expand All @@ -312,7 +302,7 @@ public override bool OnExiting(ScreenExitEvent e)
return true;
}

endHandlingTrack();
previewTrackManager.StopAnyPlaying(this);

client.LeaveRoom().FireAndForget();

Expand Down Expand Up @@ -341,8 +331,6 @@ public override void OnResuming(ScreenTransitionEvent e)
{
base.OnResuming(e);

beginHandlingTrack();

if (e.Last is not MultiplayerPlayerLoader playerLoader)
return;

Expand All @@ -355,38 +343,6 @@ public override void OnResuming(ScreenTransitionEvent e)
client.ChangeState(MultiplayerUserState.Idle).FireAndForget();
}

/// <summary>
/// Handles changes in the track to keep it looping while active.
/// </summary>
private void beginHandlingTrack()
{
Beatmap.BindValueChanged(applyLoopingToTrack, true);
}

/// <summary>
/// Stops looping the current track and stops handling further changes to the track.
/// </summary>
private void endHandlingTrack()
{
Beatmap.ValueChanged -= applyLoopingToTrack;
Beatmap.Value.Track.Looping = false;

previewTrackManager.StopAnyPlaying(this);
}

/// <summary>
/// Invoked on changes to the beatmap to loop the track. See: <see cref="beginHandlingTrack"/>.
/// </summary>
/// <param name="beatmap">The beatmap change event.</param>
private void applyLoopingToTrack(ValueChangedEvent<WorkingBeatmap> beatmap)
{
if (!this.IsCurrentScreen())
return;

beatmap.NewValue.PrepareTrackForPreview(true);
music.EnsurePlayingSomething();
}

public void PresentBeatmap(WorkingBeatmap beatmap, RulesetInfo ruleset)
{
// Do nothing to prevent the user from potentially being kicked out
Expand Down
Loading