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

Show spectating users during gameplay #31527

Merged
merged 12 commits into from
Jan 21, 2025
Merged
Prev Previous commit
Next Next commit
Bind to playing state via GameplayState instead to fix more tests
  • Loading branch information
bdach committed Jan 16, 2025
commit 5c799d733f2543cbb35295cea68333ab4bd4f31d
11 changes: 10 additions & 1 deletion osu.Game/Screens/Play/GameplayState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,20 @@ public class GameplayState

private readonly Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>();

/// <summary>
/// The local user's playing state (whether actively playing, paused, or not playing due to watching a replay or similar).
/// </summary>
public IBindable<LocalUserPlayingState> Playing { get; } = new Bindable<LocalUserPlayingState>();

public GameplayState(
IBeatmap beatmap,
Ruleset ruleset,
IReadOnlyList<Mod>? mods = null,
Score? score = null,
ScoreProcessor? scoreProcessor = null,
HealthProcessor? healthProcessor = null,
Storyboard? storyboard = null)
Storyboard? storyboard = null,
IBindable<LocalUserPlayingState>? localUserPlaying = null)
{
Beatmap = beatmap;
Ruleset = ruleset;
Expand All @@ -92,6 +98,9 @@ public GameplayState(
ScoreProcessor = scoreProcessor ?? ruleset.CreateScoreProcessor();
HealthProcessor = healthProcessor ?? ruleset.CreateHealthProcessor(beatmap.HitObjects[0].StartTime);
Storyboard = storyboard ?? new Storyboard();

if (localUserPlaying != null)
Playing.BindTo(localUserPlaying);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Screens/Play/HUD/SpectatorList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ public partial class SkinnableSpectatorList : SpectatorList, ISerialisableDrawab
public bool UsesFixedAnchor { get; set; }

[BackgroundDependencyLoader]
private void load(SpectatorClient client, Player player)
private void load(SpectatorClient client, GameplayState gameplayState)
{
((IBindableList<SpectatorUser>)Spectators).BindTo(client.WatchingUsers);
((IBindable<LocalUserPlayingState>)UserPlayingState).BindTo(player.PlayingState);
((IBindable<LocalUserPlayingState>)UserPlayingState).BindTo(gameplayState.Playing);
}
}
}
2 changes: 1 addition & 1 deletion osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void load(OsuConfigManager config, OsuGameBase game, CancellationToken c
Score.ScoreInfo.Ruleset = ruleset.RulesetInfo;
Score.ScoreInfo.Mods = gameplayMods;

dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score, ScoreProcessor, HealthProcessor, Beatmap.Value.Storyboard));
dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score, ScoreProcessor, HealthProcessor, Beatmap.Value.Storyboard, PlayingState));

var rulesetSkinProvider = new RulesetSkinProvidingContainer(ruleset, playableBeatmap, Beatmap.Value.Skin);
GameplayClockContainer.Add(new GameplayScrollWheelHandling());
Expand Down