mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 08:32:54 +08:00
Merge pull request #31533 from peppy/fix-gameplay-offset-adjust-limitations
Fix gameplay offset adjustment limits not being enforced
This commit is contained in:
commit
7d026761fc
@ -41,6 +41,7 @@ using osu.Game.Screens.OnlinePlay.Match.Components;
|
|||||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Screens.Select.Carousel;
|
using osu.Game.Screens.Select.Carousel;
|
||||||
@ -317,6 +318,92 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddUntilStep("wait for song select", () => songSelect.IsCurrentScreen());
|
AddUntilStep("wait for song select", () => songSelect.IsCurrentScreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOffsetAdjustDuringPause()
|
||||||
|
{
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
Screens.Select.SongSelect songSelect = null;
|
||||||
|
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
|
||||||
|
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
|
||||||
|
|
||||||
|
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
|
||||||
|
|
||||||
|
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||||
|
|
||||||
|
AddStep("set mods", () => Game.SelectedMods.Value = new Mod[] { new OsuModNoFail() });
|
||||||
|
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
|
AddUntilStep("wait for player", () =>
|
||||||
|
{
|
||||||
|
DismissAnyNotifications();
|
||||||
|
player = Game.ScreenStack.CurrentScreen as Player;
|
||||||
|
return player?.IsLoaded == true;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for track playing", () => Game.Beatmap.Value.Track.IsRunning);
|
||||||
|
checkOffset(0);
|
||||||
|
|
||||||
|
AddStep("adjust offset via keyboard", () => InputManager.Key(Key.Minus));
|
||||||
|
checkOffset(-1);
|
||||||
|
|
||||||
|
AddStep("pause", () => player.ChildrenOfType<GameplayClockContainer>().First().Stop());
|
||||||
|
AddUntilStep("wait for pause", () => player.ChildrenOfType<GameplayClockContainer>().First().IsPaused.Value, () => Is.True);
|
||||||
|
AddStep("attempt adjust offset via keyboard", () => InputManager.Key(Key.Minus));
|
||||||
|
checkOffset(-1);
|
||||||
|
|
||||||
|
void checkOffset(double offset)
|
||||||
|
{
|
||||||
|
AddUntilStep($"control offset is {offset}", () => this.ChildrenOfType<GameplayOffsetControl>().Single().ChildrenOfType<BeatmapOffsetControl>().Single().Current.Value,
|
||||||
|
() => Is.EqualTo(offset));
|
||||||
|
AddUntilStep($"database offset is {offset}", () => Game.BeatmapManager.QueryBeatmap(b => b.ID == Game.Beatmap.Value.BeatmapInfo.ID)!.UserSettings.Offset,
|
||||||
|
() => Is.EqualTo(offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOffsetAdjustDuringGameplay()
|
||||||
|
{
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
Screens.Select.SongSelect songSelect = null;
|
||||||
|
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
|
||||||
|
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
|
||||||
|
|
||||||
|
AddStep("import beatmap", () => BeatmapImportHelper.LoadOszIntoOsu(Game).WaitSafely());
|
||||||
|
|
||||||
|
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||||
|
|
||||||
|
AddStep("set mods", () => Game.SelectedMods.Value = new Mod[] { new OsuModNoFail() });
|
||||||
|
AddStep("press enter", () => InputManager.Key(Key.Enter));
|
||||||
|
|
||||||
|
AddUntilStep("wait for player", () =>
|
||||||
|
{
|
||||||
|
DismissAnyNotifications();
|
||||||
|
player = Game.ScreenStack.CurrentScreen as Player;
|
||||||
|
return player?.IsLoaded == true;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for track playing", () => Game.Beatmap.Value.Track.IsRunning);
|
||||||
|
checkOffset(0);
|
||||||
|
|
||||||
|
AddStep("adjust offset via keyboard", () => InputManager.Key(Key.Minus));
|
||||||
|
checkOffset(-1);
|
||||||
|
|
||||||
|
AddStep("seek beyond 10 seconds", () => player.ChildrenOfType<GameplayClockContainer>().First().Seek(10500));
|
||||||
|
AddUntilStep("wait for seek", () => player.ChildrenOfType<GameplayClockContainer>().First().CurrentTime, () => Is.GreaterThan(10600));
|
||||||
|
AddStep("attempt adjust offset via keyboard", () => InputManager.Key(Key.Minus));
|
||||||
|
checkOffset(-1);
|
||||||
|
|
||||||
|
void checkOffset(double offset)
|
||||||
|
{
|
||||||
|
AddUntilStep($"control offset is {offset}", () => this.ChildrenOfType<GameplayOffsetControl>().Single().ChildrenOfType<BeatmapOffsetControl>().Single().Current.Value,
|
||||||
|
() => Is.EqualTo(offset));
|
||||||
|
AddUntilStep($"database offset is {offset}", () => Game.BeatmapManager.QueryBeatmap(b => b.ID == Game.Beatmap.Value.BeatmapInfo.ID)!.UserSettings.Offset,
|
||||||
|
() => Is.EqualTo(offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRetryCountIncrements()
|
public void TestRetryCountIncrements()
|
||||||
{
|
{
|
||||||
|
@ -322,6 +322,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies.CacheAs(DrawableRuleset.FrameStableClock);
|
dependencies.CacheAs(DrawableRuleset.FrameStableClock);
|
||||||
|
dependencies.CacheAs<IGameplayClock>(DrawableRuleset.FrameStableClock);
|
||||||
|
|
||||||
// add the overlay components as a separate step as they proxy some elements from the above underlay/gameplay components.
|
// add the overlay components as a separate step as they proxy some elements from the above underlay/gameplay components.
|
||||||
// also give the overlays the ruleset skin provider to allow rulesets to potentially override HUD elements (used to disable combo counters etc.)
|
// also give the overlays the ruleset skin provider to allow rulesets to potentially override HUD elements (used to disable combo counters etc.)
|
||||||
|
@ -274,20 +274,36 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
beatmapOffsetSubscription?.Dispose();
|
beatmapOffsetSubscription?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
Current.Disabled = !allowOffsetAdjust;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool allowOffsetAdjust
|
||||||
|
{
|
||||||
|
get
|
||||||
{
|
{
|
||||||
// General limitations to ensure players don't do anything too weird.
|
// General limitations to ensure players don't do anything too weird.
|
||||||
// These match stable for now.
|
// These match stable for now.
|
||||||
if (player is SubmittingPlayer)
|
if (player is SubmittingPlayer)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(gameplayClock != null);
|
||||||
|
|
||||||
// TODO: the blocking conditions should probably display a message.
|
// TODO: the blocking conditions should probably display a message.
|
||||||
if (player?.IsBreakTime.Value == false && gameplayClock?.CurrentTime - gameplayClock?.StartTime > 10000)
|
if (!player.IsBreakTime.Value && gameplayClock.CurrentTime - gameplayClock.StartTime > 10000)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (gameplayClock?.IsPaused.Value == true)
|
if (gameplayClock.IsPaused.Value)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||||
|
{
|
||||||
// To match stable, this should adjust by 5 ms, or 1 ms when holding alt.
|
// To match stable, this should adjust by 5 ms, or 1 ms when holding alt.
|
||||||
// But that is hard to make work with global actions due to the operating mode.
|
// But that is hard to make work with global actions due to the operating mode.
|
||||||
// Let's use the more precise as a default for now.
|
// Let's use the more precise as a default for now.
|
||||||
@ -296,10 +312,12 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
case GlobalAction.IncreaseOffset:
|
case GlobalAction.IncreaseOffset:
|
||||||
|
if (!Current.Disabled)
|
||||||
Current.Value += amount;
|
Current.Value += amount;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case GlobalAction.DecreaseOffset:
|
case GlobalAction.DecreaseOffset:
|
||||||
|
if (!Current.Disabled)
|
||||||
Current.Value -= amount;
|
Current.Value -= amount;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user