mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 07:37:22 +09:00
Merge branch 'master' into frame-bundle-accuracy
This commit is contained in:
commit
4fb2610c82
@ -355,7 +355,11 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
protected override bool PauseOnFocusLost => false;
|
protected override bool PauseOnFocusLost => false;
|
||||||
|
|
||||||
public ScoreAccessibleReplayPlayer(Score score)
|
public ScoreAccessibleReplayPlayer(Score score)
|
||||||
: base(score, false, false)
|
: base(score, new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = false,
|
||||||
|
ShowResults = false,
|
||||||
|
})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,11 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
protected override bool PauseOnFocusLost => false;
|
protected override bool PauseOnFocusLost => false;
|
||||||
|
|
||||||
public ScoreAccessibleReplayPlayer(Score score)
|
public ScoreAccessibleReplayPlayer(Score score)
|
||||||
: base(score, false, false)
|
: base(score, new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = false,
|
||||||
|
ShowResults = false,
|
||||||
|
})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
private readonly bool userHasCustomColours;
|
private readonly bool userHasCustomColours;
|
||||||
|
|
||||||
public ExposedPlayer(bool userHasCustomColours)
|
public ExposedPlayer(bool userHasCustomColours)
|
||||||
: base(false, false)
|
: base(new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = false,
|
||||||
|
ShowResults = false,
|
||||||
|
})
|
||||||
{
|
{
|
||||||
this.userHasCustomColours = userHasCustomColours;
|
this.userHasCustomColours = userHasCustomColours;
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
protected override bool PauseOnFocusLost => false;
|
protected override bool PauseOnFocusLost => false;
|
||||||
|
|
||||||
public ScoreAccessibleReplayPlayer(Score score)
|
public ScoreAccessibleReplayPlayer(Score score)
|
||||||
: base(score, false, false)
|
: base(score, new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = false,
|
||||||
|
ShowResults = false,
|
||||||
|
})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
protected override bool PauseOnFocusLost => false;
|
protected override bool PauseOnFocusLost => false;
|
||||||
|
|
||||||
public ScoreAccessibleReplayPlayer(Score score)
|
public ScoreAccessibleReplayPlayer(Score score)
|
||||||
: base(score, false, false)
|
: base(score, new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = false,
|
||||||
|
ShowResults = false,
|
||||||
|
})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
using osu.Game.Screens.Multi.Components;
|
using osu.Game.Screens.Multi.Components;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
||||||
{
|
{
|
||||||
@ -15,6 +17,28 @@ namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
|||||||
AddUntilStep("wait for loaded", () => multi.IsLoaded);
|
AddUntilStep("wait for loaded", () => multi.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOneUserJoinedMultipleTimes()
|
||||||
|
{
|
||||||
|
var user = new User { Id = 33 };
|
||||||
|
|
||||||
|
AddRepeatStep("add user multiple times", () => Client.AddUser(user), 3);
|
||||||
|
|
||||||
|
AddAssert("room has 2 users", () => Client.Room?.Users.Count == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOneUserLeftMultipleTimes()
|
||||||
|
{
|
||||||
|
var user = new User { Id = 44 };
|
||||||
|
|
||||||
|
AddStep("add user", () => Client.AddUser(user));
|
||||||
|
AddAssert("room has 2 users", () => Client.Room?.Users.Count == 2);
|
||||||
|
|
||||||
|
AddRepeatStep("remove user multiple times", () => Client.RemoveUser(user), 3);
|
||||||
|
AddAssert("room has 1 user", () => Client.Room?.Users.Count == 1);
|
||||||
|
}
|
||||||
|
|
||||||
private class TestRealtimeMultiplayer : Screens.Multi.RealtimeMultiplayer.RealtimeMultiplayer
|
private class TestRealtimeMultiplayer : Screens.Multi.RealtimeMultiplayer.RealtimeMultiplayer
|
||||||
{
|
{
|
||||||
protected override RoomManager CreateRoomManager() => new TestRealtimeRoomManager();
|
protected override RoomManager CreateRoomManager() => new TestRealtimeRoomManager();
|
||||||
|
@ -55,8 +55,6 @@ namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.AddUser(API.LocalUser.Value);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -226,6 +226,10 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// for sanity, ensure that there can be no duplicate users in the room user list.
|
||||||
|
if (Room.Users.Any(existing => existing.UserID == user.UserID))
|
||||||
|
return;
|
||||||
|
|
||||||
Room.Users.Add(user);
|
Room.Users.Add(user);
|
||||||
|
|
||||||
RoomChanged?.Invoke();
|
RoomChanged?.Invoke();
|
||||||
|
@ -37,8 +37,8 @@ namespace osu.Game.Screens.Multi.Play
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||||
|
|
||||||
public TimeshiftPlayer(PlaylistItem playlistItem, bool allowPause = true)
|
public TimeshiftPlayer(PlaylistItem playlistItem, PlayerConfiguration configuration = null)
|
||||||
: base(allowPause)
|
: base(configuration)
|
||||||
{
|
{
|
||||||
PlaylistItem = playlistItem;
|
PlaylistItem = playlistItem;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ using osu.Game.Online.Multiplayer;
|
|||||||
using osu.Game.Online.RealtimeMultiplayer;
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Multi.Play;
|
using osu.Game.Screens.Multi.Play;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -46,7 +47,11 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
/// <param name="playlistItem">The playlist item to be played.</param>
|
/// <param name="playlistItem">The playlist item to be played.</param>
|
||||||
/// <param name="userIds">The users which are participating in this game.</param>
|
/// <param name="userIds">The users which are participating in this game.</param>
|
||||||
public RealtimePlayer(PlaylistItem playlistItem, int[] userIds)
|
public RealtimePlayer(PlaylistItem playlistItem, int[] userIds)
|
||||||
: base(playlistItem, false)
|
: base(playlistItem, new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = false,
|
||||||
|
AllowRestart = false,
|
||||||
|
})
|
||||||
{
|
{
|
||||||
this.userIds = userIds;
|
this.userIds = userIds;
|
||||||
}
|
}
|
||||||
|
@ -128,18 +128,14 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool CheckModsAllowFailure() => Mods.Value.OfType<IApplicableFailOverride>().All(m => m.PerformFail());
|
protected virtual bool CheckModsAllowFailure() => Mods.Value.OfType<IApplicableFailOverride>().All(m => m.PerformFail());
|
||||||
|
|
||||||
private readonly bool allowPause;
|
public readonly PlayerConfiguration Configuration;
|
||||||
private readonly bool showResults;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new player instance.
|
/// Create a new player instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="allowPause">Whether pausing should be allowed. If not allowed, attempting to pause will quit.</param>
|
public Player(PlayerConfiguration configuration = null)
|
||||||
/// <param name="showResults">Whether results screen should be pushed on completion.</param>
|
|
||||||
public Player(bool allowPause = true, bool showResults = true)
|
|
||||||
{
|
{
|
||||||
this.allowPause = allowPause;
|
Configuration = configuration ?? new PlayerConfiguration();
|
||||||
this.showResults = showResults;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameplayBeatmap gameplayBeatmap;
|
private GameplayBeatmap gameplayBeatmap;
|
||||||
@ -317,59 +313,77 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Drawable createOverlayComponents(WorkingBeatmap working) => new Container
|
private Drawable createOverlayComponents(WorkingBeatmap working)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
var container = new Container
|
||||||
Children = new[]
|
|
||||||
{
|
{
|
||||||
DimmableStoryboard.OverlayLayerContainer.CreateProxy(),
|
RelativeSizeAxes = Axes.Both,
|
||||||
BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
Children = new[]
|
||||||
{
|
{
|
||||||
Clock = DrawableRuleset.FrameStableClock,
|
DimmableStoryboard.OverlayLayerContainer.CreateProxy(),
|
||||||
ProcessCustomClock = false,
|
BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor)
|
||||||
Breaks = working.Beatmap.Breaks
|
|
||||||
},
|
|
||||||
// display the cursor above some HUD elements.
|
|
||||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
|
||||||
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
|
||||||
HUDOverlay = new HUDOverlay(ScoreProcessor, HealthProcessor, DrawableRuleset, Mods.Value)
|
|
||||||
{
|
|
||||||
HoldToQuit =
|
|
||||||
{
|
{
|
||||||
Action = performUserRequestedExit,
|
Clock = DrawableRuleset.FrameStableClock,
|
||||||
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
ProcessCustomClock = false,
|
||||||
|
Breaks = working.Beatmap.Breaks
|
||||||
},
|
},
|
||||||
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
|
// display the cursor above some HUD elements.
|
||||||
KeyCounter =
|
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||||
|
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
||||||
|
HUDOverlay = new HUDOverlay(ScoreProcessor, HealthProcessor, DrawableRuleset, Mods.Value)
|
||||||
{
|
{
|
||||||
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
HoldToQuit =
|
||||||
IsCounting = false
|
{
|
||||||
|
Action = performUserRequestedExit,
|
||||||
|
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
||||||
|
},
|
||||||
|
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
|
||||||
|
KeyCounter =
|
||||||
|
{
|
||||||
|
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
||||||
|
IsCounting = false
|
||||||
|
},
|
||||||
|
RequestSeek = time =>
|
||||||
|
{
|
||||||
|
GameplayClockContainer.Seek(time);
|
||||||
|
GameplayClockContainer.Start();
|
||||||
|
},
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
},
|
},
|
||||||
RequestSeek = time =>
|
skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime)
|
||||||
{
|
{
|
||||||
GameplayClockContainer.Seek(time);
|
RequestSkip = GameplayClockContainer.Skip
|
||||||
GameplayClockContainer.Start();
|
|
||||||
},
|
},
|
||||||
Anchor = Anchor.Centre,
|
FailOverlay = new FailOverlay
|
||||||
Origin = Anchor.Centre
|
{
|
||||||
},
|
OnRetry = Restart,
|
||||||
skipOverlay = new SkipOverlay(DrawableRuleset.GameplayStartTime)
|
OnQuit = performUserRequestedExit,
|
||||||
{
|
},
|
||||||
RequestSkip = GameplayClockContainer.Skip
|
PauseOverlay = new PauseOverlay
|
||||||
},
|
{
|
||||||
FailOverlay = new FailOverlay
|
OnResume = Resume,
|
||||||
{
|
Retries = RestartCount,
|
||||||
OnRetry = Restart,
|
OnRetry = Restart,
|
||||||
OnQuit = performUserRequestedExit,
|
OnQuit = performUserRequestedExit,
|
||||||
},
|
},
|
||||||
PauseOverlay = new PauseOverlay
|
new HotkeyExitOverlay
|
||||||
{
|
{
|
||||||
OnResume = Resume,
|
Action = () =>
|
||||||
Retries = RestartCount,
|
{
|
||||||
OnRetry = Restart,
|
if (!this.IsCurrentScreen()) return;
|
||||||
OnQuit = performUserRequestedExit,
|
|
||||||
},
|
fadeOut(true);
|
||||||
new HotkeyRetryOverlay
|
PerformExit(true);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, },
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Configuration.AllowRestart)
|
||||||
|
{
|
||||||
|
container.Add(new HotkeyRetryOverlay
|
||||||
{
|
{
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
@ -378,20 +392,11 @@ namespace osu.Game.Screens.Play
|
|||||||
fadeOut(true);
|
fadeOut(true);
|
||||||
Restart();
|
Restart();
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
new HotkeyExitOverlay
|
|
||||||
{
|
|
||||||
Action = () =>
|
|
||||||
{
|
|
||||||
if (!this.IsCurrentScreen()) return;
|
|
||||||
|
|
||||||
fadeOut(true);
|
|
||||||
PerformExit(true);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, },
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
private void onBreakTimeChanged(ValueChangedEvent<bool> isBreakTime)
|
private void onBreakTimeChanged(ValueChangedEvent<bool> isBreakTime)
|
||||||
{
|
{
|
||||||
@ -500,6 +505,9 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
|
if (!Configuration.AllowRestart)
|
||||||
|
return;
|
||||||
|
|
||||||
// at the point of restarting the track should either already be paused or the volume should be zero.
|
// at the point of restarting the track should either already be paused or the volume should be zero.
|
||||||
// stopping here is to ensure music doesn't become audible after exiting back to PlayerLoader.
|
// stopping here is to ensure music doesn't become audible after exiting back to PlayerLoader.
|
||||||
musicController.Stop();
|
musicController.Stop();
|
||||||
@ -539,7 +547,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
|
|
||||||
if (!showResults) return;
|
if (!Configuration.ShowResults) return;
|
||||||
|
|
||||||
scoreSubmissionTask ??= Task.Run(async () =>
|
scoreSubmissionTask ??= Task.Run(async () =>
|
||||||
{
|
{
|
||||||
@ -638,7 +646,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private bool canPause =>
|
private bool canPause =>
|
||||||
// must pass basic screen conditions (beatmap loaded, instance allows pause)
|
// must pass basic screen conditions (beatmap loaded, instance allows pause)
|
||||||
LoadedBeatmapSuccessfully && allowPause && ValidForResume
|
LoadedBeatmapSuccessfully && Configuration.AllowPause && ValidForResume
|
||||||
// replays cannot be paused and exit immediately
|
// replays cannot be paused and exit immediately
|
||||||
&& !DrawableRuleset.HasReplayLoaded.Value
|
&& !DrawableRuleset.HasReplayLoaded.Value
|
||||||
// cannot pause if we are already in a fail state
|
// cannot pause if we are already in a fail state
|
||||||
|
23
osu.Game/Screens/Play/PlayerConfiguration.cs
Normal file
23
osu.Game/Screens/Play/PlayerConfiguration.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
public class PlayerConfiguration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether pausing should be allowed. If not allowed, attempting to pause will quit.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowPause { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether results screen should be pushed on completion.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowResults { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the player should be allowed to trigger a restart.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowRestart { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
@ -16,8 +16,8 @@ namespace osu.Game.Screens.Play
|
|||||||
// Disallow replays from failing. (see https://github.com/ppy/osu/issues/6108)
|
// Disallow replays from failing. (see https://github.com/ppy/osu/issues/6108)
|
||||||
protected override bool CheckModsAllowFailure() => false;
|
protected override bool CheckModsAllowFailure() => false;
|
||||||
|
|
||||||
public ReplayPlayer(Score score, bool allowPause = true, bool showResults = true)
|
public ReplayPlayer(Score score, PlayerConfiguration configuration = null)
|
||||||
: base(allowPause, showResults)
|
: base(configuration)
|
||||||
{
|
{
|
||||||
Score = score;
|
Score = score;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual.RealtimeMultiplayer
|
|||||||
public void RemoveUser(User user)
|
public void RemoveUser(User user)
|
||||||
{
|
{
|
||||||
Debug.Assert(Room != null);
|
Debug.Assert(Room != null);
|
||||||
((IMultiplayerClient)this).UserLeft(Room.Users.Single(u => u.User == user));
|
((IMultiplayerClient)this).UserLeft(new MultiplayerRoomUser(user.Id));
|
||||||
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
public readonly List<JudgementResult> Results = new List<JudgementResult>();
|
public readonly List<JudgementResult> Results = new List<JudgementResult>();
|
||||||
|
|
||||||
public TestPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
public TestPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
||||||
: base(allowPause, showResults)
|
: base(new PlayerConfiguration
|
||||||
|
{
|
||||||
|
AllowPause = allowPause,
|
||||||
|
ShowResults = showResults
|
||||||
|
})
|
||||||
{
|
{
|
||||||
PauseOnFocusLost = pauseOnFocusLost;
|
PauseOnFocusLost = pauseOnFocusLost;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user