2019-02-02 08:11:25 +00:00
|
|
|
// 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.
|
|
|
|
|
2019-04-08 09:32:05 +00:00
|
|
|
using System.Collections.Generic;
|
2019-02-02 08:11:25 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
using osu.Framework.Bindables;
|
2019-02-02 08:11:25 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets;
|
2019-04-08 09:32:05 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-02-02 08:11:25 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Screens
|
|
|
|
{
|
|
|
|
public class OsuScreenDependencies : DependencyContainer
|
|
|
|
{
|
|
|
|
public Bindable<WorkingBeatmap> Beatmap { get; }
|
|
|
|
|
|
|
|
public Bindable<RulesetInfo> Ruleset { get; }
|
|
|
|
|
2019-04-10 08:13:12 +00:00
|
|
|
public Bindable<IReadOnlyList<Mod>> Mods { get; }
|
2019-04-08 09:32:05 +00:00
|
|
|
|
2019-02-02 08:11:25 +00:00
|
|
|
public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent)
|
|
|
|
: base(parent)
|
|
|
|
{
|
|
|
|
if (requireLease)
|
|
|
|
{
|
|
|
|
Beatmap = parent.Get<LeasedBindable<WorkingBeatmap>>()?.GetBoundCopy();
|
2019-04-01 03:16:05 +00:00
|
|
|
|
2019-02-02 08:11:25 +00:00
|
|
|
if (Beatmap == null)
|
2019-12-13 11:05:54 +00:00
|
|
|
{
|
2019-02-14 08:14:58 +00:00
|
|
|
Cache(Beatmap = parent.Get<Bindable<WorkingBeatmap>>().BeginLease(false));
|
2019-12-13 11:05:54 +00:00
|
|
|
CacheAs(Beatmap);
|
|
|
|
}
|
2019-02-02 08:11:25 +00:00
|
|
|
|
|
|
|
Ruleset = parent.Get<LeasedBindable<RulesetInfo>>()?.GetBoundCopy();
|
2019-04-01 03:16:05 +00:00
|
|
|
|
2019-02-02 08:11:25 +00:00
|
|
|
if (Ruleset == null)
|
2019-12-13 11:05:54 +00:00
|
|
|
{
|
2019-02-02 08:11:25 +00:00
|
|
|
Cache(Ruleset = parent.Get<Bindable<RulesetInfo>>().BeginLease(true));
|
2019-12-13 11:05:54 +00:00
|
|
|
CacheAs(Ruleset);
|
|
|
|
}
|
2019-04-08 09:32:05 +00:00
|
|
|
|
2019-04-10 08:13:12 +00:00
|
|
|
Mods = parent.Get<LeasedBindable<IReadOnlyList<Mod>>>()?.GetBoundCopy();
|
2019-12-13 11:05:54 +00:00
|
|
|
|
2019-04-10 03:03:57 +00:00
|
|
|
if (Mods == null)
|
2019-12-13 11:05:54 +00:00
|
|
|
{
|
2019-04-10 08:13:12 +00:00
|
|
|
Cache(Mods = parent.Get<Bindable<IReadOnlyList<Mod>>>().BeginLease(true));
|
2019-12-13 11:05:54 +00:00
|
|
|
CacheAs(Mods);
|
|
|
|
}
|
2019-02-02 08:11:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Beatmap = (parent.Get<LeasedBindable<WorkingBeatmap>>() ?? parent.Get<Bindable<WorkingBeatmap>>()).GetBoundCopy();
|
|
|
|
Ruleset = (parent.Get<LeasedBindable<RulesetInfo>>() ?? parent.Get<Bindable<RulesetInfo>>()).GetBoundCopy();
|
2019-04-10 08:13:12 +00:00
|
|
|
Mods = (parent.Get<LeasedBindable<IReadOnlyList<Mod>>>() ?? parent.Get<Bindable<IReadOnlyList<Mod>>>()).GetBoundCopy();
|
2019-02-02 08:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-14 08:14:58 +00:00
|
|
|
}
|