mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Merge branch 'master' into test-scene-osu-game-fix-async-disposal-contention
This commit is contained in:
commit
7074021d1f
@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
private bool checkSomeHit() => Player.ScoreProcessor.JudgedHits >= 4;
|
||||
|
||||
private bool objectWithIncreasedVisibilityHasIndex(int index)
|
||||
=> Player.Mods.Value.OfType<TestOsuModHidden>().Single().FirstObject == Player.GameplayState.Beatmap.HitObjects[index];
|
||||
=> Player.GameplayState.Mods.OfType<TestOsuModHidden>().Single().FirstObject == Player.GameplayState.Beatmap.HitObjects[index];
|
||||
|
||||
private class TestOsuModHidden : OsuModHidden
|
||||
{
|
||||
|
@ -205,7 +205,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
||||
AddStep("retrieve mods", () => playerMod1 = (TestMod)player.Mods.Value.Single());
|
||||
AddStep("retrieve mods", () => playerMod1 = (TestMod)player.GameplayState.Mods.Single());
|
||||
AddAssert("game mods not applied", () => gameMod.Applied == false);
|
||||
AddAssert("player mods applied", () => playerMod1.Applied);
|
||||
|
||||
@ -217,7 +217,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
});
|
||||
|
||||
AddUntilStep("wait for player to be current", () => player.IsCurrentScreen());
|
||||
AddStep("retrieve mods", () => playerMod2 = (TestMod)player.Mods.Value.Single());
|
||||
AddStep("retrieve mods", () => playerMod2 = (TestMod)player.GameplayState.Mods.Single());
|
||||
AddAssert("game mods not applied", () => gameMod.Applied == false);
|
||||
AddAssert("player has different mods", () => playerMod1 != playerMod2);
|
||||
AddAssert("player mods applied", () => playerMod2.Applied);
|
||||
|
@ -350,13 +350,13 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
// since most overlays use a scroll container that absorbs on mouse down
|
||||
NowPlayingOverlay nowPlayingOverlay = null;
|
||||
|
||||
AddStep("enter menu", () => InputManager.Key(Key.Enter));
|
||||
AddUntilStep("Wait for now playing load", () => (nowPlayingOverlay = Game.ChildrenOfType<NowPlayingOverlay>().FirstOrDefault()) != null);
|
||||
|
||||
AddStep("get and press now playing hotkey", () =>
|
||||
{
|
||||
nowPlayingOverlay = Game.ChildrenOfType<NowPlayingOverlay>().Single();
|
||||
InputManager.Key(Key.F6);
|
||||
});
|
||||
AddStep("enter menu", () => InputManager.Key(Key.Enter));
|
||||
AddUntilStep("toolbar displayed", () => Game.Toolbar.State.Value == Visibility.Visible);
|
||||
|
||||
AddStep("open now playing", () => InputManager.Key(Key.F6));
|
||||
AddUntilStep("now playing is visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
|
||||
|
||||
// drag tests
|
||||
|
||||
@ -417,7 +417,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
pushEscape(); // returns to osu! logo
|
||||
|
||||
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
|
||||
AddUntilStep("Wait for intro", () => Game.ScreenStack.CurrentScreen is IntroTriangles);
|
||||
AddUntilStep("Wait for intro", () => Game.ScreenStack.CurrentScreen is IntroScreen);
|
||||
AddStep("Release escape", () => InputManager.ReleaseKey(Key.Escape));
|
||||
AddUntilStep("Wait for game exit", () => Game.ScreenStack.CurrentScreen == null);
|
||||
AddStep("test dispose doesn't crash", () => Game.Dispose());
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -125,15 +124,11 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public DimmableStoryboard DimmableStoryboard { get; private set; }
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
protected new readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
/// <summary>
|
||||
/// Whether failing should be allowed.
|
||||
/// By default, this checks whether all selected mods allow failing.
|
||||
/// </summary>
|
||||
protected virtual bool CheckModsAllowFailure() => Mods.Value.OfType<IApplicableFailOverride>().All(m => m.PerformFail());
|
||||
protected virtual bool CheckModsAllowFailure() => GameplayState.Mods.OfType<IApplicableFailOverride>().All(m => m.PerformFail());
|
||||
|
||||
public readonly PlayerConfiguration Configuration;
|
||||
|
||||
@ -179,12 +174,12 @@ namespace osu.Game.Screens.Play
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(AudioManager audio, OsuConfigManager config, OsuGameBase game)
|
||||
{
|
||||
Mods.Value = base.Mods.Value.Select(m => m.DeepClone()).ToArray();
|
||||
var gameplayMods = Mods.Value.Select(m => m.DeepClone()).ToArray();
|
||||
|
||||
if (Beatmap.Value is DummyWorkingBeatmap)
|
||||
return;
|
||||
|
||||
IBeatmap playableBeatmap = loadPlayableBeatmap();
|
||||
IBeatmap playableBeatmap = loadPlayableBeatmap(gameplayMods);
|
||||
|
||||
if (playableBeatmap == null)
|
||||
return;
|
||||
@ -199,12 +194,12 @@ namespace osu.Game.Screens.Play
|
||||
if (game is OsuGame osuGame)
|
||||
LocalUserPlaying.BindTo(osuGame.LocalUserPlaying);
|
||||
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, gameplayMods);
|
||||
dependencies.CacheAs(DrawableRuleset);
|
||||
|
||||
ScoreProcessor = ruleset.CreateScoreProcessor();
|
||||
ScoreProcessor.ApplyBeatmap(playableBeatmap);
|
||||
ScoreProcessor.Mods.BindTo(Mods);
|
||||
ScoreProcessor.Mods.Value = gameplayMods;
|
||||
|
||||
dependencies.CacheAs(ScoreProcessor);
|
||||
|
||||
@ -223,9 +218,9 @@ namespace osu.Game.Screens.Play
|
||||
// ensure the score is in a consistent state with the current player.
|
||||
Score.ScoreInfo.BeatmapInfo = Beatmap.Value.BeatmapInfo;
|
||||
Score.ScoreInfo.Ruleset = ruleset.RulesetInfo;
|
||||
Score.ScoreInfo.Mods = Mods.Value.ToArray();
|
||||
Score.ScoreInfo.Mods = gameplayMods;
|
||||
|
||||
dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, Mods.Value, Score));
|
||||
dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score));
|
||||
|
||||
AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));
|
||||
|
||||
@ -302,13 +297,13 @@ namespace osu.Game.Screens.Play
|
||||
// this is required for mods that apply transforms to these processors.
|
||||
ScoreProcessor.OnLoadComplete += _ =>
|
||||
{
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
foreach (var mod in gameplayMods.OfType<IApplicableToScoreProcessor>())
|
||||
mod.ApplyToScoreProcessor(ScoreProcessor);
|
||||
};
|
||||
|
||||
HealthProcessor.OnLoadComplete += _ =>
|
||||
{
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToHealthProcessor>())
|
||||
foreach (var mod in gameplayMods.OfType<IApplicableToHealthProcessor>())
|
||||
mod.ApplyToHealthProcessor(HealthProcessor);
|
||||
};
|
||||
|
||||
@ -356,7 +351,7 @@ namespace osu.Game.Screens.Play
|
||||
// display the cursor above some HUD elements.
|
||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
|
||||
HUDOverlay = new HUDOverlay(DrawableRuleset, Mods.Value)
|
||||
HUDOverlay = new HUDOverlay(DrawableRuleset, GameplayState.Mods)
|
||||
{
|
||||
HoldToQuit =
|
||||
{
|
||||
@ -467,7 +462,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
private IBeatmap loadPlayableBeatmap()
|
||||
private IBeatmap loadPlayableBeatmap(Mod[] gameplayMods)
|
||||
{
|
||||
IBeatmap playable;
|
||||
|
||||
@ -481,7 +476,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
try
|
||||
{
|
||||
playable = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Mods.Value);
|
||||
playable = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, gameplayMods);
|
||||
}
|
||||
catch (BeatmapInvalidForRulesetException)
|
||||
{
|
||||
@ -489,7 +484,7 @@ namespace osu.Game.Screens.Play
|
||||
rulesetInfo = Beatmap.Value.BeatmapInfo.Ruleset;
|
||||
ruleset = rulesetInfo.CreateInstance();
|
||||
|
||||
playable = Beatmap.Value.GetPlayableBeatmap(rulesetInfo, Mods.Value);
|
||||
playable = Beatmap.Value.GetPlayableBeatmap(rulesetInfo, gameplayMods);
|
||||
}
|
||||
|
||||
if (playable.HitObjects.Count == 0)
|
||||
@ -789,7 +784,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
failAnimation.Start();
|
||||
|
||||
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
|
||||
if (GameplayState.Mods.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
|
||||
Restart();
|
||||
|
||||
return true;
|
||||
@ -919,17 +914,17 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToPlayer>())
|
||||
foreach (var mod in GameplayState.Mods.OfType<IApplicableToPlayer>())
|
||||
mod.ApplyToPlayer(this);
|
||||
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToHUD>())
|
||||
foreach (var mod in GameplayState.Mods.OfType<IApplicableToHUD>())
|
||||
mod.ApplyToHUD(HUDOverlay);
|
||||
|
||||
// Our mods are local copies of the global mods so they need to be re-applied to the track.
|
||||
// This is done through the music controller (for now), because resetting speed adjustments on the beatmap track also removes adjustments provided by DrawableTrack.
|
||||
// Todo: In the future, player will receive in a track and will probably not have to worry about this...
|
||||
musicController.ResetTrackAdjustments();
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToTrack>())
|
||||
foreach (var mod in GameplayState.Mods.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(musicController.CurrentTrack);
|
||||
|
||||
updateGameplayState();
|
||||
|
@ -22,6 +22,7 @@ using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK.Graphics;
|
||||
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
@ -126,7 +127,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
public new Bindable<IReadOnlyList<Mod>> SelectedMods => base.SelectedMods;
|
||||
|
||||
// if we don't do this, when running under nUnit the version that gets populated is that of nUnit.
|
||||
// if we don't apply these changes, when running under nUnit the version that gets populated is that of nUnit.
|
||||
public override Version AssemblyVersion => new Version(0, 0);
|
||||
public override string Version => "test game";
|
||||
|
||||
protected override Loader CreateLoader() => new TestLoader();
|
||||
@ -142,6 +144,9 @@ namespace osu.Game.Tests.Visual
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
LocalConfig.SetValue(OsuSetting.IntroSequence, IntroSequence.Circles);
|
||||
|
||||
API.Login("Rhythm Champion", "osu!");
|
||||
|
||||
Dependencies.Get<SessionStatics>().SetValue(Static.MutedAudioNotificationShownOnce, true);
|
||||
|
Loading…
Reference in New Issue
Block a user