From e02cd28df629decb58a9f19d89c25b441b8f008f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 6 Jun 2025 12:51:53 +0200 Subject: [PATCH] Prevent rank display shown in skin editor toolbox from playing samples Closes https://github.com/ppy/osu/issues/33456. --- .../Overlays/SkinEditor/SkinComponentToolbox.cs | 17 ++++++++++++++--- osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs | 6 +++++- 2 files changed, 19 insertions(+), 4 deletions(-) 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()