diff --git a/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs b/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs index 85becc1a23..4a3ae99116 100644 --- a/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs +++ b/osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs @@ -219,7 +219,7 @@ namespace osu.Game.Overlays.SkinEditor } } - public partial class DependencyBorrowingContainer : Container + private partial class DependencyBorrowingContainer : Container { protected override bool ShouldBeConsideredForInput(Drawable child) => false; @@ -232,8 +232,19 @@ namespace osu.Game.Overlays.SkinEditor this.donor = donor; } - protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => - new DependencyContainer(donor?.Dependencies ?? base.CreateChildDependencies(parent)); + protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) + { + var baseDependencies = base.CreateChildDependencies(parent); + if (donor == null) + return baseDependencies; + + var dependencies = new DependencyContainer(donor.Dependencies); + // inject `SkinEditor` again *on top* of the borrowed dependencies. + // this is designed to let components know when they are being displayed in the context of the skin editor + // via attempting to resolve `SkinEditor`. + dependencies.CacheAs(baseDependencies.Get()); + return dependencies; + } } } } diff --git a/osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs b/osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs index 83c329bb8f..61f0abd79c 100644 --- a/osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs +++ b/osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Audio; using osu.Game.Configuration; using osu.Game.Online.Leaderboards; +using osu.Game.Overlays.SkinEditor; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Skinning; @@ -39,7 +40,7 @@ namespace osu.Game.Screens.Play.HUD } [BackgroundDependencyLoader] - private void load() + private void load(SkinEditor? skinEditor) { InternalChildren = new Drawable[] { @@ -50,6 +51,9 @@ namespace osu.Game.Screens.Play.HUD RelativeSizeAxes = Axes.Both }, }; + + if (skinEditor != null) + PlaySamples.Value = false; } protected override void LoadComplete()