diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs index f03ffea5dc..c7a0df6e9f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinReloadable.cs @@ -4,7 +4,6 @@ using System; using NUnit.Framework; using osu.Framework.Audio.Sample; -using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -29,7 +28,7 @@ namespace osu.Game.Tests.Visual.Gameplay Child = new SkinSourceContainer { RelativeSizeAxes = Axes.Both, - Child = new LocalSkinOverrideContainer(secondarySource, new BindableInt()) + Child = new LocalSkinOverrideContainer(secondarySource) { RelativeSizeAxes = Axes.Both, Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true) @@ -54,7 +53,7 @@ namespace osu.Game.Tests.Visual.Gameplay Child = new SkinSourceContainer { RelativeSizeAxes = Axes.Both, - Child = target = new LocalSkinOverrideContainer(secondarySource, new BindableInt()) + Child = target = new LocalSkinOverrideContainer(secondarySource) { RelativeSizeAxes = Axes.Both, } diff --git a/osu.Game/Screens/Play/ComboEffects.cs b/osu.Game/Screens/Play/ComboEffects.cs new file mode 100644 index 0000000000..d752f4a556 --- /dev/null +++ b/osu.Game/Screens/Play/ComboEffects.cs @@ -0,0 +1,35 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Bindables; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Scoring; +using osu.Game.Skinning; + +namespace osu.Game.Screens.Play +{ + public class ComboEffects : CompositeDrawable + { + private SampleChannel sampleComboBreak; + + public ComboEffects(ScoreProcessor processor) + { + processor.Combo.BindValueChanged(onComboChange); + } + + private void onComboChange(ValueChangedEvent combo) + { + if (combo.NewValue == 0 && combo.OldValue > 20) + sampleComboBreak?.Play(); + } + + [BackgroundDependencyLoader] + private void load(ISkinSource skin, AudioManager audio) + { + sampleComboBreak = skin.GetSample(@"Gameplay/combobreak") ?? audio.Samples.Get(@"Gameplay/combobreak"); + } + } +} \ No newline at end of file diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 55d43bb4c8..7c4863fbf5 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -124,10 +124,14 @@ namespace osu.Game.Screens.Play StoryboardContainer = CreateStoryboardContainer(), new ScalingContainer(ScalingMode.Gameplay) { - Child = new LocalSkinOverrideContainer(working.Skin, ScoreProcessor.Combo) + Child = new LocalSkinOverrideContainer(working.Skin) { RelativeSizeAxes = Axes.Both, - Child = DrawableRuleset + Children = new Drawable[] + { + DrawableRuleset, + new ComboEffects(ScoreProcessor) + } } }, new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, ScoreProcessor) diff --git a/osu.Game/Skinning/LocalSkinOverrideContainer.cs b/osu.Game/Skinning/LocalSkinOverrideContainer.cs index a3606ef00c..37f4cc28a2 100644 --- a/osu.Game/Skinning/LocalSkinOverrideContainer.cs +++ b/osu.Game/Skinning/LocalSkinOverrideContainer.cs @@ -3,7 +3,6 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -25,14 +24,11 @@ namespace osu.Game.Skinning private readonly ISkin skin; - private readonly ComboEffects comboEffects; - private ISkinSource fallbackSource; - public LocalSkinOverrideContainer(ISkin skin, BindableInt combo) + public LocalSkinOverrideContainer(ISkin skin) { this.skin = skin; - comboEffects = new ComboEffects(combo); } public Drawable GetDrawableComponent(string componentName) @@ -92,9 +88,6 @@ namespace osu.Game.Skinning beatmapSkins.BindValueChanged(_ => onSourceChanged()); beatmapHitsounds.BindValueChanged(_ => onSourceChanged()); - AudioManager audio = dependencies.Get(); - comboEffects.SampleComboBreak = GetSample(@"Gameplay/combobreak") ?? audio.Samples.Get(@"Gameplay/combobreak"); - return dependencies; } @@ -108,21 +101,5 @@ namespace osu.Game.Skinning if (fallbackSource != null) fallbackSource.SourceChanged -= onSourceChanged; } - - private class ComboEffects - { - public SampleChannel SampleComboBreak; - - public ComboEffects(BindableInt combo) - { - combo.BindValueChanged(onComboChange); - } - - private void onComboChange(ValueChangedEvent combo) - { - if (combo.NewValue == 0 && combo.OldValue > 20) - SampleComboBreak?.Play(); - } - } } }