mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:25:11 +08:00
wip
This commit is contained in:
parent
ca5c8d37d1
commit
e01f342ab0
@ -61,13 +61,19 @@ namespace osu.Game.Screens.Multi
|
||||
[Resolved(CanBeNull = true)]
|
||||
private OsuLogo logo { get; set; }
|
||||
|
||||
public Bindable<WorkingBeatmap> Beatmap => screenDependencies.Beatmap;
|
||||
public Bindable<WorkingBeatmap> Beatmap { get; set; }
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset => screenDependencies.Ruleset;
|
||||
public Bindable<RulesetInfo> Ruleset { get; set; }
|
||||
|
||||
private OsuScreenDependencies screenDependencies;
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
|
||||
Beatmap = deps.Beatmap;
|
||||
Ruleset = deps.Ruleset;
|
||||
|
||||
return deps;
|
||||
}
|
||||
|
||||
public Multiplayer()
|
||||
{
|
||||
@ -188,8 +194,6 @@ namespace osu.Game.Screens.Multi
|
||||
{
|
||||
waves.Hide();
|
||||
|
||||
screenDependencies.Dispose();
|
||||
|
||||
this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut();
|
||||
|
||||
cancelLooping();
|
||||
|
@ -34,13 +34,19 @@ namespace osu.Game.Screens.Multi
|
||||
public abstract string Title { get; }
|
||||
public virtual string ShortTitle => Title;
|
||||
|
||||
public Bindable<WorkingBeatmap> Beatmap => screenDependencies.Beatmap;
|
||||
public Bindable<WorkingBeatmap> Beatmap { get; set; }
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset => screenDependencies.Ruleset;
|
||||
public Bindable<RulesetInfo> Ruleset { get; set; }
|
||||
|
||||
private OsuScreenDependencies screenDependencies;
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
|
||||
Beatmap = deps.Beatmap;
|
||||
Ruleset = deps.Ruleset;
|
||||
|
||||
return deps;
|
||||
}
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
protected OsuGame Game { get; private set; }
|
||||
@ -67,8 +73,6 @@ namespace osu.Game.Screens.Multi
|
||||
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
||||
this.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint);
|
||||
|
||||
screenDependencies.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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 Microsoft.EntityFrameworkCore.Internal;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
@ -51,7 +50,6 @@ namespace osu.Game.Screens
|
||||
|
||||
protected new OsuGameBase Game => base.Game as OsuGameBase;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children).
|
||||
/// </summary>
|
||||
@ -61,13 +59,19 @@ namespace osu.Game.Screens
|
||||
|
||||
public virtual float BackgroundParallaxAmount => 1;
|
||||
|
||||
public Bindable<WorkingBeatmap> Beatmap => screenDependencies.Beatmap;
|
||||
public Bindable<WorkingBeatmap> Beatmap { get; set; }
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset => screenDependencies.Ruleset;
|
||||
public Bindable<RulesetInfo> Ruleset { get; set; }
|
||||
|
||||
private OsuScreenDependencies screenDependencies;
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var deps = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, base.CreateChildDependencies(parent));
|
||||
Beatmap = deps.Beatmap;
|
||||
Ruleset = deps.Ruleset;
|
||||
|
||||
return deps;
|
||||
}
|
||||
|
||||
protected BackgroundScreen Background => backgroundStack?.CurrentScreen as BackgroundScreen;
|
||||
|
||||
@ -140,8 +144,6 @@ namespace osu.Game.Screens
|
||||
if (localBackground != null && backgroundStack?.CurrentScreen == localBackground)
|
||||
backgroundStack?.Exit();
|
||||
|
||||
screenDependencies.Dispose();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -208,53 +210,4 @@ namespace osu.Game.Screens
|
||||
/// </summary>
|
||||
protected virtual BackgroundScreen CreateBackground() => null;
|
||||
}
|
||||
|
||||
public class OsuScreenDependencies : DependencyContainer, IDisposable
|
||||
{
|
||||
private readonly bool leaseOwner;
|
||||
|
||||
public Bindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset { get; private set; }
|
||||
|
||||
public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent)
|
||||
: base(parent)
|
||||
{
|
||||
if (requireLease)
|
||||
{
|
||||
Beatmap = parent.Get<LeasedBindable<WorkingBeatmap>>()?.GetBoundCopy();
|
||||
if (Beatmap == null)
|
||||
{
|
||||
leaseOwner = true;
|
||||
Cache(Beatmap = parent.Get<Bindable<WorkingBeatmap>>().BeginLease(true));
|
||||
}
|
||||
|
||||
Ruleset = parent.Get<LeasedBindable<RulesetInfo>>()?.GetBoundCopy();
|
||||
if (Ruleset == null)
|
||||
{
|
||||
leaseOwner = true;
|
||||
Cache(Ruleset = parent.Get<Bindable<RulesetInfo>>().BeginLease(true));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Beatmap = (parent.Get<LeasedBindable<WorkingBeatmap>>() ?? parent.Get<Bindable<WorkingBeatmap>>()).GetBoundCopy();
|
||||
Ruleset = (parent.Get<LeasedBindable<RulesetInfo>>() ?? parent.Get<Bindable<RulesetInfo>>()).GetBoundCopy();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (leaseOwner)
|
||||
{
|
||||
((LeasedBindable<WorkingBeatmap>)Beatmap).Return();
|
||||
((LeasedBindable<RulesetInfo>)Ruleset).Return();
|
||||
}
|
||||
else
|
||||
{
|
||||
Beatmap.UnbindAll();
|
||||
Ruleset.UnbindAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
41
osu.Game/Screens/OsuScreenDependencies.cs
Normal file
41
osu.Game/Screens/OsuScreenDependencies.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Screens
|
||||
{
|
||||
public class OsuScreenDependencies : DependencyContainer
|
||||
{
|
||||
public Bindable<WorkingBeatmap> Beatmap { get; }
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset { get; }
|
||||
|
||||
public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent)
|
||||
: base(parent)
|
||||
{
|
||||
if (requireLease)
|
||||
{
|
||||
Beatmap = parent.Get<LeasedBindable<WorkingBeatmap>>()?.GetBoundCopy();
|
||||
if (Beatmap == null)
|
||||
{
|
||||
Cache(Beatmap = parent.Get<Bindable<WorkingBeatmap>>().BeginLease(true));
|
||||
}
|
||||
|
||||
Ruleset = parent.Get<LeasedBindable<RulesetInfo>>()?.GetBoundCopy();
|
||||
if (Ruleset == null)
|
||||
{
|
||||
Cache(Ruleset = parent.Get<Bindable<RulesetInfo>>().BeginLease(true));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Beatmap = (parent.Get<LeasedBindable<WorkingBeatmap>>() ?? parent.Get<Bindable<WorkingBeatmap>>()).GetBoundCopy();
|
||||
Ruleset = (parent.Get<LeasedBindable<RulesetInfo>>() ?? parent.Get<Bindable<RulesetInfo>>()).GetBoundCopy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user