mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Merge branch 'global-available-mods' into adjustable-rate-mods
This commit is contained in:
commit
59538bfd32
@ -54,6 +54,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1212.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1213.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Mods.Value = Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||||
return base.CreatePlayer(ruleset);
|
return base.CreatePlayer(ruleset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
drawableRuleset = new DrawableCatchRuleset(new CatchRuleset(), beatmap, Array.Empty<Mod>())
|
drawableRuleset = new DrawableCatchRuleset(new CatchRuleset(), beatmap.GetPlayableBeatmap(new CatchRuleset().RulesetInfo))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
private void addToPlayfield(DrawableCatchHitObject drawable)
|
private void addToPlayfield(DrawableCatchHitObject drawable)
|
||||||
{
|
{
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||||
|
|
||||||
drawableRuleset.Playfield.Add(drawable);
|
drawableRuleset.Playfield.Add(drawable);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
using osu.Game.Rulesets.Catch.Mods;
|
using osu.Game.Rulesets.Catch.Mods;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
@ -12,9 +13,10 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(CatchModHidden) }).ToList();
|
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(CatchModHidden) }).ToList();
|
||||||
|
|
||||||
public TestSceneDrawableHitObjectsHidden()
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Mods.Value = new[] { new CatchModHidden() };
|
SelectedMods.Value = new[] { new CatchModHidden() };
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
{
|
{
|
||||||
public class CatchRuleset : Ruleset
|
public class CatchRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableCatchRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableCatchRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
||||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
protected override bool UserScrollSpeedAdjustment => false;
|
protected override bool UserScrollSpeedAdjustment => false;
|
||||||
|
|
||||||
public DrawableCatchRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableCatchRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Down;
|
Direction.Value = ScrollingDirection.Down;
|
||||||
TimeRange.Value = BeatmapDifficulty.DifficultyRange(beatmap.Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450);
|
TimeRange.Value = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(Beatmap);
|
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(Beatmap);
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
||||||
|
|
||||||
public DrawableManiaEditRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableManiaEditRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
public int TotalColumns => ((ManiaPlayfield)drawableRuleset.Playfield).TotalColumns;
|
public int TotalColumns => ((ManiaPlayfield)drawableRuleset.Playfield).TotalColumns;
|
||||||
|
|
||||||
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
{
|
{
|
||||||
drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
{
|
{
|
||||||
public class ManiaRuleset : Ruleset
|
public class ManiaRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableManiaRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableManiaRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
||||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||||
|
|
||||||
public DrawableManiaRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
BarLines = new BarLineGenerator<BarLine>(Beatmap).BarLines;
|
BarLines = new BarLineGenerator<BarLine>(Beatmap).BarLines;
|
||||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
var drawable = CreateDrawableHitCircle(circle, auto);
|
var drawable = CreateDrawableHitCircle(circle, auto);
|
||||||
|
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||||
|
|
||||||
return drawable;
|
return drawable;
|
||||||
|
@ -14,9 +14,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(OsuModHidden) }).ToList();
|
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(OsuModHidden) }).ToList();
|
||||||
|
|
||||||
public TestSceneHitCircleHidden()
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Mods.Value = new[] { new OsuModHidden() };
|
SelectedMods.Value = new[] { new OsuModHidden() };
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Mods.Value = new Mod[] { new OsuModAutoplay(), new OsuModFlashlight(), };
|
SelectedMods.Value = new Mod[] { new OsuModAutoplay(), new OsuModFlashlight(), };
|
||||||
|
|
||||||
return base.CreatePlayer(ruleset);
|
return base.CreatePlayer(ruleset);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
var drawable = CreateDrawableSlider(slider);
|
var drawable = CreateDrawableSlider(slider);
|
||||||
|
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||||
|
|
||||||
drawable.OnNewResult += onNewResult;
|
drawable.OnNewResult += onNewResult;
|
||||||
|
@ -14,9 +14,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(OsuModHidden) }).ToList();
|
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(OsuModHidden) }).ToList();
|
||||||
|
|
||||||
public TestSceneSliderHidden()
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Mods.Value = new[] { new OsuModHidden() };
|
SelectedMods.Value = new[] { new OsuModHidden() };
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
Depth = depthIndex++
|
Depth = depthIndex++
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||||
|
|
||||||
Add(drawable);
|
Add(drawable);
|
||||||
|
@ -14,9 +14,10 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(OsuModHidden) }).ToList();
|
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[] { typeof(OsuModHidden) }).ToList();
|
||||||
|
|
||||||
public TestSceneSpinnerHidden()
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Mods.Value = new[] { new OsuModHidden() };
|
SelectedMods.Value = new[] { new OsuModHidden() };
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const double editor_hit_object_fade_out_extension = 500;
|
private const double editor_hit_object_fade_out_extension = 500;
|
||||||
|
|
||||||
public DrawableOsuEditRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableOsuEditRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
=> new DrawableOsuEditRuleset(ruleset, beatmap, mods);
|
=> new DrawableOsuEditRuleset(ruleset, beatmap, mods);
|
||||||
|
|
||||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
public class OsuRuleset : Ruleset
|
public class OsuRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableOsuRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableOsuRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
||||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
{
|
{
|
||||||
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
||||||
|
|
||||||
public DrawableOsuRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableOsuRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ using osu.Framework.MathUtils;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -91,7 +90,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 768,
|
Height = 768,
|
||||||
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap, Array.Empty<Mod>()) }
|
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap.GetPlayableBeatmap(new TaikoRuleset().RulesetInfo)) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
|||||||
|
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Mods.Value = Mods.Value.Concat(new[] { new TaikoModSuddenDeath() }).ToArray();
|
SelectedMods.Value = SelectedMods.Value.Concat(new[] { new TaikoModSuddenDeath() }).ToArray();
|
||||||
return new ScoreAccessiblePlayer();
|
return new ScoreAccessiblePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
{
|
{
|
||||||
public class TaikoRuleset : Ruleset
|
public class TaikoRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableTaikoRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableTaikoRuleset(this, beatmap, mods);
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
||||||
|
|
||||||
public const string SHORT_NAME = "taiko";
|
public const string SHORT_NAME = "taiko";
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
protected override bool UserScrollSpeedAdjustment => false;
|
protected override bool UserScrollSpeedAdjustment => false;
|
||||||
|
|
||||||
public DrawableTaikoRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Left;
|
Direction.Value = ScrollingDirection.Left;
|
||||||
|
427
osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs
Normal file
427
osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs
Normal file
@ -0,0 +1,427 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Input.States;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens;
|
||||||
|
using osu.Game.Screens.Backgrounds;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Background
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneUserDimBackgrounds : ManualInputManagerTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(ScreenWithBeatmapBackground),
|
||||||
|
typeof(PlayerLoader),
|
||||||
|
typeof(Player),
|
||||||
|
typeof(UserDimContainer),
|
||||||
|
typeof(OsuScreen)
|
||||||
|
};
|
||||||
|
|
||||||
|
private DummySongSelect songSelect;
|
||||||
|
private TestPlayerLoader playerLoader;
|
||||||
|
private TestPlayer player;
|
||||||
|
private BeatmapManager manager;
|
||||||
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(GameHost host, AudioManager audio)
|
||||||
|
{
|
||||||
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||||
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||||
|
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
||||||
|
|
||||||
|
manager.Import(TestResources.GetTestBeatmapForImport()).Wait();
|
||||||
|
|
||||||
|
Beatmap.SetDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public virtual void SetUp() => Schedule(() =>
|
||||||
|
{
|
||||||
|
Child = new OsuScreenStack(songSelect = new DummySongSelect())
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if <see cref="PlayerLoader"/> properly triggers the visual settings preview when a user hovers over the visual settings panel.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void PlayerLoaderSettingsHoverTest()
|
||||||
|
{
|
||||||
|
setupUserSettings();
|
||||||
|
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer { BlockLoad = true })));
|
||||||
|
AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false);
|
||||||
|
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||||
|
AddStep("Trigger background preview", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
||||||
|
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
||||||
|
});
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
|
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// In the case of a user triggering the dim preview the instant player gets loaded, then moving the cursor off of the visual settings:
|
||||||
|
/// The OnHover of PlayerLoader will trigger, which could potentially cause visual settings to be unapplied unless checked for in PlayerLoader.
|
||||||
|
/// We need to check that in this scenario, the dim and blur is still properly applied after entering player.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void PlayerLoaderTransitionTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
AddStep("Trigger hover event", () => playerLoader.TriggerOnHover());
|
||||||
|
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Make sure the background is fully invisible (Alpha == 0) when the background should be disabled by the storyboard.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void StoryboardBackgroundVisibilityTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
createFakeStoryboard();
|
||||||
|
AddStep("Enable Storyboard", () =>
|
||||||
|
{
|
||||||
|
player.ReplacesBackground.Value = true;
|
||||||
|
player.StoryboardEnabled.Value = true;
|
||||||
|
});
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible);
|
||||||
|
AddStep("Disable Storyboard", () =>
|
||||||
|
{
|
||||||
|
player.ReplacesBackground.Value = false;
|
||||||
|
player.StoryboardEnabled.Value = false;
|
||||||
|
});
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When exiting player, the screen that it suspends/exits to needs to have a fully visible (Alpha == 1) background.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void StoryboardTransitionTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
createFakeStoryboard();
|
||||||
|
AddStep("Exit to song select", () => player.Exit());
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a background.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void DisableUserDimBackgroundTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
|
AddStep("Enable user dim", () => songSelect.DimEnabled.Value = false);
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled());
|
||||||
|
AddStep("Disable user dim", () => songSelect.DimEnabled.Value = true);
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a storyboard.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void DisableUserDimStoryboardTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
createFakeStoryboard();
|
||||||
|
AddStep("Enable Storyboard", () =>
|
||||||
|
{
|
||||||
|
player.ReplacesBackground.Value = true;
|
||||||
|
player.StoryboardEnabled.Value = true;
|
||||||
|
});
|
||||||
|
AddStep("Enable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = true);
|
||||||
|
AddStep("Set dim level to 1", () => songSelect.DimLevel.Value = 1f);
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Storyboard is invisible", () => !player.IsStoryboardVisible);
|
||||||
|
AddStep("Disable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = false);
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Storyboard is visible", () => player.IsStoryboardVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the visual settings container retains dim and blur when pausing
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void PauseTest()
|
||||||
|
{
|
||||||
|
performFullSetup(true);
|
||||||
|
AddStep("Pause", () => player.Pause());
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
|
AddStep("Unpause", () => player.Resume());
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the visual settings container removes user dim when suspending <see cref="Player"/> for <see cref="SoloResults"/>
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TransitionTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
FadeAccessibleResults results = null;
|
||||||
|
AddStep("Transition to Results", () => player.Push(results =
|
||||||
|
new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
||||||
|
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is undimmed, original background retained", () =>
|
||||||
|
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if background gets undimmed and unblurred when leaving <see cref="Player"/> for <see cref="PlaySongSelect"/>
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TransitionOutTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
AddStep("Exit to song select", () => player.Exit());
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if hovering on the visual settings dialogue after resuming from player still previews the background dim.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void ResumeFromPlayerTest()
|
||||||
|
{
|
||||||
|
performFullSetup();
|
||||||
|
AddStep("Move mouse to Visual Settings", () => InputManager.MoveMouseTo(playerLoader.VisualSettingsPos));
|
||||||
|
AddStep("Resume PlayerLoader", () => player.Restart());
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||||
|
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||||
|
waitForDim();
|
||||||
|
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitForDim() => AddWaitStep("Wait for dim", 5);
|
||||||
|
|
||||||
|
private void createFakeStoryboard() => AddStep("Create storyboard", () =>
|
||||||
|
{
|
||||||
|
player.StoryboardEnabled.Value = false;
|
||||||
|
player.ReplacesBackground.Value = false;
|
||||||
|
player.DimmableStoryboard.Add(new OsuSpriteText
|
||||||
|
{
|
||||||
|
Size = new Vector2(500, 50),
|
||||||
|
Alpha = 1,
|
||||||
|
Colour = Color4.White,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Text = "THIS IS A STORYBOARD",
|
||||||
|
Font = new FontUsage(size: 50)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
private void performFullSetup(bool allowPause = false)
|
||||||
|
{
|
||||||
|
setupUserSettings();
|
||||||
|
|
||||||
|
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer(allowPause))));
|
||||||
|
|
||||||
|
AddUntilStep("Wait for Player Loader to load", () => playerLoader.IsLoaded);
|
||||||
|
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||||
|
AddUntilStep("Wait for player to load", () => player.IsLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupUserSettings()
|
||||||
|
{
|
||||||
|
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
||||||
|
AddStep("Set default user settings", () =>
|
||||||
|
{
|
||||||
|
SelectedMods.Value = SelectedMods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
||||||
|
songSelect.DimLevel.Value = 0.7f;
|
||||||
|
songSelect.BlurLevel.Value = 0.4f;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
rulesets?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DummySongSelect : PlaySongSelect
|
||||||
|
{
|
||||||
|
protected override BackgroundScreen CreateBackground()
|
||||||
|
{
|
||||||
|
FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
DimEnabled.BindTo(background.EnableUserDim);
|
||||||
|
return background;
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
||||||
|
public readonly Bindable<double> DimLevel = new Bindable<double>();
|
||||||
|
public readonly Bindable<double> BlurLevel = new Bindable<double>();
|
||||||
|
|
||||||
|
public new BeatmapCarousel Carousel => base.Carousel;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
config.BindWith(OsuSetting.DimLevel, DimLevel);
|
||||||
|
config.BindWith(OsuSetting.BlurLevel, BlurLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1f - ((FadeAccessibleBackground)Background).CurrentDim);
|
||||||
|
|
||||||
|
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
||||||
|
|
||||||
|
public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * BackgroundScreenBeatmap.USER_BLUR_FACTOR);
|
||||||
|
|
||||||
|
public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0);
|
||||||
|
|
||||||
|
public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0;
|
||||||
|
|
||||||
|
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
||||||
|
|
||||||
|
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether or not the original background (The one created in DummySongSelect) is still the current background</returns>
|
||||||
|
public bool IsBackgroundCurrent() => ((FadeAccessibleBackground)Background).IsCurrentScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class FadeAccessibleResults : SoloResults
|
||||||
|
{
|
||||||
|
public FadeAccessibleResults(ScoreInfo score)
|
||||||
|
: base(score)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
|
||||||
|
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestPlayer : Visual.TestPlayer
|
||||||
|
{
|
||||||
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
|
||||||
|
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
|
||||||
|
|
||||||
|
// Whether or not the player should be allowed to load.
|
||||||
|
public bool BlockLoad;
|
||||||
|
|
||||||
|
public Bindable<bool> StoryboardEnabled;
|
||||||
|
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>();
|
||||||
|
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
||||||
|
|
||||||
|
public TestPlayer(bool allowPause = true)
|
||||||
|
: base(allowPause)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsStoryboardVisible => DimmableStoryboard.ContentDisplayed;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config, CancellationToken token)
|
||||||
|
{
|
||||||
|
while (BlockLoad && !token.IsCancellationRequested)
|
||||||
|
Thread.Sleep(1);
|
||||||
|
|
||||||
|
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
|
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
||||||
|
DrawableRuleset.IsPaused.BindTo(IsPaused);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestPlayerLoader : PlayerLoader
|
||||||
|
{
|
||||||
|
public VisualSettings VisualSettingsPos => VisualSettings;
|
||||||
|
public BackgroundScreen ScreenPos => Background;
|
||||||
|
|
||||||
|
public TestPlayerLoader(Player player)
|
||||||
|
: base(() => player)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TriggerOnHover() => OnHover(new HoverEvent(new InputState()));
|
||||||
|
|
||||||
|
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||||
|
|
||||||
|
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
||||||
|
{
|
||||||
|
protected override DimmableBackground CreateFadeContainer() => dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
|
public Color4 CurrentColour => dimmable.CurrentColour;
|
||||||
|
|
||||||
|
public float CurrentAlpha => dimmable.CurrentAlpha;
|
||||||
|
|
||||||
|
public float CurrentDim => dimmable.DimLevel;
|
||||||
|
|
||||||
|
public Vector2 CurrentBlur => Background.BlurSigma;
|
||||||
|
|
||||||
|
private TestDimmableBackground dimmable;
|
||||||
|
|
||||||
|
public FadeAccessibleBackground(WorkingBeatmap beatmap)
|
||||||
|
: base(beatmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground
|
||||||
|
{
|
||||||
|
public Color4 CurrentColour => Content.Colour;
|
||||||
|
public float CurrentAlpha => Content.Alpha;
|
||||||
|
|
||||||
|
public new float DimLevel => base.DimLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,423 +1,98 @@
|
|||||||
// 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 System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Framework.Input.States;
|
|
||||||
using osu.Framework.Platform;
|
|
||||||
using osu.Framework.Screens;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osu.Game.Screens;
|
|
||||||
using osu.Game.Screens.Backgrounds;
|
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
using osu.Game.Screens.Play.PlayerSettings;
|
|
||||||
using osu.Game.Screens.Select;
|
|
||||||
using osu.Game.Tests.Resources;
|
|
||||||
using osu.Game.Users;
|
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Background
|
namespace osu.Game.Tests.Visual.Background
|
||||||
{
|
{
|
||||||
[TestFixture]
|
public class TestSceneUserDimContainer : OsuTestScene
|
||||||
public class TestSceneUserDimContainer : ManualInputManagerTestScene
|
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
private TestUserDimContainer userDimContainer;
|
||||||
{
|
|
||||||
typeof(ScreenWithBeatmapBackground),
|
|
||||||
typeof(PlayerLoader),
|
|
||||||
typeof(Player),
|
|
||||||
typeof(UserDimContainer),
|
|
||||||
typeof(OsuScreen)
|
|
||||||
};
|
|
||||||
|
|
||||||
private DummySongSelect songSelect;
|
private readonly BindableBool isBreakTime = new BindableBool();
|
||||||
private TestPlayerLoader playerLoader;
|
|
||||||
private TestPlayer player;
|
private Bindable<bool> lightenDuringBreaks = new Bindable<bool>();
|
||||||
private BeatmapManager manager;
|
|
||||||
private RulesetStore rulesets;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost host, AudioManager audio)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
lightenDuringBreaks = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks);
|
||||||
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
|
||||||
Dependencies.Cache(new OsuConfigManager(LocalStorage));
|
|
||||||
|
|
||||||
manager.Import(TestResources.GetTestBeatmapForImport()).Wait();
|
|
||||||
|
|
||||||
Beatmap.SetDefault();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public virtual void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = new OsuScreenStack(songSelect = new DummySongSelect())
|
Child = userDimContainer = new TestUserDimContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.White,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
userDimContainer.IsBreakTime.BindTo(isBreakTime);
|
||||||
|
isBreakTime.Value = false;
|
||||||
|
|
||||||
|
lightenDuringBreaks.Value = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
private const float test_user_dim = 0.6f;
|
||||||
/// Check if <see cref="PlayerLoader"/> properly triggers the visual settings preview when a user hovers over the visual settings panel.
|
private const float test_user_dim_lightened = test_user_dim - UserDimContainer.BREAK_LIGHTEN_AMOUNT;
|
||||||
/// </summary>
|
|
||||||
|
[TestCase(test_user_dim, test_user_dim_lightened)]
|
||||||
|
[TestCase(0.2f, 0.0f)]
|
||||||
|
[TestCase(0.0f, 0.0f)]
|
||||||
|
public void TestBreakLightening(float userDim, float expectedBreakDim)
|
||||||
|
{
|
||||||
|
AddStep($"set dim level {userDim}", () => userDimContainer.UserDimLevel.Value = userDim);
|
||||||
|
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||||
|
|
||||||
|
AddStep("set break", () => isBreakTime.Value = true);
|
||||||
|
AddUntilStep("has lightened", () => userDimContainer.DimEqual(expectedBreakDim));
|
||||||
|
AddStep("clear break", () => isBreakTime.Value = false);
|
||||||
|
AddUntilStep("not lightened", () => userDimContainer.DimEqual(userDim));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PlayerLoaderSettingsHoverTest()
|
public void TestEnableSettingDuringBreak()
|
||||||
{
|
{
|
||||||
setupUserSettings();
|
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
|
||||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer { BlockLoad = true })));
|
|
||||||
AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false);
|
AddStep("set break", () => isBreakTime.Value = true);
|
||||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||||
AddStep("Trigger background preview", () =>
|
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||||
{
|
AddUntilStep("has lightened", () => userDimContainer.DimEqual(test_user_dim_lightened));
|
||||||
InputManager.MoveMouseTo(playerLoader.ScreenPos);
|
|
||||||
InputManager.MoveMouseTo(playerLoader.VisualSettingsPos);
|
|
||||||
});
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
|
||||||
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// In the case of a user triggering the dim preview the instant player gets loaded, then moving the cursor off of the visual settings:
|
|
||||||
/// The OnHover of PlayerLoader will trigger, which could potentially cause visual settings to be unapplied unless checked for in PlayerLoader.
|
|
||||||
/// We need to check that in this scenario, the dim and blur is still properly applied after entering player.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
[Test]
|
||||||
public void PlayerLoaderTransitionTest()
|
public void TestDisableSettingDuringBreak()
|
||||||
{
|
{
|
||||||
performFullSetup();
|
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
|
||||||
AddStep("Trigger hover event", () => playerLoader.TriggerOnHover());
|
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||||
AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent());
|
|
||||||
waitForDim();
|
AddStep("set break", () => isBreakTime.Value = true);
|
||||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
AddUntilStep("has lightened", () => userDimContainer.DimEqual(test_user_dim_lightened));
|
||||||
|
AddStep("clear lighten during break", () => lightenDuringBreaks.Value = false);
|
||||||
|
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||||
|
AddStep("clear break", () => isBreakTime.Value = false);
|
||||||
|
AddUntilStep("not lightened", () => userDimContainer.DimEqual(test_user_dim));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private class TestUserDimContainer : UserDimContainer
|
||||||
/// Make sure the background is fully invisible (Alpha == 0) when the background should be disabled by the storyboard.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void StoryboardBackgroundVisibilityTest()
|
|
||||||
{
|
{
|
||||||
performFullSetup();
|
public bool DimEqual(float expectedDimLevel) => Content.Colour == OsuColour.Gray(1f - expectedDimLevel);
|
||||||
createFakeStoryboard();
|
|
||||||
AddStep("Enable Storyboard", () =>
|
|
||||||
{
|
|
||||||
player.ReplacesBackground.Value = true;
|
|
||||||
player.StoryboardEnabled.Value = true;
|
|
||||||
});
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible);
|
|
||||||
AddStep("Disable Storyboard", () =>
|
|
||||||
{
|
|
||||||
player.ReplacesBackground.Value = false;
|
|
||||||
player.StoryboardEnabled.Value = false;
|
|
||||||
});
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
public new Bindable<double> UserDimLevel => base.UserDimLevel;
|
||||||
/// When exiting player, the screen that it suspends/exits to needs to have a fully visible (Alpha == 1) background.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void StoryboardTransitionTest()
|
|
||||||
{
|
|
||||||
performFullSetup();
|
|
||||||
createFakeStoryboard();
|
|
||||||
AddStep("Exit to song select", () => player.Exit());
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Background is visible", () => songSelect.IsBackgroundVisible());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a background.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void DisableUserDimBackgroundTest()
|
|
||||||
{
|
|
||||||
performFullSetup();
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
|
||||||
AddStep("Enable user dim", () => songSelect.DimEnabled.Value = false);
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled());
|
|
||||||
AddStep("Disable user dim", () => songSelect.DimEnabled.Value = true);
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ensure <see cref="UserDimContainer"/> is properly accepting user-defined visual changes for a storyboard.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void DisableUserDimStoryboardTest()
|
|
||||||
{
|
|
||||||
performFullSetup();
|
|
||||||
createFakeStoryboard();
|
|
||||||
AddStep("Enable Storyboard", () =>
|
|
||||||
{
|
|
||||||
player.ReplacesBackground.Value = true;
|
|
||||||
player.StoryboardEnabled.Value = true;
|
|
||||||
});
|
|
||||||
AddStep("Enable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = true);
|
|
||||||
AddStep("Set dim level to 1", () => songSelect.DimLevel.Value = 1f);
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Storyboard is invisible", () => !player.IsStoryboardVisible);
|
|
||||||
AddStep("Disable user dim", () => player.DimmableStoryboard.EnableUserDim.Value = false);
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Storyboard is visible", () => player.IsStoryboardVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if the visual settings container retains dim and blur when pausing
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void PauseTest()
|
|
||||||
{
|
|
||||||
performFullSetup(true);
|
|
||||||
AddStep("Pause", () => player.Pause());
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
|
||||||
AddStep("Unpause", () => player.Resume());
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if the visual settings container removes user dim when suspending <see cref="Player"/> for <see cref="SoloResults"/>
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TransitionTest()
|
|
||||||
{
|
|
||||||
performFullSetup();
|
|
||||||
FadeAccessibleResults results = null;
|
|
||||||
AddStep("Transition to Results", () => player.Push(results =
|
|
||||||
new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } })));
|
|
||||||
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is undimmed, original background retained", () =>
|
|
||||||
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if background gets undimmed and unblurred when leaving <see cref="Player"/> for <see cref="PlaySongSelect"/>
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void TransitionOutTest()
|
|
||||||
{
|
|
||||||
performFullSetup();
|
|
||||||
AddStep("Exit to song select", () => player.Exit());
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if hovering on the visual settings dialogue after resuming from player still previews the background dim.
|
|
||||||
/// </summary>
|
|
||||||
[Test]
|
|
||||||
public void ResumeFromPlayerTest()
|
|
||||||
{
|
|
||||||
performFullSetup();
|
|
||||||
AddStep("Move mouse to Visual Settings", () => InputManager.MoveMouseTo(playerLoader.VisualSettingsPos));
|
|
||||||
AddStep("Resume PlayerLoader", () => player.Restart());
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
|
||||||
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
|
||||||
waitForDim();
|
|
||||||
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void waitForDim() => AddWaitStep("Wait for dim", 5);
|
|
||||||
|
|
||||||
private void createFakeStoryboard() => AddStep("Create storyboard", () =>
|
|
||||||
{
|
|
||||||
player.StoryboardEnabled.Value = false;
|
|
||||||
player.ReplacesBackground.Value = false;
|
|
||||||
player.DimmableStoryboard.Add(new OsuSpriteText
|
|
||||||
{
|
|
||||||
Size = new Vector2(500, 50),
|
|
||||||
Alpha = 1,
|
|
||||||
Colour = Color4.White,
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Text = "THIS IS A STORYBOARD",
|
|
||||||
Font = new FontUsage(size: 50)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
private void performFullSetup(bool allowPause = false)
|
|
||||||
{
|
|
||||||
setupUserSettings();
|
|
||||||
|
|
||||||
AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer(allowPause))));
|
|
||||||
|
|
||||||
AddUntilStep("Wait for Player Loader to load", () => playerLoader.IsLoaded);
|
|
||||||
AddStep("Move mouse to center of screen", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
|
||||||
AddUntilStep("Wait for player to load", () => player.IsLoaded);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupUserSettings()
|
|
||||||
{
|
|
||||||
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
|
||||||
AddStep("Set default user settings", () =>
|
|
||||||
{
|
|
||||||
Mods.Value = Mods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
|
||||||
songSelect.DimLevel.Value = 0.7f;
|
|
||||||
songSelect.BlurLevel.Value = 0.4f;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
rulesets?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DummySongSelect : PlaySongSelect
|
|
||||||
{
|
|
||||||
protected override BackgroundScreen CreateBackground()
|
|
||||||
{
|
|
||||||
FadeAccessibleBackground background = new FadeAccessibleBackground(Beatmap.Value);
|
|
||||||
DimEnabled.BindTo(background.EnableUserDim);
|
|
||||||
return background;
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly Bindable<bool> DimEnabled = new Bindable<bool>();
|
|
||||||
public readonly Bindable<double> DimLevel = new Bindable<double>();
|
|
||||||
public readonly Bindable<double> BlurLevel = new Bindable<double>();
|
|
||||||
|
|
||||||
public new BeatmapCarousel Carousel => base.Carousel;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
|
||||||
config.BindWith(OsuSetting.DimLevel, DimLevel);
|
|
||||||
config.BindWith(OsuSetting.BlurLevel, BlurLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsBackgroundDimmed() => ((FadeAccessibleBackground)Background).CurrentColour == OsuColour.Gray(1 - (float)DimLevel.Value);
|
|
||||||
|
|
||||||
public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White;
|
|
||||||
|
|
||||||
public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * BackgroundScreenBeatmap.USER_BLUR_FACTOR);
|
|
||||||
|
|
||||||
public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0);
|
|
||||||
|
|
||||||
public bool IsBackgroundInvisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 0;
|
|
||||||
|
|
||||||
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
|
||||||
|
|
||||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Whether or not the original background (The one created in DummySongSelect) is still the current background</returns>
|
|
||||||
public bool IsBackgroundCurrent() => ((FadeAccessibleBackground)Background).IsCurrentScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class FadeAccessibleResults : SoloResults
|
|
||||||
{
|
|
||||||
public FadeAccessibleResults(ScoreInfo score)
|
|
||||||
: base(score)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
|
||||||
|
|
||||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestPlayer : Visual.TestPlayer
|
|
||||||
{
|
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
|
||||||
|
|
||||||
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
|
|
||||||
|
|
||||||
// Whether or not the player should be allowed to load.
|
|
||||||
public bool BlockLoad;
|
|
||||||
|
|
||||||
public Bindable<bool> StoryboardEnabled;
|
|
||||||
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>();
|
|
||||||
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
|
||||||
|
|
||||||
public TestPlayer(bool allowPause = true)
|
|
||||||
: base(allowPause)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsStoryboardVisible => DimmableStoryboard.ContentDisplayed;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config, CancellationToken token)
|
|
||||||
{
|
|
||||||
while (BlockLoad && !token.IsCancellationRequested)
|
|
||||||
Thread.Sleep(1);
|
|
||||||
|
|
||||||
StoryboardEnabled = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
|
||||||
ReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
|
|
||||||
DrawableRuleset.IsPaused.BindTo(IsPaused);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestPlayerLoader : PlayerLoader
|
|
||||||
{
|
|
||||||
public VisualSettings VisualSettingsPos => VisualSettings;
|
|
||||||
public BackgroundScreen ScreenPos => Background;
|
|
||||||
|
|
||||||
public TestPlayerLoader(Player player)
|
|
||||||
: base(() => player)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TriggerOnHover() => OnHover(new HoverEvent(new InputState()));
|
|
||||||
|
|
||||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
|
||||||
{
|
|
||||||
protected override DimmableBackground CreateFadeContainer() => dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes.Both };
|
|
||||||
|
|
||||||
public Color4 CurrentColour => dimmable.CurrentColour;
|
|
||||||
|
|
||||||
public float CurrentAlpha => dimmable.CurrentAlpha;
|
|
||||||
|
|
||||||
public Vector2 CurrentBlur => Background.BlurSigma;
|
|
||||||
|
|
||||||
private TestDimmableBackground dimmable;
|
|
||||||
|
|
||||||
public FadeAccessibleBackground(WorkingBeatmap beatmap)
|
|
||||||
: base(beatmap)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground
|
|
||||||
{
|
|
||||||
public Color4 CurrentColour => Content.Colour;
|
|
||||||
public float CurrentAlpha => Content.Alpha;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Mods.Value = Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||||
return new ScoreAccessiblePlayer();
|
return new ScoreAccessiblePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
var ruleset = new TestScrollingRuleset();
|
var ruleset = new TestScrollingRuleset();
|
||||||
|
|
||||||
drawableRuleset = (TestDrawableScrollingRuleset)ruleset.CreateDrawableRulesetWith(CreateWorkingBeatmap(beatmap), Array.Empty<Mod>());
|
drawableRuleset = (TestDrawableScrollingRuleset)ruleset.CreateDrawableRulesetWith(CreateWorkingBeatmap(beatmap).GetPlayableBeatmap(ruleset.RulesetInfo));
|
||||||
drawableRuleset.FrameStablePlayback = false;
|
drawableRuleset.FrameStablePlayback = false;
|
||||||
|
|
||||||
overrideAction?.Invoke(drawableRuleset);
|
overrideAction?.Invoke(drawableRuleset);
|
||||||
@ -201,7 +201,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type) => throw new NotImplementedException();
|
public override IEnumerable<Mod> GetModsFor(ModType type) => throw new NotImplementedException();
|
||||||
|
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new TestDrawableScrollingRuleset(this, beatmap, mods);
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new TestDrawableScrollingRuleset(this, beatmap, mods);
|
||||||
|
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TestBeatmapConverter(beatmap);
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TestBeatmapConverter(beatmap);
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public new Bindable<double> TimeRange => base.TimeRange;
|
public new Bindable<double> TimeRange => base.TimeRange;
|
||||||
|
|
||||||
public TestDrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public TestDrawableScrollingRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
TimeRange.Value = time_range;
|
TimeRange.Value = time_range;
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Mods.Value = Array.Empty<Mod>();
|
SelectedMods.Value = Array.Empty<Mod>();
|
||||||
return new FailPlayer();
|
return new FailPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Mods.Value = Array.Empty<Mod>();
|
SelectedMods.Value = Array.Empty<Mod>();
|
||||||
return new FailPlayer();
|
return new FailPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
protected override Player CreatePlayer(Ruleset ruleset)
|
protected override Player CreatePlayer(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
Mods.Value = Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||||
return new RulesetExposingPlayer();
|
return new RulesetExposingPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
beforeLoadAction?.Invoke();
|
beforeLoadAction?.Invoke();
|
||||||
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
|
||||||
foreach (var mod in Mods.Value.OfType<IApplicableToTrack>())
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToTrack>())
|
||||||
mod.ApplyToTrack(Beatmap.Value.Track);
|
mod.ApplyToTrack(Beatmap.Value.Track);
|
||||||
|
|
||||||
InputManager.Child = container = new TestPlayerLoaderContainer(
|
InputManager.Child = container = new TestPlayerLoaderContainer(
|
||||||
@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestEarlyExit()
|
public void TestEarlyExit()
|
||||||
{
|
{
|
||||||
AddStep("load dummy beatmap", () => ResetPlayer(false, () => Mods.Value = new[] { new OsuModNightcore() }));
|
AddStep("load dummy beatmap", () => ResetPlayer(false, () => SelectedMods.Value = new[] { new OsuModNightcore() }));
|
||||||
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for current", () => loader.IsCurrentScreen());
|
||||||
AddAssert("mod rate applied", () => Beatmap.Value.Track.Rate != 1);
|
AddAssert("mod rate applied", () => Beatmap.Value.Track.Rate != 1);
|
||||||
AddStep("exit loader", () => loader.Exit());
|
AddStep("exit loader", () => loader.Exit());
|
||||||
@ -123,7 +123,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
TestMod playerMod1 = null;
|
TestMod playerMod1 = null;
|
||||||
TestMod playerMod2 = null;
|
TestMod playerMod2 = null;
|
||||||
|
|
||||||
AddStep("load player", () => { ResetPlayer(true, () => Mods.Value = new[] { gameMod = new TestMod() }); });
|
AddStep("load player", () => { ResetPlayer(true, () => SelectedMods.Value = new[] { gameMod = new TestMod() }); });
|
||||||
|
|
||||||
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen());
|
||||||
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
AddStep("mouse in centre", () => InputManager.MoveMouseTo(loader.ScreenSpaceDrawQuad.Centre));
|
||||||
|
@ -256,17 +256,17 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
AddStep("change ruleset", () =>
|
AddStep("change ruleset", () =>
|
||||||
{
|
{
|
||||||
Mods.ValueChanged += onModChange;
|
SelectedMods.ValueChanged += onModChange;
|
||||||
songSelect.Ruleset.ValueChanged += onRulesetChange;
|
songSelect.Ruleset.ValueChanged += onRulesetChange;
|
||||||
|
|
||||||
Ruleset.Value = new TaikoRuleset().RulesetInfo;
|
Ruleset.Value = new TaikoRuleset().RulesetInfo;
|
||||||
|
|
||||||
Mods.ValueChanged -= onModChange;
|
SelectedMods.ValueChanged -= onModChange;
|
||||||
songSelect.Ruleset.ValueChanged -= onRulesetChange;
|
songSelect.Ruleset.ValueChanged -= onRulesetChange;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex);
|
AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex);
|
||||||
AddAssert("empty mods", () => !Mods.Value.Any());
|
AddAssert("empty mods", () => !SelectedMods.Value.Any());
|
||||||
|
|
||||||
void onModChange(ValueChangedEvent<IReadOnlyList<Mod>> e) => modChangeIndex = actionIndex++;
|
void onModChange(ValueChangedEvent<IReadOnlyList<Mod>> e) => modChangeIndex = actionIndex++;
|
||||||
void onRulesetChange(ValueChangedEvent<RulesetInfo> e) => rulesetChangeIndex = actionIndex++;
|
void onRulesetChange(ValueChangedEvent<RulesetInfo> e) => rulesetChangeIndex = actionIndex++;
|
||||||
@ -275,7 +275,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestModsRetainedBetweenSongSelect()
|
public void TestModsRetainedBetweenSongSelect()
|
||||||
{
|
{
|
||||||
AddAssert("empty mods", () => !Mods.Value.Any());
|
AddAssert("empty mods", () => !SelectedMods.Value.Any());
|
||||||
|
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
|
|
||||||
AddAssert("mods retained", () => Mods.Value.Any());
|
AddAssert("mods retained", () => SelectedMods.Value.Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -332,7 +332,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private void checkMusicPlaying(bool playing) =>
|
private void checkMusicPlaying(bool playing) =>
|
||||||
AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing);
|
AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing);
|
||||||
|
|
||||||
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => Mods.Value = mods);
|
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => SelectedMods.Value = mods);
|
||||||
|
|
||||||
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
||||||
|
|
||||||
|
@ -8,13 +8,16 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Overlays.Mods.Sections;
|
using osu.Game.Overlays.Mods.Sections;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mania;
|
||||||
using osu.Game.Rulesets.Mania.Mods;
|
using osu.Game.Rulesets.Mania.Mods;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
@ -48,42 +51,48 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
private void load(RulesetStore rulesets)
|
private void load(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
|
}
|
||||||
|
|
||||||
Add(modSelect = new TestModSelectOverlay
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
modSelect = new TestModSelectOverlay
|
||||||
Origin = Anchor.BottomCentre,
|
{
|
||||||
Anchor = Anchor.BottomCentre,
|
RelativeSizeAxes = Axes.X,
|
||||||
});
|
Origin = Anchor.BottomCentre,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
},
|
||||||
|
|
||||||
Add(modDisplay = new ModDisplay
|
modDisplay = new ModDisplay
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Position = new Vector2(0, 25),
|
Position = new Vector2(0, 25),
|
||||||
});
|
Current = { BindTarget = modSelect.SelectedMods }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
modDisplay.Current.UnbindBindings();
|
[SetUpSteps]
|
||||||
modDisplay.Current.BindTo(modSelect.SelectedMods);
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
AddStep("Show", modSelect.Show);
|
AddStep("show", () => modSelect.Show());
|
||||||
AddStep("Toggle", modSelect.ToggleVisibility);
|
|
||||||
AddStep("Toggle", modSelect.ToggleVisibility);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestOsuMods()
|
public void TestOsuMods()
|
||||||
{
|
{
|
||||||
var ruleset = rulesets.AvailableRulesets.First(r => r.ID == 0);
|
changeRuleset(0);
|
||||||
changeRuleset(ruleset);
|
|
||||||
|
|
||||||
var instance = ruleset.CreateInstance();
|
var osu = new OsuRuleset();
|
||||||
|
|
||||||
var easierMods = instance.GetModsFor(ModType.DifficultyReduction);
|
var easierMods = osu.GetModsFor(ModType.DifficultyReduction);
|
||||||
var harderMods = instance.GetModsFor(ModType.DifficultyIncrease);
|
var harderMods = osu.GetModsFor(ModType.DifficultyIncrease);
|
||||||
|
|
||||||
var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
|
var noFailMod = osu.GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail);
|
||||||
var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);
|
var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);
|
||||||
|
|
||||||
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
|
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
|
||||||
@ -97,8 +106,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
testMultiMod(doubleTimeMod);
|
testMultiMod(doubleTimeMod);
|
||||||
testIncompatibleMods(easy, hardRock);
|
testIncompatibleMods(easy, hardRock);
|
||||||
testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
|
testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
|
||||||
testMultiplierTextColour(noFailMod, modSelect.LowMultiplierColour);
|
testMultiplierTextColour(noFailMod, () => modSelect.LowMultiplierColour);
|
||||||
testMultiplierTextColour(hiddenMod, modSelect.HighMultiplierColour);
|
testMultiplierTextColour(hiddenMod, () => modSelect.HighMultiplierColour);
|
||||||
|
|
||||||
testUnimplementedMod(spunOutMod);
|
testUnimplementedMod(spunOutMod);
|
||||||
}
|
}
|
||||||
@ -106,37 +115,31 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestManiaMods()
|
public void TestManiaMods()
|
||||||
{
|
{
|
||||||
var ruleset = rulesets.AvailableRulesets.First(r => r.ID == 3);
|
changeRuleset(3);
|
||||||
changeRuleset(ruleset);
|
|
||||||
|
|
||||||
testRankedText(ruleset.CreateInstance().GetModsFor(ModType.Conversion).First(m => m is ManiaModRandom));
|
testRankedText(new ManiaRuleset().GetModsFor(ModType.Conversion).First(m => m is ManiaModRandom));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRulesetChanges()
|
public void TestRulesetChanges()
|
||||||
{
|
{
|
||||||
var rulesetOsu = rulesets.AvailableRulesets.First(r => r.ID == 0);
|
changeRuleset(0);
|
||||||
var rulesetMania = rulesets.AvailableRulesets.First(r => r.ID == 3);
|
|
||||||
|
|
||||||
changeRuleset(null);
|
var noFailMod = new OsuRuleset().GetModsFor(ModType.DifficultyReduction).FirstOrDefault(m => m is OsuModNoFail);
|
||||||
|
|
||||||
var instance = rulesetOsu.CreateInstance();
|
AddStep("set mods externally", () => { SelectedMods.Value = new[] { noFailMod }; });
|
||||||
var easierMods = instance.GetModsFor(ModType.DifficultyReduction);
|
|
||||||
var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
|
|
||||||
|
|
||||||
AddStep("set mods externally", () => { modDisplay.Current.Value = new[] { noFailMod }; });
|
changeRuleset(0);
|
||||||
|
|
||||||
changeRuleset(rulesetOsu);
|
|
||||||
|
|
||||||
AddAssert("ensure mods still selected", () => modDisplay.Current.Value.Single(m => m is OsuModNoFail) != null);
|
AddAssert("ensure mods still selected", () => modDisplay.Current.Value.Single(m => m is OsuModNoFail) != null);
|
||||||
|
|
||||||
changeRuleset(rulesetMania);
|
changeRuleset(3);
|
||||||
|
|
||||||
AddAssert("ensure mods not selected", () => !modDisplay.Current.Value.Any(m => m is OsuModNoFail));
|
AddAssert("ensure mods not selected", () => modDisplay.Current.Value.Count == 0);
|
||||||
|
|
||||||
changeRuleset(rulesetOsu);
|
changeRuleset(0);
|
||||||
|
|
||||||
AddAssert("ensure mods not selected", () => !modDisplay.Current.Value.Any());
|
AddAssert("ensure mods not selected", () => modDisplay.Current.Value.Count == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSingleMod(Mod mod)
|
private void testSingleMod(Mod mod)
|
||||||
@ -198,19 +201,19 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
selectNext(mod);
|
selectNext(mod);
|
||||||
|
|
||||||
AddAssert("check for any selection", () => modSelect.SelectedMods.Value.Any());
|
AddAssert("check for any selection", () => modSelect.SelectedMods.Value.Any());
|
||||||
AddStep("deselect all", modSelect.DeselectAllButton.Action.Invoke);
|
AddStep("deselect all", () => modSelect.DeselectAllButton.Action.Invoke());
|
||||||
AddAssert("check for no selection", () => !modSelect.SelectedMods.Value.Any());
|
AddAssert("check for no selection", () => !modSelect.SelectedMods.Value.Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testMultiplierTextColour(Mod mod, Color4 colour)
|
private void testMultiplierTextColour(Mod mod, Func<Color4> getCorrectColour)
|
||||||
{
|
{
|
||||||
checkLabelColor(Color4.White);
|
checkLabelColor(() => Color4.White);
|
||||||
selectNext(mod);
|
selectNext(mod);
|
||||||
AddWaitStep("wait for changing colour", 1);
|
AddWaitStep("wait for changing colour", 1);
|
||||||
checkLabelColor(colour);
|
checkLabelColor(getCorrectColour);
|
||||||
selectPrevious(mod);
|
selectPrevious(mod);
|
||||||
AddWaitStep("wait for changing colour", 1);
|
AddWaitStep("wait for changing colour", 1);
|
||||||
checkLabelColor(Color4.White);
|
checkLabelColor(() => Color4.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testRankedText(Mod mod)
|
private void testRankedText(Mod mod)
|
||||||
@ -235,9 +238,9 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeRuleset(RulesetInfo ruleset)
|
private void changeRuleset(int? id)
|
||||||
{
|
{
|
||||||
AddStep($"change ruleset to {ruleset}", () => { Ruleset.Value = ruleset; });
|
AddStep($"change ruleset to {(id?.ToString() ?? "none")}", () => { Ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(r => r.ID == id); });
|
||||||
waitForLoad();
|
waitForLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +256,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkLabelColor(Color4 color) => AddAssert("check label has expected colour", () => modSelect.MultiplierLabel.Colour.AverageColour == color);
|
private void checkLabelColor(Func<Color4> getColour) => AddAssert("check label has expected colour", () => modSelect.MultiplierLabel.Colour.AverageColour == getColour());
|
||||||
|
|
||||||
private class TestModSelectOverlay : ModSelectOverlay
|
private class TestModSelectOverlay : ModSelectOverlay
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
private TestModSelectOverlay modSelect;
|
private TestModSelectOverlay modSelect;
|
||||||
|
|
||||||
Mod testCustomisableMod = new TestModCustomisable1();
|
private readonly Mod testCustomisableMod = new TestModCustomisable1();
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestButtonShowsOnCustomisableMod()
|
public void TestButtonShowsOnCustomisableMod()
|
||||||
@ -43,11 +43,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestButtonShowsOnModAlreadyAdded()
|
public void TestButtonShowsOnModAlreadyAdded()
|
||||||
{
|
{
|
||||||
AddStep("set active mods", () => Mods.Value = new List<Mod> { testCustomisableMod });
|
AddStep("set active mods", () => SelectedMods.Value = new List<Mod> { testCustomisableMod });
|
||||||
|
|
||||||
createModSelect();
|
createModSelect();
|
||||||
|
|
||||||
AddAssert("mods still active", () => Mods.Value.Count == 1);
|
AddAssert("mods still active", () => SelectedMods.Value.Count == 1);
|
||||||
|
|
||||||
AddStep("open", () => modSelect.Show());
|
AddStep("open", () => modSelect.Show());
|
||||||
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
|
AddAssert("button enabled", () => modSelect.CustomiseButton.Enabled.Value);
|
||||||
@ -100,14 +100,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
return Array.Empty<Mod>();
|
return Array.Empty<Mod>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => throw new NotImplementedException();
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => throw new NotImplementedException();
|
||||||
|
|
||||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => throw new NotImplementedException();
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => throw new NotImplementedException();
|
||||||
|
|
||||||
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => throw new NotImplementedException();
|
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => throw new NotImplementedException();
|
||||||
|
|
||||||
public override string Description { get; }
|
public override string Description { get; } = "test";
|
||||||
public override string ShortName { get; }
|
public override string ShortName { get; } = "tst";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||||
|
|
||||||
public override DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,6 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="mods">The <see cref="Mod"/>s to apply to the <see cref="IBeatmap"/>.</param>
|
/// <param name="mods">The <see cref="Mod"/>s to apply to the <see cref="IBeatmap"/>.</param>
|
||||||
/// <returns>The converted <see cref="IBeatmap"/>.</returns>
|
/// <returns>The converted <see cref="IBeatmap"/>.</returns>
|
||||||
/// <exception cref="BeatmapInvalidForRulesetException">If <see cref="Beatmap"/> could not be converted to <paramref name="ruleset"/>.</exception>
|
/// <exception cref="BeatmapInvalidForRulesetException">If <see cref="Beatmap"/> could not be converted to <paramref name="ruleset"/>.</exception>
|
||||||
IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods);
|
IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,10 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <returns>The applicable <see cref="IBeatmapConverter"/>.</returns>
|
/// <returns>The applicable <see cref="IBeatmapConverter"/>.</returns>
|
||||||
protected virtual IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) => ruleset.CreateBeatmapConverter(beatmap);
|
protected virtual IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) => ruleset.CreateBeatmapConverter(beatmap);
|
||||||
|
|
||||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods = null)
|
||||||
{
|
{
|
||||||
|
mods ??= Array.Empty<Mod>();
|
||||||
|
|
||||||
var rulesetInstance = ruleset.CreateInstance();
|
var rulesetInstance = ruleset.CreateInstance();
|
||||||
|
|
||||||
IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance);
|
IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance);
|
||||||
|
@ -80,6 +80,7 @@ namespace osu.Game.Configuration
|
|||||||
// Gameplay
|
// Gameplay
|
||||||
Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01);
|
Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01);
|
||||||
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
||||||
|
Set(OsuSetting.LightenDuringBreaks, true);
|
||||||
|
|
||||||
Set(OsuSetting.HitLighting, true);
|
Set(OsuSetting.HitLighting, true);
|
||||||
|
|
||||||
@ -142,6 +143,7 @@ namespace osu.Game.Configuration
|
|||||||
AutoCursorSize,
|
AutoCursorSize,
|
||||||
DimLevel,
|
DimLevel,
|
||||||
BlurLevel,
|
BlurLevel,
|
||||||
|
LightenDuringBreaks,
|
||||||
ShowStoryboard,
|
ShowStoryboard,
|
||||||
ShowVideoBackground,
|
ShowVideoBackground,
|
||||||
KeyOverlay,
|
KeyOverlay,
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
// 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 System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
@ -14,7 +16,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class UserDimContainer : Container
|
public abstract class UserDimContainer : Container
|
||||||
{
|
{
|
||||||
protected const float BACKGROUND_FADE_DURATION = 800;
|
/// <summary>
|
||||||
|
/// Amount of lightening to apply to current dim level during break times.
|
||||||
|
/// </summary>
|
||||||
|
public const float BREAK_LIGHTEN_AMOUNT = 0.3f;
|
||||||
|
|
||||||
|
protected const double BACKGROUND_FADE_DURATION = 800;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not user-configured dim levels should be applied to the container.
|
/// Whether or not user-configured dim levels should be applied to the container.
|
||||||
@ -26,6 +33,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether player is in break time.
|
||||||
|
/// Must be bound to <see cref="BreakOverlay.IsBreakTime"/> to allow for dim adjustments in gameplay.
|
||||||
|
/// </summary>
|
||||||
|
public readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the content of this container is currently being displayed.
|
/// Whether the content of this container is currently being displayed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,11 +46,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
protected Bindable<double> UserDimLevel { get; private set; }
|
protected Bindable<double> UserDimLevel { get; private set; }
|
||||||
|
|
||||||
|
protected Bindable<bool> LightenDuringBreaks { get; private set; }
|
||||||
|
|
||||||
protected Bindable<bool> ShowStoryboard { get; private set; }
|
protected Bindable<bool> ShowStoryboard { get; private set; }
|
||||||
|
|
||||||
protected Bindable<bool> ShowVideo { get; private set; }
|
protected Bindable<bool> ShowVideo { get; private set; }
|
||||||
|
|
||||||
protected double DimLevel => EnableUserDim.Value ? UserDimLevel.Value : 0;
|
private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? BREAK_LIGHTEN_AMOUNT : 0;
|
||||||
|
protected float DimLevel => Math.Max(EnableUserDim.Value ? (float)UserDimLevel.Value - breakLightening : 0, 0);
|
||||||
|
|
||||||
protected override Container<Drawable> Content => dimContent;
|
protected override Container<Drawable> Content => dimContent;
|
||||||
|
|
||||||
@ -55,11 +71,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
UserDimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
UserDimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||||
|
LightenDuringBreaks = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks);
|
||||||
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
ShowVideo = config.GetBindable<bool>(OsuSetting.ShowVideoBackground);
|
ShowVideo = config.GetBindable<bool>(OsuSetting.ShowVideoBackground);
|
||||||
|
|
||||||
EnableUserDim.ValueChanged += _ => UpdateVisuals();
|
EnableUserDim.ValueChanged += _ => UpdateVisuals();
|
||||||
UserDimLevel.ValueChanged += _ => UpdateVisuals();
|
UserDimLevel.ValueChanged += _ => UpdateVisuals();
|
||||||
|
LightenDuringBreaks.ValueChanged += _ => UpdateVisuals();
|
||||||
|
IsBreakTime.ValueChanged += _ => UpdateVisuals();
|
||||||
ShowStoryboard.ValueChanged += _ => UpdateVisuals();
|
ShowStoryboard.ValueChanged += _ => UpdateVisuals();
|
||||||
ShowVideo.ValueChanged += _ => UpdateVisuals();
|
ShowVideo.ValueChanged += _ => UpdateVisuals();
|
||||||
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
|
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
|
||||||
@ -84,7 +103,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
ContentDisplayed = ShowDimContent;
|
ContentDisplayed = ShowDimContent;
|
||||||
|
|
||||||
dimContent.FadeTo(ContentDisplayed ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
dimContent.FadeTo(ContentDisplayed ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
dimContent.FadeColour(OsuColour.Gray(1 - (float)DimLevel), BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
dimContent.FadeColour(OsuColour.Gray(1f - DimLevel), BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,13 @@ namespace osu.Game
|
|||||||
|
|
||||||
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
||||||
[Cached]
|
[Cached]
|
||||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
[Cached(typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||||
protected readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
protected readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mods available for the current <see cref="Ruleset"/>.
|
||||||
|
/// </summary>
|
||||||
|
public readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> AvailableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
||||||
|
|
||||||
protected Bindable<WorkingBeatmap> Beatmap { get; private set; } // cached via load() method
|
protected Bindable<WorkingBeatmap> Beatmap { get; private set; } // cached via load() method
|
||||||
|
|
||||||
@ -233,6 +238,18 @@ namespace osu.Game
|
|||||||
PreviewTrackManager previewTrackManager;
|
PreviewTrackManager previewTrackManager;
|
||||||
dependencies.Cache(previewTrackManager = new PreviewTrackManager());
|
dependencies.Cache(previewTrackManager = new PreviewTrackManager());
|
||||||
Add(previewTrackManager);
|
Add(previewTrackManager);
|
||||||
|
|
||||||
|
Ruleset.BindValueChanged(onRulesetChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onRulesetChanged(ValueChangedEvent<RulesetInfo> r)
|
||||||
|
{
|
||||||
|
var dict = new Dictionary<ModType, IReadOnlyList<Mod>>();
|
||||||
|
|
||||||
|
foreach (ModType type in Enum.GetValues(typeof(ModType))) dict[type] = r.NewValue?.CreateInstance().GetModsFor(type).ToList();
|
||||||
|
|
||||||
|
SelectedMods.Value = Array.Empty<Mod>();
|
||||||
|
AvailableMods.Value = dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Container CreateScalingContainer() => new DrawSizePreservingFillContainer();
|
protected virtual Container CreateScalingContainer() => new DrawSizePreservingFillContainer();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// 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 System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Configuration;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -12,14 +12,13 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public class ModControlSection : Container
|
public class ModControlSection : CompositeDrawable
|
||||||
{
|
{
|
||||||
protected FillFlowContainer FlowContent;
|
protected FillFlowContainer FlowContent;
|
||||||
protected override Container<Drawable> Content => FlowContent;
|
|
||||||
|
|
||||||
public readonly Mod Mod;
|
public readonly Mod Mod;
|
||||||
|
|
||||||
public ModControlSection(Mod mod)
|
public ModControlSection(Mod mod, IEnumerable<Drawable> modControls)
|
||||||
{
|
{
|
||||||
Mod = mod;
|
Mod = mod;
|
||||||
|
|
||||||
@ -33,9 +32,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
ChildrenEnumerable = modControls
|
||||||
};
|
};
|
||||||
|
|
||||||
AddRange(Mod.CreateSettingsControls());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -20,7 +20,6 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Mods.Sections;
|
using osu.Game.Overlays.Mods.Sections;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -50,7 +49,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
protected readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
protected readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
protected readonly IBindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
private Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods;
|
||||||
|
|
||||||
protected Color4 LowMultiplierColour;
|
protected Color4 LowMultiplierColour;
|
||||||
protected Color4 HighMultiplierColour;
|
protected Color4 HighMultiplierColour;
|
||||||
@ -322,14 +321,14 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colours, IBindable<RulesetInfo> ruleset, AudioManager audio, Bindable<IReadOnlyList<Mod>> mods)
|
private void load(OsuColour colours, AudioManager audio, Bindable<IReadOnlyList<Mod>> selectedMods, OsuGameBase osu)
|
||||||
{
|
{
|
||||||
LowMultiplierColour = colours.Red;
|
LowMultiplierColour = colours.Red;
|
||||||
HighMultiplierColour = colours.Green;
|
HighMultiplierColour = colours.Green;
|
||||||
UnrankedLabel.Colour = colours.Blue;
|
UnrankedLabel.Colour = colours.Blue;
|
||||||
|
|
||||||
Ruleset.BindTo(ruleset);
|
availableMods = osu.AvailableMods.GetBoundCopy();
|
||||||
if (mods != null) SelectedMods.BindTo(mods);
|
SelectedMods.BindTo(selectedMods);
|
||||||
|
|
||||||
sampleOn = audio.Samples.Get(@"UI/check-on");
|
sampleOn = audio.Samples.Get(@"UI/check-on");
|
||||||
sampleOff = audio.Samples.Get(@"UI/check-off");
|
sampleOff = audio.Samples.Get(@"UI/check-off");
|
||||||
@ -360,8 +359,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
SelectedMods.BindValueChanged(selectedModsChanged);
|
availableMods.BindValueChanged(availableModsChanged, true);
|
||||||
Ruleset.BindValueChanged(rulesetChanged, true);
|
SelectedMods.BindValueChanged(selectedModsChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
@ -410,22 +409,12 @@ namespace osu.Game.Overlays.Mods
|
|||||||
return base.OnKeyDown(e);
|
return base.OnKeyDown(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rulesetChanged(ValueChangedEvent<RulesetInfo> e)
|
private void availableModsChanged(ValueChangedEvent<Dictionary<ModType, IReadOnlyList<Mod>>> mods)
|
||||||
{
|
{
|
||||||
if (e.NewValue == null) return;
|
if (mods.NewValue == null) return;
|
||||||
|
|
||||||
var instance = e.NewValue.CreateInstance();
|
|
||||||
|
|
||||||
foreach (var section in ModSectionsContainer.Children)
|
foreach (var section in ModSectionsContainer.Children)
|
||||||
section.Mods = instance.GetModsFor(section.ModType);
|
section.Mods = mods.NewValue[section.ModType];
|
||||||
|
|
||||||
// attempt to re-select any already selected mods.
|
|
||||||
// this may be the first time we are receiving the ruleset, in which case they will still match.
|
|
||||||
selectedModsChanged(new ValueChangedEvent<IReadOnlyList<Mod>>(SelectedMods.Value, SelectedMods.Value));
|
|
||||||
|
|
||||||
// write the mods back to the SelectedMods bindable in the case a change was not applicable.
|
|
||||||
// this generally isn't required as the previous line will perform deselection; just here for safety.
|
|
||||||
refreshSelectedMods();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
||||||
@ -462,17 +451,17 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
private void updateModSettings(ValueChangedEvent<IReadOnlyList<Mod>> selectedMods)
|
private void updateModSettings(ValueChangedEvent<IReadOnlyList<Mod>> selectedMods)
|
||||||
{
|
{
|
||||||
foreach (var added in selectedMods.NewValue.Except(selectedMods.OldValue))
|
ModSettingsContent.Clear();
|
||||||
|
|
||||||
|
foreach (var mod in selectedMods.NewValue)
|
||||||
{
|
{
|
||||||
var controls = added.CreateSettingsControls().ToList();
|
var settings = mod.CreateSettingsControls().ToList();
|
||||||
if (controls.Count > 0)
|
if (settings.Count > 0)
|
||||||
ModSettingsContent.Add(new ModControlSection(added) { Children = controls });
|
ModSettingsContent.Add(new ModControlSection(mod, settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var removed in selectedMods.OldValue.Except(selectedMods.NewValue))
|
bool hasSettings = ModSettingsContent.Count > 0;
|
||||||
ModSettingsContent.RemoveAll(section => section.Mod == removed);
|
|
||||||
|
|
||||||
bool hasSettings = ModSettingsContent.Children.Count > 0;
|
|
||||||
CustomiseButton.Enabled.Value = hasSettings;
|
CustomiseButton.Enabled.Value = hasSettings;
|
||||||
|
|
||||||
if (!hasSettings)
|
if (!hasSettings)
|
||||||
@ -502,8 +491,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
Ruleset.UnbindAll();
|
availableMods?.UnbindAll();
|
||||||
SelectedMods.UnbindAll();
|
SelectedMods?.UnbindAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -30,6 +30,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
KeyboardStep = 0.01f
|
KeyboardStep = 0.01f
|
||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
|
{
|
||||||
|
LabelText = "Lighten playfield during breaks",
|
||||||
|
Bindable = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks)
|
||||||
|
},
|
||||||
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
LabelText = "Show score overlay",
|
LabelText = "Show score overlay",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
||||||
|
@ -48,7 +48,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BindableBeatDivisor beatDivisor { get; set; }
|
private BindableBeatDivisor beatDivisor { get; set; }
|
||||||
|
|
||||||
private IWorkingBeatmap workingBeatmap;
|
|
||||||
private Beatmap<TObject> playableBeatmap;
|
private Beatmap<TObject> playableBeatmap;
|
||||||
private IBeatmapProcessor beatmapProcessor;
|
private IBeatmapProcessor beatmapProcessor;
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, workingBeatmap, Array.Empty<Mod>()))
|
drawableRulesetWrapper = new DrawableEditRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, playableBeatmap))
|
||||||
{
|
{
|
||||||
Clock = framedClock,
|
Clock = framedClock,
|
||||||
ProcessCustomClock = false
|
ProcessCustomClock = false
|
||||||
@ -145,8 +144,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
var parentWorkingBeatmap = parent.Get<IBindable<WorkingBeatmap>>().Value;
|
var parentWorkingBeatmap = parent.Get<IBindable<WorkingBeatmap>>().Value;
|
||||||
|
|
||||||
playableBeatmap = (Beatmap<TObject>)parentWorkingBeatmap.GetPlayableBeatmap(Ruleset.RulesetInfo, Array.Empty<Mod>());
|
playableBeatmap = (Beatmap<TObject>)parentWorkingBeatmap.GetPlayableBeatmap(Ruleset.RulesetInfo);
|
||||||
workingBeatmap = new EditorWorkingBeatmap<TObject>(playableBeatmap, parentWorkingBeatmap);
|
|
||||||
|
|
||||||
beatmapProcessor = Ruleset.CreateBeatmapProcessor(playableBeatmap);
|
beatmapProcessor = Ruleset.CreateBeatmapProcessor(playableBeatmap);
|
||||||
|
|
||||||
@ -250,7 +248,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
||||||
|
|
||||||
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null);
|
||||||
|
|
||||||
public void BeginPlacement(HitObject hitObject)
|
public void BeginPlacement(HitObject hitObject)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets
|
|||||||
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
||||||
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public abstract DrawableRuleset CreateDrawableRulesetWith(IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
public abstract DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
||||||
|
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The beatmap.
|
/// The beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Beatmap<TObject> Beatmap;
|
public readonly Beatmap<TObject> Beatmap;
|
||||||
|
|
||||||
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
|
||||||
|
|
||||||
@ -118,20 +118,22 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// Creates a ruleset visualisation for the provided ruleset and beatmap.
|
/// Creates a ruleset visualisation for the provided ruleset and beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ruleset">The ruleset being represented.</param>
|
/// <param name="ruleset">The ruleset being represented.</param>
|
||||||
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
||||||
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
/// <param name="mods">The <see cref="Mod"/>s to apply.</param>
|
||||||
protected DrawableRuleset(Ruleset ruleset, IWorkingBeatmap workingBeatmap, IReadOnlyList<Mod> mods)
|
protected DrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
if (workingBeatmap == null)
|
if (beatmap == null)
|
||||||
throw new ArgumentException("Beatmap cannot be null.", nameof(workingBeatmap));
|
throw new ArgumentNullException(nameof(beatmap), "Beatmap cannot be null.");
|
||||||
|
|
||||||
this.mods = mods.ToArray();
|
if (!(beatmap is Beatmap<TObject> tBeatmap))
|
||||||
|
throw new ArgumentException($"{GetType()} expected the beatmap to contain hitobjects of type {typeof(TObject)}.", nameof(beatmap));
|
||||||
|
|
||||||
|
Beatmap = tBeatmap;
|
||||||
|
this.mods = mods?.ToArray() ?? Array.Empty<Mod>();
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Beatmap = (Beatmap<TObject>)workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);
|
|
||||||
|
|
||||||
KeyBindingInputManager = CreateInputManager();
|
KeyBindingInputManager = CreateInputManager();
|
||||||
playfield = new Lazy<Playfield>(CreatePlayfield);
|
playfield = new Lazy<Playfield>(CreatePlayfield);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
[Cached(Type = typeof(IScrollingInfo))]
|
[Cached(Type = typeof(IScrollingInfo))]
|
||||||
private readonly LocalScrollingInfo scrollingInfo;
|
private readonly LocalScrollingInfo scrollingInfo;
|
||||||
|
|
||||||
protected DrawableScrollingRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
protected DrawableScrollingRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
scrollingInfo = new LocalScrollingInfo();
|
scrollingInfo = new LocalScrollingInfo();
|
||||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
||||||
|
|
||||||
|
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||||
|
|
||||||
private readonly DimmableBackground dimmable;
|
private readonly DimmableBackground dimmable;
|
||||||
|
|
||||||
protected virtual DimmableBackground CreateFadeContainer() => new DimmableBackground { RelativeSizeAxes = Axes.Both };
|
protected virtual DimmableBackground CreateFadeContainer() => new DimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||||
@ -48,6 +50,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
InternalChild = dimmable = CreateFadeContainer();
|
InternalChild = dimmable = CreateFadeContainer();
|
||||||
dimmable.EnableUserDim.BindTo(EnableUserDim);
|
dimmable.EnableUserDim.BindTo(EnableUserDim);
|
||||||
|
dimmable.IsBreakTime.BindTo(IsBreakTime);
|
||||||
dimmable.BlurAmount.BindTo(BlurAmount);
|
dimmable.BlurAmount.BindTo(BlurAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.Graphics.Video;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Skinning;
|
|
||||||
using osu.Game.Storyboards;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Encapsulates a <see cref="WorkingBeatmap"/> while providing an overridden <see cref="Beatmap{TObject}"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TObject"></typeparam>
|
|
||||||
public class EditorWorkingBeatmap<TObject> : IWorkingBeatmap
|
|
||||||
where TObject : HitObject
|
|
||||||
{
|
|
||||||
private readonly Beatmap<TObject> playableBeatmap;
|
|
||||||
private readonly WorkingBeatmap workingBeatmap;
|
|
||||||
|
|
||||||
public EditorWorkingBeatmap(Beatmap<TObject> playableBeatmap, WorkingBeatmap workingBeatmap)
|
|
||||||
{
|
|
||||||
this.playableBeatmap = playableBeatmap;
|
|
||||||
this.workingBeatmap = workingBeatmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBeatmap Beatmap => workingBeatmap.Beatmap;
|
|
||||||
|
|
||||||
public Texture Background => workingBeatmap.Background;
|
|
||||||
|
|
||||||
public VideoSprite Video => workingBeatmap.Video;
|
|
||||||
|
|
||||||
public Track Track => workingBeatmap.Track;
|
|
||||||
|
|
||||||
public Waveform Waveform => workingBeatmap.Waveform;
|
|
||||||
|
|
||||||
public Storyboard Storyboard => workingBeatmap.Storyboard;
|
|
||||||
|
|
||||||
public ISkin Skin => workingBeatmap.Skin;
|
|
||||||
|
|
||||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods) => playableBeatmap;
|
|
||||||
}
|
|
||||||
}
|
|
@ -87,12 +87,12 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
public virtual float BackgroundParallaxAmount => 1;
|
public virtual float BackgroundParallaxAmount => 1;
|
||||||
|
|
||||||
|
public virtual bool AllowRateAdjustments => true;
|
||||||
|
|
||||||
public Bindable<WorkingBeatmap> Beatmap { get; private set; }
|
public Bindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||||
|
|
||||||
public Bindable<RulesetInfo> Ruleset { get; private set; }
|
public Bindable<RulesetInfo> Ruleset { get; private set; }
|
||||||
|
|
||||||
public virtual bool AllowRateAdjustments => true;
|
|
||||||
|
|
||||||
public Bindable<IReadOnlyList<Mod>> Mods { get; private set; }
|
public Bindable<IReadOnlyList<Mod>> Mods { get; private set; }
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
@ -26,16 +26,26 @@ namespace osu.Game.Screens
|
|||||||
Beatmap = parent.Get<LeasedBindable<WorkingBeatmap>>()?.GetBoundCopy();
|
Beatmap = parent.Get<LeasedBindable<WorkingBeatmap>>()?.GetBoundCopy();
|
||||||
|
|
||||||
if (Beatmap == null)
|
if (Beatmap == null)
|
||||||
|
{
|
||||||
Cache(Beatmap = parent.Get<Bindable<WorkingBeatmap>>().BeginLease(false));
|
Cache(Beatmap = parent.Get<Bindable<WorkingBeatmap>>().BeginLease(false));
|
||||||
|
CacheAs(Beatmap);
|
||||||
|
}
|
||||||
|
|
||||||
Ruleset = parent.Get<LeasedBindable<RulesetInfo>>()?.GetBoundCopy();
|
Ruleset = parent.Get<LeasedBindable<RulesetInfo>>()?.GetBoundCopy();
|
||||||
|
|
||||||
if (Ruleset == null)
|
if (Ruleset == null)
|
||||||
|
{
|
||||||
Cache(Ruleset = parent.Get<Bindable<RulesetInfo>>().BeginLease(true));
|
Cache(Ruleset = parent.Get<Bindable<RulesetInfo>>().BeginLease(true));
|
||||||
|
CacheAs(Ruleset);
|
||||||
|
}
|
||||||
|
|
||||||
Mods = parent.Get<LeasedBindable<IReadOnlyList<Mod>>>()?.GetBoundCopy();
|
Mods = parent.Get<LeasedBindable<IReadOnlyList<Mod>>>()?.GetBoundCopy();
|
||||||
|
|
||||||
if (Mods == null)
|
if (Mods == null)
|
||||||
|
{
|
||||||
Cache(Mods = parent.Get<Bindable<IReadOnlyList<Mod>>>().BeginLease(true));
|
Cache(Mods = parent.Get<Bindable<IReadOnlyList<Mod>>>().BeginLease(true));
|
||||||
|
CacheAs(Mods);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -114,26 +114,31 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
Mods.Value = base.Mods.Value.Select(m => m.CreateCopy()).ToArray();
|
Mods.Value = base.Mods.Value.Select(m => m.CreateCopy()).ToArray();
|
||||||
|
|
||||||
WorkingBeatmap working = loadBeatmap();
|
if (Beatmap.Value is DummyWorkingBeatmap)
|
||||||
|
return;
|
||||||
|
|
||||||
if (working == null)
|
IBeatmap playableBeatmap = loadPlayableBeatmap();
|
||||||
|
|
||||||
|
if (playableBeatmap == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sampleRestart = audio.Samples.Get(@"Gameplay/restart");
|
sampleRestart = audio.Samples.Get(@"Gameplay/restart");
|
||||||
|
|
||||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||||
|
|
||||||
|
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
||||||
|
|
||||||
ScoreProcessor = DrawableRuleset.CreateScoreProcessor();
|
ScoreProcessor = DrawableRuleset.CreateScoreProcessor();
|
||||||
ScoreProcessor.Mods.BindTo(Mods);
|
ScoreProcessor.Mods.BindTo(Mods);
|
||||||
|
|
||||||
if (!ScoreProcessor.Mode.Disabled)
|
if (!ScoreProcessor.Mode.Disabled)
|
||||||
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
||||||
|
|
||||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime);
|
InternalChild = GameplayClockContainer = new GameplayClockContainer(Beatmap.Value, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||||
|
|
||||||
addUnderlayComponents(GameplayClockContainer);
|
addUnderlayComponents(GameplayClockContainer);
|
||||||
addGameplayComponents(GameplayClockContainer, working);
|
addGameplayComponents(GameplayClockContainer, Beatmap.Value);
|
||||||
addOverlayComponents(GameplayClockContainer, working);
|
addOverlayComponents(GameplayClockContainer, Beatmap.Value);
|
||||||
|
|
||||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
||||||
|
|
||||||
@ -250,36 +255,32 @@ namespace osu.Game.Screens.Play
|
|||||||
&& !DrawableRuleset.HasReplayLoaded.Value
|
&& !DrawableRuleset.HasReplayLoaded.Value
|
||||||
&& !breakOverlay.IsBreakTime.Value;
|
&& !breakOverlay.IsBreakTime.Value;
|
||||||
|
|
||||||
private WorkingBeatmap loadBeatmap()
|
private IBeatmap loadPlayableBeatmap()
|
||||||
{
|
{
|
||||||
WorkingBeatmap working = Beatmap.Value;
|
IBeatmap playable;
|
||||||
if (working is DummyWorkingBeatmap)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var beatmap = working.Beatmap;
|
if (Beatmap.Value.Beatmap == null)
|
||||||
|
|
||||||
if (beatmap == null)
|
|
||||||
throw new InvalidOperationException("Beatmap was not loaded");
|
throw new InvalidOperationException("Beatmap was not loaded");
|
||||||
|
|
||||||
rulesetInfo = Ruleset.Value ?? beatmap.BeatmapInfo.Ruleset;
|
rulesetInfo = Ruleset.Value ?? Beatmap.Value.BeatmapInfo.Ruleset;
|
||||||
ruleset = rulesetInfo.CreateInstance();
|
ruleset = rulesetInfo.CreateInstance();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(working, Mods.Value);
|
playable = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Mods.Value);
|
||||||
}
|
}
|
||||||
catch (BeatmapInvalidForRulesetException)
|
catch (BeatmapInvalidForRulesetException)
|
||||||
{
|
{
|
||||||
// we may fail to create a DrawableRuleset if the beatmap cannot be loaded with the user's preferred ruleset
|
// A playable beatmap may not be creatable with the user's preferred ruleset, so try using the beatmap's default ruleset
|
||||||
// let's try again forcing the beatmap's ruleset.
|
rulesetInfo = Beatmap.Value.BeatmapInfo.Ruleset;
|
||||||
rulesetInfo = beatmap.BeatmapInfo.Ruleset;
|
|
||||||
ruleset = rulesetInfo.CreateInstance();
|
ruleset = rulesetInfo.CreateInstance();
|
||||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(Beatmap.Value, Mods.Value);
|
|
||||||
|
playable = Beatmap.Value.GetPlayableBeatmap(rulesetInfo, Mods.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DrawableRuleset.Objects.Any())
|
if (playable.HitObjects.Count == 0)
|
||||||
{
|
{
|
||||||
Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Error);
|
Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Error);
|
||||||
return null;
|
return null;
|
||||||
@ -292,7 +293,7 @@ namespace osu.Game.Screens.Play
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return working;
|
return playable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void performImmediateExit()
|
private void performImmediateExit()
|
||||||
@ -510,6 +511,11 @@ namespace osu.Game.Screens.Play
|
|||||||
Background.EnableUserDim.Value = true;
|
Background.EnableUserDim.Value = true;
|
||||||
Background.BlurAmount.Value = 0;
|
Background.BlurAmount.Value = 0;
|
||||||
|
|
||||||
|
// bind component bindables.
|
||||||
|
Background.IsBreakTime.BindTo(breakOverlay.IsBreakTime);
|
||||||
|
DimmableStoryboard.IsBreakTime.BindTo(breakOverlay.IsBreakTime);
|
||||||
|
DimmableVideo.IsBreakTime.BindTo(breakOverlay.IsBreakTime);
|
||||||
|
|
||||||
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||||
DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
var working = CreateWorkingBeatmap(rulesetInfo);
|
var working = CreateWorkingBeatmap(rulesetInfo);
|
||||||
|
|
||||||
Beatmap.Value = working;
|
Beatmap.Value = working;
|
||||||
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
SelectedMods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
||||||
|
|
||||||
Player?.Exit();
|
Player?.Exit();
|
||||||
Player = null;
|
Player = null;
|
||||||
|
@ -12,7 +12,6 @@ using osu.Framework.Audio.Track;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
@ -21,6 +20,7 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Screens;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
@ -28,21 +28,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
public abstract class OsuTestScene : TestScene
|
public abstract class OsuTestScene : TestScene
|
||||||
{
|
{
|
||||||
[Cached(typeof(Bindable<WorkingBeatmap>))]
|
protected Bindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||||
[Cached(typeof(IBindable<WorkingBeatmap>))]
|
|
||||||
private NonNullableBindable<WorkingBeatmap> beatmap;
|
|
||||||
|
|
||||||
protected Bindable<WorkingBeatmap> Beatmap => beatmap;
|
protected Bindable<RulesetInfo> Ruleset;
|
||||||
|
|
||||||
[Cached]
|
protected Bindable<IReadOnlyList<Mod>> SelectedMods;
|
||||||
[Cached(typeof(IBindable<RulesetInfo>))]
|
|
||||||
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
|
||||||
|
|
||||||
[Cached]
|
protected new OsuScreenDependencies Dependencies { get; private set; }
|
||||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
|
||||||
protected readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
|
||||||
|
|
||||||
protected new DependencyContainer Dependencies { get; private set; }
|
|
||||||
|
|
||||||
private readonly Lazy<Storage> localStorage;
|
private readonly Lazy<Storage> localStorage;
|
||||||
protected Storage LocalStorage => localStorage.Value;
|
protected Storage LocalStorage => localStorage.Value;
|
||||||
@ -72,18 +64,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
// This is the earliest we can get OsuGameBase, which is used by the dummy working beatmap to find textures
|
Dependencies = new OsuScreenDependencies(false, base.CreateChildDependencies(parent));
|
||||||
var working = new DummyWorkingBeatmap(parent.Get<AudioManager>(), parent.Get<TextureStore>());
|
|
||||||
|
|
||||||
beatmap = new NonNullableBindable<WorkingBeatmap>(working) { Default = working };
|
Beatmap = Dependencies.Beatmap;
|
||||||
beatmap.BindValueChanged(b => ScheduleAfterChildren(() =>
|
Beatmap.SetDefault();
|
||||||
{
|
|
||||||
// compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
|
|
||||||
if (b.OldValue?.TrackLoaded == true && b.OldValue?.Track != b.NewValue?.Track)
|
|
||||||
b.OldValue.RecycleTrack();
|
|
||||||
}));
|
|
||||||
|
|
||||||
Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
Ruleset = Dependencies.Ruleset;
|
||||||
|
Ruleset.SetDefault();
|
||||||
|
|
||||||
|
SelectedMods = Dependencies.Mods;
|
||||||
|
SelectedMods.SetDefault();
|
||||||
|
|
||||||
if (!UseOnlineAPI)
|
if (!UseOnlineAPI)
|
||||||
{
|
{
|
||||||
@ -135,8 +125,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (beatmap?.Value.TrackLoaded == true)
|
if (Beatmap?.Value.TrackLoaded == true)
|
||||||
beatmap.Value.Track.Stop();
|
Beatmap.Value.Track.Stop();
|
||||||
|
|
||||||
if (contextFactory.IsValueCreated)
|
if (contextFactory.IsValueCreated)
|
||||||
contextFactory.Value.ResetDatabase();
|
contextFactory.Value.ResetDatabase();
|
||||||
|
@ -53,14 +53,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
var noFailMod = ruleset.GetAllMods().FirstOrDefault(m => m is ModNoFail);
|
var noFailMod = ruleset.GetAllMods().FirstOrDefault(m => m is ModNoFail);
|
||||||
if (noFailMod != null)
|
if (noFailMod != null)
|
||||||
Mods.Value = new[] { noFailMod };
|
SelectedMods.Value = new[] { noFailMod };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Autoplay)
|
if (Autoplay)
|
||||||
{
|
{
|
||||||
var mod = ruleset.GetAutoplayMod();
|
var mod = ruleset.GetAutoplayMod();
|
||||||
if (mod != null)
|
if (mod != null)
|
||||||
Mods.Value = Mods.Value.Concat(mod.Yield()).ToArray();
|
SelectedMods.Value = SelectedMods.Value.Concat(mod.Yield()).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
Player = CreatePlayer(ruleset);
|
Player = CreatePlayer(ruleset);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1212.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2019.1213.0" />
|
||||||
<PackageReference Include="Sentry" Version="1.2.0" />
|
<PackageReference Include="Sentry" Version="1.2.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1212.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1213.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||||
<ItemGroup Label="Transitive Dependencies">
|
<ItemGroup Label="Transitive Dependencies">
|
||||||
@ -82,7 +82,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2019.1212.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2019.1213.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user