mirror of
https://github.com/ppy/osu
synced 2024-12-28 09:52:56 +00:00
Merge branch 'master' into spectator-listing
This commit is contained in:
commit
a3c67aabe2
@ -22,9 +22,9 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
AddStep("ensure playing something", () => Game.MusicController.EnsurePlayingSomething());
|
||||
AddStep("toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
|
||||
AddAssert("music paused", () => !Game.MusicController.IsPlaying && Game.MusicController.IsUserPaused);
|
||||
AddAssert("music paused", () => !Game.MusicController.IsPlaying && Game.MusicController.UserPauseRequested);
|
||||
AddStep("toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
|
||||
AddAssert("music resumed", () => Game.MusicController.IsPlaying && !Game.MusicController.IsUserPaused);
|
||||
AddAssert("music resumed", () => Game.MusicController.IsPlaying && !Game.MusicController.UserPauseRequested);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||
|
||||
if (withUserPause)
|
||||
AddStep("pause", () => Game.Dependencies.Get<MusicController>().Stop());
|
||||
AddStep("pause", () => Game.Dependencies.Get<MusicController>().Stop(true));
|
||||
|
||||
AddStep("press enter", () => pressAndRelease(Key.Enter));
|
||||
|
||||
|
@ -13,6 +13,7 @@ using Newtonsoft.Json;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Replays.Legacy;
|
||||
@ -122,19 +123,26 @@ namespace osu.Game.Online.Spectator
|
||||
isConnected = false;
|
||||
playingUsers.Clear();
|
||||
|
||||
if (ex != null) await tryUntilConnected();
|
||||
if (ex != null)
|
||||
{
|
||||
Logger.Log($"Spectator client lost connection: {ex}", LoggingTarget.Network);
|
||||
await tryUntilConnected();
|
||||
}
|
||||
};
|
||||
|
||||
await tryUntilConnected();
|
||||
|
||||
async Task tryUntilConnected()
|
||||
{
|
||||
Logger.Log("Spectator client connecting...", LoggingTarget.Network);
|
||||
|
||||
while (api.State.Value == APIState.Online)
|
||||
{
|
||||
try
|
||||
{
|
||||
// reconnect on any failure
|
||||
await connection.StartAsync();
|
||||
Logger.Log("Spectator client connected!", LoggingTarget.Network);
|
||||
|
||||
// success
|
||||
isConnected = true;
|
||||
@ -151,8 +159,9 @@ namespace osu.Game.Online.Spectator
|
||||
|
||||
break;
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Spectator client connection error: {e}", LoggingTarget.Network);
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,10 @@ namespace osu.Game.Overlays
|
||||
|
||||
private readonly BindableList<BeatmapSetInfo> beatmapSets = new BindableList<BeatmapSetInfo>();
|
||||
|
||||
public bool IsUserPaused { get; private set; }
|
||||
/// <summary>
|
||||
/// Whether the user has requested the track to be paused. Use <see cref="IsPlaying"/> to determine whether the track is still playing.
|
||||
/// </summary>
|
||||
public bool UserPauseRequested { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the global <see cref="WorkingBeatmap"/> has changed.
|
||||
@ -148,7 +151,7 @@ namespace osu.Game.Overlays
|
||||
/// </summary>
|
||||
public void EnsurePlayingSomething()
|
||||
{
|
||||
if (IsUserPaused) return;
|
||||
if (UserPauseRequested) return;
|
||||
|
||||
if (CurrentTrack.IsDummyDevice || beatmap.Value.BeatmapSetInfo.DeletePending)
|
||||
{
|
||||
@ -166,10 +169,17 @@ namespace osu.Game.Overlays
|
||||
/// <summary>
|
||||
/// Start playing the current track (if not already playing).
|
||||
/// </summary>
|
||||
/// <param name="restart">Whether to restart the track from the beginning.</param>
|
||||
/// <param name="requestedByUser">
|
||||
/// Whether the request to play was issued by the user rather than internally.
|
||||
/// Specifying <c>true</c> will ensure that other methods like <see cref="EnsurePlayingSomething"/>
|
||||
/// will resume music playback going forward.
|
||||
/// </param>
|
||||
/// <returns>Whether the operation was successful.</returns>
|
||||
public bool Play(bool restart = false)
|
||||
public bool Play(bool restart = false, bool requestedByUser = false)
|
||||
{
|
||||
IsUserPaused = false;
|
||||
if (requestedByUser)
|
||||
UserPauseRequested = false;
|
||||
|
||||
if (restart)
|
||||
CurrentTrack.Restart();
|
||||
@ -182,9 +192,14 @@ namespace osu.Game.Overlays
|
||||
/// <summary>
|
||||
/// Stop playing the current track and pause at the current position.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
/// <param name="requestedByUser">
|
||||
/// Whether the request to stop was issued by the user rather than internally.
|
||||
/// Specifying <c>true</c> will ensure that other methods like <see cref="EnsurePlayingSomething"/>
|
||||
/// will not resume music playback until the next explicit call to <see cref="Play"/>.
|
||||
/// </param>
|
||||
public void Stop(bool requestedByUser = false)
|
||||
{
|
||||
IsUserPaused = true;
|
||||
UserPauseRequested |= requestedByUser;
|
||||
if (CurrentTrack.IsRunning)
|
||||
CurrentTrack.Stop();
|
||||
}
|
||||
@ -196,9 +211,9 @@ namespace osu.Game.Overlays
|
||||
public bool TogglePause()
|
||||
{
|
||||
if (CurrentTrack.IsRunning)
|
||||
Stop();
|
||||
Stop(true);
|
||||
else
|
||||
Play();
|
||||
Play(requestedByUser: true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -419,11 +419,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
};
|
||||
|
||||
// bring in updates from selection changes
|
||||
EditorBeatmap.HitObjectUpdated += _ => UpdateTernaryStates();
|
||||
EditorBeatmap.HitObjectUpdated += _ => Scheduler.AddOnce(UpdateTernaryStates);
|
||||
EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) =>
|
||||
{
|
||||
Scheduler.AddOnce(updateVisibility);
|
||||
UpdateTernaryStates();
|
||||
Scheduler.AddOnce(UpdateTernaryStates);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -266,8 +266,15 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
public override string TargetMember => nameof(currentTime);
|
||||
|
||||
protected override void Apply(EditorClock clock, double time) =>
|
||||
clock.currentTime = Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
|
||||
protected override void Apply(EditorClock clock, double time) => clock.currentTime = valueAt(time);
|
||||
|
||||
private double valueAt(double time)
|
||||
{
|
||||
if (time < StartTime) return StartValue;
|
||||
if (time >= EndTime) return EndValue;
|
||||
|
||||
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
|
||||
}
|
||||
|
||||
protected override void ReadIntoStartValue(EditorClock clock) => StartValue = clock.currentTime;
|
||||
}
|
||||
|
@ -579,7 +579,8 @@ namespace osu.Game.Screens.Select
|
||||
updateComponentFromBeatmap(Beatmap.Value);
|
||||
|
||||
// restart playback on returning to song select, regardless.
|
||||
music.Play();
|
||||
// not sure this should be a permanent thing (we may want to leave a user pause paused even on returning)
|
||||
music.Play(requestedByUser: true);
|
||||
}
|
||||
|
||||
this.FadeIn(250);
|
||||
@ -681,7 +682,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||
|
||||
if (!track.IsRunning && (music.IsUserPaused != true || isNewTrack))
|
||||
if (!track.IsRunning && (music.UserPauseRequested != true || isNewTrack))
|
||||
music.Play(true);
|
||||
|
||||
lastTrack.SetTarget(track);
|
||||
|
@ -189,7 +189,7 @@ namespace osu.Game.Tests.Visual
|
||||
rulesetDependencies?.Dispose();
|
||||
|
||||
if (MusicController?.TrackLoaded == true)
|
||||
MusicController.CurrentTrack.Stop();
|
||||
MusicController.Stop();
|
||||
|
||||
if (contextFactory?.IsValueCreated == true)
|
||||
contextFactory.Value.ResetDatabase();
|
||||
|
Loading…
Reference in New Issue
Block a user