Skip to content

Commit fd3514c

Browse files
committed
Prevent rank display shown in skin editor toolbox from playing samples
Closes #33456.
1 parent 6835d76 commit fd3514c

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

osu.Game/Overlays/SkinEditor/SkinComponentToolbox.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,35 @@ protected override bool OnClick(ClickEvent e)
219219
}
220220
}
221221

222-
public partial class DependencyBorrowingContainer : Container
222+
private partial class DependencyBorrowingContainer : Container
223223
{
224224
protected override bool ShouldBeConsideredForInput(Drawable child) => false;
225225

226226
public override bool PropagateNonPositionalInputSubTree => false;
227227

228228
private readonly CompositeDrawable? donor;
229229

230+
[Resolved]
231+
private SkinEditor skinEditor { get; set; } = null!;
232+
230233
public DependencyBorrowingContainer(CompositeDrawable? donor)
231234
{
232235
this.donor = donor;
233236
}
234237

235-
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
236-
new DependencyContainer(donor?.Dependencies ?? base.CreateChildDependencies(parent));
238+
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
239+
{
240+
var baseDependencies = base.CreateChildDependencies(parent);
241+
if (donor == null)
242+
return baseDependencies;
243+
244+
var dependencies = new DependencyContainer(donor.Dependencies);
245+
// inject `SkinEditor` again *on top* of the borrowed dependencies.
246+
// this is designed to let components know when they are being displayed in the context of the skin editor
247+
// via attempting to resolve `SkinEditor`.
248+
dependencies.CacheAs(baseDependencies.Get<SkinEditor>());
249+
return dependencies;
250+
}
237251
}
238252
}
239253
}

osu.Game/Screens/Play/HUD/DefaultRankDisplay.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using osu.Game.Audio;
99
using osu.Game.Configuration;
1010
using osu.Game.Online.Leaderboards;
11+
using osu.Game.Overlays.SkinEditor;
1112
using osu.Game.Rulesets.Scoring;
1213
using osu.Game.Scoring;
1314
using osu.Game.Skinning;
@@ -39,7 +40,7 @@ public DefaultRankDisplay()
3940
}
4041

4142
[BackgroundDependencyLoader]
42-
private void load()
43+
private void load(SkinEditor? skinEditor)
4344
{
4445
InternalChildren = new Drawable[]
4546
{
@@ -50,6 +51,9 @@ private void load()
5051
RelativeSizeAxes = Axes.Both
5152
},
5253
};
54+
55+
if (skinEditor != null)
56+
PlaySamples.Value = false;
5357
}
5458

5559
protected override void LoadComplete()

0 commit comments

Comments
 (0)