mirror of
https://github.com/osukey/osukey.git
synced 2025-06-28 22:58:10 +09:00
Fix OsuTestScene
potentially mutating global bindables
This commit is contained in:
parent
014c840d80
commit
b9aae5569f
@ -28,7 +28,6 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens;
|
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osu.Game.Tests.Rulesets;
|
using osu.Game.Tests.Rulesets;
|
||||||
@ -38,13 +37,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
public abstract class OsuTestScene : TestScene
|
public abstract class OsuTestScene : TestScene
|
||||||
{
|
{
|
||||||
protected Bindable<WorkingBeatmap> Beatmap { get; private set; }
|
[Cached]
|
||||||
|
protected Bindable<WorkingBeatmap> Beatmap { get; } = new Bindable<WorkingBeatmap>();
|
||||||
|
|
||||||
protected Bindable<RulesetInfo> Ruleset;
|
[Cached]
|
||||||
|
protected Bindable<RulesetInfo> Ruleset { get; } = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
protected Bindable<IReadOnlyList<Mod>> SelectedMods;
|
[Cached]
|
||||||
|
protected Bindable<IReadOnlyList<Mod>> SelectedMods { get; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
protected new OsuScreenDependencies Dependencies { get; private set; }
|
protected new DependencyContainer Dependencies { get; private set; }
|
||||||
|
|
||||||
protected IResourceStore<byte[]> Resources;
|
protected IResourceStore<byte[]> Resources;
|
||||||
|
|
||||||
@ -139,17 +141,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
var providedRuleset = CreateRuleset();
|
var providedRuleset = CreateRuleset();
|
||||||
if (providedRuleset != null)
|
if (providedRuleset != null)
|
||||||
baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies);
|
isolatedBaseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies);
|
||||||
|
|
||||||
Dependencies = new OsuScreenDependencies(false, baseDependencies);
|
Dependencies = isolatedBaseDependencies;
|
||||||
|
|
||||||
Beatmap = Dependencies.Beatmap;
|
Beatmap.Default = parent.Get<Bindable<WorkingBeatmap>>().Default;
|
||||||
Beatmap.SetDefault();
|
Beatmap.SetDefault();
|
||||||
|
|
||||||
Ruleset = Dependencies.Ruleset;
|
Ruleset.Value = CreateRuleset()?.RulesetInfo ?? parent.Get<RulesetStore>().AvailableRulesets.First();
|
||||||
Ruleset.SetDefault();
|
|
||||||
|
|
||||||
SelectedMods = Dependencies.Mods;
|
|
||||||
SelectedMods.SetDefault();
|
SelectedMods.SetDefault();
|
||||||
|
|
||||||
if (!UseOnlineAPI)
|
if (!UseOnlineAPI)
|
||||||
@ -162,6 +162,23 @@ namespace osu.Game.Tests.Visual
|
|||||||
return Dependencies;
|
return Dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
var parentBeatmap = Parent.Dependencies.Get<Bindable<WorkingBeatmap>>();
|
||||||
|
parentBeatmap.Value = Beatmap.Value;
|
||||||
|
Beatmap.BindTo(parentBeatmap);
|
||||||
|
|
||||||
|
var parentRuleset = Parent.Dependencies.Get<Bindable<RulesetInfo>>();
|
||||||
|
parentRuleset.Value = Ruleset.Value;
|
||||||
|
Ruleset.BindTo(parentRuleset);
|
||||||
|
|
||||||
|
var parentMods = Parent.Dependencies.Get<Bindable<IReadOnlyList<Mod>>>();
|
||||||
|
parentMods.Value = SelectedMods.Value;
|
||||||
|
SelectedMods.BindTo(parentMods);
|
||||||
|
}
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content ?? base.Content;
|
protected override Container<Drawable> Content => content ?? base.Content;
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
@ -286,12 +303,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
|
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
|
||||||
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, Audio);
|
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, Audio);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(RulesetStore rulesets)
|
|
||||||
{
|
|
||||||
Ruleset.Value = CreateRuleset()?.RulesetInfo ?? rulesets.AvailableRulesets.First();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user